[m-rev.] diff: debugging traces of code to read deep profiles
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Oct 9 18:05:02 AEST 2006
Estimated hours taken: 0.5
Branches: main
Use trace goals to conditionally enable lowlevel debugging traces for the
code that reads deep profiles.
deep_profiler/read_profile.m:
Use trace goals to conditionally enable the lowlevel debugging code in
this module in preference to commenting it out. (The debugging code
itself could be more useful than it is but that's a separate change -
at the moment I'm just using it to try and isolate roughly where the
code in the runtime that writes out profiles is broken.)
Fix some formatting.
deep_profiler/mdprof_dump.m:
Fix a typo and a couple of minor formatting fixes.
boehm_gc/Mmakefile:
Avoid an error from make if realcleaning the libatomic_ops
directory fails which it will if realclean is run multiple times
without that directory being reconfigured.
Julien.
Index: boehm_gc/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/boehm_gc/Mmakefile,v
retrieving revision 1.32
diff -u -r1.32 Mmakefile
--- boehm_gc/Mmakefile 24 Aug 2006 11:54:15 -0000 1.32
+++ boehm_gc/Mmakefile 9 Oct 2006 06:29:15 -0000
@@ -89,7 +89,7 @@
clean_local:
MAKEFLAGS=""; export MAKEFLAGS; \
$(MAKE) $(BOEHMGC_MAKEFILE) $(MMAKEFLAGS) clean
- cd libatomic_ops-1.2 && $(MAKE) $(MMAKEFLAGS) clean
+ -cd libatomic_ops-1.2 && $(MAKE) $(MMAKEFLAGS) clean
rm -f libgc.$A libgc.so libpar_gc.$A libpar_gc.dll
rm -f libatomic_ops-1.2/Makefile libatomic_ops-1.2/tests/Makefile
rm -f libatomic_ops-1.2/src/Makefile
Index: deep_profiler/mdprof_dump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/mdprof_dump.m,v
retrieving revision 1.4
diff -u -r1.4 mdprof_dump.m
--- deep_profiler/mdprof_dump.m 29 Mar 2006 08:07:40 -0000 1.4
+++ deep_profiler/mdprof_dump.m 9 Oct 2006 07:51:22 -0000
@@ -6,6 +6,7 @@
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
+% File: mdprof_dump.m.
% Authors: juliensf, zs.
%
% This module is the main module of a tool for dumping out the contents
@@ -16,7 +17,6 @@
%-----------------------------------------------------------------------------%
:- module mdprof_dump.
-
:- interface.
:- import_module io.
@@ -85,7 +85,7 @@
getopt.lookup_bool_option(Options, dump_proc_dynamics, DumpPDs0),
getopt.lookup_bool_option(Options, dump_call_site_statics, DumpCSSs0),
getopt.lookup_bool_option(Options, dump_proc_statics, DumpPSs0),
- % If the user doesn't way what he/she wants, they dump everything.
+ % If the user doesn't say what he/she wants, they dump everything.
(
ProfStats0 = no,
DumpCSDs0 = no,
Index: deep_profiler/read_profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/read_profile.m,v
retrieving revision 1.17
diff -u -r1.17 read_profile.m
--- deep_profiler/read_profile.m 5 Oct 2006 04:37:51 -0000 1.17
+++ deep_profiler/read_profile.m 9 Oct 2006 07:51:22 -0000
@@ -6,13 +6,15 @@
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
+% File: read_call_graph.m.
% Authors: conway, zs.
%
% This module contains code for reading in a deep profiling data file.
% Such files, named Deep.data, are created by deep profiled executables.
+%
+%-----------------------------------------------------------------------------%
:- module read_profile.
-
:- interface.
:- import_module profile.
@@ -23,6 +25,9 @@
:- pred read_call_graph(string::in, maybe_error(initial_deep)::out,
io::di, io::uo) is det.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module array_util.
@@ -37,6 +42,8 @@
:- import_module require.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
:- type maybe_error2(T1, T2)
---> ok2(T1, T2)
; error2(string).
@@ -232,8 +239,9 @@
io::di, io::uo) is det.
read_call_site_static(Res, !IO) :-
- % DEBUGSITE
- % io.write_string("reading call_site_static.\n"),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("reading call_site_static.\n", !IO)
+ ),
io_combinator.maybe_error_sequence_4(
read_ptr(css),
read_call_site_kind_and_callee,
@@ -250,13 +258,14 @@
Res1, !IO),
(
Res1 = ok({CallSiteStatic, CSSI}),
- Res = ok2(CallSiteStatic, CSSI)
- % DEBUGSITE
- % io.write_string("read call_site_static ", !IO),
- % io.write_int(CSSI, !IO),
- % io.write_string(": ", !IO),
- % io.write(CallSiteStatic, !IO),
- % io.write_string("\n", !IO)
+ Res = ok2(CallSiteStatic, CSSI),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("read call_site_static ", !IO),
+ io.write_int(CSSI, !IO),
+ io.write_string(": ", !IO),
+ io.write(CallSiteStatic, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res1 = error(Err),
Res = error2(Err)
@@ -267,8 +276,9 @@
io::di, io::uo) is det.
read_proc_static(Res, !IO) :-
- % DEBUGSITE
- % io.write_string("reading proc_static.\n", !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("reading proc_static.\n", !IO)
+ ),
io_combinator.maybe_error_sequence_6(
read_ptr(ps),
read_proc_id,
@@ -302,13 +312,14 @@
ProcStatic = proc_static(Id, DeclModule,
RefinedStr, RawStr, FileName, LineNumber,
IsInInterface, array(CSSPtrs), not_zeroed),
- Res = ok2(ProcStatic, PSI)
- % DEBUGSITE
- % io.write_string("read proc_static ", !IO),
- % io.write_int(PSI, !IO),
- % io.write_string(": ", !IO),
- % io.write(ProcStatic, !IO),
- % io.write_string("\n", !IO)
+ Res = ok2(ProcStatic, PSI),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("read proc_static ", !IO),
+ io.write_int(PSI, !IO),
+ io.write_string(": ", !IO),
+ io.write(ProcStatic, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res2 = error(Err),
Res = error2(Err)
@@ -318,8 +329,7 @@
Res = error2(Err)
).
-:- pred read_proc_id(maybe_error(proc_id)::out,
- io::di, io::uo) is det.
+:- pred read_proc_id(maybe_error(proc_id)::out, io::di, io::uo) is det.
read_proc_id(Res, !IO) :-
read_deep_byte(Res0, !IO),
@@ -340,8 +350,8 @@
Res = error(Err)
).
-:- pred read_proc_id_uci_pred(maybe_error(proc_id)::out,
- io::di, io::uo) is det.
+:- pred read_proc_id_uci_pred(maybe_error(proc_id)::out, io::di, io::uo)
+ is det.
read_proc_id_uci_pred(Res, !IO) :-
io_combinator.maybe_error_sequence_6(
@@ -526,8 +536,9 @@
io::di, io::uo) is det.
read_proc_dynamic(Res, !IO) :-
- % DEBUGSITE
- % io.write_string("reading proc_dynamic.\n", !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("reading proc_dynamic.\n", !IO)
+ ),
io_combinator.maybe_error_sequence_3(
read_ptr(pd),
read_ptr(ps),
@@ -543,13 +554,14 @@
Res2 = ok(Refs),
PSPtr = make_psptr(PSI),
ProcDynamic = proc_dynamic(PSPtr, array(Refs)),
- Res = ok2(ProcDynamic, PDI)
- % DEBUGSITE
- % io.write_string("read proc_dynamic ", !IO),
- % io.write_int(PDI, !IO),
- % io.write_string(": ", !IO),
- % io.write(ProcDynamic, !IO),
- % io.write_string("\n", !IO)
+ Res = ok2(ProcDynamic, PDI),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("read proc_dynamic ", !IO),
+ io.write_int(PDI, !IO),
+ io.write_string(": ", !IO),
+ io.write(ProcDynamic, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res2 = error(Err),
Res = error2(Err)
@@ -563,8 +575,9 @@
io::di, io::uo) is det.
read_call_site_dynamic(Res, !IO) :-
- % DEBUGSITE
- % io.write_string("reading call_site_dynamic.\n", !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("reading call_site_dynamic.\n", !IO)
+ ),
read_ptr(csd, Res1, !IO),
(
Res1 = ok(CSDI),
@@ -578,14 +591,14 @@
CallerPDPtr = make_dummy_pdptr,
CallSiteDynamic = call_site_dynamic(
CallerPDPtr, PDPtr, Profile),
- Res = ok2(CallSiteDynamic, CSDI)
- % DEBUGSITE
- % io.write_string("read call_site_dynamic ",
- % !IO),
- % io.write_int(CSDI, !IO),
- % io.write_string(": ", !IO),
- % io.write(CallSiteDynamic, !IO),
- % io.write_string("\n", !IO)
+ Res = ok2(CallSiteDynamic, CSDI),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("read call_site_dynamic ", !IO),
+ io.write_int(CSDI, !IO),
+ io.write_string(": ", !IO),
+ io.write(CallSiteDynamic, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res3 = error(Err),
Res = error2(Err)
@@ -599,8 +612,7 @@
Res = error2(Err)
).
-:- pred read_profile(maybe_error(own_prof_info)::out,
- io::di, io::uo) is det.
+:- pred read_profile(maybe_error(own_prof_info)::out, io::di, io::uo) is det.
read_profile(Res, !IO) :-
read_num(Res0, !IO),
@@ -672,8 +684,9 @@
io::di, io::uo) is det.
read_call_site_slot(Res, !IO) :-
- % DEBUGSITE
- % io.write_string("reading call_site_slot.\n", !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("reading call_site_slot.\n", !IO)
+ ),
read_call_site_kind(Res1, !IO),
(
Res1 = ok(Kind),
@@ -682,12 +695,12 @@
(
Res2 = ok(CSDI),
CSDPtr = make_csdptr(CSDI),
- Res = ok(slot_normal(CSDPtr))
- % DEBUGSITE
- % io.write_string("normal call_site slot ",
- % !IO),
- % io.write_int(CSDI, !IO),
- % io.write_string("\n", !IO)
+ Res = ok(slot_normal(CSDPtr)),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("normal call_site slot ", !IO),
+ io.write_int(CSDI, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res2 = error(Err),
Res = error(Err)
@@ -706,12 +719,12 @@
(
Res2 = ok(CSDIs),
CSDPtrs = list.map(make_csdptr, CSDIs),
- Res = ok(slot_multi(Zeroed, array(CSDPtrs)))
- % DEBUGSITE
- % io.write_string("multi call_site slots ",
- % !IO),
- % io.write(CSDIs, !IO),
- % io.write_string("\n", !IO)
+ Res = ok(slot_multi(Zeroed, array(CSDPtrs))),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("multi call_site slots ", !IO),
+ io.write(CSDIs, !IO),
+ io.write_string("\n", !IO)
+ )
;
Res2 = error(Err),
Res = error(Err)
@@ -742,8 +755,9 @@
maybe_error(list(int))::out, io::di, io::uo) is det.
read_multi_call_site_csdis_2(CSDIs0, Res, !IO) :-
- % DEBUGSITE
- % io.format("reading multi_call_site_csdi.\n", [], !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.format("reading multi_call_site_csdi.\n", [], !IO)
+ ),
read_deep_byte(Res0, !IO),
(
Res0 = ok(Byte),
@@ -786,11 +800,12 @@
format("unexpected call_site_kind %d",
[i(Byte)], Msg),
Res = error(Msg)
+ ),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("call_site_kind ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
)
- % DEBUGSITE
- % io.write_string("call_site_kind ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO)
;
Res0 = error(Err),
Res = error(Err)
@@ -832,11 +847,12 @@
;
format("unexpected call_site_kind %d", [i(Byte)], Msg),
Res = error(Msg)
+ ),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("call_site_kind_and_callee ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
)
- % DEBUGSITE
- % io.write_string("call_site_kind_and_callee ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO)
;
Res0 = error(Err),
Res = error(Err)
@@ -915,30 +931,32 @@
;
Res1 = error(Err),
Res = error(Err)
+ ),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("string ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
).
- % DEBUGSITE
- % io.write_string("string ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO).
-:- pred read_ptr(ptr_kind::in, maybe_error(int)::out,
- io::di, io::uo) is det.
+:- pred read_ptr(ptr_kind::in, maybe_error(int)::out, io::di, io::uo) is det.
read_ptr(_Kind, Res, !IO) :-
- read_num1(0, Res, !IO).
- % DEBUGSITE
- % io.write_string("ptr ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO).
+ read_num1(0, Res, !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("ptr ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
+ ).
:- pred read_num(maybe_error(int)::out, io::di, io::uo) is det.
read_num(Res, !IO) :-
- read_num1(0, Res, !IO).
- % DEBUGSITE
- % io.write_string("num ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO).
+ read_num1(0, Res, !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("num ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
+ ).
:- pred read_num1(int::in, maybe_error(int)::out,
io::di, io::uo) is det.
@@ -1029,10 +1047,11 @@
read_deep_byte(Res, !IO) :-
read_byte(Res0, !IO),
- % DEBUGSITE
- % io.write_string("byte ", !IO),
- % io.write(Res, !IO),
- % io.write_string("\n", !IO),
+ trace [ compile_time(flag("debug_read_profdeep")), io(!IO) ] (
+ io.write_string("byte ", !IO),
+ io.write(Res, !IO),
+ io.write_string("\n", !IO)
+ ),
(
Res0 = ok(Byte),
Res = ok(Byte)
--------------------------------------------------------------------------
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