[m-dev.] Fix a bug caused by one of my recent changes
Erwan Jahier
Erwan.Jahier at irisa.fr
Tue Feb 23 06:23:05 AEDT 1999
Estimated hours taken: 3
Moves the definition of MR_dump_stack_record_print() and MR_print_proc_id()
from trace/ to runtime/ to be able to call MR_dump_stack_record_print() from
MR_dump_stack(). Indeed we can not pass down *MR_dump_stack_record_print() as a
parameter of MR_dump_stack() since MR_dump_stack() is called from the library
and we have to repect the invariant "trace -> library -> runtime".
runtime/mercury_stack_trace.c:
Add the missing argument of MR_dump_stack_from_layout() in the body of
MR_dump_stack().
runtime/mercury_stack_trace.[ch]:
trace/mercury_trace_internal.c:
trace/mercury_trace_tables.[ch]:
Move the definition of MR_dump_stack_record_print() from
mercury_trace_internal.c to mercury_stack_trace.c and
MR_print_proc_id() from mercury_trace_tables.c to mercury_stack_trace.c
runtime/mercury_stack_trace.[ch]:
trace/mercury_trace.[ch]:
Move the definition of MR_detism_names[] from mercury_trace.c to
mercury_stack_trace.c.
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.27
diff -u -r1.27 mercury_stack_trace.c
--- mercury_stack_trace.c 1999/02/20 06:58:06 1.27
+++ mercury_stack_trace.c 1999/02/22 19:20:51
@@ -49,7 +49,8 @@
layout = label->i_layout;
entry_layout = layout->MR_sll_entry;
result = MR_dump_stack_from_layout(stderr, entry_layout,
- det_stack_pointer, current_frame, include_trace_data);
+ det_stack_pointer, current_frame, include_trace_data,
+ &MR_dump_stack_record_print);
if (result != NULL) {
fprintf(stderr, "%s\n", result);
@@ -85,8 +86,7 @@
result = MR_stack_walk_step(entry_layout, &return_label_layout,
&stack_trace_sp, &stack_trace_curfr, &problem);
if (result == STEP_ERROR_BEFORE) {
- MR_dump_stack_record_flush(fp,
- print_stack_record);
+ MR_dump_stack_record_flush(fp, print_stack_record);
return problem;
} else if (result == STEP_ERROR_AFTER) {
if (include_trace_data) {
@@ -98,8 +98,7 @@
NULL, NULL, print_stack_record);
}
- MR_dump_stack_record_flush(fp,
- print_stack_record);
+ MR_dump_stack_record_flush(fp, print_stack_record);
return problem;
} else {
if (include_trace_data) {
@@ -336,3 +335,155 @@
}
}
+
+void
+MR_dump_stack_record_print(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
+ int count, int start_level, Word *base_sp, Word *base_curfr)
+{
+ fprintf(fp, "%4d ", start_level);
+
+ if (count > 1) {
+ fprintf(fp, " %3d* ", count);
+ } else if ((base_sp == NULL) && (base_curfr == NULL)) {
+ fprintf(fp, "%5s ", "");
+ } else {
+ /*
+ ** If we are printing trace data, we need all the horizonal
+ ** room we can get, and there will not be any repeated lines,
+ ** so we don't reserve space for the repeat counts.
+ */
+ }
+
+ MR_print_proc_id(fp, entry_layout, NULL, base_sp, base_curfr);
+}
+
+void
+MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
+ const char *extra, Word *base_sp, Word *base_curfr)
+{
+ if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
+ fatal_error("cannot print procedure id without layout");
+ }
+
+ if (base_sp != NULL && base_curfr != NULL) {
+ bool print_details = FALSE;
+ if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
+ Word maybe_from_full = entry->MR_sle_maybe_from_full;
+ if (maybe_from_full > 0) {
+ /*
+ ** for procedures compiled with shallow
+ ** tracing, the details will be valid only
+ ** if the value of MR_from_full saved in
+ ** the appropriate stack slot was TRUE.
+ */
+ if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+ print_details = MR_based_stackvar(
+ base_sp, maybe_from_full);
+ } else {
+ print_details = MR_based_framevar(
+ base_curfr, maybe_from_full);
+ }
+ } else {
+ /*
+ ** for procedures compiled with full tracing,
+ ** always print out the details
+ */
+ print_details = TRUE;
+ }
+ }
+ if (print_details) {
+ if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+ fprintf(fp, "%7lu %7lu %4lu ",
+ (unsigned long)
+ MR_event_num_stackvar(base_sp) + 1,
+ (unsigned long)
+ MR_call_num_stackvar(base_sp),
+ (unsigned long)
+ MR_call_depth_stackvar(base_sp));
+ } else {
+ fprintf(fp, "%7lu %7lu %4lu ",
+ (unsigned long)
+ MR_event_num_framevar(base_curfr) + 1,
+ (unsigned long)
+ MR_call_num_framevar(base_curfr),
+ (unsigned long)
+ MR_call_depth_framevar(base_curfr));
+ }
+ } else {
+ /* ensure that the remaining columns line up */
+ fprintf(fp, "%21s", "");
+ }
+ }
+
+ if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
+ fprintf(fp, "%s for %s:%s/%ld-%ld",
+ entry->MR_sle_comp.MR_comp_pred_name,
+ entry->MR_sle_comp.MR_comp_type_module,
+ entry->MR_sle_comp.MR_comp_type_name,
+ (long) entry->MR_sle_comp.MR_comp_arity,
+ (long) entry->MR_sle_comp.MR_comp_mode);
+
+ if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
+ entry->MR_sle_comp.MR_comp_def_module) != 0)
+ {
+ fprintf(fp, " {%s}",
+ entry->MR_sle_comp.MR_comp_def_module);
+ }
+ } else {
+ if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
+ fprintf(fp, "pred");
+ } else if (entry->MR_sle_user.MR_user_pred_or_func ==
+ MR_FUNCTION)
+ {
+ fprintf(fp, "func");
+ } else {
+ fatal_error("procedure is not pred or func");
+ }
+
+ fprintf(fp, " %s:%s/%ld-%ld",
+ entry->MR_sle_user.MR_user_decl_module,
+ entry->MR_sle_user.MR_user_name,
+ (long) entry->MR_sle_user.MR_user_arity,
+ (long) entry->MR_sle_user.MR_user_mode);
+
+ if (strcmp(entry->MR_sle_user.MR_user_decl_module,
+ entry->MR_sle_user.MR_user_def_module) != 0)
+ {
+ fprintf(fp, " {%s}",
+ entry->MR_sle_user.MR_user_def_module);
+ }
+ }
+
+ fprintf(fp, " (%s)", MR_detism_names[entry->MR_sle_detism]);
+
+ if (extra != NULL) {
+ fprintf(fp, " %s\n", extra);
+ } else {
+ fprintf(fp, "\n");
+ }
+}
+
+
+/*
+** The different Mercury determinisms are internally represented by integers.
+** This array gives the correspondance with the internal representation and
+** the names that are usually used to denote determinisms.
+*/
+
+extern const char * MR_detism_names[] = {
+ "failure", /* 0 */
+ "", /* 1 */
+ "semidet", /* 2 */
+ "nondet", /* 3 */
+ "erroneous", /* 4 */
+ "", /* 5 */
+ "det", /* 6 */
+ "multi", /* 7 */
+ "", /* 8 */
+ "", /* 9 */
+ "cc_nondet", /* 10 */
+ "", /* 11 */
+ "", /* 12 */
+ "", /* 13 */
+ "cc_multi" /* 14 */
+};
Index: runtime/mercury_stack_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.h,v
retrieving revision 1.16
diff -u -r1.16 mercury_stack_trace.h
--- mercury_stack_trace.h 1999/02/20 06:58:07 1.16
+++ mercury_stack_trace.h 1999/02/22 19:20:52
@@ -137,5 +137,29 @@
Word *MR_nondet_stack_trace_bottom;
+/*
+** The different Mercury determinisms are internally represented by integers.
+** This array gives the correspondance with the internal representation and
+** the names that are usually used to denote determinisms.
+*/
+
+extern const char * MR_detism_names[];
+
+/*
+** MR_print_proc_id prints an identification of the given procedure,
+** consisting of "pred" or "func", module name, pred or func name, arity,
+** mode number and determinism, followed by an optional extra string,
+** and a newline.
+**
+** If the procedure has trace layout information and the relevant one of
+** base_sp and base_curfr is not NULL, it also prints the call event number,
+** call sequence number and call depth of the call.
+*/
+
+void MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
+ const char *extra, Word *base_sp, Word *base_curfr);
+void MR_dump_stack_record_print(FILE *fp,
+ const MR_Stack_Layout_Entry *entry_layout, int count,
+ int start_level, Word *base_sp, Word *base_curfr);
#endif /* MERCURY_STACK_TRACE_H */
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_trace.c
--- mercury_trace.c 1999/02/20 06:08:10 1.7
+++ mercury_trace.c 1999/02/22 19:20:55
@@ -438,27 +438,3 @@
return 0;
}
-
-/*
-** The different Mercury determinisms are internally represented by integers.
-** This array gives the correspondance with the internal representation and
-** the names that are usually used to denote determinisms.
-*/
-
-extern const char * MR_detism_names[] = {
- "failure", /* 0 */
- "", /* 1 */
- "semidet", /* 2 */
- "nondet", /* 3 */
- "erroneous", /* 4 */
- "", /* 5 */
- "det", /* 6 */
- "multi", /* 7 */
- "", /* 8 */
- "", /* 9 */
- "cc_nondet", /* 10 */
- "", /* 11 */
- "", /* 12 */
- "", /* 13 */
- "cc_multi" /* 14 */
-};
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.7
diff -u -r1.7 mercury_trace.h
--- mercury_trace.h 1999/02/20 06:08:11 1.7
+++ mercury_trace.h 1999/02/22 19:20:56
@@ -119,13 +119,6 @@
bool MR_trace_must_check;
} MR_Trace_Cmd_Info;
-/*
-** The different Mercury determinisms are internally represented by integers.
-** This array gives the correspondance with the internal representation and
-** the names that are usually used to denote determinisms.
-*/
-
-extern const char * MR_detism_names[];
#define MR_port_is_final(port) ((port) == MR_PORT_EXIT || \
(port) == MR_PORT_FAIL || \
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.28
diff -u -r1.28 mercury_trace_internal.c
--- mercury_trace_internal.c 1999/02/20 06:08:15 1.28
+++ mercury_trace_internal.c 1999/02/22 19:21:01
@@ -210,10 +210,6 @@
static bool MR_trace_valid_command(const char *word);
-static void MR_dump_stack_record_print(FILE *fp,
- const MR_Stack_Layout_Entry *, int, int,
- Word *base_sp, Word *base_curfr);
-
Code *
MR_trace_event_internal(MR_Trace_Cmd_Info *cmd, bool interactive,
MR_Event_Info *event_info)
@@ -2451,26 +2447,5 @@
}
return FALSE;
-}
-
-static void
-MR_dump_stack_record_print(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
- int count, int start_level, Word *base_sp, Word *base_curfr)
-{
- fprintf(fp, "%4d ", start_level);
-
- if (count > 1) {
- fprintf(fp, " %3d* ", count);
- } else if ((base_sp == NULL) && (base_curfr == NULL)) {
- fprintf(fp, "%5s ", "");
- } else {
- /*
- ** If we are printing trace data, we need all the horizonal
- ** room we can get, and there will not be any repeated lines,
- ** so we don't reserve space for the repeat counts.
- */
- }
-
- MR_print_proc_id(fp, entry_layout, NULL, base_sp, base_curfr);
}
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.5
diff -u -r1.5 mercury_trace_tables.c
--- mercury_trace_tables.c 1999/02/18 23:33:01 1.5
+++ mercury_trace_tables.c 1999/02/22 19:21:01
@@ -397,108 +397,3 @@
MR_print_proc_id(fp, entry_layout, NULL, NULL, NULL);
}
-void
-MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
- const char *extra, Word *base_sp, Word *base_curfr)
-{
- if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
- fatal_error("cannot print procedure id without layout");
- }
-
- if (base_sp != NULL && base_curfr != NULL) {
- bool print_details = FALSE;
- if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
- Word maybe_from_full = entry->MR_sle_maybe_from_full;
- if (maybe_from_full > 0) {
- /*
- ** for procedures compiled with shallow
- ** tracing, the details will be valid only
- ** if the value of MR_from_full saved in
- ** the appropriate stack slot was TRUE.
- */
- if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
- print_details = MR_based_stackvar(
- base_sp, maybe_from_full);
- } else {
- print_details = MR_based_framevar(
- base_curfr, maybe_from_full);
- }
- } else {
- /*
- ** for procedures compiled with full tracing,
- ** always print out the details
- */
- print_details = TRUE;
- }
- }
- if (print_details) {
- if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
- fprintf(fp, "%7lu %7lu %4lu ",
- (unsigned long)
- MR_event_num_stackvar(base_sp) + 1,
- (unsigned long)
- MR_call_num_stackvar(base_sp),
- (unsigned long)
- MR_call_depth_stackvar(base_sp));
- } else {
- fprintf(fp, "%7lu %7lu %4lu ",
- (unsigned long)
- MR_event_num_framevar(base_curfr) + 1,
- (unsigned long)
- MR_call_num_framevar(base_curfr),
- (unsigned long)
- MR_call_depth_framevar(base_curfr));
- }
- } else {
- /* ensure that the remaining columns line up */
- fprintf(fp, "%21s", "");
- }
- }
-
- if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
- fprintf(fp, "%s for %s:%s/%ld-%ld",
- entry->MR_sle_comp.MR_comp_pred_name,
- entry->MR_sle_comp.MR_comp_type_module,
- entry->MR_sle_comp.MR_comp_type_name,
- (long) entry->MR_sle_comp.MR_comp_arity,
- (long) entry->MR_sle_comp.MR_comp_mode);
-
- if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
- entry->MR_sle_comp.MR_comp_def_module) != 0)
- {
- fprintf(fp, " {%s}",
- entry->MR_sle_comp.MR_comp_def_module);
- }
- } else {
- if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
- fprintf(fp, "pred");
- } else if (entry->MR_sle_user.MR_user_pred_or_func ==
- MR_FUNCTION)
- {
- fprintf(fp, "func");
- } else {
- fatal_error("procedure is not pred or func");
- }
-
- fprintf(fp, " %s:%s/%ld-%ld",
- entry->MR_sle_user.MR_user_decl_module,
- entry->MR_sle_user.MR_user_name,
- (long) entry->MR_sle_user.MR_user_arity,
- (long) entry->MR_sle_user.MR_user_mode);
-
- if (strcmp(entry->MR_sle_user.MR_user_decl_module,
- entry->MR_sle_user.MR_user_def_module) != 0)
- {
- fprintf(fp, " {%s}",
- entry->MR_sle_user.MR_user_def_module);
- }
- }
-
- fprintf(fp, " (%s)", MR_detism_names[entry->MR_sle_detism]);
-
- if (extra != NULL) {
- fprintf(fp, " %s\n", extra);
- } else {
- fprintf(fp, "\n");
- }
-}
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_trace_tables.h
--- mercury_trace_tables.h 1999/02/18 23:33:02 1.3
+++ mercury_trace_tables.h 1999/02/22 19:21:02
@@ -121,20 +121,8 @@
void f(void *, const MR_Stack_Layout_Entry *),
void *data);
-/*
-** MR_print_proc_id prints an identification of the given procedure,
-** consisting of "pred" or "func", module name, pred or func name, arity,
-** mode number and determinism, followed by an optional extra string,
-** and a newline.
-**
-** If the procedure has trace layout information and the relevant one of
-** base_sp and base_curfr is not NULL, it also prints the call event number,
-** call sequence number and call depth of the call.
-*/
extern void MR_print_proc_id_for_debugger(FILE *fp,
const MR_Stack_Layout_Entry *entry);
-extern void MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
- const char *extra, Word *base_sp, Word *base_curfr);
#endif /* not MERCURY_TRACE_TABLES_H */
--
R1.
More information about the developers
mailing list