[m-dev.] For review: Stacks dump in the external debugger (round 2)
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Feb 19 06:45:54 AEDT 1999
On 16-Feb-1999, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> | > + if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
> | > + MR_send_message_to_socket_format(
> | > + "proc(%s for %s:%s/%ld-%ld).\n",
> |
> | That won't be valid syntax for a Prolog term.
> | I suggest
> |
> | "proc('%s for %s:%s'/%ld-%ld).\n"
> |
> | which should work OK except when one of the names contains a
> | single quote ("'").
>
> Can it happen?
Yes. (But in practice it is unlikely.)
> Isn't that a problem?
Yes.
To do it properly, you need to escape (with backslashes)
any single quotes in the predicate or module names.
That's a bit tricky, so an /* XXX ... */ comment might do for now.
> +/*
> +** The protocol between the debugged Mercury program and the external debugger
> +** is the following:
> +** 1) The debugger sends "stack";
> +** 2) For each procedure in the stack that is not generated by the compiler, the
> +** debuggee sends:
> +** - level(int) (the level of the procedure in the stack)
> +** - detail(unsigned long, unsigned long, unsigned long) (the call event
> +** number, call sequence number and depth of the goal of the procedure)
> +** - the atom 'pred' or 'func' depending if the procedure is a function
> +** or not
> +** - proc('string:string'/long-long) (the name of the procedure)
> +** - det(string) (the determinism of the procedure)
> +** - def_module(string) (the name of the defining module if different from
> +** the current one)
Does it send def_module(string) if the name of the defining module
is the same as the name of the current one?
If not, how does the debugger know when to stop reading from the socket?
You need to fix that.
> Index: trace/mercury_trace_internal.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.h,v
> retrieving revision 1.5
> diff -u -r1.5 mercury_trace_internal.h
> --- mercury_trace_internal.h 1999/02/10 22:31:22 1.5
> +++ mercury_trace_internal.h 1999/02/16 20:22:02
> @@ -48,6 +48,7 @@
> MR_Trace_Port port, int seqno, int depth,
> const char *path, int *max_mr_num);
>
> +
> /*
> ** Debugger I/O streams.
> ** Replacements for stdin/stdout/stderr respectively.
That change looks unintentional.
Apart from that, it looks fine.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh> | but source code lives forever"
PGP: finger fjh at 128.250.37.3 | -- leaked Microsoft memo.
More information about the developers
mailing list