Skip to content

Commit 47d5217

Browse files
committed
---
yaml --- r: 584 b: refs/heads/master c: 7ccdb88 h: refs/heads/master v: v3
1 parent 4f11678 commit 47d5217

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d9e3fb2c5d5e11725977a844b2b4c26b7a05048c
2+
refs/heads/master: 7ccdb883748a66122b88663139920db4f15a6920

trunk/src/lib/dbg.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ native "rust" mod rustrt {
99
fn debug_opaque[T](&T x);
1010
fn debug_box[T](@T x);
1111
fn debug_tag[T](&T x);
12-
fn debug_obj[T](&T x, uint nmethods);
12+
fn debug_obj[T](&T x, uint nmethods, uint nbytes);
1313
fn debug_fn[T](&T x);
1414
}
1515

@@ -33,8 +33,17 @@ fn debug_tag[T](&T x) {
3333
rustrt.debug_tag[T](x);
3434
}
3535

36-
fn debug_obj[T](&T x, uint nmethods) {
37-
rustrt.debug_obj[T](x, nmethods);
36+
/**
37+
* `nmethods` is the number of methods we expect the object to have. The
38+
* runtime will print this many words of the obj vtbl).
39+
*
40+
* `nbytes` is the number of bytes of body data we expect the object to have.
41+
* The runtime will print this many bytes of the obj body. You probably want
42+
* this to at least be 4u, since an implicit captured tydesc pointer sits in
43+
* the front of any obj's data tuple.x
44+
*/
45+
fn debug_obj[T](&T x, uint nmethods, uint nbytes) {
46+
rustrt.debug_obj[T](x, nmethods, nbytes);
3847
}
3948

4049
fn debug_fn[T](&T x) {

trunk/src/rt/rust_builtin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ struct rust_obj {
308308
};
309309

310310
extern "C" CDECL void
311-
debug_obj(rust_task *task, type_desc *t, rust_obj *obj, size_t nmethods)
311+
debug_obj(rust_task *task, type_desc *t, rust_obj *obj,
312+
size_t nmethods, size_t nbytes)
312313
{
313314
task->log(rust_log::STDLIB,
314315
"debug_obj with %" PRIdPTR " methods", nmethods);
@@ -318,6 +319,11 @@ debug_obj(rust_task *task, type_desc *t, rust_obj *obj, size_t nmethods)
318319

319320
for (uintptr_t *p = obj->vtbl; p < obj->vtbl + nmethods; ++p)
320321
task->log(rust_log::STDLIB, " vtbl word: 0x%" PRIxPTR, *p);
322+
323+
for (uintptr_t i = 0; i < nbytes; ++i)
324+
task->log(rust_log::STDLIB,
325+
" body byte %" PRIdPTR ": 0x%" PRIxPTR,
326+
i, obj->body->data[i]);
321327
}
322328

323329
struct rust_fn {

0 commit comments

Comments
 (0)