Skip to content

Commit 2119a1c

Browse files
committed
Add support for --restricted-to-languages to gnatcov coverage
To avoid spurious warnings such as "no SID file found for unit <bla>" at gnatcov coverage time for units in a language that was ignored at instrumentation time by using the --restricted-to-languages switch.
1 parent 8de347f commit 2119a1c

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

testsuite/tests/instr-cov/main_autodump/disabled_lang/test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
covlevel="stmt",
2323
mains=["main"],
2424
extra_instr_args=["--restricted-to-languages=C"],
25-
extra_coverage_args=["-axcov", "--output-dir=xcov"],
25+
extra_coverage_args=[
26+
"-axcov",
27+
"--output-dir=xcov",
28+
"--restricted-to-languages=C",
29+
],
2630
trace_mode="src",
2731
)
2832
check_xcov_reports("xcov", {"tested.c.xcov": {"+": {5}, "-": {7}}})
@@ -39,7 +43,11 @@
3943
covlevel="stmt",
4044
mains=["main"],
4145
extra_instr_args=["--restricted-to-languages=Ada"],
42-
extra_coverage_args=["-axcov", "--output-dir=xcov"],
46+
extra_coverage_args=[
47+
"-axcov",
48+
"--output-dir=xcov",
49+
"--restricted-to-languages=Ada",
50+
],
4351
trace_mode="src",
4452
)
4553
check_xcov_reports(

tools/gnatcov/command_line.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,8 @@ package Command_Line is
15861586
& " C and C++. Note that main units of other languages may still be"
15871587
& " instrumented to dump the coverage state to trace files.",
15881588
Commands => (Cmd_Setup
1589-
| Cmd_Instrument_Project => True,
1589+
| Cmd_Instrument_Project
1590+
| Cmd_Coverage => True,
15901591
others => False),
15911592
Internal => False,
15921593
Accepts_Comma_Separator => True),

tools/gnatcov/project.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ package body Project is
366366
if Unit.Warned_About_Missing_Info
367367
or else (Currently_Accepted_Trace_Kind = Binary_Trace_File
368368
and then Unit.Language = CPP_Language)
369+
370+
-- Ignore units in a language that is ignored through the
371+
-- --restricted-to-languages switch.
372+
373+
or else not Src_Enabled_Languages (Unit.Language)
369374
then
370375
return;
371376
end if;

tools/gnatcov/setup_rts.adb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ package body Setup_RTS is
121121
-- Load the project file at Project_File using the Target/RTS/Config_File
122122
-- parameters, then try to guess the profile of the actual runtime in
123123
-- effect (Auto_RTS_Profile) and determine the support for libraries for
124-
-- this configuration (Lib_Support).
124+
-- this configuration (Lib_Support). Pass Db_Dir as an additional knowledge
125+
-- base. when creating the configuration file.
125126
--
126127
-- Set Actual_Target, Actual_RTS_Dir and Actual_RTS_Name to the actual
127128
-- target/RTS names for the loaded project: they can be different from

tools/gnatcov/switches.ads

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ package Switches is
223223

224224
Src_Enabled_Languages : array (Src_Supported_Language) of Boolean :=
225225
(others => False);
226-
-- List of languages for which source files should be instrumented.
227-
-- Initialized during command line arguments parsing.
226+
-- List of languages for which coverage analysis is enabled. Initialized
227+
-- during command line arguments parsing.
228228

229229
Builtin_Support : array (Src_Supported_Language) of Boolean :=
230230
(others => True);

0 commit comments

Comments
 (0)