Last active
July 22, 2018 06:59
-
-
Save k-tsj/4303292 to your computer and use it in GitHub Desktop.
CRuby ENABLE_TRAP patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tool/ruby_vm/views/_insn_entry.erb b/tool/ruby_vm/views/_insn_entry.erb | |
index bae8eae890..08d16882ec 100644 | |
--- a/tool/ruby_vm/views/_insn_entry.erb | |
+++ b/tool/ruby_vm/views/_insn_entry.erb | |
@@ -18,6 +18,11 @@ INSN_ENTRY(<%= insn.name %>) | |
% end | |
START_OF_ORIGINAL_INSN(<%= insn.name %>); | |
+if (rb_iseq_eval_main_p && getenv("ENABLE_TRAP")) { | |
+ rb_vmdebug_stack_dump_raw_current(); | |
+ fprintf(stderr, "### Next: <%= insn.name %> ################\n"); | |
+ raise(SIGTRAP); | |
+} | |
% insn.preamble.each do |konst| | |
<%= render_c_expr konst -%> | |
% end | |
diff --git a/vm.c b/vm.c | |
index 36c8833439..5606d19ad2 100644 | |
--- a/vm.c | |
+++ b/vm.c | |
@@ -339,6 +339,7 @@ rb_event_flag_t ruby_vm_event_enabled_flags; | |
rb_serial_t ruby_vm_global_method_state = 1; | |
rb_serial_t ruby_vm_global_constant_state = 1; | |
rb_serial_t ruby_vm_class_serial = 1; | |
+int rb_iseq_eval_main_p; | |
static void thread_free(void *ptr); | |
@@ -2063,6 +2064,7 @@ rb_iseq_eval_main(const rb_iseq_t *iseq) | |
VALUE val; | |
vm_set_main_stack(ec, iseq); | |
+ rb_iseq_eval_main_p = 1; | |
val = vm_exec(ec, TRUE); | |
return val; | |
} | |
diff --git a/vm_core.h b/vm_core.h | |
index 73ef51da49..2626baa770 100644 | |
--- a/vm_core.h | |
+++ b/vm_core.h | |
@@ -1527,6 +1527,8 @@ VALUE rb_proc_dup(VALUE self); | |
/* for debug */ | |
extern void rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp); | |
+extern void rb_vmdebug_stack_dump_raw_current(void); | |
+ | |
extern void rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc); | |
extern void rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp); | |
@@ -1822,6 +1824,8 @@ extern void rb_reset_coverages(void); | |
void rb_postponed_job_flush(rb_vm_t *vm); | |
+extern int rb_iseq_eval_main_p; | |
+ | |
RUBY_SYMBOL_EXPORT_END | |
#endif /* RUBY_VM_CORE_H */ | |
diff --git a/vm_dump.c b/vm_dump.c | |
index 348582b934..e72d8f1764 100644 | |
--- a/vm_dump.c | |
+++ b/vm_dump.c | |
@@ -140,7 +140,7 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c | |
void | |
rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp) | |
{ | |
-#if 0 | |
+#if 1 | |
VALUE *sp = cfp->sp; | |
const VALUE *ep = cfp->ep; | |
VALUE *p, *st, *t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment