From: hex <heixia108@gmail.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH]Add symbol whose field 'has_type' has been set to partial symbol table
Date: Fri, 25 Oct 2013 07:41:00 -0000 [thread overview]
Message-ID: <CAB_AMN7ZyhaNKZsn3WLZmRyHe4SBxMsMbuXEdmMkvGhiXdnwcw@mail.gmail.com> (raw)
In-Reply-To: <874n869zs9.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
2013/10/25 Tom Tromey <tromey@redhat.com>:
>>>>>> ">" == hex <heixia108@gmail.com> writes:
>
>>> // Then compile it with `gcc -g -c test.c`(For the lastest GCC, we
>>> need use 'gcc -g -O1 -c test.' to get the following DIE)
>>> We could see the DIE of 'var' is as following:
>>> <1><25>: Abbrev Number: 2 (DW_TAG_variable)
>>> <26> DW_AT_name : var
>>> <2a> DW_AT_decl_file : 1
>>> <2b> DW_AT_decl_line : 1
>>> <2c> DW_AT_type : <0x31>
>>> <30> DW_AT_const_value : 3
>
>>> Latest GDB will not add it to partial symbol table because its symbol
>>> satisfies 'pdi->d.locdesc == NULL'. I think we need add it to partial
>>> symbol table.
>
> This patch seems reasonable to me, but I think it needs a test case.
> This should be easy to write using the DWARF assembler in the test suite.
>
> Tom
Thank you for the review. I have attached the test case.
Jun
[-- Attachment #2: const-var.S --]
[-- Type: text/plain, Size: 2711 bytes --]
/*
Copyright 2009-2013 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 <http://www.gnu.org/licenses/>. */
/* This was compiled from a trivial program just to test whether GDB
will add const variable to partial symbol.
static const int const_var = 6;
int main(){
return 0;
}
Then it was compiled with:
gcc -g -O1
We could see the DIE of 'const_var' is as following:
<1><25>: Abbrev Number: 2 (DW_TAG_variable)
<26> DW_AT_name : var
<2a> DW_AT_decl_file : 1
<2b> DW_AT_decl_line : 1
<2c> DW_AT_type : <0x31>
<30> DW_AT_const_value : 3
We need add it to partial symbol table.
*/
.file "const-var.c"
.text
.Ltext0:
.Letext0:
.file 1 "/tmp/const-var.c"
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x36
.value 0x2
.long .Ldebug_abbrev0
.byte 0x4
.uleb128 0x1
.long .LASF0
.byte 0x1
.long .LASF1
.long .Ltext0
.long .Letext0
.long .Ldebug_line0
.uleb128 0x2
.long .LASF2
.byte 0x1
.byte 0x1
.long 0x2d
.byte 0x6
.uleb128 0x3
.long 0x32
.uleb128 0x4
.byte 0x4
.byte 0x5
.string "int"
.byte 0
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x10
.uleb128 0x6
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x1c
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0x3
.uleb128 0x26
.byte 0
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x4
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0x8
.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"
.LASF1:
.string "/tmp/const-var.c"
.LASF2:
.string "const_var"
.ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
.section .note.GNU-stack,"",@progbits
[-- Attachment #3: const-var.exp --]
[-- Type: application/octet-stream, Size: 1296 bytes --]
# Copyright 2009-2013 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 <http://www.gnu.org/licenses/>.
load_lib dwarf.exp
# Test DW_OP_stack_value and DW_OP_implicit_value.
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
return 0
}
# This test can only be run on x86 targets.
if {![is_x86_like_target]} {
return 0
}
standard_testfile .S
if {[prepare_for_testing $testfile.exp $testfile \
[list $srcfile main.c] [list {additional_flags=-O1}]]} {
return -1
}
if ![runto_main] {
return -1
}
# Print static const variable, test whether it has been added to partial
# symbol table.
gdb_test "p const_var" " = 6" "print const variable"
next prev parent reply other threads:[~2013-10-25 7:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 6:59 hex
2013-10-24 20:31 ` Tom Tromey
2013-10-25 7:41 ` hex [this message]
2013-10-29 18:34 ` Tom Tromey
2013-11-01 6:29 hex
2013-11-07 15:41 ` Tom Tromey
2014-01-24 6:19 Jun Gong
2014-01-26 9:15 ` Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAB_AMN7ZyhaNKZsn3WLZmRyHe4SBxMsMbuXEdmMkvGhiXdnwcw@mail.gmail.com \
--to=heixia108@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox