mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rp(obj)
shows func, file and line. (#2394)
rp() macro for debug also shows file location and function name such as: [OBJ_INFO:rb_call_inits@inits.c:73] 0x000056147741b248 ...
This commit is contained in:
parent
d10e28b875
commit
88b1f2dac4
Notes:
git
2019-08-31 04:40:14 +09:00
Merged-By: ko1
2 changed files with 11 additions and 2 deletions
7
gc.c
7
gc.c
|
@ -11449,6 +11449,13 @@ rb_obj_info_dump(VALUE obj)
|
|||
fprintf(stderr, "rb_obj_info_dump: %s\n", rb_raw_obj_info(buff, 0x100, obj));
|
||||
}
|
||||
|
||||
void
|
||||
rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func)
|
||||
{
|
||||
char buff[0x100];
|
||||
fprintf(stderr, "<OBJ_INFO:%s@%s:%d> %s\n", func, file, line, rb_raw_obj_info(buff, 0x100, obj));
|
||||
}
|
||||
|
||||
#if GC_DEBUG
|
||||
|
||||
void
|
||||
|
|
|
@ -1390,10 +1390,12 @@ rb_ary_entry_internal(VALUE ary, long offset)
|
|||
|
||||
/* MRI debug support */
|
||||
void rb_obj_info_dump(VALUE obj);
|
||||
void ruby_debug_breakpoint(void);
|
||||
void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
|
||||
void ruby_debug_breakpoint(void);
|
||||
|
||||
// show obj data structure without any side-effect
|
||||
#define rp(obj) rb_obj_info_dump((VALUE)obj);
|
||||
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, __func__)
|
||||
|
||||
// same as rp, but add message header
|
||||
#define rp_m(msg, obj) do { \
|
||||
fprintf(stderr, "%s", (msg)); \
|
||||
|
|
Loading…
Reference in a new issue