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`).
This commit is contained in:
Koichi Sasada 2019-08-09 13:57:47 +09:00
Родитель cb390e87dc
Коммит 6bf8db9a07
5 изменённых файлов: 16 добавлений и 6 удалений

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

@ -3035,7 +3035,6 @@ thread.$(OBJEXT): {$(VPATH)}debug_counter.h
thread.$(OBJEXT): {$(VPATH)}defines.h
thread.$(OBJEXT): {$(VPATH)}encoding.h
thread.$(OBJEXT): {$(VPATH)}eval_intern.h
thread.$(OBJEXT): {$(VPATH)}gc.h
thread.$(OBJEXT): {$(VPATH)}hrtime.h
thread.$(OBJEXT): {$(VPATH)}id.h
thread.$(OBJEXT): {$(VPATH)}intern.h

1
gc.h
Просмотреть файл

@ -100,7 +100,6 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
const char *rb_obj_info(VALUE obj);
const char *rb_raw_obj_info(char *buff, const int buff_size, VALUE obj);
void rb_obj_info_dump(VALUE obj);
VALUE rb_gc_disable_no_rest(void);

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

@ -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);

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

@ -66,7 +66,6 @@
#include "ruby/config.h"
#include "ruby/io.h"
#include "eval_intern.h"
#include "gc.h"
#include "timev.h"
#include "ruby/thread.h"
#include "ruby/thread_native.h"

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

@ -22,13 +22,10 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define dpi(i) ruby_debug_print_id(-1, 0, "", (i))
#define dpn(n) ruby_debug_print_node(-1, 0, "", (n))
#define bp() ruby_debug_breakpoint()
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
void ruby_debug_breakpoint(void);
void ruby_debug_gc_check_func(void);
void ruby_set_debug_option(const char *str);