diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-04-17 16:03:05 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-04-17 18:47:07 +0900 |
commit | 09638741ba4d9547a0e48af8c767744fb1d7f68d () | |
tree | 9fc723c63d3594e0b420d14fc7d9e876ab073125 /vm_backtrace.c | |
parent | 7bc66a366ded3ae2d07a418e17a9da6ee24612fd (diff) |
[Feature #20335] `Thread.each_caller_location` arguments
Accecpt the same arguments as `caller` and `caller_locations`.
-rw-r--r-- | vm_backtrace.c | 42 |
1 files changed, 30 insertions, 12 deletions
@@ -1170,17 +1170,17 @@ rb_make_backtrace(void) return rb_ec_backtrace_str_ary(GET_EC(), BACKTRACE_START, ALL_BACKTRACE_LINES); } -static VALUE -ec_backtrace_to_ary(const rb_execution_context_t *ec, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str) { - VALUE level, vn; long lev, n; - VALUE btval; - VALUE r; - int too_large; - rb_scan_args(argc, argv, "02", &level, &vn); if (argc == 2 && NIL_P(vn)) argc--; switch (argc) { @@ -1201,7 +1201,7 @@ ec_backtrace_to_ary(const rb_execution_context_t *ec, int argc, const VALUE *arg n = ALL_BACKTRACE_LINES; break; case Qnil: - return Qnil; default: lev = beg + lev_plus; n = len; @@ -1225,6 +1225,20 @@ ec_backtrace_to_ary(const rb_execution_context_t *ec, int argc, const VALUE *arg break; } if (n == 0) { return rb_ary_new(); } @@ -1354,15 +1368,19 @@ rb_f_caller_locations(int argc, VALUE *argv, VALUE _) /* * call-seq: - * Thread.each_caller_location{ |loc| ... } -> nil * * Yields each frame of the current execution stack as a * backtrace location object. */ static VALUE -each_caller_location(VALUE unused) { - rb_ec_partial_backtrace_object(GET_EC(), 2, ALL_BACKTRACE_LINES, NULL, FALSE, TRUE); return Qnil; } @@ -1442,7 +1460,7 @@ Init_vm_backtrace(void) rb_define_global_function("caller", rb_f_caller, -1); rb_define_global_function("caller_locations", rb_f_caller_locations, -1); - rb_define_singleton_method(rb_cThread, "each_caller_location", each_caller_location, 0); } /* debugger API */ |