[m-rev.] diff: program representations inside the deep type
Zoltan Somogyi
zs at csse.unimelb.edu.au
Fri Oct 3 17:38:46 AEST 2008
The concept has already been agreed to by Paul, and the details are trivial
enough not to need a review.
Zoltan.
Put the program representation inside the deep profiler's main data structure,
since this simplifies things. (We already handled the contents of the
exclusion threshold file this way.)
deep_profiler/profile.m:
Change the data structure's type definition as above.
deep_profiler/create_report.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/query.m:
Conform to the change above.
deep_profiler/startup.m:
Conform to the change above.
Rename a predicate to avoid ambiguity.
cvs diff: Diffing .
Index: create_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/create_report.m,v
retrieving revision 1.11
diff -u -b -r1.11 create_report.m
--- create_report.m 25 Sep 2008 03:47:03 -0000 1.11
+++ create_report.m 3 Oct 2008 04:40:31 -0000
@@ -16,23 +16,21 @@
:- module create_report.
:- interface.
-:- import_module maybe.
-:- import_module mdbcomp.
-:- import_module mdbcomp.program_representation.
:- import_module profile.
:- import_module query.
:- import_module report.
%-----------------------------------------------------------------------------%
-:- pred create_report(cmd::in, deep::in, maybe_error(prog_rep)::in,
- deep_report::out) is det.
+:- pred create_report(cmd::in, deep::in, deep_report::out) is det.
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module apply_exclusion.
+:- import_module mdbcomp.
+:- import_module mdbcomp.program_representation.
:- import_module measurement_units.
:- import_module measurements.
:- import_module program_representation_utils.
@@ -55,7 +53,7 @@
%-----------------------------------------------------------------------------%
-create_report(Cmd, Deep, MaybeProgRep, Report) :-
+create_report(Cmd, Deep, Report) :-
(
Cmd = deep_cmd_quit,
Msg = string.format("Shutting down deep profile server for %s.",
@@ -101,15 +99,8 @@
Report = report_top_procs(MaybeTopProcsReport)
;
Cmd = deep_cmd_procrep_coverage(PSPtr),
- (
- MaybeProgRep = ok(ProgRep),
- generate_procrep_coverage_dump_report(Deep, ProgRep, PSPtr,
- MaybeProcrepCoverageReport)
- ;
- MaybeProgRep = error(Error),
- MaybeProcrepCoverageReport =
- error("No procedure representation information: " ++ Error)
- ),
+ generate_procrep_coverage_dump_report(Deep, PSPtr,
+ MaybeProcrepCoverageReport),
Report = report_procrep_coverage_dump(MaybeProcrepCoverageReport)
;
Cmd = deep_cmd_proc(PSPtr),
@@ -868,10 +859,21 @@
% Code to generate the coverage annotated procedure representation report.
%
-:- pred generate_procrep_coverage_dump_report(deep::in, prog_rep::in,
+:- pred generate_procrep_coverage_dump_report(deep::in,
proc_static_ptr::in, maybe_error(procrep_coverage_info)::out) is det.
-generate_procrep_coverage_dump_report(Deep, ProgRep, PSPtr, MaybeReport) :-
+generate_procrep_coverage_dump_report(Deep, PSPtr, MaybeReport) :-
+ MaybeProgRepResult = Deep ^ procrep_file,
+ (
+ MaybeProgRepResult = no,
+ MaybeReport = error("There is no readable " ++
+ "procedure representation information file.")
+ ;
+ MaybeProgRepResult = yes(error(Error)),
+ MaybeReport = error("Error reading procedure representation " ++
+ "information file: " ++ Error)
+ ;
+ MaybeProgRepResult = yes(ok(ProgRep)),
( valid_proc_static_ptr(Deep, PSPtr) ->
deep_lookup_proc_statics(Deep, PSPtr, PS),
ProcLabel = PS ^ ps_id,
@@ -900,6 +902,7 @@
)
;
MaybeReport = error("Invalid proc_static index")
+ )
).
:- func create_cs_summary_add_to_map(deep, call_site_static_ptr,
Index: mdprof_cgi.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/mdprof_cgi.m,v
retrieving revision 1.27
diff -u -b -r1.27 mdprof_cgi.m
--- mdprof_cgi.m 17 Sep 2008 03:26:29 -0000 1.27
+++ mdprof_cgi.m 3 Oct 2008 04:10:39 -0000
@@ -424,18 +424,12 @@
RecordStartup = no,
MaybeStartupStream = no
),
- read_and_startup(Machine, ScriptName, FileName, Canonical,
- MaybeStartupStream, [], Res, !IO),
+ read_and_startup_default_deep_options(Machine, ScriptName, FileName,
+ Canonical, MaybeStartupStream, [], StartupResult, !IO),
(
- (
- Res = deep_and_progrep(Deep, Progrep),
- MaybeProgrep = ok(Progrep)
- ;
- Res = deep_and_error(Deep, Error),
- MaybeProgrep = error(Error)
- ),
+ StartupResult = ok(Deep),
Pref = solidify_preference(Deep, PrefInd),
- try_exec(Cmd, Pref, Deep, MaybeProgrep, HTML, !IO),
+ try_exec(Cmd, Pref, Deep, HTML, !IO),
(
MaybeStartupStream = yes(StartupStream1),
io.format(StartupStream1, "query 0 output:\n%s\n", [s(HTML)], !IO),
@@ -459,8 +453,7 @@
io.write_string(HTML, !IO),
io.flush_output(!IO),
start_server(Options, ToServerPipe, FromServerPipe,
- MaybeStartupStream, MutexFile, WantFile, Deep, MaybeProgrep,
- !IO)
+ MaybeStartupStream, MutexFile, WantFile, Deep, !IO)
;
Success = no,
release_lock(Debug, MutexFile, !IO),
@@ -470,7 +463,7 @@
)
)
;
- Res = error(Error),
+ StartupResult = error(Error),
release_lock(Debug, MutexFile, !IO),
remove_want_file(WantFile, !IO),
io.set_exit_status(1, !IO),
@@ -482,11 +475,10 @@
%
:- pred start_server(option_table::in, string::in, string::in,
maybe(io.output_stream)::in, string::in, string::in,
- deep::in, maybe_error(prog_rep)::in,
- io::di, io::uo) is cc_multi.
+ deep::in, io::di, io::uo) is cc_multi.
start_server(Options, ToServerPipe, FromServerPipe, MaybeStartupStream,
- MutexFile, WantFile, Deep, MaybeProgrep, !IO) :-
+ MutexFile, WantFile, Deep, !IO) :-
lookup_bool_option(Options, detach_process, DetachProcess),
lookup_bool_option(Options, record_loop, RecordLoop),
lookup_bool_option(Options, debug, Debug),
@@ -543,7 +535,7 @@
lookup_int_option(Options, timeout, TimeOut),
lookup_bool_option(Options, canonical_clique, Canonical),
server_loop(ToServerPipe, FromServerPipe, TimeOut,
- MaybeDebugStream, Debug, Canonical, 0, Deep, MaybeProgrep, !IO)
+ MaybeDebugStream, Debug, Canonical, 0, Deep, !IO)
;
DetachRes = in_parent,
% We are in the parent after we spawned the child. We cause the process
@@ -569,11 +561,10 @@
:- pred server_loop(string::in, string::in, int::in,
maybe(io.output_stream)::in, bool::in, bool::in, int::in,
- deep::in, maybe_error(prog_rep)::in,
- io::di, io::uo) is cc_multi.
+ deep::in, io::di, io::uo) is cc_multi.
server_loop(ToServerPipe, FromServerPipe, TimeOut0, MaybeStartupStream,
- Debug, Canonical, QueryNum0, Deep0, MaybeProgrep0, !IO) :-
+ Debug, Canonical, QueryNum0, Deep0, !IO) :-
setup_timeout(TimeOut0, !IO),
QueryNum = QueryNum0 + 1,
recv_term(ToServerPipe, Debug, CmdPref0, !IO),
@@ -590,29 +581,21 @@
CmdPref0 = cmd_pref(Cmd0, PrefInd0),
( Cmd0 = deep_cmd_restart ->
- read_and_startup(Deep0 ^ server_name_port, Deep0 ^ script_name,
- Deep0 ^ data_file_name, Canonical, MaybeStartupStream, [],
- MaybeDeepAndProgrep, !IO),
+ read_and_startup_default_deep_options(Deep0 ^ server_name_port,
+ Deep0 ^ script_name, Deep0 ^ data_file_name, Canonical,
+ MaybeStartupStream, [], MaybeDeep, !IO),
(
- (
- MaybeDeepAndProgrep = deep_and_progrep(Deep, Progrep),
- MaybeProgrep = ok(Progrep)
- ;
- MaybeDeepAndProgrep = deep_and_error(Deep, Error),
- MaybeProgrep = error(Error)
- ),
+ MaybeDeep = ok(Deep),
MaybeMsg = no,
Cmd = deep_cmd_menu
;
- MaybeDeepAndProgrep = error(ErrorMsg),
+ MaybeDeep = error(ErrorMsg),
MaybeMsg = yes(ErrorMsg),
Deep = Deep0,
- MaybeProgrep = MaybeProgrep0,
Cmd = deep_cmd_quit
)
;
Deep = Deep0,
- MaybeProgrep = MaybeProgrep0,
MaybeMsg = no,
Cmd = Cmd0
),
@@ -621,7 +604,7 @@
MaybeMsg = yes(HTML)
;
MaybeMsg = no,
- try_exec(Cmd, Pref0, Deep, MaybeProgrep, HTML, !IO)
+ try_exec(Cmd, Pref0, Deep, HTML, !IO)
),
ResponseFileName = response_file_name(Deep0 ^ data_file_name, QueryNum),
@@ -654,10 +637,10 @@
delete_cleanup_files(!IO)
; Cmd = deep_cmd_timeout(TimeOut) ->
server_loop(ToServerPipe, FromServerPipe, TimeOut, MaybeStartupStream,
- Debug, Canonical, QueryNum, Deep, MaybeProgrep, !IO)
+ Debug, Canonical, QueryNum, Deep, !IO)
;
server_loop(ToServerPipe, FromServerPipe, TimeOut0, MaybeStartupStream,
- Debug, Canonical, QueryNum, Deep, MaybeProgrep, !IO)
+ Debug, Canonical, QueryNum, Deep, !IO)
).
%-----------------------------------------------------------------------------%
Index: mdprof_feedback.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/mdprof_feedback.m,v
retrieving revision 1.11
diff -u -b -r1.11 mdprof_feedback.m
--- mdprof_feedback.m 30 Sep 2008 08:18:08 -0000 1.11
+++ mdprof_feedback.m 3 Oct 2008 04:11:58 -0000
@@ -83,14 +83,9 @@
check_options(Options, RequestedFeedbackInfo)
->
lookup_bool_option(Options, verbose, Verbose),
- read_deep_file(InputFileName, Verbose, MaybeDeepAndProgRep, !IO),
+ read_deep_file(InputFileName, Verbose, MaybeDeep, !IO),
(
- (
- MaybeDeepAndProgRep = deep_and_error(Deep, _ProgRepError)
- ;
- % _ProgRep will be used by a later version of this program.
- MaybeDeepAndProgRep = deep_and_progrep(Deep, _ProgRep)
- ),
+ MaybeDeep = ok(Deep),
feedback.read_or_create(OutputFileName, FeedbackReadResult,
!IO),
(
@@ -120,7 +115,7 @@
io.set_exit_status(1, !IO)
)
;
- MaybeDeepAndProgRep = error(Error),
+ MaybeDeep = error(Error),
io.stderr_stream(Stderr, !IO),
io.set_exit_status(1, !IO),
io.format(Stderr, "%s: error reading %s: %s\n",
@@ -213,10 +208,10 @@
% Read a deep profiling data file.
%
-:- pred read_deep_file(string::in, bool::in, maybe_deep_and_progrep::out,
+:- pred read_deep_file(string::in, bool::in, maybe_error(deep)::out,
io::di, io::uo) is det.
-read_deep_file(Input, Verbose, MaybeDeepAndProgrep, !IO) :-
+read_deep_file(Input, Verbose, MaybeDeep, !IO) :-
server_name_port(Machine, !IO),
script_name(ScriptName, !IO),
(
@@ -227,8 +222,8 @@
Verbose = no,
MaybeOutput = no
),
- read_and_startup(Machine, ScriptName, Input, no, MaybeOutput,
- [], MaybeDeepAndProgrep, !IO).
+ read_and_startup_default_deep_options(Machine, ScriptName, Input, no,
+ MaybeOutput, [], MaybeDeep, !IO).
%----------------------------------------------------------------------------%
%
Index: mdprof_test.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/mdprof_test.m,v
retrieving revision 1.20
diff -u -b -r1.20 mdprof_test.m
--- mdprof_test.m 17 Sep 2008 03:26:29 -0000 1.20
+++ mdprof_test.m 3 Oct 2008 04:15:07 -0000
@@ -118,25 +118,18 @@
MaybeOutput = yes(Stdout)
),
read_and_startup(Machine, ScriptName, FileName, Canonical,
- MaybeOutput, DumpStages, DumpOptions, Res, !IO),
+ MaybeOutput, DumpStages, DumpOptions, StartupResult, !IO),
(
- (
- Res = deep_and_error(Deep, _),
- MaybeProgrep = error("Couldn't read Deep.procrep file")
- ;
- Res = deep_and_progrep(Deep, ProgRep),
- MaybeProgrep = ok(ProgRep)
- ),
+ StartupResult = ok(Deep),
lookup_bool_option(Options, test, Test),
(
Test = no
;
Test = yes,
- test_server(default_preferences(Deep), Deep, MaybeProgrep,
- Options, !IO)
+ test_server(default_preferences(Deep), Deep, Options, !IO)
)
;
- Res = error(Error),
+ StartupResult = error(Error),
io.set_exit_status(1, !IO),
io.format("%s: error reading %s: %s\n",
[s(ProgName), s(FileName), s(Error)], !IO)
@@ -180,9 +173,7 @@
read_and_startup(Machine, ScriptName, FileName, Canonical, no,
[], default_dump_options, Res, !IO),
(
- Res = deep_and_error(_Deep, _ProgrepError)
- ;
- Res = deep_and_progrep(_Deep, _Progrep)
+ Res = ok(_Deep)
;
Res = error(Error),
io.set_exit_status(1, !IO),
@@ -227,10 +218,10 @@
%-----------------------------------------------------------------------------%
-:- pred test_server(preferences::in, deep::in, maybe_error(prog_rep)::in,
+:- pred test_server(preferences::in, deep::in,
option_table::in, io::di, io::uo) is cc_multi.
-test_server(Pref, Deep, MaybeProgrep, Options, !IO) :-
+test_server(Pref, Deep, Options, !IO) :-
lookup_string_option(Options, test_dir, DirName),
string.format("test -d %s || mkdir -p %s", [s(DirName), s(DirName)], Cmd),
io.call_system(Cmd, _, !IO),
@@ -242,16 +233,14 @@
% test_procs(1, NumProcStatics, DirName, Pref, Deep, !IO).
array.max(Deep ^ proc_statics, NumProcStatics),
- test_procrep_coverages(1, NumProcStatics, Pref, Deep, MaybeProgrep,
- Options, !IO).
+ test_procrep_coverages(1, NumProcStatics, Pref, Deep, Options, !IO).
:- pred test_cliques(int::in, int::in, option_table::in, preferences::in,
deep::in, io::di, io::uo) is cc_multi.
test_cliques(Cur, Max, Options, Pref, Deep, !IO) :-
( Cur =< Max ->
- try_exec(deep_cmd_clique(clique_ptr(Cur)), Pref, Deep, progrep_error,
- HTML, !IO),
+ try_exec(deep_cmd_clique(clique_ptr(Cur)), Pref, Deep, HTML, !IO),
write_test_html(Options, "clique", Cur, HTML, !IO),
test_cliques(Cur + 1, Max, Options, Pref, Deep, !IO)
;
@@ -263,8 +252,7 @@
test_procs(Cur, Max, Options, Pref, Deep, !IO) :-
( Cur =< Max ->
- try_exec(deep_cmd_proc(proc_static_ptr(Cur)), Pref, Deep,
- progrep_error, HTML, !IO),
+ try_exec(deep_cmd_proc(proc_static_ptr(Cur)), Pref, Deep, HTML, !IO),
write_test_html(Options, "proc", Cur, HTML, !IO),
test_procs(Cur + 1, Max, Options, Pref, Deep, !IO)
;
@@ -272,15 +260,14 @@
).
:- pred test_procrep_coverages(int::in, int::in, preferences::in, deep::in,
- maybe_error(prog_rep)::in, option_table::in, io::di, io::uo) is cc_multi.
+ option_table::in, io::di, io::uo) is cc_multi.
-test_procrep_coverages(Cur, Max, Pref, Deep, MaybeProgrep, Options, !IO) :-
+test_procrep_coverages(Cur, Max, Pref, Deep, Options, !IO) :-
( Cur =< Max ->
try_exec(deep_cmd_procrep_coverage(proc_static_ptr(Cur)), Pref, Deep,
- MaybeProgrep, HTML, !IO),
+ HTML, !IO),
write_test_html(Options, "procrep_coverage", Cur, HTML, !IO),
- test_procrep_coverages(Cur + 1, Max, Pref, Deep, MaybeProgrep,
- Options, !IO)
+ test_procrep_coverages(Cur + 1, Max, Pref, Deep, Options, !IO)
;
true
).
Index: profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/profile.m,v
retrieving revision 1.23
diff -u -b -r1.23 profile.m
--- profile.m 25 Sep 2008 03:47:03 -0000 1.23
+++ profile.m 3 Oct 2008 03:52:37 -0000
@@ -124,7 +124,15 @@
% MaybeExcludeFile = ok(ExcludeFile). The other case is
% MaybeExcludeFile = error(ErrorMsg), which shows that the
% contour exclusion file was malformed.
- exclude_contour_file :: maybe(maybe_error(exclude_file))
+ exclude_contour_file :: maybe(maybe_error(exclude_file)),
+
+ % If this field is `no', then there is no (readable) proc
+ % representation file. If this field is yes(MaybeProcRepFile),
+ % then there are again two possibilities. The normal case is
+ % MaybeProcRepFile = ok(ProcRepFile). The other case is
+ % MaybeProcRepFile = error(ErrorMsg), which shows that the
+ % proc representation file was malformed.
+ procrep_file :: maybe(maybe_error(prog_rep))
).
:- type compensation_table == map(proc_static_ptr, inherit_prof_info).
Index: query.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/query.m,v
retrieving revision 1.30
diff -u -b -r1.30 query.m
--- query.m 25 Sep 2008 07:33:14 -0000 1.30
+++ query.m 3 Oct 2008 04:39:24 -0000
@@ -27,8 +27,6 @@
:- module query.
:- interface.
-:- import_module mdbcomp.
-:- import_module mdbcomp.program_representation.
:- import_module measurement_units.
:- import_module profile.
@@ -38,8 +36,8 @@
%-----------------------------------------------------------------------------%
-:- pred try_exec(cmd::in, preferences::in, deep::in, maybe_error(prog_rep)::in,
- string::out, io::di, io::uo) is cc_multi.
+:- pred try_exec(cmd::in, preferences::in, deep::in, string::out,
+ io::di, io::uo) is cc_multi.
%-----------------------------------------------------------------------------%
%
@@ -341,8 +339,8 @@
%-----------------------------------------------------------------------------%
-try_exec(Cmd, Pref, Deep, MaybeProgrep, HTML, !IO) :-
- try_io(exec(Cmd, Pref, Deep, MaybeProgrep), Result, !IO),
+try_exec(Cmd, Pref, Deep, HTML, !IO) :-
+ try_io(exec(Cmd, Pref, Deep), Result, !IO),
(
Result = succeeded(HTML)
;
@@ -371,10 +369,10 @@
[s(Msg)])
).
-:- pred exec(cmd::in, preferences::in, deep::in, maybe_error(prog_rep)::in,
+:- pred exec(cmd::in, preferences::in, deep::in,
string::out, io::di, io::uo) is det.
-exec(Cmd, Prefs, Deep, MaybeProgRep, HTMLStr, !IO) :-
+exec(Cmd, Prefs, Deep, HTMLStr, !IO) :-
% XXX While we are working on converting the deep profiler to use
% the new report structures, we can use the presence or absence
% of this file to tell mdprof_cgi which method we want to use at the
@@ -412,20 +410,20 @@
old_exec(Cmd, Prefs, Deep, HTMLStr, !IO)
;
FileExists = no,
- new_exec(Cmd, Prefs, Deep, MaybeProgRep, HTMLStr, !IO)
+ new_exec(Cmd, Prefs, Deep, HTMLStr, !IO)
)
;
Cmd = deep_cmd_procrep_coverage(_),
- new_exec(Cmd, Prefs, Deep, MaybeProgRep, HTMLStr, !IO)
+ new_exec(Cmd, Prefs, Deep, HTMLStr, !IO)
).
% Run the command through the new report generation code.
%
-:- pred new_exec(cmd::in, preferences::in, deep::in, maybe_error(prog_rep)::in,
- string::out, io::di, io::uo) is det.
+:- pred new_exec(cmd::in, preferences::in, deep::in, string::out,
+ io::di, io::uo) is det.
-new_exec(Cmd, Prefs, Deep, MaybeProgRep, HTMLStr, !IO) :-
- create_report(Cmd, Deep, MaybeProgRep, Report),
+new_exec(Cmd, Prefs, Deep, HTMLStr, !IO) :-
+ create_report(Cmd, Deep, Report),
Display = report_to_display(Deep, Prefs, Report),
HTML = htmlize_display(Deep, Prefs, Display),
HTMLStr = html_to_string(HTML).
Index: startup.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/startup.m,v
retrieving revision 1.22
diff -u -b -r1.22 startup.m
--- startup.m 28 Aug 2008 10:26:14 -0000 1.22
+++ startup.m 3 Oct 2008 04:38:43 -0000
@@ -20,8 +20,6 @@
:- interface.
:- import_module dump.
-:- import_module mdbcomp.
-:- import_module mdbcomp.program_representation.
:- import_module profile.
:- import_module bool.
@@ -31,27 +29,13 @@
%-----------------------------------------------------------------------------%
- % The result of read_and_startup below.
- %
-:- type maybe_deep_and_progrep
- ---> error(string)
- % This error was raised while reading the Deep data.
-
- ; deep_and_error(deep, string)
- % The Deep data was read succesfully, but the reading the
- % Progrep data raised an error.
-
- ; deep_and_progrep(deep, prog_rep).
- % Both Deep and Progrep files where read successfully.
-
-
-:- pred read_and_startup(string::in, string::in, string::in, bool::in,
- maybe(io.output_stream)::in, list(string)::in, maybe_deep_and_progrep::out,
- io::di, io::uo) is det.
-
-:- pred read_and_startup(string::in, string::in, string::in, bool::in,
- maybe(io.output_stream)::in, list(string)::in, dump_options::in,
- maybe_deep_and_progrep::out, io::di, io::uo) is det.
+:- pred read_and_startup_default_deep_options(string::in, string::in,
+ string::in, bool::in, maybe(io.output_stream)::in, list(string)::in,
+ maybe_error(deep)::out, io::di, io::uo) is det.
+
+:- pred read_and_startup(string::in, string::in,
+ string::in, bool::in, maybe(io.output_stream)::in, list(string)::in,
+ dump_options::in, maybe_error(deep)::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -62,6 +46,8 @@
:- import_module callgraph.
:- import_module canonical.
:- import_module exclude.
+:- import_module mdbcomp.
+:- import_module mdbcomp.program_representation.
:- import_module measurements.
:- import_module profile.
:- import_module read_profile.
@@ -76,46 +62,58 @@
%-----------------------------------------------------------------------------%
-read_and_startup(Machine, ScriptName, DataFileName, Canonical,
- MaybeOutputStream, DumpStages, Res, !IO) :-
+read_and_startup_default_deep_options(Machine, ScriptName, DataFileName,
+ Canonical, MaybeOutputStream, DumpStages, Res, !IO) :-
read_and_startup(Machine, ScriptName, DataFileName, Canonical,
MaybeOutputStream, DumpStages, default_dump_options, Res, !IO).
read_and_startup(Machine, ScriptName, DataFileName, Canonical,
- MaybeOutputStream, DumpStages, DumpOptions, Res, !IO) :-
+ MaybeOutputStream, DumpStages, DumpOptions, Result, !IO) :-
maybe_report_stats(MaybeOutputStream, !IO),
maybe_report_msg(MaybeOutputStream,
"% Reading graph data...\n", !IO),
- read_call_graph(DataFileName, Res0, !IO),
+ read_call_graph(DataFileName, DataFileResult, !IO),
maybe_report_msg(MaybeOutputStream,
"% Done.\n", !IO),
maybe_report_stats(MaybeOutputStream, !IO),
(
- Res0 = ok(InitDeep),
+ DataFileResult = ok(InitDeep),
startup(Machine, ScriptName, DataFileName,
Canonical, MaybeOutputStream, DumpStages, DumpOptions,
- InitDeep, Deep, !IO),
- ProgrepFileName = make_progrep_filename(DataFileName),
+ InitDeep, Deep0, !IO),
+ ProgRepFileName = make_progrep_filename(DataFileName),
maybe_report_msg(MaybeOutputStream,
- "% Reading progrep data...\n", !IO),
- read_prog_rep_file(ProgrepFileName, Res1, !IO),
+ "% Reading program representation...\n", !IO),
+ read_prog_rep_file(ProgRepFileName, ProgRepResult, !IO),
(
- Res1 = ok(Progrep),
+ ProgRepResult = ok(ProgRep),
maybe_report_msg(MaybeOutputStream,
"% Done.\n", !IO),
- Res = deep_and_progrep(Deep, Progrep)
+ Deep = Deep0 ^ procrep_file := yes(ok(ProgRep))
;
- Res1 = error(Error),
+ ProgRepResult = error(Error),
+ (
+ io.open_input(ProgRepFileName, OpenProgRepResult, !IO),
+ (
+ OpenProgRepResult = ok(ProgRepStream),
+ % The file exists, so the error message describes something
+ % wrong with the file.
+ io.close_input(ProgRepStream, !IO),
ErrorMessage = io.error_message(Error),
maybe_report_msg(MaybeOutputStream,
"% Error: " ++ ErrorMessage ++ "\n", !IO),
- % This error isn't displayed until a query needs the progrep
- % data.
- Res = deep_and_error(Deep, ErrorMessage)
+ Deep = Deep0 ^ procrep_file := yes(error(ErrorMessage))
+ ;
+ OpenProgRepResult = error(_),
+ % The file does not exist.
+ Deep = Deep0 ^ procrep_file := no
)
+ )
+ ),
+ Result = ok(Deep)
;
- Res0 = error(Error),
- Res = error(Error)
+ DataFileResult = error(Error),
+ Result = error(Error)
).
:- func make_progrep_filename(string) = string.
@@ -124,8 +122,7 @@
( remove_suffix(DataFileName, ".data", BaseFileName) ->
ProgrepFileName = BaseFileName ++ ".procrep"
;
- error("Couldn't remove suffix from deep file name: " ++
- DataFileName)
+ error("Couldn't remove suffix from deep file name: " ++ DataFileName)
).
:- pred startup(string::in, string::in, string::in, bool::in,
@@ -262,16 +259,20 @@
array.init(NCSDs, map.init, CSDCompTable0),
ModuleData = map.map_values(initialize_module_data, ModuleProcs),
- % The field holding DummyExcludeError is given its proper, non-dummy value
- % a few calls below.
+ % The field holding DummyMaybeExcludeFile is given its proper,
+ % non-dummy value a few calls below.
DummyMaybeExcludeFile = no,
+ % The field holding DummyMaybeProcRepFile is given its proper,
+ % non-dummy value outside this predicate.
+ DummyMaybeProcRepFile = no,
!:Deep = deep(InitStats, Machine, ScriptName, DataFileName, Root,
CallSiteDynamics, ProcDynamics, CallSiteStatics, ProcStatics,
CliqueIndex, Cliques, CliqueParents, CliqueMaybeChildren,
ProcCallers, CallSiteStaticMap, CallSiteCalls,
PDOwn, PDDesc0, CSDDesc0,
PSOwn0, PSDesc0, CSSOwn0, CSSDesc0,
- PDCompTable0, CSDCompTable0, ModuleData, DummyMaybeExcludeFile),
+ PDCompTable0, CSDCompTable0, ModuleData,
+ DummyMaybeExcludeFile, DummyMaybeProcRepFile),
read_exclude_file(contour_file_name(DataFileName), !.Deep,
MaybeMaybeExcludeFile, !IO),
cvs diff: Diffing notes
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list