From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13535 invoked by alias); 21 May 2012 12:05:38 -0000 Received: (qmail 13518 invoked by uid 22791); 21 May 2012 12:05:35 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f41.google.com (HELO mail-pb0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 May 2012 12:04:43 +0000 Received: by pbbrp2 with SMTP id rp2so7269699pbb.0 for ; Mon, 21 May 2012 05:04:43 -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=bBfPbIu0NKlOjbwGJPsvevz5jmMVT0oZyWWFYcz7xAs=; b=Y1MCITdpOhbRASBdlxc/nFV57JoaWj0SSD7LalIkvNV0pKJ15EQdDiRYFkVmNcyiRV 9NglL/VtKaqYz7JAafy2dVvi2h8WJUPCJ1lUe1EimJjFTNSERfcLINuIW+OMIEnnxQEa Jl5AbDLDDk+y7n1zyOuW2dX9/DaVFdF2DJ7gDLEerBHkdsULcpL3oUCMIf73zq9Fnth9 MJ+kwS2dbndez8/6VOrNYO1a3s381NmkKe8SAIiA0woeO9hcL2gzwy0AZrUILyb0z4aX M6OH90yZ5fKgbho+BJhhwWs9hFke4oI5qvyd/tUQ0lhg2OgS5ZZwDYEKE4KZ9YLIQqF+ BdoQ== Received: by 10.68.221.39 with SMTP id qb7mr68024508pbc.120.1337601882442; Mon, 21 May 2012 05:04:42 -0700 (PDT) Received: from saaz (ppp121-45-145-2.lns10.adl6.internode.on.net. [121.45.145.2]) by mx.google.com with ESMTPS id pu5sm22933457pbc.28.2012.05.21.05.04.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 May 2012 05:04:41 -0700 (PDT) From: John Steele Scott To: Jan Kratochvil Cc: Joel Brobecker , Tom Tromey , gdb-patches@sourceware.org Subject: Re: [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries. (testcase) In-Reply-To: <20120512183741.GB20606@host2.jankratochvil.net> References: <4E9A6F3C.6010400@toojays.net> <20111019084011.GA9326@host1.jankratochvil.net> <4EA3E995.8040206@toojays.net> <20111026221057.GA24628@host1.jankratochvil.net> <4EBFAC05.2070501@toojays.net> <4FA49314.5020508@toojays.net> <20120505151557.GU15555@adacore.com> <87wr4h4vvd.fsf@quantum.com> <20120512183741.GB20606@host2.jankratochvil.net> User-Agent: Notmuch/0.12+162~gfcfb619 (http://notmuchmail.org) Emacs/24.1.50.1 (x86_64-unknown-linux-gnu) Date: Mon, 21 May 2012 12:05:00 -0000 Message-ID: <87d35xpwp4.fsf@quantum.com> MIME-Version: 1.0 Content-Type: text/plain X-Gm-Message-State: ALoCoQnHFikpwrQEWpHADRcEqylB/nC7WlJlJybhqj4YSYiZ0OAft3dWPU158SA8+sbMm7WO1KPZ 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/msg00762.txt.bz2 Jan Kratochvil writes: > On Sat, 12 May 2012 11:00:22 +0200, John Steele Scott wrote: >> --- /dev/null >> +++ b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S >> @@ -0,0 +1,192 @@ >> +/* Copyright (C) 2011-2012 Free Software Foundation, Inc. > > Only 2012 as AFAIK the copyright applies only for the time it is checked in > FSF repository. I left it with both years as per Joel's mail. > [...] >> + .file "opaque-pointer.c" > [...] >> + .file "opaque-struct.c" > > Please include these two files as a comment into this .S file, for later > investigation what was the real source code etc. Comments added. > Also please make this change: > > @@ -226,7 +226,7 @@ index 0000000..4fc6512 > -+ .byte 0x08 /* Target address size. */ > ++ .byte 0x04 /* Target address size. */ > @@ -239,8 +239,8 @@ index 0000000..4fc6512 > -+ .2byte 0x0309 /* DW_AT_location: 9 bytes, DW_OP_addr */ > -+ .8byte p_struct /* followed by the address of p_struct. */ > ++ .2byte 0x0305 /* DW_AT_location: 5 bytes, DW_OP_addr */ > ++ .4byte p_struct /* followed by the address of p_struct. */ > @@ -313,7 +313,7 @@ index 0000000..4fc6512 > -+ .byte 0x08 /* Target address size. */ > ++ .byte 0x04 /* Target address size. */ > > It will make the testcase 32-bit, therefore compatible with both 64-bit and > 32-bit targets. Otherwise it gave: > gdb compile failed, opaque-pointer.c: Assembler messages: > opaque-pointer.c:42: Error: cannot represent relocation type BFD_RELOC_64 Done. Updated patch follows. This is still only the testcase. I have the fix almost ready, but I still want to run the full testsuite with ICC and GCC before I submit it. So that will be later this week. Will you commit your change to lookup_symbol_aux_psymtabs (ref http://sourceware.org/ml/gdb-patches/2012-05/msg00739.html), or shall I include that with my fix? cheers, John diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S new file mode 100644 index 0000000..b48405b --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S @@ -0,0 +1,211 @@ +/* Copyright (C) 2011-2012 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 3 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, see . */ + +/* This test demonstrates a failure to resolve opaque structure types in + binaries compiled by the Intel C compiler. This is GDB PR symtab/13277. + + The test was derived from opaque-pointer.c, which contains the single line: + + struct opaque_struct_t *p_struct; + + and opaque_struct.c, which looks like: + + struct opaque_struct_t + { + int wrapped_value; + }; + + struct opaque_struct_t opaque_internal = { 0 }; + + What follows is a simplified version of the debug info generated by ICC + version 12.0.4.191. */ + + .file "opaque-pointer.c" + .data + .comm p_struct,8,8 + .global p_struct# + + .section .debug_info + .align 1 +debug_info_seg1: + .4byte debug_info_seg1_end - 1f /* Length of compilation unit info. */ +1: + .2byte 0x0002 /* DWARF version number. */ + .4byte .debug_abbrev_seg1 /* Points to abbrev section for this unit. */ + .byte 0x04 /* Target address size. */ + + .byte 0x01 /* DIE 1: DW_TAG_compile_unit. */ + .byte 0x01 /* DW_AT_language = DW_LANG_C89. */ + .ascii "Intel(R) C Intel(R) 64 Compiler XE " /* DW_AT_producer. */ + .ascii "for applications running on Intel(R) 64, " + .ascii "Version 12.0.4.191 Build 20110427\n " + .asciz "Fixes SameLinkageName MemberPointers" + + .byte 0x02 /* DIE 2: DW_TAG_variable. */ + .byte 0x01 /* DW_AT_accessibility. */ + .asciz "p_struct" /* DW_AT_name. */ + .4byte 3f - debug_info_seg1 /* DW_AT_type. */ + .2byte 0x0305 /* DW_AT_location: 5 bytes, DW_OP_addr */ + .4byte p_struct /* followed by the address of p_struct. */ + .byte 0x01 /* DW_AT_external. */ + +3: + .byte 0x03 /* DIE 3: DW_TAG_pointer_type. */ + .4byte 4f - debug_info_seg1 /* DW_AT_type. */ + +4: + .byte 0x04 /* DIE 4: DW_TAG_structure_type. */ + .byte 0x01 /* DW_AT_accessibility. */ + .byte 0x00 /* DW_AT_byte_size. */ + .asciz "opaque_struct_t" /* DW_AT_name. */ + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x00 +debug_info_seg1_end: + + .section .debug_abbrev +.debug_abbrev_seg1: + .align 1 + .byte 0x01 /* Abbrev 1. */ + .byte 0x11 /* DW_TAG_compile_unit. */ + .byte 0x01 /* DW_CHILDREN_yes. */ + .byte 0x13 /* DW_AT_language. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x25 /* DW_AT_producer. */ + .byte 0x08 /* DW_AT_string. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x02 /* Abbrev 2. */ + .byte 0x34 /* DW_TAG_variable. */ + .byte 0x00 /* DW_CHILDREN_no. */ + .byte 0x32 /* DW_AT_accessibility. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x03 /* DW_AT_name. */ + .byte 0x08 /* DW_FORM_string. */ + .byte 0x49 /* DW_AT_type. */ + .byte 0x13 /* DW_FORM_ref4. */ + .byte 0x02 /* DW_AT_location. */ + .byte 0x0a /* DW_FORM_block1. */ + .byte 0x3f /* DW_AT_external. */ + .byte 0x0c /* DW_FORM_flag. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x03 /* Abbrev 3. */ + .byte 0x0f /* DW_TAG_pointer_type. */ + .byte 0x00 /* DW_CHILDREN_no. */ + .byte 0x49 /* DW_AT_type. */ + .byte 0x13 /* DW_FORM_ref4. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x04 /* Abbrev 4. */ + .byte 0x13 /* DW_TAG_structure_type. */ + .byte 0x00 /* DW_CHILDREN_no. */ + .byte 0x32 /* DW_AT_accessibility. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x0b /* DW_AT_byte_size. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x03 /* DW_AT_name. */ + .byte 0x08 /* DW_FORM_string. */ + .2byte 0x0000 /* End abbrev. */ + .byte 0x00 /* End abbrev table. */ + + + .file "opaque-struct.c" + .section .debug_info + .align 1 +debug_info_seg2: + .4byte debug_info_seg2_end - 1f /* Length of compilation unit info. */ +1: + .2byte 0x0002 /* DWARF version number. */ + .4byte .debug_abbrev_seg2 /* Points to abbrev section for this unit. */ + .byte 0x04 /* Target address size. */ + + .byte 0x01 /* DIE 1: DW_TAG_compile_unit. */ + .byte 0x01 /* DW_AT_language = DW_LANG_C89. */ + .ascii "Intel(R) C Intel(R) 64 Compiler XE " /* DW_AT_producer. */ + .ascii "for applications running on Intel(R) 64, " + .ascii "Version 12.0.4.191 Build 20110427\n " + .asciz "Fixes SameLinkageName MemberPointers" + + .byte 0x02 /* DIE 2: DW_TAG_structure_type. */ + .byte 0x01 /* DW_AT_accessibility. */ + .byte 0x04 /* DW_AT_byte_size. */ + .asciz "opaque_struct_t" /* DW_AT_name. */ + + + .byte 0x03 /* DIE 3: DW_TAG_member. */ + .2byte 0x2302 /* DW_AT_data_member_location, 2 bytes, */ + .byte 0x00 /* DW_OP_plus_uconst followed by zero. */ + .asciz "wrapped_value" /* DW_AT_name. */ + .4byte 4f - debug_info_seg2 /* DW_AT_type. */ + .byte 0x00 + +4: + .byte 0x04 /* DIE 4: DW_TAG_base_type. */ + .byte 0x04 /* DW_AT_byte_size. */ + .byte 0x05 /* DW_AT_encoding. */ + .asciz "int" /* DW_AT_name. */ + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x00 +debug_info_seg2_end: + + .section .debug_abbrev +.debug_abbrev_seg2: + .align 1 + .byte 0x01 /* Abbrev 1. */ + .byte 0x11 /* DW_TAG_compile_unit. */ + .byte 0x01 /* DW_CHILDREN_yes. */ + .byte 0x13 /* DW_AT_language. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x25 /* DW_AT_producer. */ + .byte 0x08 /* DW_FORM_string. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x02 /* Abbrev 2. */ + .byte 0x13 /* DW_TAG_structure_type. */ + .byte 0x01 /* DW_CHILDREN_yes. */ + .byte 0x32 /* DW_AT_accessibility. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x0b /* DW_AT_byte_size. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x03 /* DW_AT_name. */ + .byte 0x08 /* DW_FORM_string. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x03 /* Abbrev 3. */ + .byte 0x0d /* DW_TAG_member. */ + .byte 0x00 /* DW_CHILDREN_no. */ + .byte 0x38 /* DW_AT_data_member_location. */ + .byte 0x0a /* DW_FORM_block1. */ + .byte 0x03 /* DW_AT_name. */ + .byte 0x08 /* DW_FORM_string. */ + .byte 0x49 /* DW_AT_type. */ + .byte 0x13 /* DW_FORM_ref4. */ + .2byte 0x0000 /* End abbrev. */ + + .byte 0x04 /* Abbrev 4. */ + .byte 0x24 /* DW_TAG_base_type. */ + .byte 0x00 /* DW_CHILDREN_no. */ + .byte 0x0b /* DW_AT_byte_size. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x3e /* DW_AT_encoding. */ + .byte 0x0b /* DW_FORM_data1. */ + .byte 0x03 /* DW_AT_name. */ + .byte 0x08 /* DW_FORM_string. */ + .2byte 0x0000 /* End abbrev. */ + .byte 0x00 /* End abbrev table. */ diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp new file mode 100644 index 0000000..1c7bea5 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp @@ -0,0 +1,41 @@ +# Copyright (C) 2011-2012 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 3 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, see . +load_lib dwarf.exp + +# Test that we can correctly resolve opaque structures compiled by the Intel +# compiler, which does not set DW_AT_declaration on opaque structure types. +# This is GDB PR symtab/13277. + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +set testfile "dw2-icc-opaque" +set srcfile ${testfile}.S +set executable ${testfile}.x +set binfile ${objdir}/${subdir}/${executable} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { + return -1 +} + +clean_restart $executable + +# Before PR 13277 was fixed, this would output: +# type = struct opaque_struct_t { +# +# } * +gdb_test "ptype p_struct" "type = struct opaque_struct_t {\r\n *int wrapped_value;\r\n} \\*"