[m-dev.] diff: fix mprof in hlc.gc.*prof grades
Peter Ross
peter.ross at miscrit.be
Fri Nov 24 21:39:41 AEDT 2000
Hi,
===================================================================
Estimated hours taken: 1
Not all the address in the hlc.gc profiling grades are recorded in the
Prof.Addr file. This can cause map__lookups to fail when processing the
Prof.CallPair file.
process_file.m:
When ever an unknown address is seen while processing the
Prof.CallPair file create a structure named unknown__<addr> to hold
information about the unknown address.
Index: process_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/process_file.m,v
retrieving revision 1.17
diff -u -r1.17 process_file.m
--- process_file.m 1997/12/05 15:55:53 1.17
+++ process_file.m 2000/11/24 10:05:38
@@ -51,7 +51,7 @@
maybe_write_string(VVerbose, "\n\t% Processing "),
maybe_write_string(VVerbose, DeclFile),
maybe_write_string(VVerbose, "..."),
- process_addr_decl(AddrDeclMap, ProfNodeMap0),
+ process_addr_decl(AddrDeclMap0, ProfNodeMap0),
maybe_write_string(VVerbose, " done.\n"),
% process the timing counts file
@@ -66,7 +66,8 @@
maybe_write_string(VVerbose, "\t% Processing "),
maybe_write_string(VVerbose, PairFile),
maybe_write_string(VVerbose, "..."),
- process_addr_pair(ProfNodeMap1, DynamicCallGraph, ProfNodeMap),
+ process_addr_pair(ProfNodeMap1, AddrDeclMap0, DynamicCallGraph,
+ ProfNodeMap, AddrDeclMap),
maybe_write_string(VVerbose, " done.\n"),
{ map__init(CycleMap) },
@@ -144,15 +145,17 @@
{ map__insert(ProfNodeMap0, LabelAddr, ProfNode,
ProfNodeMap1) }
->
+ { AddrDecl2 = AddrDecl1 },
{ ProfNodeMap2 = ProfNodeMap1 }
;
- lookup_addr(ProfNodeMap0, LabelAddr, ProfNode0),
+ { lookup_addr(ProfNodeMap0, AddrDecl1, LabelAddr,
+ ProfNode0, ProfNodeMap1, AddrDecl2) },
{ prof_node_concat_to_name_list(LabelName, ProfNode0,
NewProfNode) },
- { map__det_update(ProfNodeMap0, LabelAddr, NewProfNode,
+ { map__det_update(ProfNodeMap1, LabelAddr, NewProfNode,
ProfNodeMap2) }
),
- process_addr_decl_2(AddrDecl1, ProfNodeMap2, AddrDecl,
+ process_addr_decl_2(AddrDecl2, ProfNodeMap2, AddrDecl,
ProfNodeMap)
;
{ MaybeLabelAddr = no },
@@ -249,19 +252,21 @@
% lists of the prof_node structure. Also calculates the number of times
% a predicate is called.
%
-:- pred process_addr_pair(prof_node_map, relation(string), prof_node_map,
- io__state, io__state).
-:- mode process_addr_pair(in, out, out, di, uo) is det.
+:- pred process_addr_pair(prof_node_map, addrdecl, relation(string),
+ prof_node_map, addrdecl, io__state, io__state).
+:- mode process_addr_pair(in, in, out, out, out, di, uo) is det.
-process_addr_pair(ProfNodeMap0, DynamicCallGraph, ProfNodeMap) -->
+process_addr_pair(ProfNodeMap0, AddrDecl0, DynamicCallGraph,
+ ProfNodeMap, AddrDecl) -->
{ relation__init(DynamicCallGraph0) },
globals__io_lookup_bool_option(dynamic_cg, Dynamic),
globals__io_lookup_string_option(pairfile, PairFile),
io__see(PairFile, Result),
(
{ Result = ok },
- process_addr_pair_2(DynamicCallGraph0, ProfNodeMap0, Dynamic,
- DynamicCallGraph, ProfNodeMap),
+ process_addr_pair_2(DynamicCallGraph0, ProfNodeMap0, AddrDecl0,
+ Dynamic, DynamicCallGraph,
+ ProfNodeMap, AddrDecl),
io__seen
;
{ Result = error(Error) },
@@ -274,12 +279,13 @@
{ error(ErrorStr) }
).
-:- pred process_addr_pair_2(relation(string), prof_node_map, bool,
- relation(string), prof_node_map, io__state, io__state).
-:- mode process_addr_pair_2(in, in, in, out, out, di, uo) is det.
+:- pred process_addr_pair_2(relation(string), prof_node_map, addrdecl, bool,
+ relation(string), prof_node_map, addrdecl,
+ io__state, io__state).
+:- mode process_addr_pair_2(in, in, in, in, out, out, out, di, uo) is det.
-process_addr_pair_2(DynamicCallGraph0, ProfNodeMap0, Dynamic, DynamicCallGraph,
- ProfNodeMap) -->
+process_addr_pair_2(DynamicCallGraph0, ProfNodeMap0, AddrDecl0,
+ Dynamic, DynamicCallGraph, ProfNodeMap, AddrDecl) -->
maybe_read_label_addr(MaybeLabelAddr),
(
{ MaybeLabelAddr = yes(CallerAddr) },
@@ -287,8 +293,10 @@
read_int(Count),
% Get child and parent information
- lookup_addr(ProfNodeMap0, CallerAddr, CallerProfNode0),
- lookup_addr(ProfNodeMap0, CalleeAddr, CalleeProfNode0),
+ { lookup_addr(ProfNodeMap0, AddrDecl0, CallerAddr,
+ CallerProfNode0, ProfNodeMap0a, AddrDecl1) },
+ { lookup_addr(ProfNodeMap0a, AddrDecl1, CalleeAddr,
+ CalleeProfNode0, ProfNodeMap0b, AddrDecl2) },
{ prof_node_get_pred_name(CallerProfNode0, CallerName) },
{ prof_node_get_pred_name(CalleeProfNode0, CalleeName) },
@@ -296,7 +304,8 @@
{ prof_node_concat_to_child(CalleeName, Count, CallerProfNode0,
CallerProfNode) },
- {map__set(ProfNodeMap0, CallerAddr, CallerProfNode, PNodeMap1)},
+ {map__set(ProfNodeMap0b, CallerAddr, CallerProfNode,
+ PNodeMap1)},
% Update the total calls field if not self recursive
({
@@ -330,12 +339,14 @@
DynamicCallGraph99 = DynamicCallGraph0
}),
- process_addr_pair_2(DynamicCallGraph99, PNodeMap2, Dynamic,
- DynamicCallGraph, ProfNodeMap)
+ process_addr_pair_2(DynamicCallGraph99, PNodeMap2, AddrDecl2,
+ Dynamic, DynamicCallGraph, ProfNodeMap,
+ AddrDecl)
;
{ MaybeLabelAddr = no },
{ DynamicCallGraph = DynamicCallGraph0 },
- { ProfNodeMap = ProfNodeMap0 }
+ { ProfNodeMap = ProfNodeMap0 },
+ { AddrDecl = AddrDecl0 }
).
@@ -389,19 +400,26 @@
).
%-----------------------------------------------------------------------------%
+
-% Utility functions so as to replace the lookup functions
+% Attempt to lookup the addr in the prof_node_map, if it doesn't exist
+% record the name as unknown__<address> in the relevant data structures.
-:- pred lookup_addr(prof_node_map, int, prof_node, io__state, io__state).
-:- mode lookup_addr(in, in, out, di, uo) is det.
+:- pred lookup_addr(prof_node_map, addrdecl, int, prof_node,
+ prof_node_map, addrdecl).
+:- mode lookup_addr(in, in, in, out, out, out) is det.
-lookup_addr(ProfNodeMap, Addr, ProfNode) -->
+lookup_addr(ProfNodeMap0, AddrDeclMap0, Addr, ProfNode,
+ ProfNodeMap, AddrDeclMap) :-
(
- { map__search(ProfNodeMap, Addr, ProfNode0) }
+ map__search(ProfNodeMap0, Addr, ProfNode0)
->
- { ProfNode = ProfNode0 }
+ ProfNodeMap = ProfNodeMap0,
+ AddrDeclMap = AddrDeclMap0,
+ ProfNode = ProfNode0
;
- { string__format("\nKey = %d\n", [ i(Addr) ], String) },
- io__write_string(String),
- { error("map__lookup: key not found\n") }
+ Str = string__format("unknown__%d", [i(Addr)]),
+ prof_node_init(Str, ProfNode),
+ map__det_insert(ProfNodeMap0, Addr, ProfNode, ProfNodeMap),
+ map__det_insert(AddrDeclMap0, Str, Addr, AddrDeclMap)
).
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list