SCM_RETURN_NEWSMOB (scm_tc16_vm_frame, p);
}
+static int
+vm_frame_print (SCM frame, SCM port, scm_print_state *pstate)
+{
+ scm_puts ("#<vm-frame ", port);
+ scm_uintprint (SCM_UNPACK (frame), 16, port);
+ scm_putc (' ', port);
+ scm_write (scm_vm_frame_program (frame), port);
+ /* don't write args, they can get us into trouble. */
+ scm_puts (">", port);
+
+ return 1;
+}
+
static SCM
vm_frame_mark (SCM obj)
{
scm_tc16_vm_frame = scm_make_smob_type ("vm-frame", 0);
scm_set_smob_mark (scm_tc16_vm_frame, vm_frame_mark);
scm_set_smob_free (scm_tc16_vm_frame, vm_frame_free);
+ scm_set_smob_print (scm_tc16_vm_frame, vm_frame_print);
}
void
scm_t_debug_info *vect = RELOC_INFO (dframe->vect, offset);
if (SCM_PROGRAM_P (vect[0].a.proc))
{
+ if (!SCM_PROGRAM_IS_BOOT (vect[0].a.proc))
+ /* Programs can end up in the debug stack via deval; but we just
+ ignore those, because we know that the debugging VM engine
+ pushes one dframe per invocation, with the boot program as
+ the proc, so we only count those. */
+ continue;
/* count vmframe back to previous boot frame */
for (; scm_is_true (vmframe); vmframe = scm_c_vm_frame_prev (vmframe))
{
- if (SCM_PROGRAM_IS_BOOT (scm_vm_frame_program (vmframe)))
+ if (!SCM_PROGRAM_IS_BOOT (scm_vm_frame_program (vmframe)))
+ ++n;
+ else
{ /* skip boot frame, cut out of the vm backtrace */
vmframe = scm_c_vm_frame_prev (vmframe);
break;
}
- else
- ++n;
}
- if (!SCM_PROGRAM_IS_BOOT (vect[0].a.proc))
- ++n; /* increment for apply frame if this isn't a boot frame */
}
else if (scm_is_eq (vect[0].a.proc, scm_f_gsubr_apply))
/* Skip gsubr apply frames. */
continue;
else if (SCM_PROGRAM_P (iframe->proc))
{
- scm_t_info_frame saved = *iframe;
+ if (!SCM_PROGRAM_IS_BOOT (iframe->proc))
+ /* Programs can end up in the debug stack via deval; but we just
+ ignore those, because we know that the debugging VM engine
+ pushes one dframe per invocation, with the boot program as
+ the proc, so we only count those. */
+ continue;
for (; scm_is_true (vmframe);
vmframe = scm_c_vm_frame_prev (vmframe))
{
goto quit;
}
}
- if (!SCM_PROGRAM_IS_BOOT (saved.proc))
- {
- *iframe = saved;
- NEXT_FRAME (iframe, n, quit);
- }
}
else
{
#if VM_PUSH_DEBUG_FRAMES
debug.prev = scm_i_last_debug_frame ();
- if (!(debug.prev && debug.prev->status == SCM_APPLYFRAME
- && debug.prev->vect[0].a.proc != prog))
- {
- debug.status = SCM_APPLYFRAME;
- debug.vect = &debug_vect_body;
- debug.vect[0].a.proc = program; /* the boot program */
- debug.vect[0].a.args = SCM_EOL;
- scm_i_set_last_debug_frame (&debug);
- }
+ debug.status = SCM_APPLYFRAME;
+ debug.vect = &debug_vect_body;
+ debug.vect[0].a.proc = program; /* the boot program */
+ debug.vect[0].a.args = SCM_EOL;
+ scm_i_set_last_debug_frame (&debug);
#endif
/* Initial frame */
vm_done:
SYNC_ALL ();
#if VM_PUSH_DEBUG_FRAMES
- if (debug.status == SCM_APPLYFRAME)
- scm_i_set_last_debug_frame (debug.prev);
+ scm_i_set_last_debug_frame (debug.prev);
#endif
return finish_args;