diff: fix stack tracing bug

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Nov 8 00:11:25 AEDT 1998


Estimated hours taken: 2

Fix a bug with stack traces that broke tests/debugger/queens.res.

runtime/mercury_goto.h:
	Change the init_label{,_ai,_sl} and init_local{,_ai,_sl} macros
	so that they use &&entry(label) instead of &&label as the value
	to insert into the label table, and likewise update the GOTO_LABEL
	macro so that it likewise passes &&entry(label) rather than &&label
	to the debuggoto() macro.  The difference between the two is that
	&&entry(label) points to the address before the
	INLINE_ASM_FIXUP_REGS code that is used to fix up the gp
	register after returns from calls to shared libaries, whereas
	plain &&label points to after that code.
	The reason for this change is that for stack traces (and
	accurate GC) to work, the addresses in the label table need to
	match the succip values saved on the stack.

Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.16
diff -u -r1.16 mercury_goto.h
--- mercury_goto.h	1998/11/05 03:53:36	1.16
+++ mercury_goto.h	1998/11/07 13:02:23
@@ -560,23 +560,20 @@
 	}	\
 	label:	\
 	{
-  #define init_local(label)	make_local(stringify(label), &&label, label)
-  #define init_local_ai(label)	make_local_ai(stringify(label), &&label, label)
-  #define init_local_sl(label)	make_local_sl(stringify(label), &&label, label)
+  #define init_local(label)	\
+  	make_local(stringify(label), &&entry(label), label)
+  #define init_local_ai(label)	\
+  	make_local_ai(stringify(label), &&entry(label), label)
+  #define init_local_sl(label)	\
+  	make_local_sl(stringify(label), &&entry(label), label)
   #define Define_label(label)	Define_local(label)
   #define Declare_label(label)	/* no declaration required */
-  #ifdef MR_INSERT_LABELS
-   #define init_label(label)	\
+  #define init_label(label)	\
 	make_label(stringify(label), &&entry(label), label)
-   #define init_label_ai(label)	\
+  #define init_label_ai(label)	\
 	make_label_ai(stringify(label), &&entry(label), label)
-   #define init_label_sl(label)	\
+  #define init_label_sl(label)	\
 	make_label_sl(stringify(label), &&entry(label), label)
-  #else
-   #define init_label(label)	make_label(stringify(label), &&label, label)
-   #define init_label_ai(label)	make_label_ai(stringify(label), &&label, label)
-   #define init_label_sl(label)	make_label_sl(stringify(label), &&label, label)
-  #endif
 
   #define LOCAL(label)		(&&entry(label))
   #define LABEL(label)		(&&entry(label))
@@ -584,7 +581,10 @@
   #define GOTO_ENTRY(label) 	GOTO(ENTRY(label))
   #define GOTO_STATIC(label) 	GOTO(STATIC(label))
   #define GOTO_LOCAL(label) 	GOTO_LABEL(label)
-  #define GOTO_LABEL(label) 	do { debuggoto(&&label); goto label; } while(0)
+  #define GOTO_LABEL(label) 	do {					\
+  					debuggoto(LABEL(label));	\
+					goto label;			\
+				} while(0)
 
   /*
   ** GOTO_LABEL(label) is the same as GOTO(LABEL(label)) except

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list