Skip to content

Commit 2bee2eb

Browse files
committed
Merge branch 'pmderodat/error' into 'master'
Display which SID/checkpoint is being loaded in case of internal error Closes #110 See merge request eng/cov/gnatcoverage!241 Closes eng/cov/gnatcoverage#110
2 parents 13dcd3e + 47e2f82 commit 2bee2eb

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

testsuite/tests/TC11-052-internal-error/test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import re
66
import os
77

8+
from SCOV.minicheck import build_and_run
89
from SUITE.context import thistest
910
from SUITE.cutils import Wdir, contents_of
11+
from SUITE.gprutils import GPRswitches
1012
from SUITE.tutils import gprfor, xcov
1113

1214

@@ -81,4 +83,19 @@ def check(args, trigger, info):
8183
trigger="ada-instrument-insert-stmt-witness",
8284
info=r"Instrumenting ConcreteTypeDecl at [^\n]*main\.adb:6:4-6:26")
8385

86+
# Instrument the example project, run its main to produce a source trace and
87+
# then trigger an internal error while loading the SID file.
88+
xcov_args = build_and_run(
89+
gprsw=GPRswitches(root_project=prj),
90+
covlevel="stmt",
91+
mains=["main"],
92+
extra_coverage_args=[],
93+
trace_mode="src",
94+
)
95+
check(
96+
args=xcov_args,
97+
trigger="load-checkpoint",
98+
info="Loading [^\n]*main\.sid",
99+
)
100+
84101
thistest.result()

tools/gnatcov/checkpoints.adb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,19 @@ package body Checkpoints is
548548
Purpose : Checkpoint_Purpose;
549549
Ignored_Source_Files : access GNAT.Regexp.Regexp)
550550
is
551+
Dummy : constant Context_Handle :=
552+
Create_Context ("Loading " & Filename);
551553
SF : Ada.Streams.Stream_IO.File_Type;
552554
CP_Header : Checkpoint_Header;
553555
Levels : Levels_Type;
554556
begin
555557
Open (SF, In_File, Filename);
556558

559+
-- If requested, create an artificial internal error when loading
560+
-- checkpoints.
561+
562+
Raise_Stub_Internal_Error_For (Load_Checkpoint);
563+
557564
declare
558565
CLS : aliased Checkpoint_Load_State :=
559566
(Root_Stream_Type with

tools/gnatcov/outputs.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ package Outputs is
101101
Arguments_Loading,
102102
-- Raise an error after Argparse's work and before loading arguments
103103

104+
Load_Checkpoint,
105+
-- Raise an error when loading a checkpoint
106+
104107
Ada_Instrument_Start_File,
105108
-- Raise an error when starting the instrumentation of a source file
106109

0 commit comments

Comments
 (0)