aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-05-20 18:16:34 +0200
committerTristan Gingold <tgingold@free.fr>2019-05-21 20:41:20 +0200
commit4a850818bc1c674d6b4e9c4bcc44ee6bbaa13ffc (patch)
tree39db5b4ffd9706d6718bf03fa5d77936aa9dad57 /src
parentfea04f795271db8fc56655bdade20174efca8fbb (diff)
downloadghdl-4a850818bc1c674d6b4e9c4bcc44ee6bbaa13ffc.tar.gz
ghdl-4a850818bc1c674d6b4e9c4bcc44ee6bbaa13ffc.tar.bz2
ghdl-4a850818bc1c674d6b4e9c4bcc44ee6bbaa13ffc.zip
errorout-memory: handle message groups; adjust python
Diffstat (limited to 'src')
-rw-r--r--src/errorout-memory.adb38
-rw-r--r--src/errorout-memory.ads27
-rw-r--r--src/vhdl/python/libghdl/thin/errorout.py10
-rw-r--r--src/vhdl/python/libghdl/thin/errorout_memory.py20
-rwxr-xr-xsrc/vhdl/python/pnodespy.py11
5 files changed, 76 insertions, 30 deletions
diff --git a/src/errorout-memory.adb b/src/errorout-memory.adb
index 3bebfb4bc..c0e6cd1df 100644
--- a/src/errorout-memory.adb
+++ b/src/errorout-memory.adb
@@ -29,7 +29,7 @@ package body Errorout.Memory is
Table_Initial => 128);
type Error_Element is record
- Header : Error_Record;
+ Header : Error_Message;
Str : Char_Index;
end record;
@@ -39,12 +39,14 @@ package body Errorout.Memory is
Table_Low_Bound => 1,
Table_Initial => 32);
+ Group : Group_Type;
+
function Get_Nbr_Messages return Error_Index is
begin
return Errors.Last;
end Get_Nbr_Messages;
- function Get_Error_Record (Idx : Error_Index) return Error_Record is
+ function Get_Error_Record (Idx : Error_Index) return Error_Message is
begin
return Errors.Table (Idx).Header;
end Get_Error_Record;
@@ -76,9 +78,20 @@ package body Errorout.Memory is
Nbr_Errors := 0;
end Clear_Errors;
- procedure Memory_Error_Start (E : Error_Record) is
+ procedure Memory_Error_Start (E : Error_Record)
+ is
+ Msg : constant Error_Message :=
+ (Id => E.Id,
+ Group => Group,
+ File => E.File,
+ Line => E.Line,
+ Offset => E.Offset,
+ Length => E.Length);
begin
- Errors.Append ((E, Messages.Last + 1));
+ Errors.Append ((Msg, Messages.Last + 1));
+ if Group = Msg_Main then
+ Group := Msg_Related;
+ end if;
end Memory_Error_Start;
procedure Memory_Message (Str : String) is
@@ -95,7 +108,21 @@ package body Errorout.Memory is
procedure Memory_Message_Group (Start : Boolean) is
begin
- null;
+ if Start then
+ pragma Assert (Group = Msg_Single);
+ Group := Msg_Main;
+ else
+ pragma Assert (Group /= Msg_Single);
+ case Errors.Table (Errors.Last).Header.Group is
+ when Msg_Single | Msg_Last =>
+ raise Internal_Error;
+ when Msg_Main =>
+ Errors.Table (Errors.Last).Header.Group := Msg_Single;
+ when Msg_Related =>
+ Errors.Table (Errors.Last).Header.Group := Msg_Last;
+ end case;
+ Group := Msg_Single;
+ end if;
end Memory_Message_Group;
procedure Install_Handler is
@@ -104,6 +131,7 @@ package body Errorout.Memory is
Memory_Message'Access,
Memory_Message_End'Access,
Memory_Message_Group'Access));
+ Group := Msg_Single;
end Install_Handler;
end Errorout.Memory;
diff --git a/src/errorout-memory.ads b/src/errorout-memory.ads
index 4c638671e..9d1238b01 100644
--- a/src/errorout-memory.ads
+++ b/src/errorout-memory.ads
@@ -21,12 +21,37 @@ with System;
package Errorout.Memory is
type Error_Index is new Uns32;
+ type Group_Type is (Msg_Single,
+ Msg_Main, Msg_Related, Msg_Last);
+
+ type Error_Message is record
+ -- Message error/warning id
+ Id : Msgid_Type;
+
+ -- Whether this is an single message or a related one.
+ Group : Group_Type;
+
+ -- Error soure file.
+ File : Source_File_Entry;
+
+ -- The first line is line 1, 0 can be used when line number is not
+ -- relevant.
+ Line : Natural;
+
+ -- Offset in the line. The first character is at offset 0.
+ Offset : Natural;
+
+ -- Length of the location (for a range). It is assumed to be on the
+ -- same line; use 0 when unknown.
+ Length : Natural;
+ end record;
+
-- Get number of messages available.
function Get_Nbr_Messages return Error_Index;
-- Get messages.
-- Idx is from 1 to Nbr_Messages.
- function Get_Error_Record (Idx : Error_Index) return Error_Record;
+ function Get_Error_Record (Idx : Error_Index) return Error_Message;
function Get_Error_Message (Idx : Error_Index) return String;
function Get_Error_Message_Addr (Idx : Error_Index) return System.Address;
diff --git a/src/vhdl/python/libghdl/thin/errorout.py b/src/vhdl/python/libghdl/thin/errorout.py
index f059d99cc..5a79a5534 100644
--- a/src/vhdl/python/libghdl/thin/errorout.py
+++ b/src/vhdl/python/libghdl/thin/errorout.py
@@ -1,13 +1,3 @@
-from ctypes import c_int8, c_int32, Structure
-
-class Error_Record(Structure):
- _fields_ = [("origin", c_int8),
- ("id", c_int8),
- ("file", c_int32),
- ("line", c_int32),
- ("offset", c_int32),
- ("length", c_int32)]
-
class Msgid:
diff --git a/src/vhdl/python/libghdl/thin/errorout_memory.py b/src/vhdl/python/libghdl/thin/errorout_memory.py
index d0a1e255c..8027795df 100644
--- a/src/vhdl/python/libghdl/thin/errorout_memory.py
+++ b/src/vhdl/python/libghdl/thin/errorout_memory.py
@@ -1,6 +1,20 @@
from libghdl import libghdl
-from ctypes import c_int32, c_char_p
-import libghdl.thin.errorout as errorout
+from ctypes import c_int8, c_int32, c_char_p, Structure
+
+class Error_Message(Structure):
+ _fields_ = [("id", c_int8),
+ ("group", c_int8),
+ ("file", c_int32),
+ ("line", c_int32),
+ ("offset", c_int32),
+ ("length", c_int32)]
+
+
+# Values for group:
+Msg_Single = 0
+Msg_Main = 1
+Msg_Related = 2
+Msg_Last = 3
Install_Handler = libghdl.errorout__memory__install_handler
@@ -8,7 +22,7 @@ Get_Nbr_Messages = libghdl.errorout__memory__get_nbr_messages
Get_Error_Record = libghdl.errorout__memory__get_error_record
Get_Error_Record.argstypes = [c_int32]
-Get_Error_Record.restype = errorout.Error_Record
+Get_Error_Record.restype = Error_Message
Get_Error_Message = libghdl.errorout__memory__get_error_message_addr
Get_Error_Message.argstype = [c_int32]
diff --git a/src/vhdl/python/pnodespy.py b/src/vhdl/python/pnodespy.py
index b4d81a26a..4088efa3a 100755
--- a/src/vhdl/python/pnodespy.py
+++ b/src/vhdl/python/pnodespy.py
@@ -231,17 +231,6 @@ def do_libghdl_tokens():
def do_libghdl_errorout():
- print("""from ctypes import c_int8, c_int32, Structure
-
-class Error_Record(Structure):
- _fields_ = [("origin", c_int8),
- ("id", c_int8),
- ("file", c_int32),
- ("line", c_int32),
- ("offset", c_int32),
- ("length", c_int32)]
-""")
-
read_enum("../errorout.ads", "Msgid_Type", "(Msgid|Warnid)_", "Msgid",
g=lambda m: m.group(1) + '_' + m.group(2))