From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14773 invoked by alias); 17 Jun 2010 18:02:09 -0000 Received: (qmail 14113 invoked by uid 22791); 17 Jun 2010 18:02:07 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_GD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jun 2010 18:02:01 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5HI204x006506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Jun 2010 14:02:00 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5HI1x4Z015415; Thu, 17 Jun 2010 14:02:00 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5HI1wpN000681; Thu, 17 Jun 2010 14:01:59 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 7ED9D3784BE; Thu, 17 Jun 2010 12:01:58 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: DWARF reader -vs- unknown types Reply-To: Tom Tromey Date: Thu, 17 Jun 2010 18:02:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00382.txt.bz2 I plan to commit this, but as it touches on output formatting I figured I would let people comment first. Right now the DWARF reader simply throws an exception if it finds a type it does not recognize. This is not very friendly, because it results in strange behavior from GDB. In particular, it means that many commands in GDB will simply print the same error message, as GDB tries over and over to read the debuginfo. You can easily reproduce this by using a very recent GCC to compile a C++ program using rvalue references (-std=c++0x -gdwarf-4). GDB does not recognize DW_TAG_rvalue_reference_type, provoking the problem. I have also heard a report from someone who has their own compiler that emits types in the vendor-defined tag range. This patch changes the DWARF reader to create a new type using TYPE_CODE_ERROR to represent the unrecognized type. The type includes enough information for the user to find the failing DIE. (I think all the DWARF error messages should include this information -- it makes helping users much simpler.) It also changes all the places in GDB that use TYPE_CODE_ERROR to print the type's name rather than . Here is what it looks like now when I try to print a variable of rvalue reference type: (gdb) p r $1 = (gdb) ptype r type = Built and regtested on x86-64 (compile farm). Let me know what you think. In the absence of comments I will commit it before 7.2. Tom 2010-06-17 Tom Tromey * p-valprint.c (pascal_val_print): Use TYPE_ERROR_NAME. * p-typeprint.c (pascal_type_print_base): Use TYPE_ERROR_NAME. * m2-valprint.c (m2_val_print): Use TYPE_ERROR_NAME. * gdbtypes.h (TYPE_ERROR_NAME): New macro. * f-valprint.c (f_val_print): Use TYPE_ERROR_NAME. * f-typeprint.c (f_type_print_base): Use TYPE_ERROR_NAME. * dwarf2read.c (tag_type_to_type): Create a new error type on failure. * c-valprint.c (c_val_print): Use TYPE_ERROR_NAME. * c-typeprint.c (c_type_print_base): Use TYPE_ERROR_NAME. diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 2697c3a..54be98f 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1121,7 +1121,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, _("")); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_RANGE: diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 9d2da35..338faf5 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -552,7 +552,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, _("")); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_UNDEF: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 6115939..b27db70 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9151,9 +9151,18 @@ tag_type_to_type (struct die_info *die, struct dwarf2_cu *cu) this_type = read_type_die (die, cu); if (!this_type) { - dump_die_for_error (die); - error (_("Dwarf Error: Cannot find type of die [in module %s]"), - cu->objfile->name); + char *message, *saved; + + /* read_type_die already issued a complaint. */ + message = xstrprintf (_(""), + cu->objfile->name, + cu->header.offset, + die->offset); + saved = obstack_copy0 (&cu->objfile->objfile_obstack, + message, strlen (message)); + xfree (message); + + this_type = init_type (TYPE_CODE_ERROR, 0, 0, saved, cu->objfile); } return this_type; } diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 1343f68..9f8c45a 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -312,7 +312,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_ERROR: - fprintfi_filtered (level, stream, ""); + fprintfi_filtered (level, stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_RANGE: diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index acd6487..6259d87 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -394,7 +394,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, ""); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_RANGE: diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 32e5f04..ce79dc2 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1054,6 +1054,11 @@ extern void allocate_gnat_aux_type (struct type *); || TYPE_NFN_FIELDS (thistype) == 0) && \ (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype))) +/* A helper macro that returns the name of an error type. If the type + has a name, it is used; otherwise, a default is used. */ +#define TYPE_ERROR_NAME(type) \ + (TYPE_NAME (type) ? TYPE_NAME (type) : _("")) + struct builtin_type { /* Integral types. */ diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index edfd324..786cf20 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -646,7 +646,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, _("")); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_UNDEF: diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index fc54e01..bf183f6 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -758,7 +758,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, ""); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; /* this probably does not work for enums */ diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index e58f9d2..5d06492 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -539,7 +539,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, break; case TYPE_CODE_ERROR: - fprintf_filtered (stream, ""); + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_UNDEF: