summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-08-09 13:57:47 +0900
committerKoichi Sasada <ko1@atdot.net>2019-08-09 14:01:15 +0900
commit6bf8db9a07e95820705f7ec119f4038a529182ef (patch)
treeb5165573ca3ca4e4106754901d843d71545cf474
parentcb390e87dc682a277579f44fac6aea57e16e5f7a (diff)
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`).
-rw-r--r--common.mk1
-rw-r--r--gc.h1
-rw-r--r--internal.h16
-rw-r--r--thread.c1
-rw-r--r--vm_debug.h3
5 files changed, 16 insertions, 6 deletions
diff --git a/common.mk b/common.mk
index 6b4a0b0..d0b1b29 100644
--- a/common.mk
+++ b/common.mk
@@ -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
diff --git a/gc.h b/gc.h
index 018ad0e..0e7ffba 100644
--- a/gc.h
+++ b/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);
diff --git a/internal.h b/internal.h
index c502fe0..76c10c8 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);
diff --git a/thread.c b/thread.c
index f9fc70f..0f8b512 100644
--- a/thread.c
+++ b/thread.c
@@ -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"
diff --git a/vm_debug.h b/vm_debug.h
index 32e0607..8e0350d 100644
--- a/vm_debug.h
+++ b/vm_debug.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);