[m-rev.] for review: source-linking for mdb
Mark Brown
dougl at cs.mu.OZ.AU
Mon Oct 29 19:14:12 AEDT 2001
On 29-Oct-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> 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.
I considered this, but I wasn't sure if there is a portable way of
getting the hostname and pid. Can anyone tell me if it is ok to use
gethostname() and getpid()?
Apart from solving the race condition, this would also perform much
better on opening the second and subsequent windows on the same X
server. However, I'm not too concerned about it, since if the opening
of the window is painfully slow, then synchronising after each event
will be likewise. This feature is not going to be all that useful over
a slow X11 connection.
>
> 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.
Good idea. See the diff below (which is relative to the last relative
diff I posted).
>
> 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.
That sounds like a great idea. Do you mind if I leave this new feature
to a subsequent change, though? I'll get to work on it soon.
Cheers,
Mark.
diff -u trace/mercury_trace_source.c trace/mercury_trace_source.c
--- trace/mercury_trace_source.c
+++ trace/mercury_trace_source.c
@@ -257,15 +257,28 @@
return msg;
}
+ /*
+ ** Point the source server to the given context.
+ */
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;
}
+
+ /*
+ ** Center the current line in the vim window.
+ */
+ 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";
+ }
+
+ return NULL;
}
const char *
--------------------------------------------------------------------------
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