From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22197 invoked by alias); 3 Nov 2003 22:59:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 22187 invoked from network); 3 Nov 2003 22:59:54 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 3 Nov 2003 22:59:54 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id E8EDFD3368; Mon, 3 Nov 2003 14:59:52 -0800 (PST) Date: Mon, 03 Nov 2003 22:59:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFA] stabs: remember types that cross reference another type Message-ID: <20031103225952.GA2412@gnat.com> References: <20031031200851.GD1236@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline In-Reply-To: <20031031200851.GD1236@gnat.com> User-Agent: Mutt/1.4i X-SW-Source: 2003-11/txt/msg00039.txt.bz2 --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2038 [Rhaaaa, resending, with the patch this time. Thanks Daniel!] Hello, We encountered the following problem when using GNAT to compile the following pasted at the end of this message. Sorry the program is in Ada instead of C, but I couldn't reproduce it with C. The problem is when the user tries to print the type of My_Str. GDB should return a string, but instead we got: Attempt to take contents of a non-pointer value After investigating, I found that the stabs generated by the compiler contained the following entries: .stabs "s5:(0,97)=xsstring___XUP:",128,0,5,-476 .stabs "R6b:(0,97)",128,0,12,-484 (R6b is a variable that GDB ends up using in place of My_Str for reasons that are related to the encoding used by GNAT). So when GDB reads the type information for R6b, it finds that it is of type number (0,97), which should mean the same type as s5. Unfortunately, GDB forgot to save a reference to the type associated to type (0,97) in the type_vector when processing the type of variable named "s5". So later on, when GDB tries to compute the type of "R6b", it doesn't find type (0,97) and therefore assumes it will be defined later, and hence creates a empty type object which it hopes will be filled in later. As a consequence, when the ada mode tries to print the type of R6b, it trips over the unexpected symbol type code, and bails out with the error message above. The attached patch fixes this particular case. 2003-10-31 J. Brobecker * stabsread.c (read_type): Save a reference to types that are defined as cross references to other types. Tested on x86-linux, no regression. Ok to apply? -- Joel << with Ada.Strings.Unbounded; procedure Parse is type String_Ptr is access String; S5 : String_Ptr := new String'("Hello"); function Foos return String is begin return "string"; end Foos; My_Str : String := Foos; Ustring : Ada.Strings.Unbounded.Unbounded_String; -- STOP begin null; end Parse; >> -- Joel --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="stabsread.c.diff" Content-length: 508 Index: stabsread.c =================================================================== RCS file: /cvs/src/src/gdb/stabsread.c,v retrieving revision 1.65 diff -u -p -r1.65 stabsread.c --- stabsread.c 6 Oct 2003 19:27:12 -0000 1.65 +++ stabsread.c 3 Nov 2003 22:58:09 -0000 @@ -1852,6 +1852,8 @@ again: { obstack_free (&objfile->type_obstack, type_name); type = SYMBOL_TYPE (sym); + if (typenums[0] != -1) + *dbx_lookup_type (typenums) = type; return type; } } --nFreZHaLTZJo0R7j--