[m-rev.] for review: put sourced mdb commands at the front of the queue

Ian MacLarty maclarty at cs.mu.OZ.AU
Thu Apr 14 16:45:10 AEST 2005


For review by anyone.

Estimated hours taken: 2
Branches: main

When sourcing a file of mdb commands, add the commands to the front of the
queue, while maintaining their original order.  

This has the effect replacing `source' commands with the
commands in the sourced file.  Previously sourced commands would be added
to the end of the queue, so they would appear after any commands that might
appear after the original `source' command. 

For example if .mdbrc was set to:

break p
continue
finish
dd

then a whole lot of error messages would be displayed, because the commands
to read in the documentation would be executed after the `dd' command above
(and the declarative debugger doesn't recognise those commands).  Now the
commands to read in the documentation are executed first.

Also include the `continue' command in the list of breakpoint commands.

doc/mdb_categories:
	Include `continue' in the list of breakpoint commands.

trace/mercury_trace_internal.c:
	When sourcing commands, insert them at the front of the queue.  This
	requires the calls to the functions that read the default source
	files to be reversed.

Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.24
diff -u -r1.24 mdb_categories
--- doc/mdb_categories	20 Sep 2004 04:50:22 -0000	1.24
+++ doc/mdb_categories	14 Apr 2005 06:25:56 -0000
@@ -32,8 +32,8 @@
 end
 document_category 500 breakpoint
 breakpoint - Commands that let users set and control breakpoints.
-             The breakpoint commands are `break', `disable', `enable',
-             `delete', `modules', `procedures' and `register'.
+             The breakpoint commands are `break', `condition', `disable', 
+	     `enable', `delete', `modules', `procedures' and `register'.
 
 end
 document_category 600 table_io
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.200
diff -u -r1.200 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	12 Apr 2005 01:53:56 -0000	1.200
+++ trace/mercury_trace_internal.c	14 Apr 2005 06:29:50 -0000
@@ -927,9 +927,13 @@
             MR_scroll_limit = n;
         }
 
-        MR_trace_internal_init_from_env();
-        MR_trace_internal_init_from_local();
+        /*
+        ** These functions add the commands to the front of the queue, so
+        ** we call them in the reverse order we want the commands executed.
+        */
         MR_trace_internal_init_from_home_dir();
+        MR_trace_internal_init_from_local();
+        MR_trace_internal_init_from_env();
 
         MR_saved_debug_state.MR_sds_io_tabling_enabled = MR_TRUE;
         MR_io_tabling_phase = MR_IO_TABLING_BEFORE;
@@ -7549,10 +7553,36 @@
 static void
 MR_trace_source_from_open_file(FILE *fp)
 {
-    char    *line;
+    char    *contents;
+    MR_Line *line;
+    MR_Line *prev_line;
+    MR_Line *old_head;
 
-    while ((line = MR_trace_readline_raw(fp)) != NULL) {
-        MR_insert_line_at_tail(line);
+    prev_line = NULL;
+    old_head = MR_line_head;
+
+    /*
+    ** Insert the sourced commands at the front of the command queue, 
+    ** preserving their order in the sourced file.
+    */
+    while ((contents = MR_trace_readline_raw(fp)) != NULL) {
+        line = MR_NEW(MR_Line);
+        line->MR_line_contents = MR_copy_string(contents);
+        
+        if (prev_line == NULL) {
+            MR_line_head = line;
+        } else {
+            prev_line->MR_line_next = line;
+        }
+
+        prev_line = line;
+    }
+
+    if (prev_line != NULL) {
+        prev_line->MR_line_next = old_head;
+        if (MR_line_tail == NULL) {
+            MR_line_tail = prev_line;
+        }
     }
 
     MR_trace_internal_interacting = MR_FALSE;
--------------------------------------------------------------------------
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