From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2160 invoked by alias); 3 Jan 2007 14:04:42 -0000 Received: (qmail 2151 invoked by uid 22791); 3 Jan 2007 14:04:40 -0000 X-Spam-Check-By: sourceware.org Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 03 Jan 2007 14:04:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id 21B8D48CF03 for ; Wed, 3 Jan 2007 09:04:29 -0500 (EST) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 01419-01-7 for ; Wed, 3 Jan 2007 09:04:28 -0500 (EST) Received: from takamaka.act-europe.fr (AStDenis-105-1-84-180.w80-8.abo.wanadoo.fr [80.8.199.180]) by nile.gnat.com (Postfix) with ESMTP id 6696748CDEC for ; Wed, 3 Jan 2007 09:04:26 -0500 (EST) Received: by takamaka.act-europe.fr (Postfix, from userid 1000) id 1280534C099; Wed, 3 Jan 2007 18:05:14 +0400 (RET) Date: Wed, 03 Jan 2007 14:04:00 -0000 From: Joel Brobecker To: gdb@sourceware.org Subject: Re: Ada testsuite failures Message-ID: <20070103140514.GA19241@adacore.com> References: <20061231194604.GA23919@nevyn.them.org> <20070102113903.GH3434@adacore.com> <20070102143926.GA10771@nevyn.them.org> <20070102163108.GJ3434@adacore.com> <20070102163302.GL3434@adacore.com> <20070102164044.GA14566@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline In-Reply-To: <20070102164044.GA14566@nevyn.them.org> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00033.txt.bz2 --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2761 > (gdb) ptype bar.empty > No definition of "bar.empty" in current context. Thanks for sending me your objfiles. I know what's going on, now. Once I understood the source of this issue, it was actually fairly simple to reproduce the problem with a C program. Consider: struct empty {}; struct not_empty { long long a; }; int main (void) { struct empty e = {}; struct not_empty n = { 1 }; n.a = (long long) &e; return 0; } The heart of the problem is that struct empty is a struct that does not have any children. We have some guards in dwarf2read.c for both partial symbols and full symbols readers that make GDB ignore the DW_TAG_structure DIEs for type empty: add_partial_symbol (...) { case DW_TAG_structure_type: /* Skip aggregate types without children, these are external references. */ /* NOTE: carlton/2003-10-07: See comment in new_symbol about static vs. global. */ !!!-> if (pdi->has_children == 0) return; add_psymbol_to_list (actual_name, strlen (actual_name), Same for full symbols: process_structure_scope (...) { [...] if (die->child != NULL && ! die_is_declaration (die, cu)) new_symbol (die, die->type, cu); What saves us with our version of GNAT Pro is that the compiler also creates a DW_TAG_typedef DIE associated to this struct. This is this DIE that allows GDB to create a symbol for this type. With the C example above, where the language allows me to control whether typedefs are emitted or not, I can reproduce with the compiler I use the same problem as yours. The guards cited above have been there since version 1.1 of dwarf2read.c. I don't know how relevant they are now - presumably today's compilers would rather use a declaration attribute rather than empty structs. Strictly speaking, the guard as implemented is wrong. So I propose to simply remove it. 2006-02-03 Joel Brobecker * dwarf2read.c (add_partial_symbol): Update copyright year. Do not skip struct, union and enum types with no children. 2006-02-03 Joel Brobecker * gdb.base/nofield.c: New file. * gdb.base/nofield.exp: New testcase. Tested on x86_64-linux. No regression. Nofield.exp has two FAILs before the patch, and is all PASS after. OK to apply? (It should fix the problem you are seeing, but I am unable to verify this, because I can't run your program on my machine. It was compiled with the shared version of the GNAT runtime (libgnat-4.0.so). Next time I'll make sure to ask to add -bargs -static. Can you verify that your FAIL is gone with this patch? - Thank you!) -- Joel --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nochild.diff" Content-length: 1450 Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.207 diff -u -p -r1.207 dwarf2read.c --- dwarf2read.c 27 Dec 2006 22:38:57 -0000 1.207 +++ dwarf2read.c 3 Jan 2007 13:58:37 -0000 @@ -1,7 +1,7 @@ /* DWARF 2 debugging format support for GDB. Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006 + 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, @@ -1979,12 +1979,8 @@ add_partial_symbol (struct partial_die_i case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_enumeration_type: - /* Skip aggregate types without children, these are external - references. */ /* NOTE: carlton/2003-10-07: See comment in new_symbol about static vs. global. */ - if (pdi->has_children == 0) - return; add_psymbol_to_list (actual_name, strlen (actual_name), STRUCT_DOMAIN, LOC_TYPEDEF, (cu->language == language_cplus @@ -4017,7 +4013,7 @@ process_structure_scope (struct die_info child_die = sibling_die (child_die); } - if (die->child != NULL && ! die_is_declaration (die, cu)) + if (!die_is_declaration (die, cu)) new_symbol (die, die->type, cu); processing_current_prefix = previous_prefix; --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nofield.c" Content-length: 1169 /* This testcase is part of GDB, the GNU debugger. Copyright 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Please email any bugs, comments, and/or additions to this file to: bug-gdb@prep.ai.mit.edu */ struct empty {}; union empty_union {}; struct not_empty { long long e; long long u; }; int main (void) { struct empty e = {}; union empty_union u; struct not_empty n = {1, 2}; n.e = (long long) &e; n.u = (long long) &u; return 0; } --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nofield.exp" Content-length: 1594 # Copyright 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA if $tracelevel { strace $tracelevel } set testfile "nofield" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested "Couldn't compile ${srcfile}" return -1 } set eol "\[\r\n\]+" set sp "\[ \t\]*" gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} gdb_test "ptype struct not_empty" \ "type = struct not_empty {$eol${sp}long long int e;$eol${sp}long long int u;$eol}" \ "ptype struct not_empty" gdb_test "ptype struct empty" \ "type = struct empty {$eol$sp$eol}" \ "ptype struct empty" gdb_test "ptype union empty_union" \ "type = union empty_union {$eol$sp$eol}" \ "ptype union empty_union" --45Z9DzgjV8m4Oswq--