[m-dev.] for review: fix for stack traces in -O-1
Mark Anthony BROWN
dougl at cs.mu.OZ.AU
Sun Apr 12 11:39:29 AEST 1998
>
> Hi,
>
> Mark, want to review this one?
Sure.
...
> Index: library/require.m
> ===================================================================
...
> +:- pragma c_code("
> +
> +Define_extern_entry(mercury__require__error_internal_1_0);
> +
> +MR_MAKE_STACK_LAYOUT_ENTRY(mercury__require__error_internal_1_0);
> +
> +BEGIN_MODULE(require_module_internal)
> + init_entry(mercury__require__error_internal_1_0);
> +BEGIN_CODE
> +
> +/* code for predicate 'error'/1 in mode 0 */
This is the code for 'error_internal'/1 (although it is directly called
from 'error'/1).
...
> Index: runtime/mercury_stack_trace.h
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_trace.h,v
> retrieving revision 1.2
> diff -u -r1.2 mercury_stack_trace.h
> --- mercury_stack_trace.h 1998/04/07 05:23:07 1.2
> +++ mercury_stack_trace.h 1998/04/07 09:12:14
> @@ -16,8 +16,21 @@
>
> /*
> ** MR_dump_stack:
> -** Given the succip and det stack pointer, generate a stack dump
> -** showing then name of each active procedure on the stack.
> +** Given the succip, det stack pointer and current frame, generate a
> +** stack dump showing then name of each active procedure on the
s/then/the/
> +** stack.
> +** NOTE: MR_dump_stack will assume that the succip is for the
> +** topmost stack frame. If you call MR_dump_stack from some
> +** pragma c_code that may not be the case.
> +** Due to some optimizations (or lack thereof) the MR_dump_stack call
> +** may end up inside code that has a stack frame allocated, but a
s/but a/but that/
or something equivalent
> +** has a succip for the previous stack frame.
> +** Don't call MR_dump_stack from Mercury pragma c_code (calling
> +** from other C code in the runtime is probably ok, provided the
> +** succip corresponds to the topmost stack frame).
> +** If you need more convienent calling from Mercury code, it would
> +** probably be best to make an impure predicate defined as using
> +** `:- external'.
> */
Perhaps you could refer the reader to the example in require.m?
>
> extern void MR_dump_stack(Code *success_pointer, Word *det_stack_pointer,
>
Everything else looks fine.
Cheers,
Mark
--
Mark Brown (dougl at cs.mu.oz.au) | Any technology that is
MEngSc student, | distinguishable from magic
Dept of Computer Science, Melbourne Uni | is insufficiently advanced
More information about the developers
mailing list