aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-06-01 22:05:01 +0200
committerTristan Gingold <tgingold@free.fr>2020-06-02 03:24:53 +0200
commitb0de47733bf9ee5690fb2bcad919d8d92431b026 (patch)
tree390f521d899407de2ae3eb7566b1ee8e3d084261 /src/grt
parentd667339603a7a3e408b135737b058e2a9976ae44 (diff)
downloadghdl-b0de47733bf9ee5690fb2bcad919d8d92431b026.tar.gz
ghdl-b0de47733bf9ee5690fb2bcad919d8d92431b026.tar.bz2
ghdl-b0de47733bf9ee5690fb2bcad919d8d92431b026.zip
grt: add and document option --asserts
Diffstat (limited to 'src/grt')
-rw-r--r--src/grt/grt-lib.adb26
-rw-r--r--src/grt/grt-options.adb33
-rw-r--r--src/grt/grt-options.ads3
3 files changed, 40 insertions, 22 deletions
diff --git a/src/grt/grt-lib.adb b/src/grt/grt-lib.adb
index 3bd3440ec..9908d581c 100644
--- a/src/grt/grt-lib.adb
+++ b/src/grt/grt-lib.adb
@@ -27,7 +27,7 @@ with Interfaces;
with Grt.Errors; use Grt.Errors;
with Grt.Errors_Exec; use Grt.Errors_Exec;
with Grt.Severity;
-with Grt.Options;
+with Grt.Options; use Grt.Options;
with Grt.Fcvt;
with Grt.Backtraces;
@@ -96,25 +96,28 @@ package body Grt.Lib is
end if;
end Do_Report;
+ function Is_Assert_Disabled (Policy : Assert_Handling) return Boolean is
+ begin
+ return Policy = Disable_Asserts
+ or else (Policy = Disable_Asserts_At_Time_0 and Current_Time = 0);
+ end Is_Assert_Disabled;
+
procedure Ghdl_Assert_Failed
- (Str : Std_String_Ptr; Severity : Integer; Loc : Ghdl_Location_Ptr)
- is
+ (Str : Std_String_Ptr; Severity : Integer; Loc : Ghdl_Location_Ptr) is
begin
+ if Is_Assert_Disabled (Asserts_Policy) then
+ return;
+ end if;
Do_Report ("assertion", Str, "Assertion violation", Severity, Loc);
end Ghdl_Assert_Failed;
procedure Ghdl_Ieee_Assert_Failed
- (Str : Std_String_Ptr; Severity : Integer; Loc : Ghdl_Location_Ptr)
- is
- use Grt.Options;
+ (Str : Std_String_Ptr; Severity : Integer; Loc : Ghdl_Location_Ptr) is
begin
- if Ieee_Asserts = Disable_Asserts
- or else (Ieee_Asserts = Disable_Asserts_At_Time_0 and Current_Time = 0)
- then
+ if Is_Assert_Disabled (Ieee_Asserts) then
return;
- else
- Do_Report ("assertion", Str, "Assertion violation", Severity, Loc);
end if;
+ Do_Report ("assertion", Str, "Assertion violation", Severity, Loc);
end Ghdl_Ieee_Assert_Failed;
procedure Ghdl_Psl_Assert_Failed
@@ -290,7 +293,6 @@ package body Grt.Lib is
procedure Ghdl_Check_Stack_Allocation (Size : Ghdl_Index_Type)
is
- use Options;
Bt : Backtrace_Addrs;
begin
if Max_Stack_Allocation = 0 then
diff --git a/src/grt/grt-options.adb b/src/grt/grt-options.adb
index 097a9d6da..eadca0068 100644
--- a/src/grt/grt-options.adb
+++ b/src/grt/grt-options.adb
@@ -73,7 +73,8 @@ package body Grt.Options is
P (" LEVEL is note,warning,error,failure,none");
P (" --backtrace-severity=LEVEL display a backtrace for assertions");
P (" --ieee-asserts=POLICY enable or disable asserts from IEEE");
- P (" POLICY is enable,disable,disable-at-0");
+ P (" POLICY is enable, disable, disable-at-0");
+ P (" --asserts=POLICY enable or disable asserts");
P (" --stop-time=X stop the simulation at time X");
P (" X is expressed as a time value, without spaces: 1ns, ps...");
P (" --stop-delta=X stop the simulation cycle after X delta");
@@ -212,6 +213,23 @@ package body Grt.Options is
end if;
end Parse_Severity;
+ function Parse_Policy (Opt_Name : String; Arg : String)
+ return Assert_Handling is
+ begin
+ if Arg = "disable" then
+ return Disable_Asserts;
+ elsif Arg = "enable" then
+ return Enable_Asserts;
+ elsif Arg = "disable-at-0" then
+ return Disable_Asserts_At_Time_0;
+ else
+ Error_S ("bad argument for ");
+ Diag_C (Opt_Name);
+ Error_E (" option, try --help");
+ return Enable_Asserts;
+ end if;
+ end Parse_Policy;
+
procedure Decode_Option
(Option : String; Status : out Decode_Option_Status)
is
@@ -305,15 +323,10 @@ package body Grt.Options is
end if;
end;
elsif Len > 15 and then Option (1 .. 15) = "--ieee-asserts=" then
- if Option (16 .. Len) = "disable" then
- Ieee_Asserts := Disable_Asserts;
- elsif Option (16 .. Len) = "enable" then
- Ieee_Asserts := Enable_Asserts;
- elsif Option (16 .. Len) = "disable-at-0" then
- Ieee_Asserts := Disable_Asserts_At_Time_0;
- else
- Error ("bad argument for --ieee-asserts option, try --help");
- end if;
+ Ieee_Asserts := Parse_Policy ("--ieee-asserts", Option (16 .. Len));
+ elsif Len > 10 and then Option (1 .. 10) = "--asserts=" then
+ Asserts_Policy := Parse_Policy ("--asserts", Option (11 .. Len));
+ Ieee_Asserts := Asserts_Policy;
elsif Option = "--expect-failure" then
Expect_Failure := True;
elsif Len >= 13 and then Option (1 .. 13) = "--stack-size=" then
diff --git a/src/grt/grt-options.ads b/src/grt/grt-options.ads
index 495391e43..a0fb57177 100644
--- a/src/grt/grt-options.ads
+++ b/src/grt/grt-options.ads
@@ -135,6 +135,9 @@ package Grt.Options is
-- Handling of assertions from IEEE library.
Ieee_Asserts : Assert_Handling := Enable_Asserts;
+ -- Handling of assertions (except from IEEE library).
+ Asserts_Policy : Assert_Handling := Enable_Asserts;
+
-- Set by --stop-delta=XXX to stop the simulation after XXX delta cycles.
Stop_Delta : Natural := 5000;