mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 05:13:48 +00:00
Estimated hours taken: 8 Ensure that all names are properly demangled, both by mdemangle and in the profiler. util/mdemangle.c: Add code to demangle the special-case names properly. tests/misc_tests/mdemangle_test.inp: tests/misc_tests/mdemangle_test.exp: Modify the expected output to reflect the bug fix to util/demangle.c. profiler/demangle.m: New module: contains a procedure for demangling Mercury labels. profiler/demangle_test.m: Test harness for demangle.m. Duplicates the functionality of util/demangle.c. (Currently not used for anything except testing, but we might one day want to use this code to replace util/demangle.c) profiler/read.m: Use the code in demangle.m to demangle labels. profiler/output.m: Output the alphabetic listing using one column rather than two, since the demangled names are often too long to fit in a two-column format. profiler/options.m: profiler/prof_info.m: Remove some unnecessary `import_module' declarations. compiler/unused_args.m: Fix a bug in the mangling of predicate names for unused-arg versions of special preds (index, compare, unify).
77 lines
2.3 KiB
Mathematica
77 lines
2.3 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
%
|
|
% Copyright (C) 1997 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: demangle_test.m
|
|
% Author: fjh
|
|
%
|
|
% Front-end to a mercury symbol demangler.
|
|
% This is used to convert error messages from the linker back
|
|
% into a form that users can understand.
|
|
%
|
|
% BEWARE:
|
|
% The code here duplicates the functionality of util/mdemangle.c.
|
|
% Any changes here will require corresponding changes there.
|
|
%
|
|
% We might eventually replace util/mdemangle.c with this Mercury version.
|
|
%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module demangle_test.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
:- pred main(state::di, state::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module demangle.
|
|
:- import_module list, char, string.
|
|
|
|
main -->
|
|
io__command_line_arguments(Args),
|
|
( { Args \= [] } ->
|
|
%
|
|
% invoke demangle/2 on each command line argument
|
|
%
|
|
{ list__map(demangle, Args, DemangledArgs) },
|
|
io__write_list(DemangledArgs, "\n", io__write_string), io__nl
|
|
;
|
|
%
|
|
% copy stdin to stdout, calling demangle/2 for
|
|
% every valid C identifier in the input
|
|
%
|
|
demangle_stdin([])
|
|
).
|
|
|
|
:- pred demangle_stdin(list(char)::in, state::di, state::uo) is det.
|
|
demangle_stdin(RevChars) -->
|
|
io__read_char(Result),
|
|
( { Result = ok(Char) },
|
|
( { char__is_alnum_or_underscore(Char) } ->
|
|
demangle_stdin([Char | RevChars])
|
|
;
|
|
{ string__from_rev_char_list(RevChars, MangledName) },
|
|
{ demangle(MangledName, DemangledName) },
|
|
io__write_string(DemangledName),
|
|
io__write_char(Char),
|
|
demangle_stdin([])
|
|
)
|
|
; { Result = eof },
|
|
{ string__from_rev_char_list(RevChars, MangledName) },
|
|
{ demangle(MangledName, DemangledName) },
|
|
io__write_string(DemangledName)
|
|
; { Result = error(Error) },
|
|
{ io__error_message(Error, Message) },
|
|
io__input_stream_name(StreamName),
|
|
io__progname("demangle_test", ProgName),
|
|
io__write_strings([ProgName, ": ",
|
|
"error reading input file `", StreamName, "': \n\t",
|
|
Message, "\n"])
|
|
).
|
|
|
|
%-----------------------------------------------------------------------------%
|