diff options
author | Koichi Sasada <ko1@atdot.net> | 2019-08-09 13:57:47 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-08-09 14:01:15 +0900 |
commit | 6bf8db9a07e95820705f7ec119f4038a529182ef (patch) | |
tree | b5165573ca3ca4e4106754901d843d71545cf474 /internal.h | |
parent | cb390e87dc682a277579f44fac6aea57e16e5f7a (diff) | |
download | ruby-6bf8db9a07e95820705f7ec119f4038a529182ef.tar.gz |
add rp() and bp() in internal.h.
debug utility macro rp() (rp_m()) and bp() are introduced.
* rp(obj) shows obj information w/o any side-effect to STDERR.
* rp_m(m, obj) is similar to rp(obj), but show m before.
* bp() is alias of ruby_debug_breakpoint(), which is registered
as a breakpoint in run.gdb (used by `make gdb` or make gdb-ruby`).
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal.h b/internal.h index c502fe076c..76c10c8bf5 100644 --- a/internal.h +++ b/internal.h @@ -1388,6 +1388,22 @@ rb_ary_entry_internal(VALUE ary, long offset) return ptr[offset]; } +/* MRI debug support */ +void rb_obj_info_dump(VALUE obj); +void ruby_debug_breakpoint(void); + +// show obj data structure without any side-effect +#define rp(obj) rb_obj_info_dump((VALUE)obj); +// same as rp, but add message header +#define rp_m(msg, obj) do { \ + fprintf(stderr, "%s", (msg)); \ + rb_obj_info_dump((VALUE)obj); \ +} while (0) + +// `ruby_debug_breakpoint()` does nothing, +// but breakpoint is set in run.gdb, so `make gdb` can stop here. +#define bp() ruby_debug_breakpoint() + /* bignum.c */ extern const char ruby_digitmap[]; double rb_big_fdiv_double(VALUE x, VALUE y); |