[m-rev.] for post-commit review: deep profiler customization

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Sep 8 12:36:57 AEST 2009


Several improvements to make the deep profiler more convenient to use.

deep_profiler/mdprof_cgi.m:
	If the data file does not end in .data, generate an explicit error
	message. Without this, the deep profiler just hangs forever on such
	filenames.

deep_profiler/query.m:
	Add a couple more categories of user preferences. The first new
	category controls whether, in reports for procedures and cliques,
	the deep profiler will display call sites through which there were no
	calls. The second new category controls whether the deep profiler
	includes module qualifications in the names of procedures. Module
	qualifying everything, as we did before, can clutter up the output,
	so the new default is to module qualify only the names of procedures
	that are in different modules from the module that defines the current
	procedure.

deep_profiler/profile.m:
deep_profiler/report.m:
	Remember module names and unqualified as well as qualified names
	of procedures.

deep_profiler/create_report.m:
deep_profiler/read_profile.m:
	Remember the newly needed information.

deep_profiler/display_report.m:
	Implement the two new categories of preferences.

	When generating the menu, make the "follow the action" links
	more useful by implicitly preferring to (a) hide inactive call sites,
	and (b) sort by overall time.

	When sorting by time, if two times (clock ticks) are equal,
	try to use call sequence numbers to resolve the order.

	When generating the menu, print the total quanta as well as the total
	runtime computed from it.

deep_profiler/dump.m:
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
	Conform to the changes above.

Zoltan.

cvs diff: Diffing .
Index: create_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/create_report.m,v
retrieving revision 1.17
diff -u -b -r1.17 create_report.m
--- create_report.m	7 Feb 2009 07:13:15 -0000	1.17
+++ create_report.m	7 Sep 2009 11:11:08 -0000
@@ -1137,14 +1137,15 @@
     ( valid_proc_static_ptr(Deep, PSPtr) ->
         deep_lookup_proc_statics(Deep, PSPtr, PS),
         % Should we dump some other fields?
-        PS = proc_static(_ProcId, _DeclModule, RefinedName, RawName,
-            FileName, LineNumber, _InInterface, CallSites, CoveragePoints,
-            _IsZeroed),
+        PS = proc_static(_ProcId, _DeclModule,
+            UnQualRefinedName, QualRefinedName, RawName, FileName, LineNumber,
+            _InInterface, CallSites, CoveragePoints, _IsZeroed),
         array.max(CallSites, MaxCallSiteIdx),
         NumCallSites = MaxCallSiteIdx + 1,
         array.max(CoveragePoints, MaxCoveragePointIdx),
         NumCoveragePoints = MaxCoveragePointIdx + 1,
-        ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName, RefinedName,
+        ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName,
+            UnQualRefinedName, QualRefinedName,
             FileName, LineNumber, NumCallSites, NumCoveragePoints),
         MaybeProcStaticDumpInfo = ok(ProcStaticDumpInfo)
     ;
@@ -1160,10 +1161,13 @@
         PD = proc_dynamic(PSPtr, CallSiteArray),
         deep_lookup_proc_statics(Deep, PSPtr, PS),
         RawName = PS ^ ps_raw_id,
-        RefinedName = PS ^ ps_refined_id,
+        ModuleName = PS ^ ps_decl_module,
+        UnQualRefinedName = PS ^ ps_uq_refined_id,
+        QualRefinedName = PS ^ ps_q_refined_id,
         array.to_list(CallSiteArray, CallSites),
         ProcDynamicDumpInfo = proc_dynamic_dump_info(PDPtr, PSPtr,
-            RawName, RefinedName, CallSites),
+            RawName, ModuleName, UnQualRefinedName, QualRefinedName,
+            CallSites),
         MaybeProcDynamicDumpInfo = ok(ProcDynamicDumpInfo)
     ;
         MaybeProcDynamicDumpInfo = error("invalid proc_dynamic index")
@@ -1374,13 +1378,18 @@
         deep_lookup_proc_statics(Deep, PSPtr, PS),
         FileName = PS ^ ps_file_name,
         LineNumber = PS ^ ps_line_number,
-        RefinedName = PS ^ ps_refined_id
+        ModuleName = PS ^ ps_decl_module,
+        UnQualRefinedName = PS ^ ps_uq_refined_id,
+        QualRefinedName = PS ^ ps_q_refined_id
     ;
         FileName = "",
         LineNumber = 0,
-        RefinedName = "mercury_runtime"
+        ModuleName = "",
+        UnQualRefinedName = "mercury_runtime",
+        QualRefinedName = "mercury_runtime"
     ),
-    ProcDesc = proc_desc(PSPtr, FileName, LineNumber, RefinedName).
+    ProcDesc = proc_desc(PSPtr, FileName, LineNumber, ModuleName,
+        UnQualRefinedName, QualRefinedName).
 
     % Create a call_site_desc structure for a given call site static pointer.
     %
@@ -1393,7 +1402,9 @@
             GoalPathString),
         deep_lookup_proc_statics(Deep, ContainingPSPtr, ContainingPS),
         FileName = ContainingPS ^ ps_file_name,
-        RefinedName = ContainingPS ^ ps_refined_id,
+        ModuleName = ContainingPS ^ ps_decl_module,
+        UnQualRefinedName = ContainingPS ^ ps_uq_refined_id,
+        QualRefinedName = ContainingPS ^ ps_q_refined_id,
         goal_path_from_string_det(GoalPathString, GoalPath),
         (
             Kind = normal_call_and_callee(CalleePSPtr, _TypeSubst),
@@ -1411,14 +1422,16 @@
         ContainingPSPtr = dummy_proc_static_ptr,
         FileName = "",
         LineNumber = 0,
-        RefinedName = "mercury_runtime",
+        ModuleName = "",
+        UnQualRefinedName = "mercury_runtime",
+        QualRefinedName = "mercury_runtime",
         SlotNumber = -1,
         GoalPath = empty_goal_path,
         MaybeCalleeDesc = no
     ),
     CallSiteDesc = call_site_desc(CSSPtr, ContainingPSPtr,
-        FileName, LineNumber, RefinedName, SlotNumber, GoalPath,
-        MaybeCalleeDesc).
+        FileName, LineNumber, ModuleName, UnQualRefinedName, QualRefinedName,
+        SlotNumber, GoalPath, MaybeCalleeDesc).
 
     % describe_clique(Deep, CliquePtr, MaybeEntryPDPtr) = CliqueDesc
     %
Index: display_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/display_report.m,v
retrieving revision 1.21
diff -u -b -r1.21 display_report.m
--- display_report.m	31 Aug 2009 02:15:12 -0000	1.21
+++ display_report.m	7 Sep 2009 12:41:17 -0000
@@ -217,83 +217,117 @@
 display_report_menu(Deep, Prefs, MenuReport, Display) :-
     MenuReport = menu_report(ProgramName, QuantaPerSec, UserQuanta, InstQuanta,
         NumCallseqs, NumCSD, NumCSS, NumPD, NumPS, NumClique),
+    TotalQuanta = UserQuanta + InstQuanta,
+    TotalTime = ticks_to_time(TotalQuanta, QuantaPerSec),
 
     ShouldDisplayTimes = should_display_times(Deep),
 
     % Display the links section of the report.
-    LinksExploration =
-        [(deep_cmd_root(no) -
+    ActionPrefs0 = Prefs,
+    ActionPrefs1 = ActionPrefs0 ^ pref_inactive :=
+        inactive_items(inactive_hide, inactive_hide, inactive_hide),
+    ActionPrefs = ActionPrefs1 ^ pref_criteria :=
+        by_cost(cost_time, self_and_desc, overall),
+
+    LinksExploration = [
+        link_base(deep_cmd_root(no), yes(ActionPrefs),
             "Exploring the call graph, starting at the root."),
-         (deep_cmd_root(yes(90)) -
+        link_base(deep_cmd_root(yes(90)), yes(ActionPrefs),
             "Exploring the call graph, starting at the action."),
-         (deep_cmd_program_modules -
-            "Exploring the program module by module.")],
+        link_base(deep_cmd_program_modules, no,
+            "Exploring the program module by module.")
+    ],
 
     (
         ShouldDisplayTimes = yes,
-        LinksTopProcsByLimitTime =
-            [(deep_cmd_top_procs(rank_range(1, 100), cost_time, self, overall)
-                - "Top 100 most expensive procedures: time, self."),
-             (deep_cmd_top_procs(rank_range(1, 100), cost_time, self_and_desc,
-                    overall) -
-                "Top 100 most expensive procedures: time, self+descendants.")]
+        Top100SelfCmd = deep_cmd_top_procs(rank_range(1, 100),
+            cost_time, self, overall),
+        Top100SelfAndDescCmd = deep_cmd_top_procs(rank_range(1, 100),
+            cost_time, self_and_desc, overall),
+
+        LinksTopProcsByLimitTime = [
+            link_base(Top100SelfCmd, no,
+                "Top 100 most expensive procedures: time, self."),
+            link_base(Top100SelfAndDescCmd, no,
+                "Top 100 most expensive procedures: time, self+descendants.")
+        ]
     ;
         ShouldDisplayTimes = no,
         LinksTopProcsByLimitTime = []
     ),
 
-    LinksTopProcsByLimit =
-        [(deep_cmd_top_procs(rank_range(1, 100), cost_callseqs, self,
-                overall) -
+    TopLimitCallSeqsSelf = deep_cmd_top_procs(rank_range(1, 100),
+        cost_callseqs, self, overall),
+    TopLimitCallSeqsSelfAndDesc = deep_cmd_top_procs(rank_range(1, 100),
+        cost_callseqs, self_and_desc, overall),
+    TopLimitWordsSelf = deep_cmd_top_procs(rank_range(1, 100),
+        cost_words, self, overall),
+    TopLimitWordsSelfAndDesc = deep_cmd_top_procs(rank_range(1, 100),
+        cost_words, self_and_desc, overall),
+
+    LinksTopProcsByLimit = [
+        link_base(TopLimitCallSeqsSelf, no,
             "Top 100 most expensive procedures: callseqs, self."),
-         (deep_cmd_top_procs(rank_range(1, 100), cost_callseqs, self_and_desc,
-                overall) -
+        link_base(TopLimitCallSeqsSelfAndDesc, no,
             "Top 100 most expensive procedures: callseqs, self+descendants."),
-         (deep_cmd_top_procs(rank_range(1, 100), cost_words, self, overall) -
+        link_base(TopLimitWordsSelf, no,
             "Top 100 most expensive procedures: words, self."),
-         (deep_cmd_top_procs(rank_range(1, 100), cost_words, self_and_desc,
-                overall) -
-            "Top 100 most expensive procedures: words, self+descendants.")],
+        link_base(TopLimitWordsSelfAndDesc, no,
+            "Top 100 most expensive procedures: words, self+descendants.")
+    ],
 
     (
         ShouldDisplayTimes = yes,
-        LinksTopProcsByPercentTime =
-            [(deep_cmd_top_procs(threshold_percent(0.1), cost_time, self,
-                    overall) -
+        TimeAbove01PercentCmd = deep_cmd_top_procs(threshold_percent(0.1),
+            cost_time, self, overall),
+        TimeAbove1PercentCmd = deep_cmd_top_procs(threshold_percent(1.0),
+            cost_time, self, overall),
+        TimeAbove1SecondCmd = deep_cmd_top_procs(threshold_value(100.0),
+            cost_time, self_and_desc, overall),
+
+        LinksTopProcsByPercentTime = [
+            link_base(TimeAbove01PercentCmd, no,
                 "Procedures above 0.1% threshold: time, self."),
-             (deep_cmd_top_procs(threshold_percent(1.0), cost_time,
-                    self_and_desc, overall) -
+            link_base(TimeAbove1PercentCmd, no,
                 "Procedures above 1% threshold: time, self+descendants."),
-             (deep_cmd_top_procs(threshold_value(100.0), cost_time,
-                    self_and_desc, overall) -
-                "Procedures above 1 second threshold: time, self+descendants."
-             )]
+            link_base(TimeAbove1SecondCmd, no,
+                "Procedures above 1 second threshold: time, self+descendants.")
+        ]
     ;
         ShouldDisplayTimes = no,
         LinksTopProcsByPercentTime = []
     ),
 
-    LinksTopProcsByPercent =
-        [(deep_cmd_top_procs(threshold_percent(0.1), cost_callseqs, self,
-                overall) -
+    CallSeqsAbove01PercentCmd = deep_cmd_top_procs(threshold_percent(0.1),
+        cost_callseqs, self, overall),
+    CallSeqsAbove1PercentCmd = deep_cmd_top_procs(threshold_percent(1.0),
+        cost_callseqs, self_and_desc, overall),
+    CallSeqsAboveMillionCmd = deep_cmd_top_procs(threshold_value(1000000.0),
+        cost_callseqs, self_and_desc, overall),
+    WordsAbove01PercentCmd = deep_cmd_top_procs(threshold_percent(0.1),
+        cost_words, self, overall),
+    WordsAbove1PercentCmd = deep_cmd_top_procs(threshold_percent(1.0),
+        cost_words, self_and_desc, overall),
+    % 2M words is 8MB on ia32.
+    WordsAbove2Megawords = deep_cmd_top_procs(
+        threshold_value(float(1024 * 1024 * 2)),
+        cost_words, self_and_desc, overall),
+
+    LinksTopProcsByPercent = [
+        link_base(CallSeqsAbove01PercentCmd, no,
             "Procedures above 0.1% threshold: callseqs, self."),
-         (deep_cmd_top_procs(threshold_percent(1.0), cost_callseqs,
-                self_and_desc, overall) -
+        link_base(CallSeqsAbove1PercentCmd, no,
             "Procedures above 1% threshold: callseqs, self+descendants."),
-         (deep_cmd_top_procs(threshold_value(1000000.0), cost_callseqs,
-                self_and_desc, overall) -
+        link_base(CallSeqsAboveMillionCmd, no,
             ("Procedures above 1,000,000 callseqs threshold: callseqs, " ++
                 "self+descendants.")),
-         (deep_cmd_top_procs(threshold_percent(0.1), cost_words, self,
-                overall) -
+        link_base(WordsAbove01PercentCmd, no,
             "Procedures above 0.1% threshold: words, self."),
-         (deep_cmd_top_procs(threshold_percent(1.0), cost_words,
-                self_and_desc, overall) -
+        link_base(WordsAbove1PercentCmd, no,
             "Procedures above 1% threshold: words, self+descendants."),
-         % 2M words is chosen because it is 8MB on ia32.
-         (deep_cmd_top_procs(threshold_value(float(1024 * 1024 * 2)),
-                cost_words, self_and_desc, overall) -
-            "Procedures above 2M words threshold: words, self+descendants.")],
+        link_base(WordsAbove2Megawords, no,
+            "Procedures above 2M words threshold: words, self+descendants.")
+    ],
 
     LinkCmds = LinksExploration ++
         LinksTopProcsByLimitTime ++ LinksTopProcsByLimit ++
@@ -309,6 +343,8 @@
         ("Quanta per second:"           - td_i(QuantaPerSec)),
         ("Quanta in user code:"         - td_i(UserQuanta)),
         ("Quanta in instrumentation:"   - td_i(InstQuanta)),
+        ("Total quanta:"                - td_i(TotalQuanta)),
+        ("Total time:"                  - td_t(TotalTime)),
         ("Call sequence numbers:"       - td_i(NumCallseqs)),
         ("CallSiteDynamic structures:"  - td_i(NumCSD)),
         ("ProcDynamic structures:"      - td_i(NumPD)),
@@ -378,17 +414,36 @@
     ),
 
     list.reverse(InnerToOuterAncestorCallSites, AncestorCallSites),
-    AncestorDataRows = list.map(clique_ancestor_to_row(Prefs),
+    ModuleQual = Prefs ^ pref_module_qual,
+    CliqueModuleNames = list.map(clique_proc_report_module_name, CliqueProcs0),
+    (
+        CliqueModuleNames = [FirstModuleName | _],
+        list.all_same(CliqueModuleNames)
+    ->
+        MaybeCurModuleName = yes(FirstModuleName)
+    ;
+        MaybeCurModuleName = no
+    ),
+    AncestorDataRows = list.map(
+        clique_ancestor_to_row(MaybeCurModuleName, ModuleQual, Prefs),
         AncestorCallSites),
     AncestorSectionHeaderRow = table_section_header(td_s(AncestorTitle)),
     AncestorRows = [AncestorSectionHeaderRow, table_separator_row] ++
         AncestorDataRows,
 
-    CliqueProcsHeaderRow =
-        table_section_header(td_s("Procedures of the clique:")),
-
-    sort_clique_procs_by_preferences(Prefs, CliqueProcs0, CliqueProcs),
-    ProcRowLists0 = list.map(clique_proc_to_table_rows(Prefs, CliquePtr),
+    list.length(CliqueProcs0, NumCliqueprocs),
+    ( NumCliqueprocs > 1 ->
+        ProcsTitle = "Procedures of the clique:"
+    ;
+        ProcsTitle = "The clique has one procedure:"
+    ),
+    CliqueProcsHeaderRow = table_section_header(td_s(ProcsTitle)),
+
+    sort_clique_procs_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        CliqueProcs0, CliqueProcs),
+    ProcRowLists0 = list.map(
+        clique_proc_to_table_rows(MaybeCurModuleName, ModuleQual, Prefs,
+            CliquePtr),
         CliqueProcs),
     ProcRowLists = list.map(add_front_separator_row, ProcRowLists0),
     list.condense(ProcRowLists, ProcRows),
@@ -400,6 +455,8 @@
 
     % Build controls at the bottom of the page.
     AncestorControls = ancestor_controls(Prefs, Cmd),
+    InactiveCallSiteControls = inactive_call_site_controls(Prefs, Cmd),
+    ModuleQualControls = module_qual_controls(Prefs, Cmd),
     FieldControls = field_controls(Prefs, Cmd),
     FormatControls = format_controls(Prefs, Cmd),
     MenuRestartQuitControls = cmds_menu_restart_quit(yes(Prefs)),
@@ -407,45 +464,58 @@
     Display = display(yes(Title),
         [DisplayTable,
         display_paragraph_break, AncestorControls,
+        display_paragraph_break, InactiveCallSiteControls,
+        display_paragraph_break, ModuleQualControls,
         display_paragraph_break, FieldControls,
         display_paragraph_break, FormatControls,
         display_paragraph_break, MenuRestartQuitControls]).
 
+
+:- func clique_proc_report_module_name(clique_proc_report) = string.
+
+clique_proc_report_module_name(CliqueProc) =
+    CliqueProc ^ cpr_proc_summary ^ perf_row_subject ^ pdesc_module_name.
+
 :- func add_front_separator_row(list(table_row)) = list(table_row).
 
 add_front_separator_row(Rows) = [table_separator_row | Rows].
 
-:- func clique_ancestor_to_row(preferences, perf_row_data(ancestor_desc))
-    = table_row.
+:- func clique_ancestor_to_row(maybe(string), module_qual, preferences,
+    perf_row_data(ancestor_desc)) = table_row.
 
-clique_ancestor_to_row(Prefs, AncestorRowData) = Row :-
+clique_ancestor_to_row(MaybeCurModuleName, ModuleQual, Prefs, AncestorRowData)
+        = Row :-
     AncestorDesc = AncestorRowData ^ perf_row_subject,
     CallSiteDesc = AncestorDesc ^ ad_call_site_desc,
     SourceCell = call_site_desc_source_cell(CallSiteDesc),
-    CliqueProcCell = call_site_desc_clique_proc_cell(Prefs, AncestorDesc),
+    CliqueProcCell = call_site_desc_clique_proc_cell(MaybeCurModuleName,
+        ModuleQual, Prefs, AncestorDesc),
     Fields = Prefs ^ pref_fields,
     perf_table_row(total_columns_meaningful, Fields, AncestorRowData,
         PerfCells),
     AllCells = [SourceCell, CliqueProcCell] ++ PerfCells,
     Row = table_row(AllCells).
 
-:- func clique_proc_to_table_rows(preferences, clique_ptr, clique_proc_report)
-    = list(table_row).
+:- func clique_proc_to_table_rows(maybe(string), module_qual, preferences,
+    clique_ptr, clique_proc_report) = list(table_row).
 
-clique_proc_to_table_rows(Prefs, CliquePtr, CliqueProcReport) = ProcRows :-
+clique_proc_to_table_rows(MaybeCurModuleName, ModuleQual, Prefs, CliquePtr,
+        CliqueProcReport) = ProcRows :-
     CliqueProcReport = clique_proc_report(SummaryRowData,
         FirstPDReport, LaterPDReports),
     (
         LaterPDReports = [],
-        ProcRows = clique_proc_dynamic_to_table_rows(Prefs, CliquePtr,
-            FirstPDReport)
+        ProcRows = clique_proc_dynamic_to_table_rows(MaybeCurModuleName,
+            ModuleQual, Prefs, CliquePtr, FirstPDReport)
     ;
         LaterPDReports = [_ | _],
         AllPDReports = [FirstPDReport | LaterPDReports],
         sort_clique_proc_dynamics_by_preferences(Prefs, AllPDReports,
             SortedAllPDReports),
         PDProcRowLists =
-            list.map(clique_proc_dynamic_to_table_rows(Prefs, CliquePtr),
+            list.map(
+                clique_proc_dynamic_to_table_rows(MaybeCurModuleName,
+                    ModuleQual, Prefs, CliquePtr),
                 SortedAllPDReports),
         % Do we want separators between the rows of different proc dynamics?
         list.condense(PDProcRowLists, PDProcRows),
@@ -454,39 +524,43 @@
             SummaryPerfCells),
         ProcDesc = SummaryRowData ^ perf_row_subject,
         SourceCell = proc_desc_to_source_cell(ProcDesc),
-        ProcCell = proc_desc_to_prefix_proc_name_cell(Prefs, [attr_bold],
-            ProcDesc, "summary "),
+        ProcCell = proc_desc_to_prefix_proc_name_cell(no,
+            ModuleQual, Prefs, [attr_bold], ProcDesc, "summary "),
         SummaryRowCells = [SourceCell, ProcCell] ++ SummaryPerfCells,
         SummaryRow = table_row(SummaryRowCells),
         ProcRows = [SummaryRow, table_separator_row] ++ PDProcRows
     ).
 
-:- func clique_proc_dynamic_to_table_rows(preferences, clique_ptr,
-    clique_proc_dynamic_report) = list(table_row).
+:- func clique_proc_dynamic_to_table_rows(maybe(string), module_qual,
+    preferences, clique_ptr, clique_proc_dynamic_report) = list(table_row).
 
-clique_proc_dynamic_to_table_rows(Prefs, CliquePtr, CliqueProcDynamicReport)
-        = ProcRows :-
+clique_proc_dynamic_to_table_rows(MaybeCurModuleName, ModuleQual,
+        Prefs, CliquePtr, CliqueProcDynamicReport) = ProcRows :-
     CliqueProcDynamicReport = clique_proc_dynamic_report(SummaryRowData,
         CallSiteReports0),
     ProcDesc = SummaryRowData ^ perf_row_subject,
-    ProcCell = proc_desc_to_proc_name_cell_span(Prefs, [attr_bold],
-        ProcDesc, 2),
+    ProcCell = proc_desc_to_proc_name_cell_span(no, ModuleQual, Prefs,
+        [attr_bold], ProcDesc, 2),
     Fields = Prefs ^ pref_fields,
     perf_table_row(total_columns_meaningful, Fields, SummaryRowData,
         SummaryPerfCells),
     SummaryRowCells = [ProcCell] ++ SummaryPerfCells,
     SummaryRow = table_row(SummaryRowCells),
-    sort_clique_call_site_reports_by_preferences(Prefs,
-        CallSiteReports0, CallSiteReports),
+    sort_clique_call_site_reports_by_preferences(MaybeCurModuleName,
+        ModuleQual, Prefs, CallSiteReports0, CallSiteReports),
     CallSiteRowLists =
-        list.map(clique_call_site_to_rows(Prefs, CliquePtr), CallSiteReports),
+        list.map(
+            clique_call_site_to_rows(MaybeCurModuleName, ModuleQual, Prefs,
+                CliquePtr),
+        CallSiteReports),
     list.condense(CallSiteRowLists, CallSiteRows),
     ProcRows = [SummaryRow, table_separator_row] ++ CallSiteRows.
 
-:- func clique_call_site_to_rows(preferences, clique_ptr,
-    clique_call_site_report) = list(table_row).
+:- func clique_call_site_to_rows(maybe(string), module_qual, preferences,
+    clique_ptr, clique_call_site_report) = list(table_row).
 
-clique_call_site_to_rows(Prefs, CliquePtr, CallSiteReport) = Rows :-
+clique_call_site_to_rows(MaybeCurModuleName, ModuleQual, Prefs,
+        CliquePtr, CallSiteReport) = Rows :-
     CallSiteReport = clique_call_site_report(CallSiteRowData, Kind,
         CalleePerfs),
     CallSiteDesc = CallSiteRowData ^ perf_row_subject,
@@ -498,15 +572,25 @@
         Kind = normal_call_and_callee(CalleeProcDesc, _TypeSubst),
         (
             CalleePerfs = [],
-            CalleeProcCell = proc_desc_to_prefix_proc_name_cell(Prefs,
+            Inactive = Prefs ^ pref_inactive,
+            Inactive = inactive_items(InactiveCallSites, _, _),
+            (
+                InactiveCallSites = inactive_show,
+                CalleeProcCell = proc_desc_to_prefix_proc_name_cell(
+                    MaybeCurModuleName, ModuleQual, Prefs,
                 [], CalleeProcDesc, "no calls made to "),
             RowCells = [SourceCell, CalleeProcCell] ++ SummaryPerfCells,
             Row = table_row(RowCells),
             Rows = [Row]
         ;
+                InactiveCallSites = inactive_hide,
+                Rows = []
+            )
+        ;
             CalleePerfs = [CalleePerf],
             CalleeCliqueDesc = CalleePerf ^ perf_row_subject,
-            CalleeProcCell = clique_desc_to_non_self_link_proc_name_cell(Prefs,
+            CalleeProcCell = clique_desc_to_non_self_link_proc_name_cell(
+                MaybeCurModuleName, ModuleQual, Prefs,
                 CalleeCliqueDesc, CliquePtr),
             RowCells = [SourceCell, CalleeProcCell] ++ SummaryPerfCells,
             Row = table_row(RowCells),
@@ -541,26 +625,29 @@
         SummaryRow = table_row(SummaryRowCells),
         Summarize = Prefs ^ pref_summarize,
         (
-            Summarize = summarize,
+            Summarize = summarize_ho_call_sites,
             Rows = [SummaryRow]
         ;
-            Summarize = do_not_summarize,
+            Summarize = do_not_summarize_ho_call_sites,
             sort_clique_rows_by_preferences(Prefs, CalleePerfs,
                 SortedCalleePerfs),
             CalleeRows =
-                list.map(clique_call_site_callee_to_row(Prefs, CliquePtr),
+                list.map(
+                    clique_call_site_callee_to_row(MaybeCurModuleName,
+                        ModuleQual, Prefs, CliquePtr),
                     SortedCalleePerfs),
             Rows = [SummaryRow] ++ CalleeRows
         )
     ).
 
-:- func clique_call_site_callee_to_row(preferences, clique_ptr,
-    perf_row_data(clique_desc)) = table_row.
+:- func clique_call_site_callee_to_row(maybe(string), module_qual,
+    preferences, clique_ptr, perf_row_data(clique_desc)) = table_row.
 
-clique_call_site_callee_to_row(Prefs, CliquePtr, CalleeRowData) = Row :-
+clique_call_site_callee_to_row(MaybeCurModuleName, ModuleQual, Prefs,
+        CliquePtr, CalleeRowData) = Row :-
     CalleeCliqueDesc = CalleeRowData ^ perf_row_subject,
-    CalleeProcCell = clique_desc_to_non_self_link_proc_name_cell(Prefs,
-        CalleeCliqueDesc, CliquePtr),
+    CalleeProcCell = clique_desc_to_non_self_link_proc_name_cell(
+        MaybeCurModuleName, ModuleQual, Prefs, CalleeCliqueDesc, CliquePtr),
     Fields = Prefs ^ pref_fields,
     perf_table_row(total_columns_meaningful, Fields, CalleeRowData, PerfCells),
     EmptyCell = table_cell(td_s("")),
@@ -671,7 +758,10 @@
         list.filter(active_proc, ProcRowDatas0, ProcRowDatas1)
     ),
 
-    sort_proc_active_rows_by_preferences(Prefs, ProcRowDatas1, ProcRowDatas),
+    MaybeCurModuleName = yes(ModuleName),
+    ModuleQual = Prefs ^ pref_module_qual,
+    sort_proc_active_rows_by_preferences(MaybeCurModuleName, ModuleQual,
+        Prefs, ProcRowDatas1, ProcRowDatas),
 
     % Build the table of all modules.
     SortByNamePrefs = Prefs ^ pref_criteria := by_name,
@@ -692,7 +782,8 @@
 
     list.map_foldl(
         maybe_ranked_subject_perf_table_row(Prefs, ranked,
-            total_columns_meaningful, proc_active_to_proc_name_cell),
+            total_columns_meaningful,
+            proc_active_to_proc_name_cell(MaybeCurModuleName, ModuleQual)),
         ProcRowDatas, Rows, 1, _),
     Table = table(table_class_box_if_pref, NumColumns, yes(Header), Rows),
     DisplayTable = display_table(Table),
@@ -788,18 +879,20 @@
     pair(field_name, gs_field_info)::in, list(table_row)::out,
     int::in, int::out) is det.
 
-display_field_getter_setters(Prefs, _ModuleName, FieldName - FieldInfo, Rows,
+display_field_getter_setters(Prefs, ModuleName, FieldName - FieldInfo, Rows,
         !Rank):-
     Fields = Prefs ^ pref_fields,
     FieldName = field_name(Name),
     RankCell = table_cell(td_i(!.Rank)),
+    MaybeCurModuleName = yes(ModuleName),
+    ModuleQual = Prefs ^ pref_module_qual,
     (
         FieldInfo = gs_field_getter(GetterRowData),
         perf_table_row(total_columns_meaningful, Fields, GetterRowData,
             GetterPerfCells),
         GetterProcDesc = GetterRowData ^ perf_row_subject,
-        GetterFieldNameCell = proc_desc_to_proc_name_cell(Prefs,
-            GetterProcDesc),
+        GetterFieldNameCell = proc_desc_to_proc_name_cell(MaybeCurModuleName,
+            ModuleQual, Prefs, GetterProcDesc),
         GetterRow =
             table_row([RankCell, GetterFieldNameCell | GetterPerfCells]),
         Rows = [table_separator_row, GetterRow]
@@ -808,8 +901,8 @@
         perf_table_row(total_columns_meaningful, Fields, SetterRowData,
             SetterPerfCells),
         SetterProcDesc = SetterRowData ^ perf_row_subject,
-        SetterFieldNameCell = proc_desc_to_proc_name_cell(Prefs,
-            SetterProcDesc),
+        SetterFieldNameCell = proc_desc_to_proc_name_cell(MaybeCurModuleName,
+            ModuleQual, Prefs, SetterProcDesc),
         SetterRow =
             table_row([RankCell, SetterFieldNameCell | SetterPerfCells]),
         Rows = [table_separator_row, SetterRow]
@@ -826,16 +919,16 @@
         perf_table_row(total_columns_meaningful, Fields, GetterRowData,
             GetterPerfCells),
         GetterProcDesc = GetterRowData ^ perf_row_subject,
-        GetterFieldNameCell = proc_desc_to_proc_name_cell(Prefs,
-            GetterProcDesc),
+        GetterFieldNameCell = proc_desc_to_proc_name_cell(MaybeCurModuleName,
+            ModuleQual, Prefs, GetterProcDesc),
         GetterRow =
             table_row([EmptyCell, GetterFieldNameCell | GetterPerfCells]),
 
         perf_table_row(total_columns_meaningful, Fields, SetterRowData,
             SetterPerfCells),
         SetterProcDesc = SetterRowData ^ perf_row_subject,
-        SetterFieldNameCell = proc_desc_to_proc_name_cell(Prefs,
-            SetterProcDesc),
+        SetterFieldNameCell = proc_desc_to_proc_name_cell(MaybeCurModuleName,
+            ModuleQual, Prefs, SetterProcDesc),
         SetterRow =
             table_row([EmptyCell, SetterFieldNameCell | SetterPerfCells]),
 
@@ -864,9 +957,11 @@
         CostKind, InclDesc, Scope),
     maybe_ranked_proc_table_header(Prefs, ranked, MakeHeaderData,
         NumColumns, Header),
+    ModuleQual = Prefs ^ pref_module_qual,
     list.map_foldl(
         maybe_ranked_subject_perf_table_row(Prefs, ranked,
-            total_columns_meaningful, proc_desc_to_proc_name_cell),
+            total_columns_meaningful,
+            proc_desc_to_proc_name_cell(no, ModuleQual)),
         TopProcs, Rows, 1, _),
     Table = table(table_class_box_if_pref, NumColumns, yes(Header), Rows),
     DisplayTable = display_table(Table),
@@ -936,7 +1031,7 @@
 display_report_proc(Prefs, ProcReport, Display) :-
     ProcReport = proc_report(ProcSummaryRowData, CallSitePerfs0),
     ProcDesc = ProcSummaryRowData ^ perf_row_subject,
-    RefinedName = ProcDesc ^ pdesc_refined_name,
+    RefinedName = ProcDesc ^ pdesc_q_refined_name,
     Title = "Summary of procedure " ++ RefinedName,
 
     PSPtr = ProcDesc ^ pdesc_ps_ptr,
@@ -975,8 +1070,13 @@
     SummaryCells = [SummaryProcCell] ++ SummaryPerfCells,
     SummaryRow = table_row(SummaryCells),
 
-    sort_call_sites_by_preferences(Prefs, CallSitePerfs0, CallSitePerfs),
-    CallSiteRowLists = list.map(report_proc_call_site(Prefs), CallSitePerfs),
+    MaybeCurModuleName = yes(ProcDesc ^ pdesc_module_name),
+    ModuleQual = Prefs ^ pref_module_qual,
+    sort_call_sites_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        CallSitePerfs0, CallSitePerfs),
+    CallSiteRowLists = list.map(
+        report_proc_call_site(MaybeCurModuleName, ModuleQual, Prefs),
+        CallSitePerfs),
     list.condense(CallSiteRowLists, CallSiteRows),
     AllRows = [SummaryRow, table_separator_row] ++ CallSiteRows,
     Table = table(table_class_box_if_pref, NumColumns, yes(Header), AllRows),
@@ -986,6 +1086,8 @@
     ProcCallersControls = proc_callers_group_controls(Prefs, Cmd,
         PSPtr, group_by_call_site, Prefs ^ pref_contour),
     SummarizeControls = summarize_controls(Prefs, Cmd),
+    InactiveCallSitesControls = inactive_call_site_controls(Prefs, Cmd),
+    ModuleQualControls = module_qual_controls(Prefs, Cmd),
     SortControls = sort_controls(Prefs, Cmd),
     FieldControls = field_controls(Prefs, Cmd),
     FormatControls = format_controls(Prefs, Cmd),
@@ -996,15 +1098,19 @@
         [DisplayTable,
         display_paragraph_break, ProcCallersControls,
         display_paragraph_break, SummarizeControls,
+        display_paragraph_break, InactiveCallSitesControls,
+        display_paragraph_break, ModuleQualControls,
         display_paragraph_break, SortControls,
         display_paragraph_break, FieldControls,
         display_paragraph_break, FormatControls,
         display_paragraph_break, ProcReportControls,
         display_paragraph_break, MenuRestartQuitControls]).
 
-:- func report_proc_call_site(preferences, call_site_perf) = list(table_row).
+:- func report_proc_call_site(maybe(string), module_qual, preferences,
+    call_site_perf) = list(table_row).
 
-report_proc_call_site(Prefs, CallSitePerf) = Rows :-
+report_proc_call_site(MaybeCurModuleName, ModuleQual, Prefs, CallSitePerf)
+        = Rows :-
     CallSitePerf =
         call_site_perf(KindAndCallee, SummaryPerfRowData, SubPerfs0),
 
@@ -1014,7 +1120,8 @@
     (
         KindAndCallee = normal_call_and_info(NormalCalleeId),
         NormalCalleeId = normal_callee_id(CalleeDesc, TypeSubstStr),
-        CalleeRefinedName = CalleeDesc ^ pdesc_refined_name,
+        CalleeRefinedName = proc_desc_get_refined_id(MaybeCurModuleName,
+            ModuleQual, CalleeDesc),
         ( TypeSubstStr = "" ->
             CallSiteStr = CalleeRefinedName
         ;
@@ -1054,23 +1161,29 @@
 
     Summarize = Prefs ^ pref_summarize,
     (
-        Summarize = summarize,
+        Summarize = summarize_ho_call_sites,
         Rows = [SummaryRow]
     ;
-        Summarize = do_not_summarize,
-        sort_proc_desc_rows_by_preferences(Prefs, SubPerfs0, SubPerfs),
-        SubRows = list.map(report_proc_call_site_callee(Prefs), SubPerfs),
+        Summarize = do_not_summarize_ho_call_sites,
+        sort_proc_desc_rows_by_preferences(MaybeCurModuleName, ModuleQual,
+            Prefs, SubPerfs0, SubPerfs),
+        SubRows = list.map(
+            report_proc_call_site_callee(MaybeCurModuleName, ModuleQual,
+                Prefs),
+            SubPerfs),
         Rows = [SummaryRow] ++ SubRows
     ).
 
-:- func report_proc_call_site_callee(preferences, perf_row_data(proc_desc))
-    = table_row.
+:- func report_proc_call_site_callee(maybe(string), module_qual,
+    preferences, perf_row_data(proc_desc)) = table_row.
 
-report_proc_call_site_callee(Prefs, RowData) = Row :-
+report_proc_call_site_callee(MaybeCurModuleName, ModuleQual,
+        Prefs, RowData) = Row :-
     Fields = Prefs ^ pref_fields,
     EmptyCell = table_empty_cell,
     ProcDesc = RowData ^ perf_row_subject,
-    ProcCell = proc_desc_to_proc_name_cell(Prefs, ProcDesc),
+    ProcCell = proc_desc_to_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, ProcDesc),
     perf_table_row(total_columns_meaningful, Fields, RowData, PerfCells),
     Cells = [EmptyCell, ProcCell] ++ PerfCells,
     Row = table_row(Cells).
@@ -1088,7 +1201,10 @@
 display_report_proc_callers(Prefs0, ProcCallersReport, Display) :-
     ProcCallersReport = proc_callers_report(ProcDesc, CallerRowDatas,
         BunchNum, ContourExcl, _ContourErrorMessages),
-    RefinedName = ProcDesc ^ pdesc_refined_name,
+    RefinedName = ProcDesc ^ pdesc_q_refined_name,
+
+    MaybeCurModuleName = yes(ProcDesc ^ pdesc_module_name),
+    ModuleQual = Prefs ^ pref_module_qual,
 
     % Remember the selected value of contour exclusion.
     Prefs = Prefs0 ^ pref_contour := ContourExcl,
@@ -1101,12 +1217,13 @@
         Cmd = deep_cmd_proc_callers(PSPtr, CallerGroups, BunchNum,
             ContourExcl),
         Title = "The call sites calling " ++ RefinedName,
-        sort_call_site_desc_rows_by_preferences(Prefs, CallSiteRowDatas,
-            SortedCallSiteRowDatas),
+        sort_call_site_desc_rows_by_preferences(MaybeCurModuleName, ModuleQual,
+            Prefs, CallSiteRowDatas, SortedCallSiteRowDatas),
         select_displayed_rows(SortedCallSiteRowDatas, BunchNum,
             DisplayedCallSiteRowDatas, TotalNumRows, FirstRowNum, LastRowNum,
             DisplayedBunchNum, MaybeFirstAndLastBunchNum),
-        list.map_foldl(display_caller_call_site(Prefs),
+        list.map_foldl(
+            display_caller_call_site(MaybeCurModuleName, ModuleQual, Prefs),
             DisplayedCallSiteRowDatas, Rows, FirstRowNum, AfterLastRowNum),
 
         SortByContextPrefs = Prefs ^ pref_criteria := by_context,
@@ -1127,12 +1244,13 @@
         Cmd = deep_cmd_proc_callers(PSPtr, CallerGroups, BunchNum,
             ContourExcl),
         Title = "The procedures calling " ++ RefinedName,
-        sort_proc_desc_rows_by_preferences(Prefs, ProcRowDatas,
-            SortedProcRowDatas),
+        sort_proc_desc_rows_by_preferences(MaybeCurModuleName, ModuleQual,
+            Prefs, ProcRowDatas, SortedProcRowDatas),
         select_displayed_rows(SortedProcRowDatas, BunchNum,
             DisplayedProcRowDatas, TotalNumRows, FirstRowNum, LastRowNum,
             DisplayedBunchNum, MaybeFirstAndLastBunchNum),
-        list.map_foldl(display_caller_proc(Prefs),
+        list.map_foldl(
+            display_caller_proc(MaybeCurModuleName, ModuleQual, Prefs),
             DisplayedProcRowDatas, Rows, FirstRowNum, AfterLastRowNum),
 
         SortByContextPrefs = Prefs ^ pref_criteria := by_context,
@@ -1179,7 +1297,8 @@
         select_displayed_rows(SortedCliqueRowDatas, BunchNum,
             DisplayedCliqueRowDatas, TotalNumRows, FirstRowNum, LastRowNum,
             DisplayedBunchNum, MaybeFirstAndLastBunchNum),
-        list.map_foldl(display_caller_clique(Prefs),
+        list.map_foldl(
+            display_caller_clique(MaybeCurModuleName, ModuleQual, Prefs),
             DisplayedCliqueRowDatas, Rows, FirstRowNum, AfterLastRowNum),
 
         SortByNamePrefs = Prefs ^ pref_criteria := by_name,
@@ -1319,17 +1438,19 @@
 
 bunch_size = 5.
 
-:- pred display_caller_call_site(preferences::in,
-    perf_row_data(call_site_desc)::in, table_row::out, int::in, int::out)
-    is det.
+:- pred display_caller_call_site(maybe(string)::in, module_qual::in,
+    preferences::in, perf_row_data(call_site_desc)::in, table_row::out,
+    int::in, int::out) is det.
 
-display_caller_call_site(Prefs, CallSiteRowData, Row, !RowNum) :-
+display_caller_call_site(MaybeCurModuleName, ModuleQual, Prefs,
+        CallSiteRowData, Row, !RowNum) :-
     RankCell = table_cell(td_i(!.RowNum)),
     !:RowNum = !.RowNum + 1,
 
     CallSiteDesc = CallSiteRowData ^ perf_row_subject,
     SourceCell = call_site_desc_to_source_cell(CallSiteDesc),
-    ProcCell = call_site_desc_to_caller_proc_name_cell(Prefs, CallSiteDesc),
+    ProcCell = call_site_desc_to_caller_proc_name_cell(MaybeCurModuleName,
+        ModuleQual, Prefs, CallSiteDesc),
 
     Fields = Prefs ^ pref_fields,
     perf_table_row(total_columns_meaningful, Fields, CallSiteRowData,
@@ -1337,16 +1458,19 @@
     Cells = [RankCell, SourceCell, ProcCell] ++ PerfCells,
     Row = table_row(Cells).
 
-:- pred display_caller_proc(preferences::in, perf_row_data(proc_desc)::in,
-    table_row::out, int::in, int::out) is det.
+:- pred display_caller_proc(maybe(string)::in, module_qual::in,
+    preferences::in, perf_row_data(proc_desc)::in, table_row::out,
+    int::in, int::out) is det.
 
-display_caller_proc(Prefs, ProcRowData, Row, !RowNum) :-
+display_caller_proc(MaybeCurModuleName, ModuleQual, Prefs, ProcRowData, Row,
+        !RowNum) :-
     RankCell = table_cell(td_i(!.RowNum)),
     !:RowNum = !.RowNum + 1,
 
     ProcDesc = ProcRowData ^ perf_row_subject,
     SourceCell = proc_desc_to_source_cell(ProcDesc),
-    ProcCell = proc_desc_to_proc_name_cell(Prefs, ProcDesc),
+    ProcCell = proc_desc_to_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, ProcDesc),
 
     Fields = Prefs ^ pref_fields,
     perf_table_row(total_columns_meaningful, Fields, ProcRowData, PerfCells),
@@ -1368,10 +1492,12 @@
     Cells = [RankCell, ModuleCell] ++ PerfCells,
     Row = table_row(Cells).
 
-:- pred display_caller_clique(preferences::in, perf_row_data(clique_desc)::in,
-    table_row::out, int::in, int::out) is det.
+:- pred display_caller_clique(maybe(string)::in, module_qual::in,
+    preferences::in, perf_row_data(clique_desc)::in, table_row::out,
+    int::in, int::out) is det.
 
-display_caller_clique(Prefs, CliqueRowData, Row, !RowNum) :-
+display_caller_clique(MaybeCurModuleName, ModuleQual, Prefs,
+        CliqueRowData, Row, !RowNum) :-
     RankCell = table_cell(td_i(!.RowNum)),
     !:RowNum = !.RowNum + 1,
 
@@ -1385,7 +1511,8 @@
         link_class_link),
     CliqueCell = table_cell(td_l(CliqueLink)),
 
-    MembersStrs = list.map(project_proc_desc_refined_name,
+    MembersStrs = list.map(
+        proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual),
         [EntryProcDesc | OtherProcDescs]),
     MembersStr = string.join_list(", ", MembersStrs),
     MembersCell = table_cell(td_s(MembersStr)),
@@ -1395,10 +1522,6 @@
     Cells = [RankCell, CliqueCell, MembersCell] ++ PerfCells,
     Row = table_row(Cells).
 
-:- func project_proc_desc_refined_name(proc_desc) = string.
-
-project_proc_desc_refined_name(ProcDesc) = ProcDesc ^ pdesc_refined_name.
-
 :- func make_proc_callers_link(preferences, string, proc_static_ptr,
     caller_groups, int, contour_exclusion) = display_item.
 
@@ -1459,7 +1582,6 @@
         String = string.format(" _ - %d", [i(After)])
     ).
 
-
 %-----------------------------------------------------------------------------%
 %
 % Code to display proc_static and proc_dynamic dumps.
@@ -1471,14 +1593,16 @@
     display::out) is det.
 
 display_report_proc_static_dump(ProcStaticDumpInfo, Display) :-
-    ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName, RefinedName,
-        FileName, LineNumber, NumCallSites, NumCoveragePoints),
+    ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName,
+        UnQualRefinedName, QualRefinedName, FileName, LineNumber,
+        NumCallSites, NumCoveragePoints),
     PSPtr = proc_static_ptr(PSI),
     string.format("Dump of proc_static %d", [i(PSI)], Title),
 
     Values =
         [("Raw name:"                   - td_s(RawName)),
-        ("Refined name:"                - td_s(RefinedName)),
+        ("Unqualified refined name:"    - td_s(UnQualRefinedName)),
+        ("Qualified refined name:"      - td_s(QualRefinedName)),
         ("File name:"                   - td_s(FileName)),
         ("Line number:"                 - td_i(LineNumber)),
         ("Number of call sites:"        - td_i(NumCallSites)),
@@ -1494,8 +1618,8 @@
     proc_dynamic_dump_info::in, display::out) is det.
 
 display_report_proc_dynamic_dump(_Deep, Prefs, ProcDynamicDumpInfo, Display) :-
-    ProcDynamicDumpInfo = proc_dynamic_dump_info(PDPtr, PSPtr,
-        RawName, RefinedName, CallSites),
+    ProcDynamicDumpInfo = proc_dynamic_dump_info(PDPtr, PSPtr, RawName,
+        ModuleName, UnQualRefinedName, QualRefinedName, CallSites),
     PDPtr = proc_dynamic_ptr(PDI),
     PSPtr = proc_static_ptr(PSI),
     string.format("Dump of proc_dynamic %d", [i(PDI)], Title),
@@ -1505,7 +1629,9 @@
     MainValues =
         [("Proc static:"            - td_l(ProcStaticLink)),
         ("Raw name:"                - td_s(RawName)),
-        ("Refined name:"            - td_s(RefinedName))],
+        ("Module name:"                 - td_s(ModuleName)),
+        ("Unqualified refined name:"    - td_s(UnQualRefinedName)),
+        ("Qualified refined name:"      - td_s(QualRefinedName))],
 
     MainRows = list.map(make_labelled_table_row, MainValues),
     MainTable = table(table_class_do_not_box, 2, no, MainRows),
@@ -1656,7 +1782,8 @@
     maybe_ranked_proc_table_header(Prefs, non_ranked, MakeHeaderData,
         NumColumns, Header),
     maybe_ranked_subject_perf_table_row(Prefs, non_ranked,
-        total_columns_meaningful, call_site_desc_to_name_path_slot_cell,
+        total_columns_meaningful,
+        call_site_desc_to_name_path_slot_cell(no, module_qual_always),
         RowData, PerfRow, 1, _),
     PerfTable = table(table_class_box, NumColumns, yes(Header), [PerfRow]),
 
@@ -2617,13 +2744,16 @@
     Context = string.format("%s:%d", [s(FileName), i(LineNumber)]),
     Cell = table_cell(td_s(Context)).
 
-:- func call_site_desc_clique_proc_cell(preferences, ancestor_desc)
-    = table_cell.
+:- func call_site_desc_clique_proc_cell(maybe(string), module_qual,
+    preferences, ancestor_desc) = table_cell.
 
-call_site_desc_clique_proc_cell(Prefs, AncestorDesc) = Cell :-
+call_site_desc_clique_proc_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, AncestorDesc) = Cell :-
     AncestorDesc = ancestor_desc(CallerCliquePtr, _CalleeCliquePtr,
         _CalleeProcDesc, CallSiteDesc),
-    ContainingProcName = CallSiteDesc ^ csdesc_caller_refined_name,
+    ContainingProcName =
+        call_site_desc_get_caller_refined_id(MaybeCurModuleName, ModuleQual,
+            CallSiteDesc),
     Cmd = deep_cmd_clique(CallerCliquePtr),
     Link = deep_link(Cmd, yes(Prefs), attr_str([], ContainingProcName),
         link_class_link),
@@ -3069,12 +3199,12 @@
 
 summarize_toggles = [
     "Do not summarize higher order calls" -
-        set_summarize(do_not_summarize),
+        set_summarize(do_not_summarize_ho_call_sites),
     "Summarize higher order calls" -
-        set_summarize(summarize)
+        set_summarize(summarize_ho_call_sites)
 ].
 
-:- pred set_summarize(summarize::in,
+:- pred set_summarize(summarize_ho_call_sites::in,
     preferences::in, preferences::out) is det.
 
 set_summarize(Summarize, !Prefs) :-
@@ -3082,6 +3212,38 @@
 
 %-----------------------------------------------------------------------------%
 %
+% Control whether we display call sites that do not get any calls.
+%
+
+:- func module_qual_controls(preferences, cmd) = display_item.
+
+module_qual_controls(Prefs, Cmd) = ControlsItem :-
+    make_prefs_controls_item(Prefs, Cmd, no,
+        module_qual_toggles, ShowNoCallSitesControls),
+    ControlsItem = display_list(list_class_vertical_no_bullets,
+        yes("Toggle show no calls site options:"), [ShowNoCallSitesControls]).
+
+:- func module_qual_toggles =
+    (assoc_list(string, (pred(preferences, preferences)))::
+    out(list_skel(pair(ground, (pred(in, out) is det))))) is det.
+
+module_qual_toggles = [
+    "Never module qualify predicate and function names" -
+        set_module_qual(module_qual_never),
+    "Module qualify predicate and function names only when needed" -
+        set_module_qual(module_qual_when_diff),
+    "Always module qualify predicate and function names" -
+        set_module_qual(module_qual_always)
+].
+
+:- pred set_module_qual(module_qual::in,
+    preferences::in, preferences::out) is det.
+
+set_module_qual(ModuleQual, !Prefs) :-
+    !Prefs ^ pref_module_qual := ModuleQual.
+
+%-----------------------------------------------------------------------------%
+%
 % Control how pages are displayed.
 %
 
@@ -3217,6 +3379,37 @@
 
 %-----------------------------------------------------------------------------%
 %
+% Control whether we display inactive call sites.
+%
+
+:- func inactive_call_site_controls(preferences, cmd) = display_item.
+
+inactive_call_site_controls(Prefs, Cmd) = ControlsItem :-
+    make_prefs_controls_item(Prefs, Cmd, no,
+        inactive_call_site_toggles, InactiveModuleControls),
+    Controls = [InactiveModuleControls],
+    ControlsItem = display_list(list_class_vertical_no_bullets,
+        yes("Toggle display of inactive call_sites:"), Controls).
+
+:- func inactive_call_site_toggles =
+    (assoc_list(string, (pred(preferences, preferences)))::
+    out(list_skel(pair(ground, (pred(in, out) is det))))) is det.
+
+inactive_call_site_toggles = [
+    "Do not display inactive call sites" -
+        set_inactive_call_sites(inactive_hide),
+    "Display inactive call sites" -
+        set_inactive_call_sites(inactive_show)
+].
+
+:- pred set_inactive_call_sites(inactive_status::in,
+    preferences::in, preferences::out) is det.
+
+set_inactive_call_sites(Status, !Prefs) :-
+    !Prefs ^ pref_inactive ^ inactive_call_sites := Status.
+
+%-----------------------------------------------------------------------------%
+%
 % Control how many ancestors we display.
 %
 
@@ -3450,10 +3643,13 @@
         link_class_link),
     Cell = table_cell(td_l(Link)).
 
-:- func proc_active_to_proc_name_cell(preferences, proc_active) = table_cell.
+:- func proc_active_to_proc_name_cell(maybe(string), module_qual,
+    preferences, proc_active) = table_cell.
 
-proc_active_to_proc_name_cell(Prefs, ProcActive) =
-    proc_desc_to_proc_name_cell(Prefs, ProcActive ^ pa_proc_desc).
+proc_active_to_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, ProcActive) =
+    proc_desc_to_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, ProcActive ^ pa_proc_desc).
 
 :- func proc_desc_to_source_cell(proc_desc) = table_cell.
 
@@ -3463,45 +3659,56 @@
     Source = string.format("%s:%d", [s(FileName), i(LineNumber)]),
     Cell = table_cell(td_s(Source)).
 
-:- func proc_desc_to_proc_name_cell(preferences, proc_desc) = table_cell.
+:- func proc_desc_to_proc_name_cell(maybe(string), module_qual,
+    preferences, proc_desc) = table_cell.
 
-proc_desc_to_proc_name_cell(Prefs, ProcDesc) = Cell :-
+proc_desc_to_proc_name_cell(MaybeCurModuleName, ModuleQual, Prefs, ProcDesc)
+        = Cell :-
     PSPtr = ProcDesc ^ pdesc_ps_ptr,
-    RefinedName = ProcDesc ^ pdesc_refined_name,
+    RefinedName = proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual,
+        ProcDesc),
     Cmd = deep_cmd_proc(PSPtr),
     Link = deep_link(Cmd, yes(Prefs), attr_str([], RefinedName),
         link_class_link),
     Cell = table_cell(td_l(Link)).
 
-:- func proc_desc_to_proc_name_cell_span(preferences, list(str_attr),
-    proc_desc, int) = table_cell.
+:- func proc_desc_to_proc_name_cell_span(maybe(string), module_qual,
+    preferences, list(str_attr), proc_desc, int) = table_cell.
 
-proc_desc_to_proc_name_cell_span(Prefs, Attrs, ProcDesc, Span) = Cell :-
+proc_desc_to_proc_name_cell_span(MaybeCurModuleName, ModuleQual,
+        Prefs, Attrs, ProcDesc, Span) = Cell :-
     PSPtr = ProcDesc ^ pdesc_ps_ptr,
-    RefinedName = ProcDesc ^ pdesc_refined_name,
+    RefinedName = proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual,
+        ProcDesc),
     Cmd = deep_cmd_proc(PSPtr),
     Link = deep_link(Cmd, yes(Prefs), attr_str(Attrs, RefinedName),
         link_class_link),
     Cell = table_multi_cell(td_l(Link), Span).
 
-:- func proc_desc_to_prefix_proc_name_cell(preferences, list(str_attr),
-    proc_desc, string) = table_cell.
+:- func proc_desc_to_prefix_proc_name_cell(maybe(string), module_qual,
+    preferences, list(str_attr), proc_desc, string) = table_cell.
 
-proc_desc_to_prefix_proc_name_cell(Prefs, Attrs, ProcDesc, Prefix) = Cell :-
+proc_desc_to_prefix_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, Attrs, ProcDesc, Prefix) = Cell :-
     PSPtr = ProcDesc ^ pdesc_ps_ptr,
-    RefinedName = ProcDesc ^ pdesc_refined_name,
+    RefinedName = proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual,
+        ProcDesc),
     Cmd = deep_cmd_proc(PSPtr),
     Link = deep_link(Cmd, yes(Prefs), attr_str(Attrs, Prefix ++ RefinedName),
         link_class_link),
     Cell = table_cell(td_l(Link)).
 
-:- func call_site_desc_to_name_path_slot_cell(preferences, call_site_desc)
-    = table_cell.
+:- func call_site_desc_to_name_path_slot_cell(maybe(string), module_qual,
+    preferences, call_site_desc) = table_cell.
 
-call_site_desc_to_name_path_slot_cell(Prefs, CallSiteDesc) = Cell :-
+call_site_desc_to_name_path_slot_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, CallSiteDesc) = Cell :-
     CallSiteDesc = call_site_desc(CSSPtr, _ContainerPSPtr,
-        _FileName, _LineNumber, RefinedName, SlotNumber, GoalPath,
-        _MaybeCallee),
+        _FileName, _LineNumber, _ModuleName,
+        _UnQualRefinedName, _QualRefinedName,
+        SlotNumber, GoalPath, _MaybeCallee),
+    RefinedName = call_site_desc_get_caller_refined_id(MaybeCurModuleName,
+        ModuleQual, CallSiteDesc),
     GoalPathStr = goal_path_to_string(GoalPath),
     string.format("%s @ %s #%d", 
         [s(RefinedName), s(GoalPathStr), i(SlotNumber)], Name),
@@ -3517,24 +3724,28 @@
     Source = string.format("%s:%d", [s(FileName), i(LineNumber)]),
     Cell = table_cell(td_s(Source)).
 
-:- func call_site_desc_to_caller_proc_name_cell(preferences,
-    call_site_desc) = table_cell.
+:- func call_site_desc_to_caller_proc_name_cell(maybe(string), module_qual,
+    preferences, call_site_desc) = table_cell.
 
-call_site_desc_to_caller_proc_name_cell(Prefs, CallSiteDesc) = Cell :-
+call_site_desc_to_caller_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, CallSiteDesc) = Cell :-
     PSPtr = CallSiteDesc ^ csdesc_container,
-    CallerRefinedName = CallSiteDesc ^ csdesc_caller_refined_name,
+    CallerRefinedName =
+    call_site_desc_get_caller_refined_id(MaybeCurModuleName, ModuleQual,
+        CallSiteDesc),
     Cmd = deep_cmd_proc(PSPtr),
     Link = deep_link(Cmd, yes(Prefs), attr_str([], CallerRefinedName),
         link_class_link),
     Cell = table_cell(td_l(Link)).
 
-:- func clique_desc_to_non_self_link_proc_name_cell(preferences,
-    clique_desc, clique_ptr) = table_cell.
+:- func clique_desc_to_non_self_link_proc_name_cell(maybe(string), module_qual,
+    preferences, clique_desc, clique_ptr) = table_cell.
 
-clique_desc_to_non_self_link_proc_name_cell(Prefs, CliqueDesc, SelfCliquePtr)
-        = Cell :-
+clique_desc_to_non_self_link_proc_name_cell(MaybeCurModuleName, ModuleQual,
+        Prefs, CliqueDesc, SelfCliquePtr) = Cell :-
     CliqueDesc = clique_desc(CliquePtr, EntryProcDesc, _OtherProcDescs),
-    EntryProcName = EntryProcDesc ^ pdesc_refined_name,
+    EntryProcName = proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual,
+        EntryProcDesc),
     ( CliquePtr = SelfCliquePtr ->
         Cell = table_cell(td_s(EntryProcName))
     ;
@@ -3556,12 +3767,15 @@
 make_labelled_table_row(Label - Value) =
     table_row([table_cell(td_s(Label)), table_cell(Value)]).
 
-    % Make a link from a command and label.
+:- type link_base
+    --->    link_base(cmd, maybe(preferences), string).
+
+    % Make a link from a command, preferences and a label.
     %
-:- pred make_link(pair(cmd, string)::in, display_item::out) is det.
+:- pred make_link(link_base::in, display_item::out) is det.
 
-make_link(Cmd - Label, Item) :-
-    Item = display_link(deep_link(Cmd, no, attr_str([], Label),
+make_link(link_base(Cmd, MaybePrefs, Label), Item) :-
+    Item = display_link(deep_link(Cmd, MaybePrefs, attr_str([], Label),
         link_class_link)).
 
     % Make a control from a command and label and optional preferences
@@ -3579,17 +3793,21 @@
 % Sort procedures in a clique by the preferred criteria of performance.
 %
 
-:- pred sort_clique_procs_by_preferences(preferences::in,
+:- pred sort_clique_procs_by_preferences(maybe(string)::in, module_qual::in,
+    preferences::in,
     list(clique_proc_report)::in, list(clique_proc_report)::out) is det.
 
-sort_clique_procs_by_preferences(Prefs, !CliqueProcs) :-
+sort_clique_procs_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        !CliqueProcs) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
         list.sort(compare_clique_procs_by_context, !CliqueProcs)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_clique_procs_by_name, !CliqueProcs)
+        list.sort(
+            compare_clique_procs_by_name(MaybeCurModuleName, ModuleQual),
+            !CliqueProcs)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_clique_procs_by_cost(CostKind, InclDesc, Scope),
@@ -3608,14 +3826,16 @@
     CliqueProcDescB = CliqueProcReportB ^ cpr_proc_summary ^ perf_row_subject,
     compare_proc_descs_by_context(CliqueProcDescA, CliqueProcDescB, Result).
 
-:- pred compare_clique_procs_by_name(
+:- pred compare_clique_procs_by_name(maybe(string)::in, module_qual::in,
     clique_proc_report::in, clique_proc_report::in, comparison_result::out)
     is det.
 
-compare_clique_procs_by_name(CliqueProcReportA, CliqueProcReportB, Result) :-
+compare_clique_procs_by_name(MaybeCurModuleName, ModuleQual,
+        CliqueProcReportA, CliqueProcReportB, Result) :-
     CliqueProcDescA = CliqueProcReportA ^ cpr_proc_summary ^ perf_row_subject,
     CliqueProcDescB = CliqueProcReportB ^ cpr_proc_summary ^ perf_row_subject,
-    compare_proc_descs_by_name(CliqueProcDescA, CliqueProcDescB, Result).
+    compare_proc_descs_by_name(MaybeCurModuleName, ModuleQual,
+        CliqueProcDescA, CliqueProcDescB, Result).
 
 :- pred compare_clique_procs_by_cost(
     cost_kind::in, include_descendants::in, measurement_scope::in,
@@ -3675,11 +3895,13 @@
 % Sort clique_call_site_reports by the preferred criteria of performance.
 %
 
-:- pred sort_clique_call_site_reports_by_preferences(preferences::in,
+:- pred sort_clique_call_site_reports_by_preferences(maybe(string)::in,
+    module_qual::in, preferences::in,
     list(clique_call_site_report)::in, list(clique_call_site_report)::out)
     is det.
 
-sort_clique_call_site_reports_by_preferences(Prefs, !CallSiteReports) :-
+sort_clique_call_site_reports_by_preferences(MaybeCurModuleName, ModuleQual,
+        Prefs, !CallSiteReports) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
@@ -3687,7 +3909,10 @@
             !CallSiteReports)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_clique_call_site_reports_by_name, !CallSiteReports)
+        list.sort(
+            compare_clique_call_site_reports_by_name(MaybeCurModuleName,
+                ModuleQual),
+            !CallSiteReports)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_clique_call_site_reports_by_cost(CostKind,
@@ -3708,17 +3933,18 @@
         CallSiteReportB ^ ccsr_call_site_summary ^ perf_row_subject,
     compare_call_site_descs_by_context(CallSiteDescA, CallSiteDescB, Result).
 
-:- pred compare_clique_call_site_reports_by_name(
-    clique_call_site_report::in, clique_call_site_report::in,
+:- pred compare_clique_call_site_reports_by_name(maybe(string)::in,
+    module_qual::in, clique_call_site_report::in, clique_call_site_report::in,
     comparison_result::out) is det.
 
-compare_clique_call_site_reports_by_name(CallSiteReportA, CallSiteReportB,
-        Result) :-
+compare_clique_call_site_reports_by_name(MaybeCurModuleName, ModuleQual,
+        CallSiteReportA, CallSiteReportB, Result) :-
     CallSiteDescA =
         CallSiteReportA ^ ccsr_call_site_summary ^ perf_row_subject,
     CallSiteDescB =
         CallSiteReportB ^ ccsr_call_site_summary ^ perf_row_subject,
-    compare_call_site_descs_by_name(CallSiteDescA, CallSiteDescB, Result).
+    compare_call_site_descs_by_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescA, CallSiteDescB, Result).
 
 :- pred compare_clique_call_site_reports_by_cost(
     cost_kind::in, include_descendants::in, measurement_scope::in,
@@ -3737,17 +3963,22 @@
 % Sort call_site_perfs by the preferred criteria of performance.
 %
 
-:- pred sort_call_sites_by_preferences(preferences::in,
+:- pred sort_call_sites_by_preferences(maybe(string)::in, module_qual::in,
+    preferences::in,
     list(call_site_perf)::in, list(call_site_perf)::out) is det.
 
-sort_call_sites_by_preferences(Prefs, !CallSitePerfs) :-
+sort_call_sites_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        !CallSitePerfs) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
         list.sort(compare_call_site_perfs_by_context, !CallSitePerfs)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_call_site_perfs_by_callee_name, !CallSitePerfs)
+        list.sort(
+            compare_call_site_perfs_by_callee_name(MaybeCurModuleName,
+                ModuleQual),
+            !CallSitePerfs)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_call_site_perfs_by_cost(CostKind, InclDesc, Scope),
@@ -3764,14 +3995,16 @@
     CallSiteDescB = CallSitePerfB ^ csf_summary_perf ^ perf_row_subject,
     compare_call_site_descs_by_context(CallSiteDescA, CallSiteDescB, Result).
 
-:- pred compare_call_site_perfs_by_callee_name(
+:- pred compare_call_site_perfs_by_callee_name(maybe(string)::in,
+    module_qual::in,
     call_site_perf::in, call_site_perf::in, comparison_result::out) is det.
 
-compare_call_site_perfs_by_callee_name(CallSitePerfA, CallSitePerfB, Result) :-
+compare_call_site_perfs_by_callee_name(MaybeCurModuleName, ModuleQual,
+        CallSitePerfA, CallSitePerfB, Result) :-
     CallSiteDescA = CallSitePerfA ^ csf_summary_perf ^ perf_row_subject,
     CallSiteDescB = CallSitePerfB ^ csf_summary_perf ^ perf_row_subject,
-    compare_call_site_descs_by_callee_name(CallSiteDescA, CallSiteDescB,
-        Result).
+    compare_call_site_descs_by_callee_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescA, CallSiteDescB, Result).
 
 :- pred compare_call_site_perfs_by_cost(
     cost_kind::in, include_descendants::in, measurement_scope::in,
@@ -3789,18 +4022,23 @@
 % Sort perf_data_rows of call_site_descs by the preferred criteria.
 %
 
-:- pred sort_call_site_desc_rows_by_preferences(preferences::in,
+:- pred sort_call_site_desc_rows_by_preferences(maybe(string)::in,
+    module_qual::in, preferences::in,
     list(perf_row_data(call_site_desc))::in,
     list(perf_row_data(call_site_desc))::out) is det.
 
-sort_call_site_desc_rows_by_preferences(Prefs, !CallSiteRowDatas) :-
+sort_call_site_desc_rows_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        !CallSiteRowDatas) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
         list.sort(compare_call_site_desc_rows_by_context, !CallSiteRowDatas)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_call_site_desc_rows_by_name, !CallSiteRowDatas)
+        list.sort(
+            compare_call_site_desc_rows_by_name(MaybeCurModuleName,
+                ModuleQual),
+            !CallSiteRowDatas)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_perf_row_datas_by_cost(CostKind, InclDesc, Scope),
@@ -3819,33 +4057,38 @@
     CallSiteDescB = CallSiteDescRowDataB ^ perf_row_subject,
     compare_call_site_descs_by_context(CallSiteDescA, CallSiteDescB, Result).
 
-:- pred compare_call_site_desc_rows_by_name(
+:- pred compare_call_site_desc_rows_by_name(maybe(string)::in, module_qual::in,
     perf_row_data(call_site_desc)::in, perf_row_data(call_site_desc)::in,
     comparison_result::out) is det.
 
-compare_call_site_desc_rows_by_name(CallSiteDescRowDataA, CallSiteDescRowDataB,
-        Result) :-
+compare_call_site_desc_rows_by_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescRowDataA, CallSiteDescRowDataB, Result) :-
     CallSiteDescA = CallSiteDescRowDataA ^ perf_row_subject,
     CallSiteDescB = CallSiteDescRowDataB ^ perf_row_subject,
-    compare_call_site_descs_by_name(CallSiteDescA, CallSiteDescB, Result).
+    compare_call_site_descs_by_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescA, CallSiteDescB, Result).
 
 %-----------------------------------------------------------------------------%
 %
 % Sort perf_data_rows of proc_descs by the preferred criteria.
 %
 
-:- pred sort_proc_desc_rows_by_preferences(preferences::in,
+:- pred sort_proc_desc_rows_by_preferences(maybe(string)::in, module_qual::in,
+    preferences::in,
     list(perf_row_data(proc_desc))::in, list(perf_row_data(proc_desc))::out)
     is det.
 
-sort_proc_desc_rows_by_preferences(Prefs, !ProcDescRowDatas) :-
+sort_proc_desc_rows_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        !ProcDescRowDatas) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
         list.sort(compare_proc_desc_rows_by_context, !ProcDescRowDatas)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_proc_desc_rows_by_name, !ProcDescRowDatas)
+        list.sort(
+            compare_proc_desc_rows_by_name(MaybeCurModuleName, ModuleQual),
+            !ProcDescRowDatas)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_perf_row_datas_by_cost(CostKind, InclDesc, Scope),
@@ -3864,32 +4107,38 @@
     ProcDescB = ProcDescRowDataB ^ perf_row_subject,
     compare_proc_descs_by_context(ProcDescA, ProcDescB, Result).
 
-:- pred compare_proc_desc_rows_by_name(
+:- pred compare_proc_desc_rows_by_name(maybe(string)::in, module_qual::in,
     perf_row_data(proc_desc)::in, perf_row_data(proc_desc)::in,
     comparison_result::out) is det.
 
-compare_proc_desc_rows_by_name(ProcDescRowDataA, ProcDescRowDataB, Result) :-
+compare_proc_desc_rows_by_name(MaybeCurModuleName, ModuleQual,
+        ProcDescRowDataA, ProcDescRowDataB, Result) :-
     ProcDescA = ProcDescRowDataA ^ perf_row_subject,
     ProcDescB = ProcDescRowDataB ^ perf_row_subject,
-    compare_proc_descs_by_name(ProcDescA, ProcDescB, Result).
+    compare_proc_descs_by_name(MaybeCurModuleName, ModuleQual,
+        ProcDescA, ProcDescB, Result).
 
 %-----------------------------------------------------------------------------%
 %
 % Sort perf_data_rows of proc_actives by the preferred criteria.
 %
 
-:- pred sort_proc_active_rows_by_preferences(preferences::in,
+:- pred sort_proc_active_rows_by_preferences(maybe(string)::in,
+    module_qual::in, preferences::in,
     list(perf_row_data(proc_active))::in,
     list(perf_row_data(proc_active))::out) is det.
 
-sort_proc_active_rows_by_preferences(Prefs, !ProcRowDatas) :-
+sort_proc_active_rows_by_preferences(MaybeCurModuleName, ModuleQual, Prefs,
+        !ProcRowDatas) :-
     OrderCriteria = Prefs ^ pref_criteria,
     (
         OrderCriteria = by_context,
         list.sort(compare_proc_active_rows_by_context, !ProcRowDatas)
     ;
         OrderCriteria = by_name,
-        list.sort(compare_proc_active_rows_by_name, !ProcRowDatas)
+        list.sort(
+            compare_proc_active_rows_by_name(MaybeCurModuleName, ModuleQual),
+            !ProcRowDatas)
     ;
         OrderCriteria = by_cost(CostKind, InclDesc, Scope),
         list.sort(compare_perf_row_datas_by_cost(CostKind, InclDesc, Scope),
@@ -3907,14 +4156,16 @@
     ProcDescB = ProcRowDataB ^ perf_row_subject ^ pa_proc_desc,
     compare_proc_descs_by_context(ProcDescA, ProcDescB, Result).
 
-:- pred compare_proc_active_rows_by_name(
+:- pred compare_proc_active_rows_by_name(maybe(string)::in, module_qual::in,
     perf_row_data(proc_active)::in, perf_row_data(proc_active)::in,
     comparison_result::out) is det.
 
-compare_proc_active_rows_by_name(ModuleRowDataA, ModuleRowDataB, Result) :-
+compare_proc_active_rows_by_name(MaybeCurModuleName, ModuleQual,
+        ModuleRowDataA, ModuleRowDataB, Result) :-
     ProcDescA = ModuleRowDataA ^ perf_row_subject ^ pa_proc_desc,
     ProcDescB = ModuleRowDataB ^ perf_row_subject ^ pa_proc_desc,
-    compare_proc_descs_by_name(ProcDescA, ProcDescB, Result).
+    compare_proc_descs_by_name(MaybeCurModuleName, ModuleQual,
+        ProcDescA, ProcDescB, Result).
 
 %-----------------------------------------------------------------------------%
 %
@@ -4160,18 +4411,23 @@
         compare(Result, LineNumberA, LineNumberB)
     ).
 
-:- pred compare_call_site_descs_by_name(call_site_desc::in, call_site_desc::in,
-    comparison_result::out) is det.
+:- pred compare_call_site_descs_by_name(maybe(string)::in, module_qual::in,
+    call_site_desc::in, call_site_desc::in, comparison_result::out) is det.
 
-compare_call_site_descs_by_name(CallSiteDescA, CallSiteDescB, Result) :-
-    NameA = CallSiteDescA ^ csdesc_caller_refined_name,
-    NameB = CallSiteDescB ^ csdesc_caller_refined_name,
+compare_call_site_descs_by_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescA, CallSiteDescB, Result) :-
+    NameA = call_site_desc_get_caller_refined_id(MaybeCurModuleName,
+        ModuleQual, CallSiteDescA),
+    NameB = call_site_desc_get_caller_refined_id(MaybeCurModuleName,
+        ModuleQual, CallSiteDescB),
     compare(Result, NameA, NameB).
 
-:- pred compare_call_site_descs_by_callee_name(
-    call_site_desc::in, call_site_desc::in, comparison_result::out) is det.
+:- pred compare_call_site_descs_by_callee_name(maybe(string)::in,
+    module_qual::in, call_site_desc::in, call_site_desc::in,
+    comparison_result::out) is det.
 
-compare_call_site_descs_by_callee_name(CallSiteDescA, CallSiteDescB, Result) :-
+compare_call_site_descs_by_callee_name(MaybeCurModuleName, ModuleQual,
+        CallSiteDescA, CallSiteDescB, Result) :-
     MaybeCalleeA = CallSiteDescA ^ csdesc_maybe_callee,
     MaybeCalleeB = CallSiteDescB ^ csdesc_maybe_callee,
     (
@@ -4189,15 +4445,19 @@
     ;
         MaybeCalleeA = yes(CalleeNameA),
         MaybeCalleeB = yes(CalleeNameB),
-        compare_proc_descs_by_name(CalleeNameA, CalleeNameB, Result)
+        compare_proc_descs_by_name(MaybeCurModuleName, ModuleQual,
+            CalleeNameA, CalleeNameB, Result)
     ).
 
-:- pred compare_proc_descs_by_name(proc_desc::in, proc_desc::in,
-    comparison_result::out) is det.
+:- pred compare_proc_descs_by_name(maybe(string)::in, module_qual::in,
+    proc_desc::in, proc_desc::in, comparison_result::out) is det.
 
-compare_proc_descs_by_name(ProcDescA, ProcDescB, Result) :-
-    NameA = ProcDescA ^ pdesc_refined_name,
-    NameB = ProcDescB ^ pdesc_refined_name,
+compare_proc_descs_by_name(MaybeCurModuleName, ModuleQual,
+        ProcDescA, ProcDescB, Result) :-
+    NameA =
+        proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual, ProcDescA),
+    NameB =
+        proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual, ProcDescB),
     compare(Result, NameA, NameB).
 
 %-----------------------------------------------------------------------------%
@@ -4223,6 +4483,35 @@
         compare(Result, RedosA, RedosB)
     ;
         CostKind = cost_time,
+        compare_perf_row_datas_by_time(InclDesc, Scope, PerfA, PerfB,
+            TimeResult),
+        (
+            TimeResult = (=),
+            compare_perf_row_datas_by_callseqs(InclDesc, Scope, PerfA, PerfB,
+                Result)
+        ;
+            ( TimeResult = (<)
+            ; TimeResult = (>)
+            ),
+            Result = TimeResult
+        )
+    ;
+        CostKind = cost_callseqs,
+        compare_perf_row_datas_by_callseqs(InclDesc, Scope, PerfA, PerfB,
+            Result)
+    ;
+        CostKind = cost_allocs,
+        compare_perf_row_datas_by_allocs(InclDesc, Scope, PerfA, PerfB, Result)
+    ;
+        CostKind = cost_words,
+        compare_perf_row_datas_by_words(InclDesc, Scope, PerfA, PerfB, Result)
+    ).
+
+:- pred compare_perf_row_datas_by_time(
+    include_descendants::in, measurement_scope::in,
+    perf_row_data(T)::in, perf_row_data(T)::in, comparison_result::out) is det.
+
+compare_perf_row_datas_by_time(InclDesc, Scope, PerfA, PerfB, Result) :-
         (
             InclDesc = self,
             SelfA = PerfA ^ perf_row_self,
@@ -4260,9 +4549,13 @@
             ;
                 error("compare_perf_row_datas_by_cost: self_and_desc")
             )
-        )
-    ;
-        CostKind = cost_callseqs,
+    ).
+
+:- pred compare_perf_row_datas_by_callseqs(
+    include_descendants::in, measurement_scope::in,
+    perf_row_data(T)::in, perf_row_data(T)::in, comparison_result::out) is det.
+
+compare_perf_row_datas_by_callseqs(InclDesc, Scope, PerfA, PerfB, Result) :-
         (
             InclDesc = self,
             SelfA = PerfA ^ perf_row_self,
@@ -4300,9 +4593,13 @@
             ;
                 error("compare_perf_row_datas_by_cost: self_and_desc")
             )
-        )
-    ;
-        CostKind = cost_allocs,
+    ).
+
+:- pred compare_perf_row_datas_by_allocs(
+    include_descendants::in, measurement_scope::in,
+    perf_row_data(T)::in, perf_row_data(T)::in, comparison_result::out) is det.
+
+compare_perf_row_datas_by_allocs(InclDesc, Scope, PerfA, PerfB, Result) :-
         (
             InclDesc = self,
             SelfA = PerfA ^ perf_row_self,
@@ -4340,9 +4637,13 @@
             ;
                 error("compare_perf_row_datas_by_cost: self_and_desc")
             )
-        )
-    ;
-        CostKind = cost_words,
+    ).
+
+:- pred compare_perf_row_datas_by_words(
+    include_descendants::in, measurement_scope::in,
+    perf_row_data(T)::in, perf_row_data(T)::in, comparison_result::out) is det.
+
+compare_perf_row_datas_by_words(InclDesc, Scope, PerfA, PerfB, Result) :-
         (
             InclDesc = self,
             SelfA = PerfA ^ perf_row_self,
@@ -4380,7 +4681,61 @@
             ;
                 error("compare_perf_row_datas_by_cost: self_and_desc")
             )
+    ).
+
+%-----------------------------------------------------------------------------%
+
+:- func proc_desc_get_refined_id(maybe(string), module_qual, proc_desc)
+    = string.
+
+proc_desc_get_refined_id(MaybeCurModuleName, ModuleQual, ProcDesc) = Name :-
+    (
+        ModuleQual = module_qual_never,
+        Name = ProcDesc ^ pdesc_uq_refined_name
+    ;
+        ModuleQual = module_qual_when_diff,
+        (
+            MaybeCurModuleName = no,
+            Name = ProcDesc ^ pdesc_q_refined_name
+        ;
+            MaybeCurModuleName = yes(CurModuleName),
+            ModuleName = ProcDesc ^ pdesc_module_name,
+            ( ModuleName = CurModuleName ->
+                Name = ProcDesc ^ pdesc_uq_refined_name
+            ;
+                Name = ProcDesc ^ pdesc_q_refined_name
+            )
         )
+    ;
+        ModuleQual = module_qual_always,
+        Name = ProcDesc ^ pdesc_q_refined_name
+    ).
+
+:- func call_site_desc_get_caller_refined_id(maybe(string), module_qual,
+    call_site_desc) = string.
+
+call_site_desc_get_caller_refined_id(MaybeCurModuleName, ModuleQual,
+        CallSiteDesc) = Name :-
+    (
+        ModuleQual = module_qual_never,
+        Name = CallSiteDesc ^ csdesc_caller_uq_refined_name
+    ;
+        ModuleQual = module_qual_when_diff,
+        (
+            MaybeCurModuleName = no,
+            Name = CallSiteDesc ^ csdesc_caller_q_refined_name
+        ;
+            MaybeCurModuleName = yes(CurModuleName),
+            ModuleName = CallSiteDesc ^ csdesc_caller_module_name,
+            ( ModuleName = CurModuleName ->
+                Name = CallSiteDesc ^ csdesc_caller_uq_refined_name
+            ;
+                Name = CallSiteDesc ^ csdesc_caller_q_refined_name
+            )
+        )
+    ;
+        ModuleQual = module_qual_always,
+        Name = CallSiteDesc ^ csdesc_caller_q_refined_name
     ).
 
 %-----------------------------------------------------------------------------%
Index: dump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/dump.m,v
retrieving revision 1.16
diff -u -b -r1.16 dump.m
--- dump.m	12 Aug 2008 02:51:07 -0000	1.16
+++ dump.m	7 Sep 2009 09:27:21 -0000
@@ -438,13 +438,14 @@
     ProcDynamic = proc_dynamic(PSPtr, Sites),
     PSPtr = proc_static_ptr(PSI),
     lookup_proc_statics(ProcStatics, PSPtr, PS),
-    ( PS ^ ps_refined_id = "" ->
-        RefinedPSId = "UNKNOWN_PS"
+    ( PS ^ ps_q_refined_id = "" ->
+        QualRefinedPSId = "UNKNOWN_PS"
     ;
-        RefinedPSId = PS ^ ps_refined_id
+        QualRefinedPSId = PS ^ ps_q_refined_id
     ),
     io.format("pd%d:\n", [i(Index)], !IO),
-    io.format("\tpd_proc_static = %d (%s)\n", [i(PSI), s(RefinedPSId)], !IO),
+    io.format("\tpd_proc_static = %d (%s)\n",
+        [i(PSI), s(QualRefinedPSId)], !IO),
     array_foldl_from_0(dump_call_site_array_slot, Sites, !IO),
     io.nl(!IO).
 
@@ -520,22 +521,22 @@
             set.member(proc_static_ptr(Index), UsedProcStatics)
         )
     ->
-        ProcStatic = proc_static(Id, DeclModule, RefinedId, RawId,
-            FileName, LineNumber, InInterface, Sites, CoveragePoints,
-            IsZeroed),
+        ProcStatic = proc_static(Id, DeclModule,
+            _UnQualRefinedId, QualRefinedId, RawId, FileName, LineNumber,
+            InInterface, Sites, CoveragePoints, IsZeroed),
         IdStr = dump_proc_id(Id),
         io.format("ps%d:\n", [i(Index)], !IO),
         io.format("\tps_id\t\t= %s", [s(IdStr)], !IO),
         io.nl(!IO),
         io.format("\tps_decl_module\t= %s\n", [s(DeclModule)], !IO),
-        ( RefinedId = string.append_list([DeclModule, ":", IdStr]) ->
+        ( QualRefinedId = DeclModule ++ "." ++ IdStr ->
             % The output is too big already; don't include
             % redundant information.
             true
         ;
-            io.format("\tps_refined_id\t= %s\n", [s(RefinedId)], !IO)
+            io.format("\tps_q_refined_id\t= %s\n", [s(QualRefinedId)], !IO)
         ),
-        ( RefinedId \= RawId ->
+        ( QualRefinedId \= RawId ->
             % The output is too big already; don't include
             % redundant information.
             true
Index: mdprof_cgi.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/mdprof_cgi.m,v
retrieving revision 1.29
diff -u -b -r1.29 mdprof_cgi.m
--- mdprof_cgi.m	31 Aug 2009 02:15:12 -0000	1.29
+++ mdprof_cgi.m	7 Sep 2009 11:48:04 -0000
@@ -313,6 +313,7 @@
         DeepFileName = DeepFileName0,
         Options = Options0
     ),
+    ( remove_suffix(DeepFileName, ".data", _BaseFileName) ->
     ToServerPipe = to_server_pipe_name(DeepFileName),
     FromServerPipe = from_server_pipe_name(DeepFileName),
     StartupFile = server_startup_name(DeepFileName),
@@ -331,16 +332,26 @@
     ),
     check_for_existing_fifos(ToServerPipe, FromServerPipe, FifoCount, !IO),
     ( FifoCount = 0 ->
-        handle_query_from_new_server(Cmd, PrefInd, DeepFileName, ToServerPipe,
-            FromServerPipe, StartupFile, MutexFile, WantFile, Options, !IO)
+            handle_query_from_new_server(Cmd, PrefInd, DeepFileName,
+                ToServerPipe, FromServerPipe, StartupFile, MutexFile, WantFile,
+                Options, !IO)
     ; FifoCount = 2 ->
         handle_query_from_existing_server(Cmd, PrefInd,
-            ToServerPipe, FromServerPipe, MutexFile, WantFile, Options, !IO)
+                ToServerPipe, FromServerPipe, MutexFile, WantFile, Options,
+                !IO)
     ;
         release_lock(Debug, MutexFile, !IO),
         remove_want_file(WantFile, !IO),
         io.set_exit_status(1, !IO),
         io.write_string("mdprof internal error: bad fifo count", !IO)
+        )
+    ;
+        io.set_exit_status(1, !IO),
+        io.format("<h3> Invalid file name %s.<h3>\n\n",
+            [s(DeepFileName)], !IO),
+        io.write_string(
+            "Deep profiling data files must have a .data suffix, " ++
+            "to allow the deep profiler to locate any related files.\n", !IO)
     ).
 
     % This type is used to pass queries between the two servers.
Index: old_html_format.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/old_html_format.m,v
retrieving revision 1.3
diff -u -b -r1.3 old_html_format.m
--- old_html_format.m	2 Jan 2009 02:59:35 -0000	1.3
+++ old_html_format.m	7 Sep 2009 09:28:06 -0000
@@ -736,12 +736,12 @@
 
 footer_summarize_toggle(Cmd, Pref, Deep) = HTML :-
     (
-        Pref ^ pref_summarize = summarize,
-        Pref1 = Pref ^ pref_summarize := do_not_summarize,
+        Pref ^ pref_summarize = summarize_ho_call_sites,
+        Pref1 = Pref ^ pref_summarize := do_not_summarize_ho_call_sites,
         Msg1 = "[Expand higher order calls]"
     ;
-        Pref ^ pref_summarize = do_not_summarize,
-        Pref1 = Pref ^ pref_summarize := summarize,
+        Pref ^ pref_summarize = do_not_summarize_ho_call_sites,
+        Pref1 = Pref ^ pref_summarize := summarize_ho_call_sites,
         Msg1 = "[Summarize higher order calls]"
     ),
     HTML = string.format("<A CLASS=""button"" HREF=""%s"">%s</A>\n",
@@ -999,15 +999,17 @@
 :- func footer_inactive_modules_toggle(cmd, preferences, deep) = string.
 
 footer_inactive_modules_toggle(Cmd, Pref0, Deep) = HTML :-
-    Pref0 ^ pref_inactive = inactive_items(Procs, Modules),
+    Pref0 ^ pref_inactive = inactive_items(CallsSites, Procs, Modules),
     (
         Modules = inactive_show,
         Msg  = "[Hide inactive modules]",
-        Pref = Pref0 ^ pref_inactive := inactive_items(Procs, inactive_hide)
+        Pref = Pref0 ^ pref_inactive :=
+            inactive_items(CallsSites, Procs, inactive_hide)
     ;
         Modules = inactive_hide,
         Msg  = "[Show inactive modules]",
-        Pref = Pref0 ^ pref_inactive := inactive_items(Procs, inactive_show)
+        Pref = Pref0 ^ pref_inactive :=
+            inactive_items(CallsSites, Procs, inactive_show)
     ),
     HTML = string.format("<A CLASS=""button"" HREF=""%s"">%s</A>\n",
         [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)), s(Msg)]).
@@ -1015,15 +1017,17 @@
 :- func footer_inactive_procs_toggle(cmd, preferences, deep) = string.
 
 footer_inactive_procs_toggle(Cmd, Pref0, Deep) = HTML :-
-    Pref0 ^ pref_inactive = inactive_items(Procs, Modules),
+    Pref0 ^ pref_inactive = inactive_items(CallsSites, Procs, Modules),
     (
         Procs = inactive_show,
         Msg = "[Hide inactive procedures]",
-        Pref = Pref0 ^ pref_inactive := inactive_items(inactive_hide, Modules)
+        Pref = Pref0 ^ pref_inactive :=
+            inactive_items(CallsSites, inactive_hide, Modules)
     ;
         Procs = inactive_hide,
         Msg = "[Show inactive procedures]",
-        Pref = Pref0 ^ pref_inactive := inactive_items(inactive_show, Modules)
+        Pref = Pref0 ^ pref_inactive :=
+            inactive_items(CallsSites, inactive_show, Modules)
     ),
     HTML = string.format("<A CLASS=""button"" HREF=""%s"">%s</A>\n",
         [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)), s(Msg)]).
@@ -2152,11 +2156,11 @@
     deep_lookup_proc_dynamics(Deep, PDPtr, PD),
     PSPtr = PD ^ pd_proc_static,
     deep_lookup_proc_statics(Deep, PSPtr, PS),
-    Name = PS ^ ps_refined_id.
+    Name = PS ^ ps_q_refined_id.
 
 proc_static_name(Deep, PSPtr) = Name :-
     deep_lookup_proc_statics(Deep, PSPtr, PS),
-    Name = PS ^ ps_refined_id.
+    Name = PS ^ ps_q_refined_id.
 
 %-----------------------------------------------------------------------------%
 
@@ -2186,7 +2190,7 @@
         deep_lookup_proc_statics(Deep, PSPtr, PS),
         FileName = PS ^ ps_file_name,
         LineNumber = PS ^ ps_line_number,
-        Name = PS ^ ps_refined_id,
+        Name = PS ^ ps_q_refined_id,
         HTML = proc_static_to_html_ref(Pref, Deep, PSPtr)
     ;
         FileName = "",
@@ -2198,7 +2202,7 @@
 proc_static_to_html_ref(Pref, Deep, PSPtr) = HTML :-
     URL = deep_cmd_pref_to_url(Pref, Deep, deep_cmd_proc(PSPtr)),
     deep_lookup_proc_statics(Deep, PSPtr, PS),
-    ProcName = PS ^ ps_refined_id,
+    ProcName = PS ^ ps_q_refined_id,
     HTML = string.format("<A HREF=""%s"">%s</A>",
         [s(URL), s(escape_break_html_string(ProcName))]).
 
Index: old_query.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/old_query.m,v
retrieving revision 1.3
diff -u -b -r1.3 old_query.m
--- old_query.m	2 Jan 2009 02:59:35 -0000	1.3
+++ old_query.m	7 Sep 2009 09:28:50 -0000
@@ -154,7 +154,7 @@
 generate_proc_static_debug_page(PSPtr, Deep) = HTML :-
     ( valid_proc_static_ptr(Deep, PSPtr) ->
         deep_lookup_proc_statics(Deep, PSPtr, PS),
-        Refined = PS ^ ps_refined_id,
+        Refined = PS ^ ps_q_refined_id,
         Raw = PS ^ ps_raw_id,
         FileName = PS ^ ps_file_name,
         HTML =
@@ -1096,11 +1096,11 @@
         % 'CallSiteName' because it has already been done.
         string.format("<TD CLASS=id>%s</TD>\n", [s(CallSiteName)]),
     (
-        Pref ^ pref_summarize = summarize,
+        Pref ^ pref_summarize = summarize_ho_call_sites,
         LineGroup = line_group(FileName, LineNumber, RawCallSiteName,
             Own, Desc, SummaryHTML, sub_lines(two_id, []))
     ;
-        Pref ^ pref_summarize = do_not_summarize,
+        Pref ^ pref_summarize = do_not_summarize_ho_call_sites,
         LineGroup = line_group(FileName, LineNumber, RawCallSiteName,
             Own, Desc, SummaryHTML, sub_lines(two_id, SubLines))
     ),
@@ -1137,7 +1137,7 @@
 normal_call_site_summary_to_html(Pref, Deep, FileName, LineNumber,
         CallerPSPtr, CalleePSPtr, CallSiteCallList) = LineGroup :-
     deep_lookup_proc_statics(Deep, CalleePSPtr, CalleePS),
-    ProcName = CalleePS ^ ps_refined_id,
+    ProcName = CalleePS ^ ps_q_refined_id,
     (
         CallSiteCallList = [],
         Own = zero_own_prof_info,
@@ -1181,11 +1181,11 @@
     SummaryHTML =
         string.format("<TD CLASS=id>%s</TD>\n", [s(CallSiteName)]),
     (
-        Pref ^ pref_summarize = summarize,
+        Pref ^ pref_summarize = summarize_ho_call_sites,
         LineGroup = line_group(FileName, LineNumber, RawCallSiteName,
             Own, Desc, SummaryHTML, sub_lines(two_id, []))
     ;
-        Pref ^ pref_summarize = do_not_summarize,
+        Pref ^ pref_summarize = do_not_summarize_ho_call_sites,
         ContextSubLines = list.map(add_context(""), SubLines),
         LineGroup = line_group(FileName, LineNumber, RawCallSiteName,
             Own, Desc, SummaryHTML, sub_lines(two_id, ContextSubLines))
@@ -1217,10 +1217,10 @@
         CallList = [_ | _],
         Summarize = Pref ^ pref_summarize,
         (
-            Summarize = summarize,
+            Summarize = summarize_ho_call_sites,
             CallSiteName = RawCallSiteName ++ " (summary)"
         ;
-            Summarize = do_not_summarize,
+            Summarize = do_not_summarize_ho_call_sites,
             CallSiteName = RawCallSiteName
         )
     ).
@@ -1695,7 +1695,7 @@
     deep_lookup_call_site_statics(Deep, CSSPtr, CSS),
     CallerPSPtr = CSS ^ css_container,
     deep_lookup_proc_statics(Deep, CallerPSPtr, CallerPS),
-    CallerProcName = CallerPS ^ ps_refined_id,
+    CallerProcName = CallerPS ^ ps_q_refined_id,
     compute_parent_csd_prof_info(Deep, CalleePSPtr, CSDPtrs, Own, Desc),
     HTML =
         string.format("<TD CLASS=id>%s:%d</TD>\n",
@@ -1712,7 +1712,7 @@
         = LineGroup :-
     proc_static_context(Deep, CallerPSPtr, FileName, LineNumber),
     deep_lookup_proc_statics(Deep, CallerPSPtr, CallerPS),
-    CallerProcName = CallerPS ^ ps_refined_id,
+    CallerProcName = CallerPS ^ ps_q_refined_id,
     compute_parent_csd_prof_info(Deep, CalleePSPtr, CSDPtrs, Own, Desc),
     HTML =
         string.format("<TD CLASS=id>%s:%d</TD>\n",
Index: profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/profile.m,v
retrieving revision 1.26
diff -u -b -r1.26 profile.m
--- profile.m	2 Apr 2009 09:49:27 -0000	1.26
+++ profile.m	7 Sep 2009 09:16:48 -0000
@@ -182,7 +182,8 @@
     --->    proc_static(
                 ps_id               :: string_proc_label, % procedure ID
                 ps_decl_module      :: string,      % declaring module
-                ps_refined_id       :: string,      % refined procedure id
+                ps_uq_refined_id    :: string,      % unqualified refined id
+                ps_q_refined_id     :: string,      % qualied refined id
                 ps_raw_id           :: string,      % raw procedure id
                 ps_file_name        :: string,      % file name of proc
                 ps_line_number      :: int,         % line number of proc
Index: query.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/query.m,v
retrieving revision 1.33
diff -u -b -r1.33 query.m
--- query.m	2 Jan 2009 02:59:35 -0000	1.33
+++ query.m	7 Sep 2009 07:46:36 -0000
@@ -185,7 +185,7 @@
                 pref_anc            :: maybe(int),
 
                 % Whether pages should summarize at higher order call sites.
-                pref_summarize      :: summarize,
+                pref_summarize      :: summarize_ho_call_sites,
 
                 % The criteria for ordering lines in pages, if the command
                 % doesn't specify otherwise.
@@ -203,6 +203,8 @@
 
                 pref_time           :: time_format,
 
+                pref_module_qual    :: module_qual,
+
                 % Whether we should show modules/procs that haven't been
                 % called.
                 pref_inactive       :: inactive_items
@@ -257,9 +259,9 @@
     --->    colour_column_groups
     ;       do_not_colour_column_groups.
 
-:- type summarize
-    --->    summarize
-    ;       do_not_summarize.
+:- type summarize_ho_call_sites
+    --->    summarize_ho_call_sites
+    ;       do_not_summarize_ho_call_sites.
 
 :- type order_criteria
     --->    by_context
@@ -283,12 +285,18 @@
     ;       scale_by_millions
     ;       scale_by_thousands.
 
+:- type module_qual
+    --->    module_qual_always
+    ;       module_qual_when_diff
+    ;       module_qual_never.
+
 :- type inactive_status
     --->    inactive_hide
     ;       inactive_show.
 
 :- type inactive_items
     --->    inactive_items(
+                inactive_call_sites :: inactive_status,
                 inactive_procs   :: inactive_status,
                 inactive_modules :: inactive_status
             ).
@@ -310,13 +318,14 @@
 :- func default_box_tables = box_tables.
 :- func default_colour_column_groups = colour_column_groups.
 :- func default_ancestor_limit = maybe(int).
-:- func default_summarize = summarize.
+:- func default_summarize_ho_call_sites = summarize_ho_call_sites.
 :- func default_order_criteria = order_criteria.
 :- func default_cost_kind = cost_kind.
 :- func default_incl_desc = include_descendants.
 :- func default_scope = measurement_scope.
 :- func default_contour_exclusion = contour_exclusion.
 :- func default_time_format = time_format.
+:- func default_module_qual = module_qual.
 :- func default_inactive_items = inactive_items.
 
 %-----------------------------------------------------------------------------%
@@ -472,10 +481,11 @@
         default_box_tables,
         default_colour_column_groups,
         default_ancestor_limit,
-        default_summarize,
+        default_summarize_ho_call_sites,
         default_order_criteria,
         default_contour_exclusion,
         default_time_format,
+        default_module_qual,
         default_inactive_items
     ).
 
@@ -496,14 +506,16 @@
 default_box_tables = box_tables.
 default_colour_column_groups = colour_column_groups.
 default_ancestor_limit = yes(5).
-default_summarize = do_not_summarize.
+default_summarize_ho_call_sites = do_not_summarize_ho_call_sites.
 default_order_criteria = by_context.
 default_cost_kind = cost_callseqs.
 default_incl_desc = self_and_desc.
 default_scope = overall.
 default_contour_exclusion = do_not_apply_contour_exclusion.
 default_time_format = scale_by_thousands.
-default_inactive_items = inactive_items(inactive_hide, inactive_hide).
+default_module_qual = module_qual_when_diff.
+default_inactive_items =
+    inactive_items(inactive_hide, inactive_hide, inactive_hide).
 
 %-----------------------------------------------------------------------------%
 
@@ -636,7 +648,7 @@
 
 preferences_to_string(Pref) = PrefStr :-
     Pref = preferences(Fields, Box, Colour, MaybeAncestorLimit,
-        Summarize, Order, Contour, Time, InactiveItems),
+        SummarizeHoCallSites, Order, Contour, Time, ModuleQual, InactiveItems),
     (
         MaybeAncestorLimit = yes(AncestorLimit),
         MaybeAncestorLimitStr =
@@ -645,15 +657,16 @@
         MaybeAncestorLimit = no,
         MaybeAncestorLimitStr = "no"
     ),
-    PrefStr = string.format("%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s",
+    PrefStr = string.format("%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s",
         [s(fields_to_string(Fields)),
         c(pref_separator_char), s(box_to_string(Box)),
         c(pref_separator_char), s(colour_scheme_to_string(Colour)),
         c(pref_separator_char), s(MaybeAncestorLimitStr),
-        c(pref_separator_char), s(summarize_to_string(Summarize)),
+        c(pref_separator_char), s(summarize_to_string(SummarizeHoCallSites)),
         c(pref_separator_char), s(order_criteria_to_string(Order)),
         c(pref_separator_char), s(contour_exclusion_to_string(Contour)),
         c(pref_separator_char), s(time_format_to_string(Time)),
+        c(pref_separator_char), s(module_qual_to_string(ModuleQual)),
         c(pref_separator_char), s(inactive_items_to_string(InactiveItems))
     ]).
 
@@ -809,7 +822,8 @@
     split(QueryString, pref_separator_char, Pieces),
     (
         Pieces = [FieldsStr, BoxStr, ColourStr, MaybeAncestorLimitStr,
-            SummarizeStr, OrderStr, ContourStr, TimeStr, InactiveItemsStr],
+            SummarizeHoCallSitesStr, OrderStr, ContourStr, TimeStr,
+            ModuleQualStr, InactiveItemsStr],
         string_to_fields(FieldsStr, Fields),
         string_to_box(BoxStr, Box),
         string_to_colour_scheme(ColourStr, Colour),
@@ -820,14 +834,16 @@
         ;
             fail
         ),
-        string_to_summarize(SummarizeStr, Summarize),
+        string_to_summarize(SummarizeHoCallSitesStr, SummarizeHoCallSites),
         string_to_order_criteria(OrderStr, Order),
         string_to_contour_exclusion(ContourStr, Contour),
         string_to_time_format(TimeStr, Time),
+        string_to_module_qual(ModuleQualStr, ModuleQual),
         string_to_inactive_items(InactiveItemsStr, InactiveItems)
     ->
         Preferences = preferences(Fields, Box, Colour, MaybeAncestorLimit,
-            Summarize, Order, Contour, Time, InactiveItems),
+            SummarizeHoCallSites, Order, Contour, Time, ModuleQual,
+            InactiveItems),
         MaybePreferences = yes(Preferences)
     ;
         MaybePreferences = no
@@ -1068,15 +1084,28 @@
         fail
     ).
 
-:- func summarize_to_string(summarize) = string.
+:- func summarize_to_string(summarize_ho_call_sites) = string.
+
+summarize_to_string(summarize_ho_call_sites) = "sum".
+summarize_to_string(do_not_summarize_ho_call_sites) = "nosum".
+
+:- pred string_to_summarize(string::in, summarize_ho_call_sites::out)
+    is semidet.
+
+string_to_summarize("sum",   summarize_ho_call_sites).
+string_to_summarize("nosum", do_not_summarize_ho_call_sites).
+
+:- func module_qual_to_string(module_qual) = string.
 
-summarize_to_string(summarize)      = "sum".
-summarize_to_string(do_not_summarize) = "nosum".
+module_qual_to_string(module_qual_always) = "mqa".
+module_qual_to_string(module_qual_when_diff) = "mqwd".
+module_qual_to_string(module_qual_never) = "mqn".
 
-:- pred string_to_summarize(string::in, summarize::out) is semidet.
+:- pred string_to_module_qual(string::in, module_qual::out) is semidet.
 
-string_to_summarize("sum",   summarize).
-string_to_summarize("nosum", do_not_summarize).
+string_to_module_qual("mqa",  module_qual_always).
+string_to_module_qual("mqwd", module_qual_when_diff).
+string_to_module_qual("mqn",  module_qual_never).
 
 :- func order_criteria_to_string(order_criteria) = string.
 
@@ -1161,10 +1190,22 @@
 :- mode string_to_inactive_items(in, out) is semidet.
 :- mode string_to_inactive_items(out, in) is det.
 
-string_to_inactive_items("hh", inactive_items(inactive_hide, inactive_hide)).
-string_to_inactive_items("sh", inactive_items(inactive_show, inactive_hide)).
-string_to_inactive_items("hs", inactive_items(inactive_hide, inactive_show)).
-string_to_inactive_items("ss", inactive_items(inactive_show, inactive_show)).
+string_to_inactive_items("hhh",
+    inactive_items(inactive_hide, inactive_hide, inactive_hide)).
+string_to_inactive_items("hhs",
+    inactive_items(inactive_hide, inactive_hide, inactive_show)).
+string_to_inactive_items("hsh",
+    inactive_items(inactive_hide, inactive_show, inactive_hide)).
+string_to_inactive_items("hss",
+    inactive_items(inactive_hide, inactive_show, inactive_show)).
+string_to_inactive_items("shh",
+    inactive_items(inactive_show, inactive_hide, inactive_hide)).
+string_to_inactive_items("shs",
+    inactive_items(inactive_show, inactive_hide, inactive_show)).
+string_to_inactive_items("ssh",
+    inactive_items(inactive_show, inactive_show, inactive_hide)).
+string_to_inactive_items("sss",
+    inactive_items(inactive_show, inactive_show, inactive_show)).
 
 :- func colour_scheme_to_string(colour_column_groups) = string.
 
Index: read_profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/read_profile.m,v
retrieving revision 1.26
diff -u -b -r1.26 read_profile.m
--- read_profile.m	18 Aug 2008 02:14:51 -0000	1.26
+++ read_profile.m	7 Sep 2009 09:15:31 -0000
@@ -218,7 +218,7 @@
                 normal_call_and_callee(make_dummy_psptr, ""), -1, ""
             )),
         array.init(MaxPS + 1,
-            proc_static(dummy_proc_id, "", "", "", "", -1, no,
+            proc_static(dummy_proc_id, "", "", "", "", "", -1, no,
                 array([]), array([]), not_zeroed))
     ).
 
@@ -363,7 +363,7 @@
                 MaybeCoveragePoints = ok(CoveragePoints),
                 CSSPtrs = list.map(make_cssptr, CSSIs),
                 DeclModule = decl_module(Id),
-                RefinedStr = refined_proc_id_to_string(Id),
+                create_refined_proc_ids(Id, UnQualRefinedStr, QualRefinedStr),
                 RawStr = raw_proc_id_to_string(Id),
                 ( Interface = 0 ->
                     IsInInterface = no
@@ -374,9 +374,9 @@
                 % is ever zeroed is the default. The startup phase will set it
                 % to `zeroed' in the proc_statics which are ever zeroed.
                 ProcStatic = proc_static(Id, DeclModule,
-                    RefinedStr, RawStr, FileName, LineNumber,
-                    IsInInterface, array(CSSPtrs), array(CoveragePoints),
-                    not_zeroed),
+                    UnQualRefinedStr, QualRefinedStr, RawStr,
+                    FileName, LineNumber, IsInInterface,
+                    array(CSSPtrs), array(CoveragePoints), not_zeroed),
                 MaybePS = ok2(ProcStatic, PSI),
                 trace [compile_time(flag("debug_read_profdeep")), io(!IO)] (
                     io.write_string("read proc_static ", !IO),
@@ -490,10 +490,13 @@
         add_plus_one_for_function(PredOrFunc),
         "-", string.int_to_string(Mode)]).
 
-:- func refined_proc_id_to_string(string_proc_label) = string.
+:- pred create_refined_proc_ids(string_proc_label::in,
+    string::out, string::out) is det.
 
-refined_proc_id_to_string(str_special_proc_label(TypeName, TypeModule,
-        _DefModule, RawPredName, Arity, Mode)) = Name :-
+create_refined_proc_ids(ProcLabel, UnQualName, QualName) :-
+    (
+        ProcLabel = str_special_proc_label(TypeName, TypeModule,
+            _DefModule, RawPredName, Arity, Mode),
     ( RawPredName = "__Unify__" ->
         PredName = "Unify"
     ; RawPredName = "__Compare__" ->
@@ -505,18 +508,24 @@
     ; RawPredName = "__Initialise__" ->
         PredName = "Initialise"
     ;
-        string.append("unknown special predicate name ", RawPredName, Msg),
+            Msg = "unknown special predicate name " ++ RawPredName,
         error(Msg)
     ),
-    Name0 = string.append_list([PredName, " for ", TypeModule, ".", TypeName,
-        "/", string.int_to_string(Arity)]),
+        Prefix = PredName ++ " for ",
+        AritySuffix = "/" ++ string.int_to_string(Arity),
+        UnQualName0 = Prefix ++ TypeName ++ AritySuffix,
+        QualName0 = Prefix ++ TypeModule ++ "." ++ TypeName ++ AritySuffix,
     ( Mode = 0 ->
-        Name = Name0
+            UnQualName = UnQualName0,
+            QualName = QualName0
     ;
-        Name = string.append_list([Name0, " mode ", int_to_string(Mode)])
-    ).
-refined_proc_id_to_string(str_ordinary_proc_label(PredOrFunc, DeclModule,
-        _DefModule, ProcName, Arity, Mode)) = Name :-
+            ModeSuffix = " mode " ++ int_to_string(Mode),
+            UnQualName = UnQualName0 ++ ModeSuffix,
+            QualName = QualName0 ++ ModeSuffix
+        )
+    ;
+        ProcLabel = str_ordinary_proc_label(PredOrFunc, DeclModule,
+            _DefModule, ProcName, Arity, Mode),
     (
         string.append("TypeSpecOf__", ProcName1, ProcName),
         ( string.append("pred__", ProcName2A, ProcName1) ->
@@ -532,11 +541,12 @@
         fix_type_spec_suffix(ProcName2Chars, ProcNameChars, SpecInfo)
     ->
         RefinedProcName = string.from_char_list(ProcNameChars),
-        Name = string.append_list([DeclModule, ".", RefinedProcName,
-            "/", string.int_to_string(Arity),
-            add_plus_one_for_function(PredOrFunc),
-            "-", string.int_to_string(Mode),
-            " [", SpecInfo, "]"])
+            Suffix = "/" ++ string.int_to_string(Arity) ++
+                add_plus_one_for_function(PredOrFunc) ++
+                "-" ++ string.int_to_string(Mode) ++
+                " [" ++ SpecInfo ++ "]",
+            UnQualName = RefinedProcName ++ Suffix,
+            QualName = DeclModule ++ "." ++ RefinedProcName ++ Suffix
     ;
         string.append("IntroducedFrom__", ProcName1, ProcName),
         ( string.append("pred__", ProcName2A, ProcName1) ->
@@ -553,15 +563,20 @@
     ->
         string.from_char_list(ContainingNameChars, ContainingName),
         string.from_char_list(LineNumberChars, LineNumber),
-        Name = string.append_list([DeclModule, ".", ContainingName,
-            " lambda line ", LineNumber,
-            "/", string.int_to_string(Arity),
-            add_plus_one_for_function(PredOrFunc)])
-    ;
-        Name = string.append_list([DeclModule, ".", ProcName,
-            "/", string.int_to_string(Arity),
+            Suffix =
+                " lambda line " ++ LineNumber ++
+                "/" ++ string.int_to_string(Arity) ++
             add_plus_one_for_function(PredOrFunc),
-            "-", string.int_to_string(Mode)])
+            UnQualName = ContainingName ++ Suffix,
+            QualName = DeclModule ++ "." ++ ContainingName ++ Suffix
+        ;
+            Suffix =
+                "/" ++ string.int_to_string(Arity) ++
+                add_plus_one_for_function(PredOrFunc) ++
+                "-" ++ string.int_to_string(Mode),
+            UnQualName = ProcName ++ Suffix,
+            QualName = DeclModule ++ "." ++ ProcName ++ Suffix
+        )
     ).
 
 :- func add_plus_one_for_function(pred_or_func) = string.
Index: report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/report.m,v
retrieving revision 1.19
diff -u -b -r1.19 report.m
--- report.m	12 Mar 2009 03:33:42 -0000	1.19
+++ report.m	7 Sep 2009 10:56:03 -0000
@@ -351,7 +351,8 @@
     --->    proc_static_dump_info(
                 psdi_psptr                  :: proc_static_ptr,
                 psdi_raw_name               :: string,
-                psdi_refined_name           :: string,
+                psdi_uq_refined_name        :: string,
+                psdi_q_refined_name         :: string,
                 psdi_filename               :: string,
                 psdi_linenumber             :: int,
                 % Should we list the call_site_statics and coverage points
@@ -365,7 +366,9 @@
                 pddi_pdptr                  :: proc_dynamic_ptr,
                 pddi_psptr                  :: proc_static_ptr,
                 pddi_ps_raw_name            :: string,
-                pddi_ps_refined_name        :: string,
+                pddi_ps_module_name         :: string,
+                pddi_ps_uq_refined_name     :: string,
+                pddi_ps_q_refined_name      :: string,
                 pddi_call_sites             :: list(call_site_array_slot)
             ).
 
@@ -500,7 +503,9 @@
                 pdesc_ps_ptr                :: proc_static_ptr,
                 pdesc_file_name             :: string,
                 pdesc_line_number           :: int,
-                pdesc_refined_name          :: string
+                pdesc_module_name               :: string,
+                pdesc_uq_refined_name           :: string,
+                pdesc_q_refined_name            :: string
             ).
 
     % The representation of a call site in a report structure, including
@@ -512,7 +517,9 @@
                 csdesc_container            :: proc_static_ptr,
                 csdesc_file_name            :: string,
                 csdesc_line_number          :: int,
-                csdesc_caller_refined_name  :: string,
+                csdesc_caller_module_name       :: string,
+                csdesc_caller_uq_refined_name   :: string,
+                csdesc_caller_q_refined_name    :: string,
                 csdesc_slot_number          :: int,
                 csdesc_goal_path            :: goal_path,
                 csdesc_maybe_callee         :: maybe(proc_desc)
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