Skip to content

Commit 5ddc15e

Browse files
nikomatsakisbrson
authored andcommitted
migrate debugging funcs
1 parent c04f42e commit 5ddc15e

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

src/lib/dbg.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88
* logging.
99
*/
1010

11-
native "rust" mod rustrt {
12-
fn debug_tydesc<T>();
13-
fn debug_opaque<T>(x: T);
14-
fn debug_box<T>(x: @T);
15-
fn debug_tag<T>(x: T);
16-
fn debug_obj<T>(x: T, nmethods: uint, nbytes: uint);
17-
fn debug_fn<T>(x: T);
18-
fn debug_ptrcast<T, U>(x: @T) -> @U;
11+
native "c-stack-cdecl" mod rustrt {
12+
fn debug_tydesc(td: *sys::type_desc);
13+
fn debug_opaque<T>(td: *sys::type_desc, x: T);
14+
fn debug_box<T>(td: *sys::type_desc, x: @T);
15+
fn debug_tag<T>(td: *sys::type_desc, x: T);
16+
fn debug_obj<T>(td: *sys::type_desc, x: T, nmethods: uint, nbytes: uint);
17+
fn debug_fn<T>(td: *sys::type_desc, x: T);
18+
fn debug_ptrcast<T, U>(td: *sys::type_desc, x: @T) -> @U;
1919
}
2020

21-
fn debug_tydesc<T>() { rustrt::debug_tydesc::<T>(); }
21+
fn debug_tydesc<T>() {
22+
rustrt::debug_tydesc(sys::get_type_desc::<T>());
23+
}
2224

23-
fn debug_opaque<T>(x: T) { rustrt::debug_opaque::<T>(x); }
25+
fn debug_opaque<T>(x: T) {
26+
rustrt::debug_opaque::<T>(sys::get_type_desc::<T>(), x);
27+
}
2428

25-
fn debug_box<T>(x: @T) { rustrt::debug_box::<T>(x); }
29+
fn debug_box<T>(x: @T) {
30+
rustrt::debug_box::<T>(sys::get_type_desc::<T>(), x);
31+
}
2632

27-
fn debug_tag<T>(x: T) { rustrt::debug_tag::<T>(x); }
33+
fn debug_tag<T>(x: T) {
34+
rustrt::debug_tag::<T>(sys::get_type_desc::<T>(), x);
35+
}
2836

2937

3038
/**
@@ -37,13 +45,15 @@ fn debug_tag<T>(x: T) { rustrt::debug_tag::<T>(x); }
3745
* the front of any obj's data tuple.x
3846
*/
3947
fn debug_obj<T>(x: T, nmethods: uint, nbytes: uint) {
40-
rustrt::debug_obj::<T>(x, nmethods, nbytes);
48+
rustrt::debug_obj::<T>(sys::get_type_desc::<T>(), x, nmethods, nbytes);
4149
}
4250

43-
fn debug_fn<T>(x: T) { rustrt::debug_fn::<T>(x); }
51+
fn debug_fn<T>(x: T) {
52+
rustrt::debug_fn::<T>(sys::get_type_desc::<T>(), x);
53+
}
4454

4555
unsafe fn ptr_cast<T, U>(x: @T) -> @U {
46-
ret rustrt::debug_ptrcast::<T, U>(x);
56+
ret rustrt::debug_ptrcast::<T, U>(sys::get_type_desc::<T>(), x);
4757
}
4858

4959
fn refcount<T>(a: @T) -> uint unsafe {

src/rt/rust_builtin.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,12 @@ rand_new() {
160160
}
161161

162162
extern "C" CDECL size_t
163-
<<<<<<< HEAD
164163
rand_next(randctx *rctx) {
165-
=======
166-
rand_next(randctx *rctx)
167-
{
168-
>>>>>>> move rand functions into c-stack-cdecl mode
169164
return isaac_rand(rctx);
170165
}
171166

172167
extern "C" CDECL void
173-
<<<<<<< HEAD
174168
rand_free(randctx *rctx) {
175-
=======
176-
rand_free(randctx *rctx)
177-
{
178-
>>>>>>> move rand functions into c-stack-cdecl mode
179169
rust_task *task = rust_scheduler::get_task();
180170
task->free(rctx);
181171
}
@@ -221,7 +211,9 @@ task_join(rust_task_id tid) {
221211
/* Debug builtins for std::dbg. */
222212

223213
static void
224-
debug_tydesc_helper(rust_task* task, type_desc *t) {
214+
debug_tydesc_helper(type_desc *t)
215+
{
216+
rust_task *task = rust_scheduler::get_task();
225217
LOG(task, stdlib, " size %" PRIdPTR ", align %" PRIdPTR
226218
", first_param 0x%" PRIxPTR,
227219
t->size, t->align, t->first_param);
@@ -231,14 +223,14 @@ extern "C" CDECL void
231223
debug_tydesc(type_desc *t) {
232224
rust_task *task = rust_scheduler::get_task();
233225
LOG(task, stdlib, "debug_tydesc");
234-
debug_tydesc_helper(task, t);
226+
debug_tydesc_helper(t);
235227
}
236228

237229
extern "C" CDECL void
238230
debug_opaque(type_desc *t, uint8_t *front) {
239231
rust_task *task = rust_scheduler::get_task();
240232
LOG(task, stdlib, "debug_opaque");
241-
debug_tydesc_helper(task, t);
233+
debug_tydesc_helper(t);
242234
// FIXME may want to actually account for alignment. `front` may not
243235
// indeed be the front byte of the passed-in argument.
244236
for (uintptr_t i = 0; i < t->size; ++front, ++i) {
@@ -257,7 +249,7 @@ extern "C" CDECL void
257249
debug_box(type_desc *t, rust_box *box) {
258250
rust_task *task = rust_scheduler::get_task();
259251
LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
260-
debug_tydesc_helper(task, t);
252+
debug_tydesc_helper(t);
261253
LOG(task, stdlib, " refcount %" PRIdPTR,
262254
box->ref_count - 1); // -1 because we ref'ed for this call
263255
for (uintptr_t i = 0; i < t->size; ++i) {
@@ -275,7 +267,7 @@ debug_tag(type_desc *t, rust_tag *tag) {
275267
rust_task *task = rust_scheduler::get_task();
276268

277269
LOG(task, stdlib, "debug_tag");
278-
debug_tydesc_helper(task, t);
270+
debug_tydesc_helper(t);
279271
LOG(task, stdlib, " discriminant %" PRIdPTR, tag->discriminant);
280272

281273
for (uintptr_t i = 0; i < t->size - sizeof(tag->discriminant); ++i)
@@ -293,7 +285,7 @@ debug_obj(type_desc *t, rust_obj *obj, size_t nmethods, size_t nbytes) {
293285
rust_task *task = rust_scheduler::get_task();
294286

295287
LOG(task, stdlib, "debug_obj with %" PRIdPTR " methods", nmethods);
296-
debug_tydesc_helper(task, t);
288+
debug_tydesc_helper(t);
297289
LOG(task, stdlib, " vtbl at 0x%" PRIxPTR, obj->vtbl);
298290
LOG(task, stdlib, " body at 0x%" PRIxPTR, obj->body);
299291

@@ -314,7 +306,7 @@ extern "C" CDECL void
314306
debug_fn(type_desc *t, rust_fn *fn) {
315307
rust_task *task = rust_scheduler::get_task();
316308
LOG(task, stdlib, "debug_fn");
317-
debug_tydesc_helper(task, t);
309+
debug_tydesc_helper(t);
318310
LOG(task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk);
319311
LOG(task, stdlib, " closure at 0x%" PRIxPTR, fn->closure);
320312
if (fn->closure) {
@@ -328,9 +320,9 @@ debug_ptrcast(type_desc *from_ty,
328320
void *ptr) {
329321
rust_task *task = rust_scheduler::get_task();
330322
LOG(task, stdlib, "debug_ptrcast from");
331-
debug_tydesc_helper(task, from_ty);
323+
debug_tydesc_helper(from_ty);
332324
LOG(task, stdlib, "to");
333-
debug_tydesc_helper(task, to_ty);
325+
debug_tydesc_helper(to_ty);
334326
return ptr;
335327
}
336328

0 commit comments

Comments
 (0)