[m-dev.] For review: Stacks dump in the external debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 12 10:32:38 AEDT 1999


On 11-Feb-1999, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> | On 11-Feb-1999, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> | > Estimated hours taken: 1
> | > 
> | > This change implement stack dump commands for the external debugger.
> | > 
> | > browser/debugger_interface.m:
> | > 	Add three new kinds of requests: stack, nondet_stack and stack_regs.
> | > 
> | > trace/mercury_trace_external.c:
> | > 	Implement the ancestors, non det and registers stack dump.
> | 
> | Is there much point in implementing the `nondet_stack' and `stack_regs'
> | commands in the external debugger? 
> | These commands are intended for developers of the Mercury implementation only,
> | to debug the low-level execution mechanism.
> | 
> | I suppose it can't do much harm...
> 
> That's what I thougth...
> Futhermore, maybe developpers will use my debugger one day ? ;)

OK, fair enough.  But currently I'm just a bit worried that
by writing to stdout it may be doing some harm.

> | > +			case MR_REQUEST_STACK:
> | > +				if (MR_debug_socket) {
> | > +					fprintf(stderr, "\nMercury runtime: "
> | > +						"REQUEST_STACK\n");
> | > +				}
> | > +				include_trace_data = TRUE;
> | > +				do_init_modules();
> | > +				message = MR_dump_stack_from_layout(stdout,
> | 
> | I think stdout is not a good place to send such things.
> | That might interfere with the output of the program being debugged.
> | Shouldn't they be sent down the socket?
> 
> Well the problem is that I only read Prolog terms from the socket.
> 
> One thing I can do is create a temporary file, put in it the output of
> MR_dump_stack_from_layout, reread it word by word and send them to the socket.

Ugh.  Horrible.

> Do you see some simpler to do that? (without rewriting all the stack_dump stuff)

How about changing the stack_dump stuff so that the function
`MR_dump_stack_record_print' is passed down as a parameter?
Then the internal debugger can pass down the current
`MR_dump_stack_record_print', and the external debugger
can pass down the address of a new function which prints
the data to the socket as a Prolog term.

I think you will find that this is *much* nicer than using a
temporary file :-)

> I can't do that for the nondet_stack since not all the outputs are done in the
> * FILE argument (some are done in stderr). So I let it as it was in my previous
> diff.

At very least I think you should add an "XXX" comment
explaining what is wrong.

-- 
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