Record more info from CALLCACHE in heap dumps

This records the called_id and klass from imemo_callcache objects in
heap dumps.
This commit is contained in:
John Hawthorn 2023-10-13 10:31:56 -07:00
Родитель 775ed27d6d
Коммит b41270842a
1 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -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;
@ -187,6 +185,14 @@ dump_append_ref(struct dump_config *dc, VALUE ref)
buffer_append(dc, buffer_start, buffer_end - buffer_start);
}
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)
{
@ -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;
}