Skip to content

Commit c8f8386

Browse files
committed
Modify 'cpp_demangle' callback options to use "-Xlinker' list append
behaviour - to make consistent with other callback arguments. "--demangle-cpp" parameter is optional, and defaults to "c++filt" if not specified. Note that this _does_ affect tool behaviour in uses such as: genhtml -o html_dir --demangele-cpp myData.info # genhtml will complain that tool 'myData.info' does not exist # or cannot be called, and that no tracefile has been specified. If this happens, change the command line to: genhtml -o html_dir --demangle-cpp -- myData.info Deprecate RC file parameters 'genthml_demangle_cpp_tool' and 'genhtml_demangle_cpp_params'. Signed-off-by: Henry Cox <[email protected]>
1 parent b0d143a commit c8f8386

File tree

10 files changed

+204
-104
lines changed

10 files changed

+204
-104
lines changed

bin/genhtml

+4-1
Original file line numberDiff line numberDiff line change
@@ -5051,6 +5051,9 @@ my %genhtml_rc_opts = (
50515051
"genhtml_flat_view" => \$flat,
50525052
"genhtml_show_havigation" => \$show_tla,
50535053
"genhtml_show_function_proportion" => \$show_functionProportions,
5054+
"genhtml_demangle_cpp" => \@lcovutil::cpp_demangle,
5055+
"genhtml_demangle_cpp_tool" => \$lcovutil::cpp_demangle_tool,
5056+
"genhtml_demangle_cpp_params" => \$lcovutil::cpp_demangle_params,
50545057
'genhtml_annotate_script' => \@rc_annotate_script,
50555058
'genhtml_criteria_script' => \@rc_criteria_script,
50565059
'criteria_callback_data' => \@criteriaCallbackTypes,
@@ -5542,7 +5545,7 @@ HTML OUTPUT
55425545
--html-extension EXT Use EXT as filename extension for pages
55435546
--html-gzip Use gzip to compress HTML
55445547
--(no-)sort Enable (disable) sorted coverage views
5545-
--demangle-cpp Demangle C++ function names
5548+
--demangle-cpp [OPT] Demangle C++ function names
55465549
--precision NUM Set precision of coverage rate
55475550
--missed Show miss counts as negative numbers
55485551
--dark-mode Use the dark-mode CSS

bin/geninfo

+9-6
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,12 @@ OPTIONS
667667
--(no-)checksum Enable (disable) line checksumming
668668
--(no-)compat-libtool Enable (disable) libtool compatibility mode
669669
--gcov-tool TOOL Specify gcov tool location
670+
--ignore-errors ERROR Continue after ERROR (gcov, source, graph)
671+
--keep-going Do not stop if error occurs. Try to
672+
produce a result
670673
--filter TYPE Apply FILTERS to input data (see man page
671674
for full list of filters and their effects)
672-
--demangle-cpp Demangle C++ function names
675+
--demangle-cpp [PARAM] Demangle C++ function names
673676
--no-recursion Exclude subdirectories from processing
674677
--no-markers Ignore exclusion markers in source code
675678
--derive-func-data Generate function data from line data
@@ -1817,7 +1820,7 @@ sub read_gcov_file($$$)
18171820
my $branchId;
18181821
my $unexec;
18191822

1820-
my $f = InOutFile->in($filename, $lcovutil::cpp_demangle);
1823+
my $f = InOutFile->in($filename, $lcovutil::demangle_cpp_cmd);
18211824
my $input = $f->hdl();
18221825

18231826
my $currentBlock;
@@ -2016,7 +2019,7 @@ sub read_intermediate_text($$)
20162019
my ($gcov_filename, $data) = @_;
20172020
my $filename;
20182021

2019-
my $f = InOutFile->in($gcov_filename, $lcovutil::cpp_demangle);
2022+
my $f = InOutFile->in($gcov_filename, $lcovutil::demangle_cpp_cmd);
20202023
my $h = $f->hdl();
20212024
while (my $line = <$h>) {
20222025
if ($line =~ /^file:(.*)$/) {
@@ -2241,7 +2244,7 @@ sub intermediate_json_to_info($)
22412244
my $end_line = $d->{"end_line"}
22422245
if exists($d->{end_line});
22432246
my $count = $d->{"execution_count"};
2244-
my $name = $lcovutil::cpp_demangle ? $d->{demangled_name} :
2247+
my $name = $lcovutil::demangle_cpp_cmd ? $d->{demangled_name} :
22452248
$d->{"name"};
22462249

22472250
if ($count < 0) {
@@ -2792,7 +2795,7 @@ sub process_graphfile($$)
27922795
$linedata = $funcdata->{$func};
27932796
my $lineNo = $linedata->[0];
27942797
my $fnName =
2795-
filter_fn_name($func, defined($lcovutil::cpp_demangle));
2798+
filter_fn_name($func, defined($lcovutil::demangle_cpp_cmd));
27962799
my $func =
27972800
$functionMap->define_function($fnName, $filename, $lineNo);
27982801
$func->addAlias($fnName, 0);
@@ -2814,7 +2817,7 @@ sub filter_fn_name($$)
28142817
my ($fn, $demangle) = @_;
28152818
my $f;
28162819
if ($demangle) {
2817-
$f = `$lcovutil::cpp_demangle $fn`;
2820+
$f = `$lcovutil::demangle_cpp_cmd $fn`;
28182821
chomp($f);
28192822
die("unable to demangle '$fn': $!") if ($?);
28202823
} else {

bin/lcov

+2-2
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ sub lcov_geninfo(@)
829829
if ($follow) {
830830
push(@param, "--follow");
831831
}
832-
if ($lcovutil::cpp_demangle) {
833-
push(@param, "--demangle-cpp");
832+
foreach my $param (@lcovutil::cpp_demangle) {
833+
push(@param, "--demangle-cpp", $param);
834834
}
835835
if ($lcovutil::verbose != 0) {
836836
if ($lcovutil::verbose < 0) {

lcovrc

+5-2
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ genhtml_desc_html=0
189189
#trivial_function_threshold = 5
190190

191191
# Demangle C++ symbols
192-
#genhtml_demangle_cpp=1
192+
# Call multiple times to specify command and command line arguments
193+
# ('-Xlinker'-like behaviour)
194+
#demangle_cpp = c++filt
193195

194196
# Name of the tool used for demangling C++ function names
197+
# This argument is deprecated - please use 'demangle_cpp' instead
195198
#genhtml_demangle_cpp_tool = c++filt
196-
197199
# Specify extra parameters to be passed to the demangling tool
200+
# This argument is deprecated - please use 'demangle_cpp' instead
198201
#genhtml_demangle_cpp_params = ""
199202

200203
# Location of the gcov tool (same as --gcov-info option of geninfo)

lib/lcovutil.pm

+52-28
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ our @EXPORT_OK = qw($tool_name $tool_dir $lcov_version $lcov_url
3535
@file_subst_patterns subst_file_name
3636
3737
$br_coverage $func_coverage
38-
$cpp_demangle $cpp_demangle_tool $cpp_demangle_params do_mangle_check
38+
@cpp_demangle do_mangle_check $demangle_cpp_cmd
39+
$cpp_demangle_tool $cpp_demangle_params
3940
4041
$FILTER_BRANCH_NO_COND $FILTER_FUNCTION_ALIAS
4142
$FILTER_EXCLUDE_REGION $FILTER_EXCLUDE_BRANCH $FILTER_LINE
@@ -147,9 +148,12 @@ our $opt_no_external;
147148
our @file_subst_patterns;
148149

149150
# C++ demangling
150-
our $cpp_demangle;
151-
our $cpp_demangle_tool = "c++filt"; # Default demangler for C++ function names
152-
our $cpp_demangle_params = ""; # Extra parameters for demangling
151+
our @cpp_demangle; # the options passed in
152+
our $demangle_cpp_cmd; # the computed command string
153+
# deprecated: demangler for C++ function names is c++filt
154+
our $cpp_demangle_tool;
155+
# Deprecated: prefer -Xlinker approach with @cpp_dmangle_tool
156+
our $cpp_demangle_params;
153157

154158
our @extractVersionScript; # script/callback to find version ID of file
155159
our $verify_checksum; # compute and/or check MD5 sum of source code lines
@@ -653,22 +657,41 @@ sub set_c_extensions
653657

654658
sub do_mangle_check
655659
{
656-
return unless $lcovutil::cpp_demangle;
657-
$lcovutil::cpp_demangle = $lcovutil::cpp_demangle_tool;
658-
$lcovutil::cpp_demangle .= ' ' . $lcovutil::cpp_demangle_params
659-
if '' ne $lcovutil::cpp_demangle_params;
660-
$lcovutil::cpp_demangle =~ s/^\s*(\S+)\s*$/$1/;
661-
662-
my @params = split(" ", $lcovutil::cpp_demangle);
663-
my $tool = $params[0];
664-
die("ERROR: could not find $tool tool needed for --demangle-cpp")
665-
if (lcovutil::system_no_output(3, "echo \"\" | $tool"));
660+
return unless @lcovutil::cpp_demangle;
666661

662+
if (1 == scalar(@lcovutil::cpp_demangle)) {
663+
if ('' eq $lcovutil::cpp_demangle[0]) {
664+
# no demangler specified - use c++filt by default
665+
if (defined($lcovutil::cpp_demangle_tool)) {
666+
$lcovutil::cpp_demangle[0] = $lcovutil::cpp_demangle_tool;
667+
} else {
668+
$lcovutil::cpp_demangle[0] = 'c++filt';
669+
}
670+
}
671+
} elsif (1 < scalar(@lcovutil::cpp_demangle)) {
672+
die("unsupported usage: --demangle-cpp with genhtml_demangle_cpp_tool")
673+
if (defined($lcovutil::cpp_demangle_tool));
674+
die(
675+
"unsupported usage: --demangle-cpp with genhtml_demangle_cpp_params")
676+
if (defined($lcovutil::cpp_demangle_params));
677+
}
678+
if ($lcovutil::cpp_demangle_params) {
679+
# deprecated usage
680+
push(@lcovutil::cpp_demangle,
681+
split(' ', $lcovutil::cpp_demangle_params));
682+
}
667683
# Extra flag necessary on OS X so that symbols listed by gcov get demangled
668684
# properly.
669-
$lcovutil::cpp_demangle .= " --no-strip-underscores"
670-
if (scalar(@params) == 1 &&
671-
$^ eq "darwin");
685+
push(@lcovutil::cpp_demangle, '--no-strip-underscores')
686+
if ($^ eq "darwin");
687+
688+
$lcovutil::demangle_cpp_cmd = '';
689+
foreach my $e (@lcovutil::cpp_demangle) {
690+
$lcovutil::demangle_cpp_cmd .= (($e =~ /\s/) ? "'$e'" : $e) . ' ';
691+
}
692+
my $tool = $lcovutil::cpp_demangle[0];
693+
die("ERROR: could not find $tool tool needed for --demangle-cpp")
694+
if (lcovutil::system_no_output(3, "echo \"\" | '$tool'"));
672695
}
673696

674697
#
@@ -805,7 +828,10 @@ our @opt_config_files;
805828
our @opt_ignore_errors;
806829
our @opt_filter;
807830

808-
my %deprecated_rc = ("geninfo_checksum" => "checksum",
831+
my %deprecated_rc = ("genhtml_demangle_cpp" => "demangle_cpp",
832+
"genhtml_demangle_cpp_tool" => "demangle_cpp",
833+
"genhtml_demangle_cpp_params" => "demangle_cpp",
834+
"geninfo_checksum" => "checksum",
809835
"geninfo_no_exception_branch" => "no_exception_branch",
810836
"lcov_branch_coverage" => "branch_coverage",
811837
"lcov_function_coverage" => "function_coverage",
@@ -856,9 +882,7 @@ my %rc_common = (
856882
"forget_testcase_names" => \$TraceFile::ignore_testcase_name,
857883
"split_char" => \$lcovutil::split_char,
858884

859-
"genhtml_demangle_cpp" => \$lcovutil::cpp_demangle,
860-
"genhtml_demangle_cpp_tool" => \$lcovutil::cpp_demangle_tool,
861-
"genhtml_demangle_cpp_params" => \$lcovutil::cpp_demangle_params,
885+
"demangle_cpp" => \@lcovutil::cpp_demangle,
862886

863887
);
864888

@@ -878,7 +902,7 @@ our %argCommon = ("tempdir=s" => \$tempdirname,
878902
"no-branch-coverage" => \$rc_no_branch_coverage,
879903

880904
"filter=s" => \@opt_filter,
881-
"demangle-cpp" => \$lcovutil::cpp_demangle,
905+
"demangle-cpp:s" => \@lcovutil::cpp_demangle,
882906
"ignore-errors=s" => \@opt_ignore_errors,
883907
"keep-going" => \$keepGoing,
884908
"config-file=s" => \@unsupported_config,
@@ -1805,14 +1829,14 @@ sub out
18051829
if (!defined($f) ||
18061830
'-' eq $f) {
18071831
if ($demangle) {
1808-
open(HANDLE, '|-', $lcovutil::cpp_demangle) or
1832+
open(HANDLE, '|-', $lcovutil::demangle_cpp_cmd) or
18091833
die("Error: unable to demangle: $!\n");
18101834
$self->[0] = \*HANDLE;
18111835
} else {
18121836
$self->[0] = \*STDOUT;
18131837
}
18141838
} else {
1815-
my $cmd = $demangle ? "$lcovutil::cpp_demangle " : '';
1839+
my $cmd = $demangle ? "$lcovutil::demangle_cpp_cmd " : '';
18161840
if ($f =~ /\.gz$/) {
18171841
checkGzip()
18181842
unless defined($checkedGzipAvail);
@@ -1862,14 +1886,14 @@ sub in
18621886

18631887
# Open compressed file
18641888
my $cmd = "gzip -cd '$f'";
1865-
$cmd .= " | " . $lcovutil::cpp_demangle
1889+
$cmd .= " | " . $lcovutil::demangle_cpp_cmd
18661890
if ($demangle);
18671891
open(HANDLE, "-|", $cmd) or
18681892
die("ERROR: cannot start gunzip to decompress file $f: $!\n");
18691893

18701894
} elsif ($demangle &&
1871-
defined($lcovutil::cpp_demangle)) {
1872-
open(HANDLE, "-|", "cat '$f' | $lcovutil::cpp_demangle") or
1895+
defined($lcovutil::demangle_cpp_cmd)) {
1896+
open(HANDLE, "-|", "cat '$f' | $lcovutil::demangle_cpp_cmd") or
18731897
die("ERROR: cannot start demangler for file $f: $!\n");
18741898
} else {
18751899
# Open decompressed file
@@ -4385,7 +4409,7 @@ sub _read_info
43854409
}
43864410

43874411
# Check for .gz extension
4388-
my $inFile = InOutFile->in($tracefile, $lcovutil::cpp_demangle);
4412+
my $inFile = InOutFile->in($tracefile, $lcovutil::demangle_cpp_cmd);
43894413
my $infoHdl = $inFile->hdl();
43904414

43914415
$testname = "";

man/genhtml.1

+19-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ genhtml \- Generate HTML view from LCOV coverage data files
7474
.RB [ \-\-branch\-coverage ]
7575
.RB [ \-\-no\-branch\-coverage ]
7676
.br
77-
.RB [ \-\-demangle\-cpp ]
77+
.RB [ \-\-demangle\-cpp
78+
.IR [ param ] ]
7879
.br
7980
.RB [ \-\-ignore\-errors
8081
.IR errors ]
@@ -1914,15 +1915,30 @@ option
19141915
.IR genhtml_branch_coverage .
19151916

19161917
.RE
1917-
.B \-\-demangle\-cpp
1918+
.B \-\-demangle\-cpp [param]
19181919
.RS
19191920
Specify whether to demangle C++ function names.
19201921

19211922
Use this option if you want to convert C++ internal function names to
19221923
human readable format for display on the HTML function overview page.
1923-
This option requires that the c++filt tool is installed (see
1924+
1925+
If called with no parameters, genhtml will use
1926+
.I c++filt
1927+
for demangling. This requires that the c++filt tool is installed (see
19241928
.BR c++filt (1)).
19251929

1930+
If
1931+
.I param
1932+
is specified, it is treated as th tool to call to demangle source code.
1933+
The
1934+
.I \-\-demangle\-cpp
1935+
option can be used multiple times to specify the demangling tool and a set of
1936+
command line options that are passed to the tool - similar to how the gcc
1937+
.I -Xlinker
1938+
paramter works. In that case, you callback will be executed as:
1939+
.I | demangle_param0 demangle_param1 ...
1940+
Note that the demangle tool is called as a pipe and is expected to read from stdin and write to stdout.
1941+
19261942
.RE
19271943
.B \-\-ignore\-errors
19281944
.I errors

man/geninfo.1

+7-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ geninfo \- Generate tracefiles from GCOV coverage data files
5757
.RB [ \-\-filter
5858
.IR type ]
5959
.br
60-
.RB [ \-\-demangle\-cpp ]
60+
.RB [ \-\-demangle\-cpp [param]]
6161
.br
6262
.RB [ \-\-no\-recursion ]
6363
.RB [ \-\-external ]
@@ -701,6 +701,11 @@ corrupt/unreadable file found.
701701
An excessive number of messages of some class have been reported - subsequent messages of that type will be suppressed.
702702
The limit can be controlled by the 'max_message_count' variable. See the lcovrc man page.
703703

704+
.B deprecated:
705+
You are using a deprecated option.
706+
This option will be removed in an upcoming release - so you should change your
707+
scripts now.
708+
704709
.B empty:
705710
the .info data file is empty (e.g., because all the code was 'removed' or excluded.
706711

@@ -788,7 +793,7 @@ Specify a list of coverpoint filters to apply to input data.
788793
See the genhtml man page for details.
789794

790795
.RE
791-
.BI "\-\-demangle\-cpp "
796+
.BI "\-\-demangle\-cpp [param]"
792797
.RS
793798
Demangle C++ method and function names in captured output.
794799
See the genhtml man page for details.

man/lcov.1

+7-1
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,11 @@ corrupt/unreadable file found.
924924
An excessive number of messages of some class have been reported - subsequent messages of that type will be suppressed.
925925
The limit can be controlled by the 'max_message_count' variable. See the lcovrc man page.
926926

927+
.B deprecated:
928+
You are using a deprecated option.
929+
This option will be removed in an upcoming release - so you should change your
930+
scripts now.
931+
927932
.B empty:
928933
the .info data file is empty (e.g., because all the code was 'removed' or excluded.
929934

@@ -1001,7 +1006,8 @@ See the genhtml man page for details.
10011006

10021007

10031008
.RE
1004-
.BI "\-\-demangle\-cpp "
1009+
.BI "\-\-demangle\-cpp [param]"
1010+
.I
10051011
.RS
10061012
Demangle C++ function names. See the genhtml man page for details.
10071013

0 commit comments

Comments
 (0)