[m-dev.] diff: fix mdb bug with exception line numbers
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Dec 16 06:14:41 AEDT 1999
Estimated hours taken: 4
Fix a bug where mdb was not printing line numbers for exception events.
The bug was that MR_trace_throw() was making a modified copy of the
return label stack layout, and passing the address of that copy
to MR_trace(), but in many places MR_trace() was depending on the
address passed to it being in the module layout table.
runtime/mercury_stack_layout.h:
Define a new type MR_Exception_Layout, containing both
the modified copy and the address of the original return label
layout.
library/exception.m:
Use the new type. Store the modified copy of the layout in
the first field. Store the address of the original return label
layout in the second field. Pass the address of the first field
to MR_trace().
trace/mercury_trace.c:
Change MR_trace_real() and MR_trace_event() so that after
extracting the port and path from the layout, they check for
MR_PORT_EXCEPTION, and if so, (down)cast the layout pointer
to `MR_Exception_Layout *', retrieve the return_label_layout
from that struct, and use that for the new layout pointer.
Workspace: /d-drive/home/hg/fjh/ws-hg2/mercury
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.8
diff -u -d -r1.8 exception.m
--- library/exception.m 1999/12/14 04:53:45 1.8
+++ library/exception.m 1999/12/15 18:24:37
@@ -506,7 +506,7 @@
Code *MR_jumpaddr;
MR_Stack_Walk_Step_Result result;
const char *problem;
- MR_Stack_Layout_Label exception_layout;
+ MR_Exception_Layout exception_layout;
/*
** check if we've reached a frame with an exception handler
@@ -528,15 +528,16 @@
** module-wide string table; the string at index 0 will
** always be the empty string.
*/
- MR_memcpy(&exception_layout, return_label_layout,
+ MR_memcpy(&exception_layout.MR_el_layout, return_label_layout,
sizeof(exception_layout));
- exception_layout.MR_sll_port = MR_PORT_EXCEPTION;
- exception_layout.MR_sll_goal_path = 0;
+ exception_layout.MR_el_layout.MR_sll_port = MR_PORT_EXCEPTION;
+ exception_layout.MR_el_layout.MR_sll_goal_path = 0;
+ exception_layout.MR_el_return_layout = return_label_layout;
/*
** invoke MR_trace() to trace the exception
*/
- MR_jumpaddr = MR_trace(&exception_layout);
+ MR_jumpaddr = MR_trace(&exception_layout.MR_el_layout);
if (MR_jumpaddr != NULL) {
return MR_jumpaddr;
}
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.33
diff -u -d -r1.33 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h 1999/12/14 04:54:05 1.33
+++ runtime/mercury_stack_layout.h 1999/12/15 18:15:18
@@ -555,6 +555,20 @@
/*-------------------------------------------------------------------------*/
/*
+** Definitions for MR_Exception_Layout
+**
+** The first field will be a copy of the stack layout for the return label,
+** with the port changed to `MR_PORT_EXCEPTION', and with an empty goal path.
+** The second field will hold the address of the original return label layout.
+*/
+
+typedef struct MR_Exception_Layout_Struct {
+ MR_Stack_Layout_Label MR_el_layout;
+ MR_Stack_Layout_Label *MR_el_return_layout;
+} MR_Exception_Layout;
+
+/*-------------------------------------------------------------------------*/
+/*
** Definitions for MR_Module_Layout
**
** The layout struct for a module contains three main components.
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.17
diff -u -d -r1.17 mercury_trace.c
--- trace/mercury_trace.c 1999/12/16 19:09:34 1.17
+++ trace/mercury_trace.c 1999/12/15 18:32:20
@@ -216,6 +216,20 @@
*/
port = (MR_Trace_Port) layout->MR_sll_port;
+ if (port == MR_PORT_EXCEPTION) {
+ /*
+ ** `layout' has the correct values, but the wrong
+ ** address -- its address won't be in the module
+ ** layout table, so MR_event_matches_spy_point()
+ ** won't find it. Now that we've already
+ ** extracted the port, we can use the return
+ ** layout, which does have the correct address
+ ** (but the wrong port and path; the path is
+ ** not used here).
+ */
+ layout = ((const MR_Exception_Layout *) layout)
+ ->MR_el_return_layout;
+ }
match = MR_event_matches_spy_point(layout, port, &action);
if (! match) {
if (MR_trace_ctrl.MR_trace_print_level ==
@@ -265,9 +279,25 @@
event_info.MR_call_seqno = seqno;
event_info.MR_call_depth = depth;
event_info.MR_trace_port = port;
- event_info.MR_event_sll = layout;
+
event_info.MR_event_path = layout->MR_sll_entry->MR_sle_module_layout
->MR_ml_string_table + layout->MR_sll_goal_path;
+
+ if (port == MR_PORT_EXCEPTION) {
+ /*
+ ** `layout' has the correct values, but the
+ ** wrong address -- its address won't be in the
+ ** module layout table, so MR_find_context() etc.
+ ** won't find it. Now that we've already
+ ** extracted the port and path, we can use the return
+ ** layout, which does have the correct address
+ ** (but the wrong port and path).
+ */
+ layout = ((const MR_Exception_Layout *) layout)
+ ->MR_el_return_layout;
+ }
+
+ event_info.MR_event_sll = layout;
max_r_num = layout->MR_sll_entry->MR_sle_max_r_num;
if (max_r_num + MR_NUM_SPECIAL_REG > MR_MAX_SPECIAL_REG_MR) {
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list