Skip to content

Commit

Permalink
print filenames of objects instantiated during the test
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Jul 8, 2024
1 parent 85f37ce commit bf5738e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ext/datadog_cov/datadog_cov.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,34 @@ static void process_newobj_event(VALUE tracepoint_data, void *data)
}

VALUE klass = rb_class_of(new_object);
if (klass == Qnil)
{
return;
}

VALUE klass_name = rb_class_name(klass);
if (klass_name == Qnil)
{
return;
}

printf("New object of class %s\n", RSTRING_PTR(klass_name));

VALUE rb_module = rb_const_get_at(rb_cObject, rb_intern("Module"));
VALUE source_location = rb_funcall(rb_module, rb_intern("const_source_location"), 1, klass_name);

if (source_location == Qnil)
{
return;
}
VALUE filename = RARRAY_AREF(source_location, 0);

if (filename == Qnil)
{
return;
}

printf("New filename %s\n", RSTRING_PTR(filename));
}

static VALUE dd_cov_start(VALUE self)
Expand Down

0 comments on commit bf5738e

Please sign in to comment.