From 7170baa878ac0223f26fcf8c8bf25492415e6eaa Mon Sep 17 00:00:00 2001 From: tmm1 Date: Tue, 10 Dec 2013 02:26:09 +0000 Subject: objspace_dump.c: include object's gc flags in dump * ext/objspace/objspace_dump.c (dump_object): include fstring flag on strings. include gc flags (old, remembered, wb_protected) on all objects. * ext/objspace/objspace_dump.c (Init_objspace_dump): initialize lazy IDs before first use. * gc.c (rb_obj_gc_flags): new function to retrieve object flags * internal.h (RB_OBJ_GC_FLAGS_MAX): maximum flags allowed for one obj * test/objspace/test_objspace.rb (test_dump_flags): test for above * test/objspace/test_objspace.rb (test_trace_object_allocations): resolve name before dump (for rb_class_path_cached) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/objspace/objspace_dump.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ext/objspace') diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index a9906b8538..9a694d33aa 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -20,6 +20,7 @@ #include "node.h" #include "vm_core.h" #include "objspace.h" +#include "internal.h" static VALUE sym_output, sym_stdout, sym_string, sym_file; @@ -148,6 +149,8 @@ dump_object(VALUE obj, struct dump_config *dc) size_t memsize; struct allocation_info *ainfo; rb_io_t *fptr; + ID flags[RB_OBJ_GC_FLAGS_MAX]; + size_t n, i; dc->cur_obj = obj; dc->cur_obj_references = 0; @@ -175,6 +178,8 @@ dump_object(VALUE obj, struct dump_config *dc) dump_append(dc, ", \"associated\":true"); if (is_broken_string(obj)) dump_append(dc, ", \"broken\":true"); + if (FL_TEST(obj, RSTRING_FSTR)) + dump_append(dc, ", \"fstring\":true"); if (STR_SHARED_P(obj)) dump_append(dc, ", \"shared\":true"); else { @@ -249,6 +254,15 @@ dump_object(VALUE obj, struct dump_config *dc) if ((memsize = rb_obj_memsize_of(obj)) > 0) dump_append(dc, ", \"memsize\":%"PRIuSIZE, memsize); + if ((n = rb_obj_gc_flags(obj, flags, sizeof(flags))) > 0) { + dump_append(dc, ", \"flags\":{"); + for (i=0; i