From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2699 invoked by alias); 12 Sep 2012 08:07:09 -0000 Received: (qmail 2684 invoked by uid 22791); 12 Sep 2012 08:07:07 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_TM 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; Wed, 12 Sep 2012 08:06:51 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8C86not020237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Sep 2012 04:06:49 -0400 Received: from host2.jankratochvil.net (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8C86hhh023892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 12 Sep 2012 04:06:46 -0400 Date: Wed, 12 Sep 2012 08:07:00 -0000 From: Jan Kratochvil To: Yao Qi Cc: gdb@sourceware.org Subject: Re: Symbol can't be found unless type 'tab' Message-ID: <20120912080639.GA16010@host2.jankratochvil.net> References: <504DE251.1020702@codesourcery.com> <20120910131828.GA13062@host2.jankratochvil.net> <50503D6C.6070704@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: <50503D6C.6070704@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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: 2012-09/txt/msg00026.txt.bz2 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1928 On Wed, 12 Sep 2012 09:44:44 +0200, Yao Qi wrote: > On 09/10/2012 09:18 PM, Jan Kratochvil wrote: > >On Mon, 10 Sep 2012 14:51:29 +0200, Yao Qi wrote: > >>> <1><2c>: Abbrev Number: 3 (DW_TAG_variable) > >>> <2d> DW_AT_name : i > >>> <2f> DW_AT_type : <0x23> > >>> <33> DW_AT_location : 0x0 (location list) > >I guess because GDB does not like such complicated location expression for > >glboal variables. > > Jan, thanks for the pointer. > > The "symptom" is symbol is not found in psymtab, but in symtab when > I press 'tab' which triggers converting psymtab to symtab. I wonder > why symbol 'i' is *not* included in psymtab. Because it has the complex location I suggested above. > Examine the source of > dwarf2read.c:add_partial_symbol, especially the case block for > 'DW_TAG_variable', gives me some clue, and I add attribute > DW_AT_external to symbol 'i' like this, > > <1><33>: Abbrev Number: 3 (DW_TAG_variable) > <34> DW_AT_name : i > <36> DW_AT_type : <0x2a> > <3a> DW_AT_external : 1 <--- here > <3b> DW_AT_location : 0x0 (location list) > > and then symbol 'i' can be found by GDB without typing extra 'tab'. It is difficult to talk about the problem when you have not provided the testcase, I have provided mine now. But DW_AT_external is not significant to GDB as GDB can display even static variables, even when they are not in current CU. It is good to verify 'maintenance info symtabs' is empty during these experiments, when one tries to print the variable. I am very sure that this complex DW_AT_location is not properly supported by psymtabs in GDB, this is one of the reasons I was doing the fix and its later undo as I referenced in the previous mail. Why didn't use just normal DWARF block, instead of the location list? This part does not matter for your testcase and it will work with GDB. Jan --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="i.c" Content-length: 7 int i; --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="i.s" Content-length: 2693 .file "i.c" .text .Ltext0: .comm i,4,4 .Letext0: .file 1 "i.c" .section .debug_info,"",@progbits .Ldebug_info0: .long 1f - 2f # Length of Compilation Unit Info 2: .value 0x4 # DWARF version number .long .Ldebug_abbrev0 # Offset Into Abbrev. Section .byte 0x8 # Pointer Size (in bytes) .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) .long .LASF0 # DW_AT_producer: "GNU C 4.6.3 20120306 (Red Hat 4.6.3-2) -mtune=generic -march=x86-64 -g" .byte 0x2 # DW_AT_language .ascii "i.c\0" # DW_AT_name # .long .LASF1 # DW_AT_comp_dir: "/home/jkratoch/t" # .long .Ldebug_line0 # DW_AT_stmt_list .uleb128 0x2 # (DIE (0x1d) DW_TAG_variable) .ascii "i\0" # DW_AT_name # .byte 0x1 # DW_AT_decl_file (i.c) # .byte 0x1 # DW_AT_decl_line .long die30-.Ldebug_info0 # DW_AT_type # DW_AT_external .uleb128 0x9 # DW_AT_location .byte 0x3 # DW_OP_addr .quad i die30: .uleb128 0x3 # (DIE (0x30) DW_TAG_base_type) .byte 0x8 # DW_AT_byte_size .byte 0x5 # DW_AT_encoding .ascii "int\0" # DW_AT_name .byte 0 # end of children of DIE 0xb 1: .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .uleb128 0x1 # (abbrev code) .uleb128 0x11 # (TAG: DW_TAG_compile_unit) .byte 0x1 # DW_children_yes .uleb128 0x25 # (DW_AT_producer) .uleb128 0xe # (DW_FORM_strp) .uleb128 0x13 # (DW_AT_language) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) # .uleb128 0x1b # (DW_AT_comp_dir) # .uleb128 0xe # (DW_FORM_strp) # .uleb128 0x10 # (DW_AT_stmt_list) # .uleb128 0x17 # (DW_FORM_sec_offset) .byte 0 .byte 0 .uleb128 0x2 # (abbrev code) .uleb128 0x34 # (TAG: DW_TAG_variable) .byte 0 # DW_children_no .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) # .uleb128 0x3a # (DW_AT_decl_file) # .uleb128 0xb # (DW_FORM_data1) # .uleb128 0x3b # (DW_AT_decl_line) # .uleb128 0xb # (DW_FORM_data1) .uleb128 0x49 # (DW_AT_type) .uleb128 0x13 # (DW_FORM_ref4) # .uleb128 0x3f # (DW_AT_external) # .uleb128 0x19 # (DW_FORM_flag_present) .uleb128 0x2 # (DW_AT_location) .uleb128 0x18 # (DW_FORM_exprloc) .byte 0 .byte 0 .uleb128 0x3 # (abbrev code) .uleb128 0x24 # (TAG: DW_TAG_base_type) .byte 0 # DW_children_no .uleb128 0xb # (DW_AT_byte_size) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3e # (DW_AT_encoding) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) .byte 0 .byte 0 .byte 0 .section .debug_line,"",@progbits .Ldebug_line0: .section .debug_str,"MS",@progbits,1 .LASF0: .string "GNU C 4.6.3 20120306 (Red Hat 4.6.3-2) -mtune=generic -march=x86-64 -g" .LASF1: .string "/home/jkratoch/t" .ident "GCC: (GNU) 4.6.3 20120306 (Red Hat 4.6.3-2)" .section .note.GNU-stack,"",@progbits --3V7upXqbjpZ4EhLz--