[m-rev.] diff: fix bug in list command
Ian MacLarty
maclarty at cs.mu.OZ.AU
Sat Nov 12 21:49:35 AEDT 2005
Rafe, where is the list command test case?!
Estimated hours taken: 2
Branches: main
Fix a bug in the list mdb command which was breaking the declarative
debugger when the browser directory is traced.
trace/mercury_trace_internal.c:
Do not initialize MR_LISTING_path in MR_trace_internal_ensure_init,
because MR_trace_internal_ensure_init is called before the current call
sequence number is recorded, so if any traced Mercury code is called in
MR_trace_internal_ensure_init then it will screw up the call sequence
numbers.
Wrap some calls to MR_make_aligned_string in MR_TRACE_USE_HP.
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.217
diff -u -r1.217 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 25 Oct 2005 04:00:55 -0000 1.217
+++ trace/mercury_trace_internal.c 12 Nov 2005 10:32:38 -0000
@@ -660,6 +660,7 @@
static void MR_trace_print_dice(char *pass_trace_counts_file,
char *fail_trace_counts_file, char *sort_str,
int number_of_lines, char *out_str, char *module);
+static void MR_trace_listing_path_ensure_init(void);
static const MR_Proc_Layout *MR_find_single_matching_proc(MR_Proc_Spec *spec,
MR_bool verbose);
@@ -955,12 +956,6 @@
}
/*
- ** Set up MR_LISTING_path.
- */
-
- MR_LISTING_path = MR_LISTING_new_list_path();
-
- /*
** These functions add the commands to the front of the queue, so
** we call them in the reverse order we want the commands executed.
*/
@@ -2709,6 +2704,8 @@
MR_bool num = MR_num_context_lines;
MR_String aligned_filename;
+ MR_trace_listing_path_ensure_init();
+
if (word_count > 2) {
MR_trace_usage("browsing", "list");
return KEEP_INTERACTING;
@@ -2722,7 +2719,9 @@
MR_trace_current_level_details(&entry_ptr, &filename, &lineno,
&base_sp_ptr, &base_curfr_ptr);
- MR_make_aligned_string(aligned_filename, (MR_String) filename);
+ MR_TRACE_USE_HP(
+ MR_make_aligned_string(aligned_filename, (MR_String) filename);
+ );
MR_TRACE_CALL_MERCURY(
MR_LISTING_list_file(MR_mdb_out, MR_mdb_err, (char *) aligned_filename,
@@ -2740,10 +2739,14 @@
int i;
MR_String aligned_word;
+ MR_trace_listing_path_ensure_init();
+
MR_TRACE_CALL_MERCURY(
MR_LISTING_clear_list_path(MR_LISTING_path, &MR_LISTING_path);
for(i = word_count - 1; i >= 1; i--) {
- MR_make_aligned_string(aligned_word, (MR_String) words[i]);
+ MR_TRACE_USE_HP(
+ MR_make_aligned_string(aligned_word, (MR_String) words[i]);
+ );
MR_LISTING_push_list_path(aligned_word,
MR_LISTING_path, &MR_LISTING_path);
}
@@ -2760,6 +2763,8 @@
int i;
MR_String aligned_word;
+ MR_trace_listing_path_ensure_init();
+
if (word_count < 2) {
MR_trace_usage("browsing", "push_list_dir");
return KEEP_INTERACTING;
@@ -2767,7 +2772,9 @@
MR_TRACE_CALL_MERCURY(
for(i = word_count - 1; i >= 1; i--) {
- MR_make_aligned_string(aligned_word, (MR_String) words[i]);
+ MR_TRACE_USE_HP(
+ MR_make_aligned_string(aligned_word, (MR_String) words[i]);
+ );
MR_LISTING_push_list_path(aligned_word,
MR_LISTING_path, &MR_LISTING_path);
}
@@ -2781,6 +2788,8 @@
MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
MR_Event_Details *event_details, MR_Code **jumpaddr)
{
+ MR_trace_listing_path_ensure_init();
+
if (word_count > 1) {
MR_trace_usage("browsing", "pop_list_dir");
return KEEP_INTERACTING;
@@ -2793,6 +2802,19 @@
return KEEP_INTERACTING;
}
+static void
+MR_trace_listing_path_ensure_init()
+{
+ static MR_bool MR_trace_listing_path_initialized = MR_FALSE;
+
+ if (! MR_trace_listing_path_initialized) {
+ MR_TRACE_CALL_MERCURY(
+ MR_LISTING_path = MR_LISTING_new_list_path();
+ );
+ MR_trace_listing_path_initialized = MR_TRUE;
+ }
+}
+
static MR_Next
MR_trace_cmd_break(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
MR_Event_Info *event_info, MR_Event_Details *event_details,
--------------------------------------------------------------------------
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