[m-dev.] diff: move the initialisation of MR_mmc_options in MR_trace_event_external()

Fergus Henderson fjh at cs.mu.OZ.AU
Sat May 22 10:14:42 AEST 1999


On 21-May-1999, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> Estimated hours taken: 0.1
> 
> Initialise the variable MR_mmc_options only if an interactive query request is
> made; it is useless to pay the price of a call to MR_TRACE_CALL_MERCURY() for
> the other kinds of requests.
> 
> trace/mercury_trace_external.c:
> 	Move the call to 
> 	MR_TRACE_CALL_MERCURY(ML_DI_init_mercury_string(&MR_mmc_options))
> 	from the body of MR_trace_event_external() to the cases of an 
> 	interactive query is made. 

That is a bug.  If you initialize MR_mmc_options every time, then
the MR_REQUEST_MMC_OPTIONS request, which lets the external debugger
set MR_mmc_options, will not work anymore.

Probably mmc_options should not be initialized at each call to
MR_trace_event_external(), for similar reasons.  Instead, its value
should be persistent.  One way to achieve that would be

	static bool MR_mmc_options_initialized = FALSE;
	if (!MR_mmc_options_initialized) {
		... initialization goes here ...
		MR_mmc_options_initialized = TRUE;
	}

Another way would be to initialize it in MR_trace_init_external()
(this would of course require making it a global static variable
rather than a local static variable).  However, this approach
might cause order-of-initialization problems, because you are
calling Mercury code to to the initialization, and the Mercury
memory areas might not have been set up yet at the time that
MR_trace_init_external() is called, or the Mercury code might
have been compiled with debugging enabled and might then call
MR_trace() before MR_trace_init_external() has finished.
Therefore I recommend the former approach.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list