Skip to content

Commit b135bcb

Browse files
committed
replace top rquired by file path
see tmm1#140
1 parent 5d83283 commit b135bcb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ext/stackprof/stackprof.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,20 @@ frame_lines_i(st_data_t key, st_data_t val, st_data_t arg)
322322
return ST_CONTINUE;
323323
}
324324

325+
static VALUE
326+
coerce_frame_name(VALUE name, VALUE line)
327+
{
328+
char *start_pointer = strstr(RSTRING_PTR(name), "<top (required)>\0");
329+
if (start_pointer) {
330+
VALUE new_name = rb_str_new(RSTRING_PTR(name), start_pointer - RSTRING_PTR(name));
331+
rb_str_cat_cstr(new_name, "<require:");
332+
rb_str_cat_cstr(new_name, RSTRING_PTR(line));
333+
rb_str_cat_cstr(new_name, ">");
334+
return new_name;
335+
}
336+
return name;
337+
}
338+
325339
static int
326340
frame_i(st_data_t key, st_data_t val, st_data_t arg)
327341
{
@@ -347,6 +361,8 @@ frame_i(st_data_t key, st_data_t val, st_data_t arg)
347361
line = rb_profile_frame_first_lineno(frame);
348362
}
349363

364+
name = coerce_frame_name(name, file);
365+
350366
rb_hash_aset(details, sym_name, name);
351367
rb_hash_aset(details, sym_file, file);
352368
if (line != INT2FIX(0)) {

0 commit comments

Comments
 (0)