From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14163 invoked by alias); 23 May 2012 23:29:46 -0000 Received: (qmail 14154 invoked by uid 22791); 23 May 2012 23:29:45 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BJ,TW_GD X-Spam-Check-By: sourceware.org Received: from mail-pz0-f41.google.com (HELO mail-pz0-f41.google.com) (209.85.210.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 May 2012 23:29:31 +0000 Received: by dakp5 with SMTP id p5so11126185dak.0 for ; Wed, 23 May 2012 16:29:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:x-gm-message-state; bh=YVio3fePELTxCQG6/WnDdZeKwu706wPp1Xq7P7x/uuI=; b=ACMlBnHkxgLJt/XoB6RThtzMBEy+L2m4FDDaVzQq9SKJBvKBgWtvqz+JMtPP6/zEEX Q5ELMeNvhb9cQHh5inst7iIeZ8BBJML6UmI8zW57K/mmOMJj9Z1mbuiDau22Z2m0t54H T0cZFAGT0wrNEoZdV/poSU2gPLBkvpDOcRAmZq8f+TmHCLr0cWf8Vlhgffr9KXkuphoy 80YE6oyXc0+BaipT5qStWUqS04w3YfqOZmqcFetMp5lWg/Z+Km4KbyAXMNE5hXB6BVST if8jZxLeKesNLSpqUs0jsoq3Esx0DKV4onAr9mQ7JE1jruJVcISKTMTEABINSYaTz6wh 16Tw== Received: by 10.68.203.7 with SMTP id km7mr3777771pbc.7.1337815770612; Wed, 23 May 2012 16:29:30 -0700 (PDT) Received: from saaz ([146.174.200.100]) by mx.google.com with ESMTPS id qt10sm3323301pbc.57.2012.05.23.16.29.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 May 2012 16:29:30 -0700 (PDT) From: John Steele Scott To: Jan Kratochvil Cc: Tom Tromey , gdb-patches@sourceware.org, Joel Brobecker Subject: Re: [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries. In-Reply-To: <20120520131719.GB7416@host2.jankratochvil.net> References: <4EA3E995.8040206@toojays.net> <20111026221057.GA24628@host1.jankratochvil.net> <4EBFB451.8030503@toojays.net> <4FA4912E.9050709@toojays.net> <20120512183722.GA20606@host2.jankratochvil.net> <4FB10DD8.7040501@toojays.net> <20120518144642.GA19690@host2.jankratochvil.net> <4FB8E4BD.6000501@toojays.net> <20120520130919.GA6990@host2.jankratochvil.net> <20120520131719.GB7416@host2.jankratochvil.net> User-Agent: Notmuch/0.12+162~gfcfb619 (http://notmuchmail.org) Emacs/24.1.50.1 (x86_64-unknown-linux-gnu) Date: Wed, 23 May 2012 23:29:00 -0000 Message-ID: <87ipfmxyro.fsf@quantum.com> MIME-Version: 1.0 Content-Type: text/plain X-Gm-Message-State: ALoCoQlJG2rPmN2ySQKOaERvKei9y/bE1tti3tgoX0XPpUZ8xrU6KD34Hcu1ib0FB1iZZbgpVjev 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/msg00916.txt.bz2 Hi Jan, Jan Kratochvil writes: > [ Cc to gdb-patches has been lost. ] > On Sun, 20 May 2012 15:09:19 +0200, Jan Kratochvil wrote: > Hi John, > > On Sun, 20 May 2012 14:34:05 +0200, John Steele Scott wrote: >> basic_lookup_transparent_type will only do one psymbol->symbol expansion per >> call. For a frequently referenced opaque type in a non-trivial program, >> initially "ptype" will show it as "no data fields". But if I repeatedly >> invoke ptype, eventually it resolves the type correctly. > > sorry I did not write a proper reproducer + testcase for it but I believe the > attached patch should fix it. It is probably a regression since introduction > of quick_symbol_functions. > > >> On the question of caching the producer info in the dwarf2_cu; I propose to >> extract out the second half of producer_is_gxx_lt_4_6 into a new >> check_producer function which will set cu->producer_is_gxx_lt_4_6 and >> cu->producer_is_icc as appropriate (and then set cu->checked_producer). >> producer_is_gxx_lt_4_6 and producer_is_icc will call check_producer if >> cu->checked_producer is not set. Sound okay? > > Yes, I find such approach appropriate. The below patch implements this. I ran the full testsuite on amd64 with gcc (Ubuntu/Linaro 4.4.4-14ubuntu5.1) 4.4.5; it passes my testcase from http://sourceware.org/ml/gdb-patches/2012-05/msg00763.html, and there are no new failures. I also ran the full testsuite with icc, as: make -j10 check RUNTESTFLAGS="CC_FOR_TARGET=icc CFLAGS_FOR_TARGET='-debug extended' CXX_FOR_TARGET=icpc CXXFLAGS_FOR_TARGET='-debug extended'". In addition to fixing my testcase, this fixes the four similar broken cases in gdb.base/opaque, now that set of tests all pass. Two tests in gdb.base/type-opaque effectively changed polarity: previously "opaque {struct,union} type resolving" failed, now those pass and "empty {struct,union} type resolving" fail. As previously discussed, this is the lesser of the two evils as far as I'm concerned. The patch at http://sourceware.org/ml/gdb-patches/2012-05/msg00739.html is still required to fix my non-trivial case, I hope that (or something like it) can be committed soon. thanks, John 2012-05-24 John Steele Scott PR symtab/13277: Resolving opaque structures in ICC generated binaries. * dwarf2read.c (struct dwarf2_cu) : New field. (producer_is_gxx_lt_4_6): Move the checking and caching to... (check_producer): ... this new function, which also checks for ICC and caches the result. (producer_is_icc): New function. (read_structure_type): Don't set TYPE_STUB_SUPPORTED if the producer was ICC. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b590134..2afefaf 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -429,12 +429,13 @@ struct dwarf2_cu unoptimized code. For a future better test see GCC PR other/32998. */ unsigned int has_loclist : 1; - /* These cache the results of producer_is_gxx_lt_4_6. - CHECKED_PRODUCER is set if PRODUCER_IS_GXX_LT_4_6 is valid. This - information is cached because profiling CU expansion showed - excessive time spent in producer_is_gxx_lt_4_6. */ + /* These cache the results for producer_is_gxx_lt_4_6 and producer_is_icc. + CHECKED_PRODUCER is set if both PRODUCER_IS_GXX_LT_4_6 and PRODUCER_IS_ICC + are valid. This information is cached because profiling CU expansion + showed excessive time spent in producer_is_gxx_lt_4_6. */ unsigned int checked_producer : 1; unsigned int producer_is_gxx_lt_4_6 : 1; + unsigned int producer_is_icc : 1; /* Non-zero if DW_AT_addr_base was found. Used when processing DWO files. */ @@ -8271,16 +8272,14 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, } } -/* Check for GCC PR debug/45124 fix which is not present in any G++ version up - to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed - during 4.6.0 experimental. */ +/* Check whether the producer field indicates either of GCC < 4.6, or the + Intel C/C++ compiler, and cache the result in CU. */ -static int -producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) +static void +check_producer (struct dwarf2_cu *cu) { const char *cs; int major, minor, release; - int result = 0; if (cu->producer == NULL) { @@ -8292,22 +8291,11 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4 combination. gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility interpreted incorrectly by GDB now - GCC PR debug/48229. */ - - return 0; - } - - if (cu->checked_producer) - return cu->producer_is_gxx_lt_4_6; - - /* Skip any identifier after "GNU " - such as "C++" or "Java". */ - - if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0) - { - /* For non-GCC compilers expect their behavior is DWARF version - compliant. */ } - else + else if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) == 0) { + /* Skip any identifier after "GNU " - such as "C++" or "Java". */ + cs = &cu->producer[strlen ("GNU ")]; while (*cs && !isdigit (*cs)) cs++; @@ -8316,13 +8304,30 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) /* Not recognized as GCC. */ } else - result = major < 4 || (major == 4 && minor < 6); + cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6); + } + else if (strncmp (cu->producer, "Intel(R) C", strlen ("Intel(R) C")) == 0) + cu->producer_is_icc = 1; + else + { + /* For other non-GCC compilers, expect their behavior is DWARF version + compliant. */ } cu->checked_producer = 1; - cu->producer_is_gxx_lt_4_6 = result; +} - return result; +/* Check for GCC PR debug/45124 fix which is not present in any G++ version up + to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed + during 4.6.0 experimental. */ + +static int +producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) +{ + if (!cu->checked_producer) + check_producer(cu); + + return cu->producer_is_gxx_lt_4_6; } /* Return the default accessibility type if it is not overriden by @@ -9005,6 +9010,18 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) smash_to_methodptr_type (type, new_type); } +/* Return non-zero if the CU's PRODUCER string matches the Intel C/C++ compiler + (icc). */ + +static int +producer_is_icc (struct dwarf2_cu *cu) +{ + if (!cu->checked_producer) + check_producer(cu); + + return cu->producer_is_icc; +} + /* 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 @@ -9107,7 +9124,14 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) TYPE_LENGTH (type) = 0; } - TYPE_STUB_SUPPORTED (type) = 1; + if (producer_is_icc (cu)) + { + /* ICC does not output the required DW_AT_declaration + on incomplete types, but gives them a size of zero. */ + } + else + TYPE_STUB_SUPPORTED (type) = 1; + if (die_is_declaration (die, cu)) TYPE_STUB (type) = 1; else if (attr == NULL && die->child == NULL