diff: profiler demangling bug fix
Fergus Henderson
fjh at cs.mu.oz.au
Mon Oct 13 20:18:09 AEST 1997
Fix a bug that caused problems with profiling.
util/mdemangle.c:
profiler/demangle.m:
When demangling lambda goals, include the sequence number
and module name in the demangled name.
The profiler requires that the mapping between mangled
and demangled names must be one-to-one.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Update the tests to reflect the new demangling algorithm.
cvs diff profiler/demangle.m tests/misc_tests/mdemangle_test.exp tests/misc_tests/mdemangle_test.inp util/mdemangle.c
Index: profiler/demangle.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/profiler/demangle.m,v
retrieving revision 1.3
diff -u -r1.3 demangle.m
--- demangle.m 1997/08/28 17:52:10 1.3
+++ demangle.m 1997/10/13 09:15:12
@@ -29,9 +29,18 @@
:- implementation.
:- import_module int, list, char, std_util, bool, require.
-:- type pred_category ---> index ; unify ; compare ; ordinary ;
- lambda(int, string).
-:- type data_category ---> common ; info ; layout ; functors.
+:- type pred_category
+ ---> index
+ ; unify
+ ; compare
+ ; ordinary
+ ; lambda(int, int, string). % line, sequence number, pred name
+
+:- type data_category
+ ---> common
+ ; info
+ ; layout
+ ; functors.
demangle(MangledName, Name) :-
( demangle_from_asm(MangledName, DemangledName) ->
@@ -214,7 +223,9 @@
remove_maybe_module_prefix(MPredName),
{ MPredName = yes(PredName) },
remove_int(Line),
- { Category = lambda(Line, LambdaPredOrFunc) }
+ remove_prefix("__"),
+ remove_int(Seq),
+ { Category = lambda(Line, Seq, LambdaPredOrFunc) }
;
{ Category = Category0 },
{ PredName = PredName0 }
@@ -258,10 +269,10 @@
[s(PredOrFunc), s(QualifiedName), i(Arity), i(ModeNum)],
MainPart)
;
- Category = lambda(Line, LambdaPredOrFunc),
- string__format("%s goal from %s, line %d",
- [s(LambdaPredOrFunc), s(QualifiedName), i(Line)],
- MainPart)
+ Category = lambda(Line, Seq, LambdaPredOrFunc),
+ string__format("%s goal (#%d) from %s line %d",
+ [s(LambdaPredOrFunc), i(Seq), s(QualifiedName),
+ i(Line)], MainPart)
},
[MainPart],
( { HigherOrder = yes } ->
Index: tests/misc_tests/mdemangle_test.exp
===================================================================
RCS file: /home/staff/zs/imp/tests/misc_tests/mdemangle_test.exp,v
retrieving revision 1.8
diff -u -r1.8 mdemangle_test.exp
--- mdemangle_test.exp 1997/09/29 07:23:26 1.8
+++ mdemangle_test.exp 1997/10/13 10:09:43
@@ -85,10 +85,10 @@
mercury_data_foo
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>
+<pred goal (#9) from 'simplex' in module 'lp' line 262 label 5>
+<pred goal (#9) from 'simplex' in module 'lp' line 262 label 5>
+<func goal (#4) from 'collect_vars' in module 'lp' line 153>
+<func goal (#4) from 'collect_vars' in module 'lp' line 153>
A realistic test
ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
Index: tests/misc_tests/mdemangle_test.inp
===================================================================
RCS file: /home/staff/zs/imp/tests/misc_tests/mdemangle_test.inp,v
retrieving revision 1.9
diff -u -r1.9 mdemangle_test.inp
--- mdemangle_test.inp 1997/09/29 07:23:29 1.9
+++ mdemangle_test.inp 1997/10/13 10:09:23
@@ -86,9 +86,9 @@
some lambda goals
mercury__lp__IntroducedFrom__pred__simplex__262__9_7_0_i5
-<pred goal from 'simplex' line 262 label 5>
+<pred goal (#9) from 'simplex' in module 'lp' line 262 label 5>
mercury__lp__IntroducedFrom__func__collect_vars__153__4_3_0
-<func goal from 'collect_vars' line 153>
+<func goal (#4) from 'collect_vars' in module 'lp' line 153>
A realistic test
ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
Index: util/mdemangle.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/util/mdemangle.c,v
retrieving revision 1.26
diff -u -r1.26 mdemangle.c
--- mdemangle.c 1997/10/02 02:46:10 1.26
+++ mdemangle.c 1997/10/13 10:07:22
@@ -129,6 +129,7 @@
bool higher_order = FALSE; /* has this proc been specialized */
int internal = -1;
int lambda_line = 0;
+ int lambda_seq_number = 0;
char *lambda_pred_name = NULL;
const char *lambda_kind = NULL;
enum { ORDINARY, UNIFY, COMPARE, INDEX, LAMBDA } category;
@@ -321,6 +322,15 @@
lambda_line = lambda_line * 10 + (*start - '0');
start++;
}
+ if (!cut_at_double_underscore(&start, end)) {
+ goto wrong_format;
+ }
+ lambda_seq_number = 0;
+ while (start < end && isdigit(*start)) {
+ lambda_seq_number = lambda_seq_number * 10 +
+ (*start - '0');
+ start++;
+ }
}
/*
@@ -341,8 +351,9 @@
module, start, arity);
break;
case LAMBDA:
- printf("%s goal from '%s' line %d",
- lambda_kind, lambda_pred_name, lambda_line);
+ printf("%s goal (#%d) from '%s' in module '%s' line %d",
+ lambda_kind, lambda_seq_number,
+ lambda_pred_name, module, lambda_line);
break;
default:
if (*module == '\0') {
--
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