for review: fix stack traces (runtime)

Tyson Dowd trd at cs.mu.OZ.AU
Thu Apr 16 17:48:54 AEST 1998


Hi,

Here's the other half of my change fixing new bugs in stack traces.

===================================================================


Estimated hours taken: 4

Fix stack traces, which were broken with recent tracing code changes.

runtime/mercury_ho_call.c:
runtime/mercury_wrapper.c:
	Use init_label_sl, instead of init_label.

runtime/mercury_stack_layout.h:
	Update MR_MAKE_STACK_LAYOUT_INTERNAL_* to have new fields
	so that stack layouts generated in this way are correct.

runtime/mercury_stack_trace.c:
	Change algorithm to be a little more robust (doing bit
	operations on a possibly negative integer probably isn't a good
	idea, so check the value isn't -1 first).


Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_ho_call.c
--- mercury_ho_call.c	1998/03/11 05:58:31	1.7
+++ mercury_ho_call.c	1998/04/16 07:32:55
@@ -96,12 +96,12 @@
 
 	init_entry(mercury__unify_2_0);
 	init_entry(mercury__index_2_0);
-	init_label(mercury__index_2_0_i1);
+	init_label_sl(mercury__index_2_0_i1);
 	init_entry(mercury__compare_3_0);
 	init_entry(mercury__compare_3_1);
 	init_entry(mercury__compare_3_2);
 	init_entry(mercury__compare_3_3);
-	init_label(mercury__compare_3_0_i1);
+	init_label_sl(mercury__compare_3_0_i1);
 BEGIN_CODE
 
 Define_entry(do_call_det_closure);
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_stack_layout.h
--- mercury_stack_layout.h	1998/04/08 11:34:03	1.3
+++ mercury_stack_layout.h	1998/04/16 06:22:08
@@ -190,11 +190,17 @@
  const struct mercury_data__stack_layout__##l##_struct {		\
 	const Word * f1;						\
 	Integer f2;							\
-	const Word * f3;						\
+	Integer f3;							\
+	const Word * f4;						\
+	const Word * f5;						\
+	const Word * f6;						\
  } mercury_data__stack_layout__##l = {					\
 	(const Word *) &mercury_data__stack_layout__##e,		\
+	(Integer) -1,		/* Unknown label number */		\
 	(Integer) -1,		/* Unknown number of live values */	\
-	(const Word *) NULL	/* No list of live valeus */		\
+	(const Word *) NULL,	/* No vector of live values */		\
+	(const Word *) NULL,	/* No vector of variable names */	\
+	(const Word *) NULL	/* No vector of type parameters */	\
  };
 #else
  #define MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(l, e)        
@@ -221,11 +227,17 @@
  const struct mercury_data__stack_layout__##e##_i##x##_struct {		\
 	const Word * f1;						\
 	Integer f2;							\
-	const Word * f3;						\
+	Integer f3;							\
+	const Word * f4;						\
+	const Word * f5;						\
+	const Word * f6;						\
  } mercury_data__stack_layout__##e##_i##x = {				\
 	(const Word *) &mercury_data__stack_layout__##e,		\
+	(Integer) -1,		/* Unknown label number */		\
 	(Integer) -1,		/* Unknown number of live values */	\
-	(const Word *) NULL	/* No list of live valeus */		\
+	(const Word *) NULL,	/* No vector of live values */		\
+	(const Word *) NULL,	/* No vector of variable names */	\
+	(const Word *) NULL	/* No vector of type parameters */	\
  };
 #else
  #define MR_MAKE_STACK_LAYOUT_INTERNAL(l, x)        
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.4
diff -u -r1.4 mercury_stack_trace.c
--- mercury_stack_trace.c	1998/04/08 11:34:06	1.4
+++ mercury_stack_trace.c	1998/04/16 07:18:02
@@ -51,20 +51,23 @@
 
 		determinism = entry_layout->MR_sle_detism;
 
-		if (MR_DETISM_DET_STACK(determinism)) {
-			fprintf(stderr, "\t%s\n", label->e_name);
-			if (type == MR_LVAL_TYPE_STACKVAR) {
-				success_pointer = (Code *) field(0, 
-					det_stack_pointer, -number);
+		if (determinism != -1) {
+			if (MR_DETISM_DET_STACK(determinism)) {
+				fprintf(stderr, "\t%s\n", label->e_name);
+				if (type == MR_LVAL_TYPE_STACKVAR) {
+					success_pointer = (Code *) field(0, 
+						det_stack_pointer, -number);
+				} else {
+					fatal_error(
+						"can only handle stackvars");
+				}
+				det_stack_pointer = det_stack_pointer - 
+					entry_layout->MR_sle_stack_slots;
 			} else {
-				fatal_error("can only handle stackvars");
+				fprintf(stderr, "\t%s\n", label->e_name);
+				success_pointer = bt_succip(current_frame);
+				current_frame = bt_succfr(current_frame);
 			}
-			det_stack_pointer = det_stack_pointer - 
-				entry_layout->MR_sle_stack_slots;
-		} else if (determinism != -1) {
-			fprintf(stderr, "\t%s\n", label->e_name);
-			success_pointer = bt_succip(current_frame);
-			current_frame = bt_succfr(current_frame);
 		}
 	} while (determinism != -1);
 #endif /* MR_STACK_TRACE */
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.9
diff -u -r1.9 mercury_wrapper.c
--- mercury_wrapper.c	1998/04/08 11:34:15	1.9
+++ mercury_wrapper.c	1998/04/16 06:50:21
@@ -879,9 +879,9 @@
 
 BEGIN_MODULE(interpreter_module)
 	init_entry(do_interpreter);
-	init_label(global_success);
-	init_label(global_fail);
-	init_label(all_done);
+	init_label_sl(global_success);
+	init_label_sl(global_fail);
+	init_label_sl(all_done);
 BEGIN_CODE
 
 Define_entry(do_interpreter);


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list