summaryrefslogtreecommitdiffhomepage
path: root/src/backtrace.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2021-01-10 10:50:22 +0900
committerdearblue <[email protected]>2021-01-10 13:23:43 +0900
commitced89c25ffc9ac748dc2dd336cce24d080ebf419 (patch)
treec72aa35170876cf2904315a43a383127f796ce34 /src/backtrace.c
parent16baea06771f38fea810ad1eaf3239086442c258 (diff)
downloadmruby-ced89c25ffc9ac748dc2dd336cce24d080ebf419.tar.gz
mruby-ced89c25ffc9ac748dc2dd336cce24d080ebf419.zip
Unified `pc` and `err` of `mrb_callinfo`
This enhances self-containment. - Changed the `mrb_callinfo::pc` field to point to itself. Previously it indicated the return destination of the previous call level. `mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`. - Removed `mrb_callinfo::err` field. This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`. - The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted. - It removes the argument because `cipush()` doesn't need to save the previous `pc`.
Diffstat (limited to 'src/backtrace.c')
-rw-r--r--src/backtrace.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/backtrace.c b/src/backtrace.c
index 1006f2f86..508fe99e9 100644
--- a/src/backtrace.c
+++ b/src/backtrace.c
@@ -29,7 +29,7 @@ mrb_value mrb_exc_inspect(mrb_state *mrb, mrb_value exc);
mrb_value mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace);
static void
-each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, const mrb_code *pc0, each_backtrace_func func, void *data)
+each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void *data)
{
ptrdiff_t i;
@@ -50,15 +50,11 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, const mrb_code *pc0, each_backtr
irep = ci->proc->body.irep;
if (!irep) continue;
- if (mrb->c->cibase[i].err) {
- pc = mrb->c->cibase[i].err;
- }
- else if (i+1 <= ciidx) {
- if (!mrb->c->cibase[i + 1].pc) continue;
- pc = &mrb->c->cibase[i+1].pc[-1];
+ if (mrb->c->cibase[i].pc) {
+ pc = &mrb->c->cibase[i].pc[-1];
}
else {
- pc = pc0;
+ continue;
}
loc.lineno = mrb_debug_get_line(mrb, irep, pc - irep->iseq);
@@ -159,12 +155,12 @@ packed_backtrace(mrb_state *mrb)
int size;
void *ptr;
- each_backtrace(mrb, ciidx, mrb->c->ci->pc, count_backtrace_i, &len);
+ each_backtrace(mrb, ciidx, count_backtrace_i, &len);
size = len * sizeof(struct backtrace_location);
ptr = mrb_malloc(mrb, size);
backtrace = mrb_data_object_alloc(mrb, NULL, ptr, &bt_type);
backtrace->flags = (uint32_t)len;
- each_backtrace(mrb, ciidx, mrb->c->ci->pc, pack_backtrace_i, &ptr);
+ each_backtrace(mrb, ciidx, pack_backtrace_i, &ptr);
return mrb_obj_value(backtrace);
}