From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27183 invoked by alias); 5 May 2012 02:32:33 -0000 Received: (qmail 27174 invoked by uid 22791); 5 May 2012 02:32:32 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,TW_BJ X-Spam-Check-By: sourceware.org Received: from ipmail05.adl6.internode.on.net (HELO ipmail05.adl6.internode.on.net) (150.101.137.143) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 May 2012 02:32:19 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAGqQpE95LZEC/2dsb2JhbAANLgq1ewEBAQQnUQEQCxgJFg8JAwIBAgFFBg0BAwICAQHDCYp7BwmGAwSIYqBWLoEe Received: from ppp121-45-145-2.lns10.adl6.internode.on.net (HELO [192.168.1.1]) ([121.45.145.2]) by ipmail05.adl6.internode.on.net with ESMTP; 05 May 2012 12:02:16 +0930 Message-ID: <4FA4912E.9050709@toojays.net> Date: Sat, 05 May 2012 02:32:00 -0000 From: John Steele Scott User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20 MIME-Version: 1.0 To: Tom Tromey CC: Jan Kratochvil , gdb-patches@sourceware.org Subject: Re: [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries. References: <4E9A6F3C.6010400@toojays.net> <20111019084011.GA9326@host1.jankratochvil.net> <4EA3E995.8040206@toojays.net> <20111026221057.GA24628@host1.jankratochvil.net> <4EBFB451.8030503@toojays.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2012-05/txt/msg00144.txt.bz2 On 16/11/11 03:48, Tom Tromey wrote: > John> 2011-11-13 John Steele Scott > > John> PR symtab/13277: Resolving opaque structures in ICC generated binaries. > John> * dwarf2read.c (producer_is_icc): New function. > John> (read_structure_type): Set TYPE_STUB on structures/unions/classes > John> with a byte size of zero, if they were produced by ICC. > John> (process_structure_scope): Extract "external reference" check into > John> die_is_incomplete_type. > John> (die_is_incomplete_type): New function. > John> (read_partial_die): If a structure/union/class has a byte_size of zero, > John> and it was produced by ICC, set part_die->is_declaration instead of > > This patch is ok. You didn't say, but I assume it passed all regression > tests? I'm resending this old patch (rebased to current trunk) since I finally got word that my paperwork has been processed. I ran the dwarf2 and base tests and saw no new failures. Please apply. I'll resend the tests in a separate mail. Thanks, John gdb/Changelog: 2012-05-05 John Steele Scott PR symtab/13277: Resolving opaque structures in ICC generated binaries. * dwarf2read.c (producer_is_icc): New function. (read_structure_type): Set TYPE_STUB on structures/unions/classes with a byte size of zero, if they were produced by ICC. (process_structure_scope): Extract "external reference" check into die_is_incomplete_type. (die_is_incomplete_type): New function. (read_partial_die): If a structure/union/class has a byte_size of zero, and it was produced by ICC, set part_die->is_declaration instead of part_die->has_byte_size. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 412fe5b..ea29ad4 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8727,6 +8727,23 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) smash_to_methodptr_type (type, new_type); } +/* Return non-zero if the supplied PRODUCER string matches the Intel C/C++ + compiler (icc). */ + +static int +producer_is_icc (const char *producer) +{ + static const char *const icc_ident = "Intel(R) C Intel(R) 64 Compiler XE"; + + if (producer == NULL) + return 0; + + if (strncmp (producer, icc_ident, strlen (icc_ident)) == 0) + return 1; + + return 0; +} + /* Called when we find the DIE that starts a structure or union scope (definition) to create a type for the structure or union. Fill in the type's name and general properties; the members will not be @@ -8837,6 +8854,11 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) /* RealView does not output the required DW_AT_declaration on incomplete types. */ TYPE_STUB (type) = 1; + else if (attr != NULL && die->child == NULL && TYPE_LENGTH (type) == 0 + && producer_is_icc (cu->producer)) + /* ICC does not output the required DW_AT_declaration + on incomplete types, but gives them a size of zero. */ + TYPE_STUB (type) = 1; /* We need to add the type field to the die immediately so we don't infinitely recurse when dealing with pointers to the structure @@ -8849,6 +8871,30 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) return type; } +/* Return non-zero if the DIE from the compilation unit CU is an incomplete + type. "An incomplete structure, union or class type is represented by a + structure, union or class entry that does not have a byte size attribute and + that has a DW_AT_declaration attribute." */ + +static int +die_is_incomplete_type (struct die_info *die, struct dwarf2_cu *cu) +{ + struct attribute *attr = dwarf2_attr (die, DW_AT_byte_size, cu); + + if (dwarf2_flag_true_p (die, DW_AT_declaration, cu) && attr == NULL) + return 1; + else if (producer_is_icc (cu->producer) + && attr != NULL && DW_UNSND (attr) == 0 && die->child == NULL + && (die->tag == DW_TAG_structure_type + || die->tag == DW_TAG_class_type + || die->tag == DW_TAG_union_type)) + /* ICC does not output the required DW_AT_declaration on incomplete + structure, union and class types, but gives them a size of zero. */ + return 1; + + return 0; +} + /* Finish creating a structure or union type, including filling in its members and creating a symbol for it. */ @@ -9053,11 +9099,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) child_die = sibling_die (child_die); } - /* Do not consider external references. According to the DWARF standard, - these DIEs are identified by the fact that they have no byte_size - attribute, and a declaration attribute. */ - if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL - || !die_is_declaration (die, cu)) + if (!die_is_incomplete_type (die, cu)) new_symbol (die, type, cu); } @@ -10991,8 +11033,23 @@ read_partial_die (const struct die_reader_specs *reader, part_die->sibling = buffer + dwarf2_get_ref_die_offset (&attr).sect_off; break; case DW_AT_byte_size: - part_die->has_byte_size = 1; - break; + if (DW_UNSND (&attr) == 0 && producer_is_icc (cu->producer) + && (part_die->tag == DW_TAG_structure_type + || part_die->tag == DW_TAG_union_type + || part_die->tag == DW_TAG_class_type)) + { + /* ICC ddoes not output DW_AT_declaration on incomplete types, + instead giving them a size of zero. Fix that up so that we + treat this as an incomplete type. Ideally we would do this in + fixup_partial_die(), but that would mean re-reading the + DW_AT_byte_size attribute. */ + part_die->is_declaration = 1; + } + else + { + part_die->has_byte_size = 1; + } + break; case DW_AT_calling_convention: /* DWARF doesn't provide a way to identify a program's source-level entry point. DW_AT_calling_convention attributes are only meant