Permalink
Switch branches/tags
version-14_01_1 version-14_01 version-13_05_2 version-13_05_1 version-13_05 version-12_08-branchpoint version-12_08-GIT version-11_07_2 version-11_07_1 version-11_07 version-11_07-branchpoint version-11_01 version-11_01-branchpoint version-10_04_2 version-10_04_1 version-10_04 version-10_04-branchpoint version-0_13_1 version-0_13-branchpoint version-0_12_2 version-0_12_1 version-0_12-branchpoint version-0_11_0 version-0_11-branchpoint version-0_10 version-0_9_1 version-0_9 version-0_9_x-snapshot version-0_9_x-snapshot-19991220 unstable-version-0_13_1-x86_64-unknown-linux-gnu-libc2_3 unstable-version-0_13_1-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_13-branch-x86_64-unknown-linux-gnu-libc2_3 unstable-version-0_13-branch-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_12_2-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12_2-i386-pc-solaris2_8 unstable-version-0_12_1-i686-pc-linux-libc2_3-gnu-O4-intermod unstable-version-0_12_1-i686-pc-linux-libc2_3-gnu-O2 unstable-version-0_12_1-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12_1-i386-pc-solaris2_8 unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O5 unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O4-intermod unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O4-hlc unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O2 unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O5 unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O3 unstable-version-0_12-branch-i386-pc-solaris2_8 unstable-version-0_11_0-sparc-sun-solaris2_7 unstable-version-0_11_0-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5 unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-lcc unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-hlc unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4-asm unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O3 unstable-version-0_11_0-i386-pc-solaris2_8 unstable-version-0_11-branch-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-hlc unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-hlc unstable-version-0_11-branch-alpha-dec-osf5_1 unstable-version-0_10_y-sparc-sun-solaris2_7 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-intermod unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-hlc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O4-hlc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O2 unstable-version-0_10_y-i586-pc-linux-libc2_1-gnu-O0 unstable-version-0_10_y-alpha-dec-osf5_1 unstable-version-0_10_y-alpha-dec-osf3_2 unstable-version-0_10_x-sparc-sun-solaris2_7 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O4-hlc unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O3 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O2 unstable-version-0_10_x-i586-pc-linux-libc2_1-gnu-O0 unstable-version-0_10_x-alpha-dec-osf3_2 termination2_trunk stable-version-0_11_0-i686-pc-linux-libc2_3-gnu-O5-intermod stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5 stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-lcc stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-hlc stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4 stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4-asm stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O3 stable-version-0_11-branch-i686-pc-linux-libc2_3-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-lcc stable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5 stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-lcc stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-hlc stable-version-0_11-branch-alpha-dec-osf5_1
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
196 lines (163 sloc) 6.44 KB
%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
% Copyright (C) 2011 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%---------------------------------------------------------------------------%
%
% File: mdprof_report_feedback.m.
% Author: pbone.
%
% This module contains code for showing the contents of feedback files
% in a human-readable form.
%
%---------------------------------------------------------------------------%
:- module mdprof_report_feedback.
:- interface.
:- import_module io.
%---------------------------------------------------------------------------%
:- pred main(io::di, io::uo) is det.
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module mdbcomp.
:- import_module mdbcomp.feedback.
:- import_module mdprof_fb.
:- import_module mdprof_fb.automatic_parallelism.
:- import_module mdprof_fb.automatic_parallelism.autopar_reports.
:- import_module bool.
:- import_module char.
:- import_module getopt.
:- import_module int.
:- import_module library.
:- import_module list.
:- import_module map.
:- import_module maybe.
:- import_module string.
%---------------------------------------------------------------------------%
main(!IO) :-
io.progname_base("mdprof_report_feedback", ProgName, !IO),
io.command_line_arguments(Args0, !IO),
getopt.process_options(option_ops_multi(short, long, defaults),
Args0, Args, MaybeOptions),
io.stderr_stream(Stderr, !IO),
(
MaybeOptions = ok(Options0),
post_process_options(ProgName, Options0, Options, !IO),
lookup_bool_option(Options, help, Help),
lookup_bool_option(Options, version, Version),
( if Version = yes then
write_version_message(ProgName, !IO)
else if Help = yes then
write_help_message(ProgName, !IO)
else
(
Args = [FeedbackFileName],
feedback.read_feedback_file(FeedbackFileName, no,
FeedbackResult, !IO),
(
FeedbackResult = ok(Feedback),
print_feedback_report(Feedback, !IO)
;
FeedbackResult = error(FeedbackError),
feedback_read_error_message_string(FeedbackFileName,
FeedbackError, Message),
io.format(Stderr, "%s: %s\n",
[s(ProgName), s(Message)], !IO),
io.set_exit_status(1, !IO)
)
;
( Args = []
; Args = [_, _ | _]
),
write_help_message(ProgName, !IO),
io.set_exit_status(1, !IO)
)
)
;
MaybeOptions = error(Msg),
io.format(Stderr, "%s: error parsing options: %s\n",
[s(ProgName), s(Msg)], !IO),
write_help_message(ProgName, !IO),
io.set_exit_status(1, !IO)
).
:- func help_message(string) = string.
help_message(ProgName) = HelpMessage :-
FormatStr =
"Usage: %s [options] <feedbackfile>
This command outputs a report that shows the contents of the named
feedback file in a human-readable form.
You may specify the following general options:
-h --help Generate this help message.
-V --version Report the program's version number.
-v --verbosity <0-4>
Generate messages. The higher the argument, the more
verbose the program becomes. 2 is recommended, and
is the default.
",
HelpMessage = string.format(FormatStr, [s(ProgName)]).
:- pred write_help_message(string::in, io::di, io::uo) is det.
write_help_message(ProgName, !IO) :-
io.write_string(help_message(ProgName), !IO).
:- pred write_version_message(string::in, io::di, io::uo) is det.
write_version_message(ProgName, !IO) :-
library.version(Version, Fullarch),
io.format("%s: Mercury deep profiler\n", [s(ProgName)], !IO),
io.format("version: %s, on %s.\n", [s(Version), s(Fullarch)], !IO).
%---------------------------------------------------------------------------%
%
% This section describes and processes command line options. Individual
% feedback information can be requested by the user, as well as options named
% after optimizations that may imply one or more feedback information types,
% which that optimization uses.
%
% Command line options.
%
:- type option
---> help
; version
; verbosity.
% TODO: Introduce an option to disable parallelisation of dependent
% conjunctions, or switch to the simple calculations for independent
% conjunctions.
:- pred short(char::in, option::out) is semidet.
short('h', help).
short('v', verbosity).
short('V', version).
:- pred long(string::in, option::out) is semidet.
long("help", help).
long("verbosity", verbosity).
long("version", version).
:- pred defaults(option::out, option_data::out) is multi.
defaults(help, bool(no)).
defaults(verbosity, int(2)).
defaults(version, bool(no)).
:- pred post_process_options(string::in,
option_table(option)::in, option_table(option)::out,
io::di, io::uo) is det.
post_process_options(ProgName, !Options, !IO) :-
lookup_int_option(!.Options, verbosity, VerbosityLevel),
io.stderr_stream(Stderr, !IO),
( if VerbosityLevel < 0 then
io.format(Stderr,
"%s: warning: verbosity level should not be negative.\n",
[s(ProgName)], !IO),
set_option(verbosity, int(0), !Options)
else if VerbosityLevel > 4 then
io.format(Stderr,
"%s: warning: verbosity level should not exceed 4.\n",
[s(ProgName)], !IO),
set_option(verbosity, int(4), !Options)
else
true
).
% Set the value of an option in the option table.
%
:- pred set_option(option::in, option_data::in,
option_table(option)::in, option_table(option)::out) is det.
set_option(Option, Value, !Options) :-
map.set(Option, Value, !Options).
%---------------------------------------------------------------------------%
:- end_module mdprof_report_feedback.
%---------------------------------------------------------------------------%