[m-rev.] for review: source-linking for mdb

Ralph Becket rafe at cs.mu.OZ.AU
Mon Oct 29 11:20:46 AEDT 2001


Mark Brown, Friday, 26 October 2001:
> 
> +	/*
> +	** We generate a unique name by appending a number to a fixed
> +	** string.  The number used is determined by trying all numbers
> +	** in sequence until one is found that is not being used.
> +	**
> +	** XXX this is quite a slow way of doing things, and there is
> +	** also a race condition, but it is difficult to see a better way.
> +	** We should let the server pick a unique name for itself, but
> +	** how would you communicate this name back to this process?
> +	*/

<hostname>-<mdb process id> should be unique.

But I think the risk of two people starting source-tracing debugging
sessions on the same machine at exactly the same time is so low that
your solution seems practical to me.

> +const char *
> +MR_trace_source_sync(MR_Trace_Source_Server *server, const char *filename,
> +		int lineno)
> +{
> +	const char	*real_server_cmd;
> +	const char	*msg;
> +	char		system_call[MR_SYSCALL_BUFFER_SIZE];
> +	int		status;
> +
> +	if (server->server_cmd != NULL) {
> +		real_server_cmd = server->server_cmd;
> +	} else {
> +		real_server_cmd = MR_DEFAULT_SOURCE_SERVER_COMMAND;
> +	}
> +
> +	msg = MR_trace_source_check_server(real_server_cmd,
> +			server->server_name);
> +	if (msg != NULL) {
> +		return msg;
> +	}
> +
> +	sprintf(system_call, "%s --servername \"%s\" --remote '+%d' %s",
> +			real_server_cmd, server->server_name, lineno,
> +			filename);
> +	status = system(system_call);
> +	if (status != 0) {
> +		return "warning: source synchronisation failed";
> +	} else {
> +		return NULL;
> +	}

You should also do

	sprintf(system_call, "%s --servername \"%s\" --remote-send 'z.'",
			real_server_cmd, server->server_name);
	status = system(system_call);
	if (status != 0) {
		return "warning: source synchronisation failed";
	} else {
		return NULL;
	}

in order to centre the window on the source line.  Not sending `z.'
will result in the line in question frequently appearing as the last
line in the window.

One idea that occurs to me is that we could split the vim window
in two, with the upper window showing the caller and the lower
window showing the callee.

This can be arranged as follows.  Initialize the server and send

	--remote +<start source line no.> <source file>
	--remote-send 'z.'		# Centre on source line
	--remote-send '^Ws'		# Split the window
	--remote-send '^Wb'		# Ensure cursor is in lower window

thereafter send

	--remote-send '^Wx'		# Swap upper and lower windows
	--remote-send '^Wb'		# Ensure cursor is in lower window
	--remote +<callee source line no.> <callee source file>
	--remote-send 'z.'		# Centre on source line

Consecutive remote-sends can be condensed into one.

- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list