diff options
author | John Hawthorn <john@hawthorn.email> | 2023-10-13 10:31:56 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2023-11-13 15:03:11 -0800 |
commit | b41270842aae73bf59e17fb1d175a4ff557f0e87 (patch) | |
tree | 7b341e2c50e09f48c348f446d90ca998439b0652 /ext/objspace/objspace_dump.c | |
parent | 775ed27d6d361c9c50236497dd4382bbf85068d9 (diff) |
Record more info from CALLCACHE in heap dumps
This records the called_id and klass from imemo_callcache objects in
heap dumps.
Diffstat (limited to 'ext/objspace/objspace_dump.c')
-rw-r--r-- | ext/objspace/objspace_dump.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index c80c38eba4..8fd3d9d0f3 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -168,10 +168,8 @@ dump_append_c(struct dump_config *dc, unsigned char c) } static void -dump_append_ref(struct dump_config *dc, VALUE ref) +dump_append_ptr(struct dump_config *dc, VALUE ref) { - RUBY_ASSERT(ref > 0); - char buffer[roomof(sizeof(VALUE) * CHAR_BIT, 4) + rb_strlen_lit("\"0x\"")]; char *buffer_start, *buffer_end; @@ -188,6 +186,14 @@ dump_append_ref(struct dump_config *dc, VALUE ref) } static void +dump_append_ref(struct dump_config *dc, VALUE ref) +{ + RUBY_ASSERT(ref > 0); + dump_append_ptr(dc, ref); +} + + +static void dump_append_string_value(struct dump_config *dc, VALUE obj) { long i; @@ -441,6 +447,20 @@ dump_object(VALUE obj, struct dump_config *dc) } break; + case imemo_callcache: + mid = vm_cc_cme((const struct rb_callcache *)obj)->called_id; + if (mid != 0) { + dump_append(dc, ", \"called_id\":"); + dump_append_string_value(dc, rb_id2str(mid)); + + VALUE klass = ((const struct rb_callcache *)obj)->klass; + if (klass != 0) { + dump_append(dc, ", \"receiver_class\":"); + dump_append_ref(dc, klass); + } + } + break; + default: break; } |