[gvd-devel] Bug in GVD-1.2.4 handling templates and empty structures

Sergey Koshcheyev serko84@hotmail.com
Fri, 08 Feb 2002 14:13:07 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_4c2a_3a98_7b9d
Content-Type: text/plain; format=flowed

OK, I have modified my patch a little, now Skip_Matching raises 
Constraint_Error if it hits the end of the string and doesn't find the 
matching delimiter. The modified version is attached.

Sergey Koshcheyev.

>From: Arnaud Charlet <charlet@ACT-Europe.FR>
>To: Sergey Koshcheyev <serko84@hotmail.com>
>CC: charlet@ACT-Europe.FR, gvd-devel@lists.act-europe.fr
>Subject: Re: [gvd-devel] Bug in GVD-1.2.4 handling templates and empty 
>structures
>Date: Fri, 8 Feb 2002 11:16:51 +0100
>
necessary. I
> > don't know however what to do on erroneous strings where there is no
> > matching delimiter - should the code raise an exception (which one?) or
> > should it just silently stop after the last character and pretend 
>nothing
> > happened?
>
>I don't know, but clearly silently going after the last character isn't 
>user
>friendly. Anything else would be more user friendly.
>
> > I'm attaching the test case you asked for. It declares two variables, D 
>of a
> > complex type involving template parameters, and EMPTY - an empty 
>structure.
> > GVD 1.2.4 using GDB 5.1 can not graph display either variable, GVD 1.2.4
> > using GDB 4.17.gnat.3.13p can not display D.
>
>Thanks.
>
>Arno




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

------=_NextPart_000_4c2a_3a98_7b9d
Content-Type: text/plain; name="patch.diff"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="patch.diff"

diff -ru gvd-1.2.4-sergey/common/string_utils.adb 
gvd-1.2.4-src/common/string_utils.adb
--- gvd-1.2.4-sergey/common/string_utils.adb	Fri Feb  8 14:09:12 2002
+++ gvd-1.2.4-src/common/string_utils.adb	Mon Nov 26 17:17:38 2001
@@ -120,40 +120,6 @@
       end loop;
    end Skip_To_String;

-   -------------------
-   -- Skip_Matching --
-   -------------------
-
-   procedure Skip_Matching
-     (Type_Str  : String;
-      Index     : in out Natural;
-      Opening   : Character;
-      Closing   : Character)
-   is
-      Nesting_Level : Natural := 0;
-   begin
-      --  Need to be at the opening delimiter at the time of the call
-      pragma Assert (Type_Str (Index) = Opening);
-
-      while Index <= Type_Str'Last
-      loop
-         if Type_Str (Index) = Opening then
-            Nesting_Level := Nesting_Level + 1;
-         elsif Type_Str (Index) = Closing then
-            Nesting_Level := Nesting_Level - 1;
-         end if;
-
-         Index := Index + 1;
-         exit when Nesting_Level = 0;
-      end loop;
-
-      if Nesting_Level /= 0 then
-         --  No matching delimiter
-         raise Constraint_Error;
-      end if;
-
-   end Skip_Matching;
-
    ---------------
    -- Parse_Num --
    ---------------
diff -ru gvd-1.2.4-sergey/common/string_utils.ads 
gvd-1.2.4-src/common/string_utils.ads
--- gvd-1.2.4-sergey/common/string_utils.ads	Fri Feb  8 13:41:18 2002
+++ gvd-1.2.4-src/common/string_utils.ads	Mon Nov 26 17:17:38 2001
@@ -58,15 +58,6 @@
    --  Skip every character until an occurence of Substring is found.
    --  Index is set to the first character of the occurence.

-   procedure Skip_Matching
-     (Type_Str  : String;
-      Index     : in out Natural;
-      Opening   : Character;
-      Closing   : Character);
-   --  Skip beyond the Closing character that matches the Opening one, 
handling
-   --  nested occurences correctly.  Will raise Constraint_Error if the
-   --  matching delimiter is not found.
-
    procedure Skip_Word
      (Type_Str : String;
       Index    : in out Natural;
diff -ru gvd-1.2.4-sergey/gvd/debugger-gdb-c.adb 
gvd-1.2.4-src/gvd/debugger-gdb-c.adb
--- gvd-1.2.4-sergey/gvd/debugger-gdb-c.adb	Thu Feb  7 23:34:51 2002
+++ gvd-1.2.4-src/gvd/debugger-gdb-c.adb	Mon Nov 26 17:17:48 2001
@@ -178,7 +178,19 @@

          --  Begin of union or struct => skip to the end
          elsif Type_Str (Index) = '{' then
-            Skip_Matching (Type_Str, Index, '{', '}');
+            declare
+               Num : Natural := 1;
+            begin
+               Index := Index + 1;
+               while Num /= 0 loop
+                  if Type_Str (Index) = '}' then
+                     Num := Num - 1;
+                  elsif Type_Str (Index) = '{' then
+                     Num := Num + 1;
+                  end if;
+                  Index := Index + 1;
+               end loop;
+            end;

          --  Access to subprogram
          elsif Type_Str (Index) = '(' then
@@ -272,7 +284,7 @@
       case Type_Str (Index) is
          when '<' =>
             --  Simple types, like <4-byte integer> and <4-byte float>
-            Skip_Matching (Type_Str, Index, '<', '>');
+            Skip_To_Char (Type_Str, Index, '>');
             Result := New_Simple_Type;
             Set_Type_Name (Result, Type_Str (Tmp .. Index));
             Index := Index + 1;
@@ -553,8 +565,7 @@
       if Looking_At (Type_Str, Tmp, "struct {")
         or else Looking_At (Type_Str, Tmp, "union {")
       then
-         Skip_To_Char (Type_Str, Tmp, '{');
-         Skip_Matching (Type_Str, Tmp, '{', '}');
+         Skip_To_Char (Type_Str, Tmp, '}');
       end if;

       Skip_To_Char (Type_Str, Tmp, ';');
@@ -659,10 +670,8 @@
       loop
          --  embedded unions or structs
          if Type_Str (Index) = '{' then
-            Skip_Matching (Type_Str, Index, '{', '}');
-         elsif Type_Str (Index) = '<' then
-            Skip_Matching (Type_Str, Index, '<', '>');
-            Index := Index - 1; -- the '<' will be skipped below
+            Skip_To_Char (Type_Str, Index, '}');
+
          elsif Type_Str (Index) = ';' then
             Num_Fields := Num_Fields + 1;
          end if;
diff -ru gvd-1.2.4-sergey/gvd/debugger-gdb-cpp.adb 
gvd-1.2.4-src/gvd/debugger-gdb-cpp.adb
--- gvd-1.2.4-sergey/gvd/debugger-gdb-cpp.adb	Fri Feb  8 13:48:44 2002
+++ gvd-1.2.4-src/gvd/debugger-gdb-cpp.adb	Mon Nov 26 17:17:48 2001
@@ -69,7 +69,6 @@
       Result   : out Generic_Type_Access);
    --  Parse the contents of a class/union in C++ (ie the part after '{'
    --  Index should point to the character after '{'
-
    --------------------
    -- Is_Simple_Type --
    --------------------
@@ -252,15 +251,10 @@
             Index := Index + 1;
          end if;

-         if Looking_At (Type_Str, Index, "<No data fields>") then
-            Index := Index + 16; --  skips "<No data fields>"
-         end if;
-
          --  Parse the ancestors
          while Type_Str (Index) = '<' loop
-            Skip_Matching (Type_Str, Index, '<', '>');
-
-            Index := Index + 4;  --  skips " = "
+            Skip_To_Char (Type_Str, Index, '>');
+            Index := Index + 5;  --  skips "> = "
             V := Get_Ancestor (Class_Type (Result.all), Ancestor);
             Parse_Value (Lang, Type_Str, Index, V, Repeat_Num);
             pragma Assert (Looking_At (Type_Str, Index, ", "));
@@ -423,7 +417,7 @@
       Num_Ancestors  : Natural := 0;
       Tmp            : Natural := Index;
       Ancestor       : Natural := 1;
-      Ancestor_Start : Natural;
+      Ancestor_Start :  Natural;
       Child          : Generic_Type_Access;

    begin
@@ -432,12 +426,6 @@
       --  Count the number of ancestors

       while Type_Str (Tmp) /= '{' loop
-
-         --  Skip template parameters
-         if Type_Str (Tmp) = '<' then
-            Skip_Matching (Type_Str, Tmp, '<', '>');
-         end if;
-
          if Type_Str (Tmp) = ':' or else Type_Str (Tmp) = ',' then
             Num_Ancestors := Num_Ancestors + 1;
          end if;
@@ -487,8 +475,6 @@

             Ancestor_Start := Tmp;

-         elsif Type_Str (Tmp)  = '<' then
-            Skip_Matching (Type_Str, Tmp, '<', '>');
          else
             Tmp := Tmp + 1;
          end if;


------=_NextPart_000_4c2a_3a98_7b9d--