diff: mdemangle bug fix

Fergus Henderson fjh at kryten.cs.mu.OZ.AU
Mon Sep 29 17:22:45 AEST 1997


Hi,

Tyson, can you please review this one?

util/mdemangle.c:
	Fix a bug introduced in Tom's recent changes to handle
	lamdbda goals: for ordinary predicates, it was just
	printing out the module name, not the predicate name.

tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
	Some regression tests for the above bug fix.

cvs diff tests/misc_tests/mdemangle_test.exp tests/misc_tests/mdemangle_test.inp util/mdemangle.c
Index: tests/misc_tests/mdemangle_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/misc_tests/mdemangle_test.exp,v
retrieving revision 1.7
diff -u -r1.7 mdemangle_test.exp
--- 1.7	1997/08/27 05:03:48
+++ mdemangle_test.exp	1997/09/29 07:11:15
@@ -86,4 +86,41 @@
 
 	some lambda goals
 <pred goal from 'simplex' line 262 label 5>
+<pred goal from 'simplex' line 262 label 5>
 <func goal from 'collect_vars' line 153>
+<func goal from 'collect_vars' line 153>
+
+	A realistic test
+ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
+interpreter.o -lcfloat_lib 
+Undefined			first referenced
+ symbol  			    in file
+<predicate 'tr_store:get_mutvar'/4 mode 0> interpreter.o
+<index/2 predicate for type 'store:mutvar'/2> interpreter.o
+<compare/3 predicate for type 'store:mutvar'/2> interpreter.o
+<predicate 'std_util:unsorted_aggregate'/4 mode 5> interpreter.o
+<base type_info for type 'store:some_store_type'/0> interpreter.o
+<unification predicate for type 'store:mutvar'/2 mode 0> interpreter.o
+<predicate 'tr_store:new_mutvar'/4 mode 0> interpreter.o
+<predicate 'tr_store:set_mutvar'/4 mode 0> interpreter.o
+<base type_info for type 'store:mutvar'/2> interpreter.o
+ld: fatal: Symbol referencing errors. No output written to interpreter
+gmake: *** [interpreter] Error 1
+
+	A realistic test
+ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
+interpreter.o -lcfloat_lib 
+Undefined			first referenced
+ symbol  			    in file
+<predicate 'tr_store:get_mutvar'/4 mode 0> interpreter.o
+<index/2 predicate for type 'store:mutvar'/2> interpreter.o
+<compare/3 predicate for type 'store:mutvar'/2> interpreter.o
+<predicate 'std_util:unsorted_aggregate'/4 mode 5> interpreter.o
+<base type_info for type 'store:some_store_type'/0> interpreter.o
+<unification predicate for type 'store:mutvar'/2 mode 0> interpreter.o
+<predicate 'tr_store:new_mutvar'/4 mode 0> interpreter.o
+<predicate 'tr_store:set_mutvar'/4 mode 0> interpreter.o
+<base type_info for type 'store:mutvar'/2> interpreter.o
+ld: fatal: Symbol referencing errors. No output written to interpreter
+gmake: *** [interpreter] Error 1
+
Index: tests/misc_tests/mdemangle_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/misc_tests/mdemangle_test.inp,v
retrieving revision 1.8
diff -u -r1.8 mdemangle_test.inp
--- 1.8	1997/09/10 20:03:24
+++ mdemangle_test.inp	1997/09/29 07:10:38
@@ -86,4 +86,41 @@
 
 	some lambda goals
 mercury__lp__IntroducedFrom__pred__simplex__262__9_7_0_i5
+<pred goal from 'simplex' line 262 label 5>
 mercury__lp__IntroducedFrom__func__collect_vars__153__4_3_0
+<func goal from 'collect_vars' line 153>
+
+	A realistic test
+ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
+interpreter.o -lcfloat_lib 
+Undefined			first referenced
+ symbol  			    in file
+_entry_mercury__tr_store__get_mutvar_4_0 interpreter.o
+_entry_mercury____Index___store__mutvar_2_0 interpreter.o
+_entry_mercury____Compare___store__mutvar_2_0 interpreter.o
+_entry_mercury__std_util__unsorted_aggregate_4_5 interpreter.o
+mercury_data_store__base_type_info_some_store_type_0 interpreter.o
+_entry_mercury____Unify___store__mutvar_2_0 interpreter.o
+_entry_mercury__tr_store__new_mutvar_4_0 interpreter.o
+_entry_mercury__tr_store__set_mutvar_4_0 interpreter.o
+mercury_data_store__base_type_info_mutvar_2 interpreter.o
+ld: fatal: Symbol referencing errors. No output written to interpreter
+gmake: *** [interpreter] Error 1
+
+	A realistic test
+ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
+interpreter.o -lcfloat_lib 
+Undefined			first referenced
+ symbol  			    in file
+<predicate 'tr_store:get_mutvar'/4 mode 0> interpreter.o
+<index/2 predicate for type 'store:mutvar'/2> interpreter.o
+<compare/3 predicate for type 'store:mutvar'/2> interpreter.o
+<predicate 'std_util:unsorted_aggregate'/4 mode 5> interpreter.o
+<base type_info for type 'store:some_store_type'/0> interpreter.o
+<unification predicate for type 'store:mutvar'/2 mode 0> interpreter.o
+<predicate 'tr_store:new_mutvar'/4 mode 0> interpreter.o
+<predicate 'tr_store:set_mutvar'/4 mode 0> interpreter.o
+<base type_info for type 'store:mutvar'/2> interpreter.o
+ld: fatal: Symbol referencing errors. No output written to interpreter
+gmake: *** [interpreter] Error 1
+
Index: util/mdemangle.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/util/mdemangle.c,v
retrieving revision 1.24
diff -u -r1.24 mdemangle.c
--- 1.24	1997/09/06 12:53:33
+++ mdemangle.c	1997/09/29 07:05:42
@@ -83,7 +83,8 @@
 */
 
 static void 
-demangle(char *name) {
+demangle(char *name)
+{
 	static const char entry[]   = "_entry_";
 	static const char mercury[] = "mercury__";
 	static const char func_prefix[] = "fn__"; /* added for functions */
@@ -108,7 +109,7 @@
 	static const char common[] = "common";
 
 	char *start = name;
-	const char *type_module = ""; /* module name of type for special pred */
+	const char *module = "";	/* module name */
 	char *end = name + strlen(name);
 	char *position;		/* current position in string */
 	int mode_num;
@@ -145,8 +146,6 @@
 		goto not_plain_mercury;
 	}
 
-/*---------------------------------------------------------------------------*/
-
 /*
 ** Code for dealing with predicate symbols.
 */
@@ -272,14 +271,11 @@
 	*end = '\0';
 
 	/*
-	** Separate the module name from the type name for the compiler
-	** generated predicates.
+	** Strip off the module name
 	*/
-	if (category != ORDINARY) {
-		type_module = start;
-		if (!cut_at_double_underscore(&start, end)) {
-			type_module = "";
-		}
+	module = start;
+	if (!cut_at_double_underscore(&start, end)) {
+		module = "";
 	}
 
 	/*
@@ -294,13 +290,11 @@
 	}
 
 	/*
-	** chop off the module name,
 	** look for "IntroducedFrom"
 	*/
-	position = start;
 	if (category == ORDINARY
-			&& cut_at_double_underscore(&start, end)
-			&& strip_prefix(&start, introduced)) {
+			&& strip_prefix(&start, introduced))
+	{
 		category = LAMBDA;
 		if (strip_prefix(&start, pred)) {
 			lambda_kind = "pred";
@@ -318,12 +312,8 @@
 			lambda_line = lambda_line * 10 + (*start - '0');
 			start++;
 		}
-	} else {
-		start = position;
 	}
 
-			
-
 	/*
 	** Now, finally, we can print the demangled symbol name
 	*/
@@ -331,23 +321,28 @@
 	switch(category) {
 	case UNIFY:
 		printf("unification predicate for type '%s:%s'/%d mode %d",
-			type_module, start, arity, mode_num);
+			module, start, arity, mode_num);
 		break;
 	case COMPARE:
 		printf("compare/3 predicate for type '%s:%s'/%d",
-			type_module, start, arity);
+			module, start, arity);
 		break;
 	case INDEX:
 		printf("index/2 predicate for type '%s:%s'/%d",
-			type_module, start, arity);
+			module, start, arity);
 		break;
 	case LAMBDA:
 		printf("%s goal from '%s' line %d",
 			lambda_kind, lambda_pred_name, lambda_line);
 		break;
 	default:
-		printf("%s '%s'/%d mode %d",
-			pred_or_func, start, arity, mode_num);
+		if (*module == '\0') {
+			printf("%s '%s'/%d mode %d",
+				pred_or_func, start, arity, mode_num);
+		} else {
+			printf("%s '%s:%s'/%d mode %d",
+				pred_or_func, module, start, arity, mode_num);
+		}
 	}
 	if (higher_order) {
 		printf(" (specialized)");
@@ -361,8 +356,6 @@
 	printf(">");
 	return;
 
-/*---------------------------------------------------------------------------*/
-
 /* 
 ** Code to deal with mercury_data items.
 */
@@ -372,9 +365,9 @@
 	if (!strip_prefix(&start, mercury_data)) {
 		goto wrong_format;
 	}
-	type_module = start;
+	module = start;
 	if (!cut_at_double_underscore(&start, end)) {
-		type_module = "";
+		module = "";
 	}
 
 	if (strip_prefix(&start, base_type_info)) {
@@ -406,35 +399,35 @@
 	switch (data_category) {
 
 	case INFO:
-		if (*type_module == '\0') {
+		if (*module == '\0') {
 			printf("<base type_info for type '%s'/%d>",
 				start, arity);
 		} else {
 			printf("<base type_info for type '%s:%s'/%d>",
-				type_module, start, arity);
+				module, start, arity);
 		}
 		break;
 	case LAYOUT:
-		if (*type_module == '\0') {
+		if (*module == '\0') {
 			printf("<type layout for type '%s'/%d>",
 				start, arity);
 		} else {
 			printf("<type layout for type '%s:%s'/%d>",
-				type_module, start, arity);
+				module, start, arity);
 		}
 		break;
 	case FUNCTORS:
-		if (*type_module == '\0') {
+		if (*module == '\0') {
 			printf("<type functors for type '%s'/%d>",
 				start, arity);
 		} else {
 			printf("<type functors for type '%s:%s'/%d>",
-				type_module, start, arity);
+				module, start, arity);
 		}
 		break;
 	case COMMON:
 		printf("<shared constant number %d for module %s>",
-			arity, type_module);
+			arity, module);
 		break;
 
 	default:

-- 
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.



More information about the developers mailing list