diff: Fix link error mentioned by Fergus

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Thu Apr 15 00:18:23 AEST 1999


Estimated hours taken: 3

Fix a bug causing the debugger tests to get link errors.

browser/declarative_debugger.m:
	Call MR_edt_root_node indirectly via MR_address_of_edt_root_node.

runtime/mercury_wrapper.{c,h}:
	Add a global function pointer, MR_address_of_edt_root_node.

util/mkinit.c:
	Make sure MR_address_of_edt_root_node is initialized.

trace/mercury_trace_declarative.c:
	Define MR_edt_root_node even if the declarative debugger is not
	used.


Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.1
diff -u -r1.1 declarative_debugger.m
--- declarative_debugger.m	1999/04/12 04:11:41	1.1
+++ declarative_debugger.m	1999/04/14 13:20:28
@@ -89,6 +89,7 @@
 :- pragma c_header_code("
 	#include ""mercury_trace_declarative.h""
 	#include ""mercury_type_info.h""
+	#include ""mercury_wrapper.h""
 ").
 
 :- pred edt_first_child(evaluation_tree, evaluation_tree).
@@ -134,9 +135,17 @@
 :- pred edt_root(evaluation_tree, edt_node).
 :- mode edt_root(in, out) is det.
 
-:- pragma import(edt_root(in, out),
+:- pragma c_code(edt_root(EDT::in, Root::out),
 	[will_not_call_mercury],
-	"MR_edt_root_node"
+	"
+		/*
+		** We wish to call MR_edt_root_node in the trace
+		** directory, but due to problems with linking we
+		** call it indirectly via a pointer defined in
+		** runtime/mercury_wrapper.c.
+		*/
+		MR_address_of_edt_root_node(EDT, &Root);
+	"
 ).
 
 %-----------------------------------------------------------------------------%
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.32
diff -u -r1.32 mercury_wrapper.c
--- mercury_wrapper.c	1999/03/17 08:10:53	1.32
+++ mercury_wrapper.c	1999/04/14 13:21:32
@@ -139,6 +139,8 @@
 void	(*MR_address_of_trace_final_external)(void);
 #endif
 
+void	(*MR_address_of_edt_root_node)(Word, Word *);
+
 #ifdef CONSERVATIVE_GC
 void	(*address_of_init_gc)(void);
 #endif
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.17
diff -u -r1.17 mercury_wrapper.h
--- mercury_wrapper.h	1999/02/04 10:52:58	1.17
+++ mercury_wrapper.h	1999/04/14 10:47:07
@@ -72,6 +72,15 @@
 extern	void		(*MR_address_of_trace_final_external)(void);
 
 /*
+** MR_edt_root_node(Word, Word *) is defined in
+** trace/mercury_trace_declarative.c but is referenced in
+** browser/declarative_debugger.m.  As we can not do direct calls from
+** browse/ to trace/, we do an indirect call via the following pointer.
+*/
+
+extern void		(*MR_address_of_edt_root_node)(Word, Word *);
+
+/*
 ** XXX This is obsolete too.
 ** This variable has been replaced by MR_io_print_to_*_stream,
 ** but the installed mkinit executable may still generate references to it.
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.3
diff -u -r1.3 mercury_trace_declarative.c
--- mercury_trace_declarative.c	1999/04/12 04:11:46	1.3
+++ mercury_trace_declarative.c	1999/04/14 13:55:18
@@ -16,13 +16,13 @@
 */
 
 #include "mercury_imp.h"
+#include "mercury_trace_declarative.h"
 
 #ifdef MR_USE_DECLARATIVE_DEBUGGER
 
 #include "mercury_trace.h"
 #include "mercury_trace_browse.h"
 #include "mercury_trace_internal.h"
-#include "mercury_trace_declarative.h"
 #include "mercury_trace_tables.h"
 #include "mercury_trace_util.h"
 #include "mercury_layout_util.h"
@@ -559,4 +559,11 @@
 	return arglist;
 }
 
-#endif	/* MR_USE_DECLARATIVE_DEBUGGER */
+#else	/* not MR_USE_DECLARATIVE_DEBUGGER */
+
+extern void
+MR_edt_root_node(Word EDT, Word *Node)
+{
+	fatal_error("MR_edt_root_node should not have been called");
+}
+#endif
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.47
diff -u -r1.47 mkinit.c
--- mkinit.c	1999/03/20 07:16:30	1.47
+++ mkinit.c	1999/04/14 13:28:22
@@ -161,6 +161,9 @@
 	"	MR_address_of_trace_final_external = NULL;\n"
 	"  #endif\n"
 	"#endif\n"
+	"#ifdef MR_USE_DECLARATIVE_DEBUGGER\n"
+	"	MR_address_of_edt_root_node = MR_edt_root_node;\n"
+	"#endif\n"
 	"#if MR_TRACE_ENABLED\n"
 	"	MR_trace_func_ptr = MR_trace_real;\n"
 	"#else\n"
-- 
Mark Brown  (dougl at cs.mu.oz.au)       )O+   |  For Microsoft to win,
MEngSc student,                             |  the customer must lose
Dept of Computer Science, Melbourne Uni     |          -- Eric S. Raymond



More information about the developers mailing list