Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [PATCH]Add symbol whose field 'has_type' has been set to partial symbol table
@ 2013-11-01  6:29 hex
  2013-11-07 15:41 ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: hex @ 2013-11-01  6:29 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

> 2013/10/30 Tom Tromey <tromey@redhat.com>
>
> >>>>> ">" == hex  <heixia108@gmail.com> writes:
>
> >> Thank you for the review. I have attached the test case.
>
> The test case needs a ChangeLog entry.
>
> I'd much prefer a test using the DWARF assembler than one using actual
> assembly code.  There are other examples in gdb.dwarf2.  The reason to
> prefer the DWARF assembler is that it is more portable.
>
> >> # 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
>
> A blank line between the comments and the first line of code, please.
>
> >> # Test DW_OP_stack_value and DW_OP_implicit_value.
>
> This comment seems incorrect.
>
> Tom

Thank you for the comments. A new version of test file is attached.
And the original patch is at
https://sourceware.org/ml/gdb-patches/2013-10/msg00747.html.

gdb/testsuite/Changelog:

2013-11-01  Jun Gong  <heixia108@gmail.com>

      * gdb.dwarf2/const-var.exp: New file.


Jun

[-- Attachment #2: const-var.exp --]
[-- Type: application/octet-stream, Size: 1749 bytes --]

# Copyright 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

# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
    return 0
}

standard_testfile main.c .S

# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
    declare_labels int_label

    cu {} {
	compile_unit {{language @DW_LANG_C}} {
	    int_label: base_type {
		{name int}
		{byte_size 4 sdata}
		{encoding @DW_ATE_signed}
	    }

	    DW_TAG_variable {
		{name const_var}
		{type :$int_label}
		{const_value 6 data1}
	    }
	}
    }
}

if  { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
	   object {nodebug}] != "" } {
    return -1
}

if  { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
    return -1
}

if  { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
	   "${binfile}" executable {}] != "" } {
    return -1
}

clean_restart ${testfile}

if ![runto_main] {
    return -1
}

# Print const variable, test whether it has been added to partial
# symbol table.
gdb_test "print const_var" " = 6" "print const variable"

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH]Add symbol whose field 'has_type' has been set to partial symbol table
@ 2014-01-24  6:19 Jun Gong
  2014-01-26  9:15 ` Yao Qi
  0 siblings, 1 reply; 8+ messages in thread
From: Jun Gong @ 2014-01-24  6:19 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]

This patch intends to add symbol whose field 'has_type' has been set
to partial symbol table.

The patch and corresponding test case have been discussed and reviewed
before at https://sourceware.org/ml/gdb-patches/2013-10/msg00747.html
and https://sourceware.org/ml/gdb-patches/2013-11/msg00003.html.
However it has not been committed because Tom Tromey is very busy and
could not help commit it now. I have received copyright assignment.
Could you help review and commit the patch? Thank you!

The following are the summary of the patch, and the attachment
const-var.exp is test case.

1. Change for gdb/ChangeLog

2014-01-24  Jun Gong  <heixia108@gmail.com>

          * dwarf2read.c(add_partial_symbol): Add symbol whose field
'has_type' has been set to partial symbol table.

2. Diff for dwarf2read.c

diff -up gdb-7.7.50.20140124.orig/gdb/dwarf2read.c
gdb-7.7.50.20140124/gdb/dwarf2read.c
--- gdb-7.7.50.20140124.orig/gdb/dwarf2read.c 2014-01-24
13:04:04.169111566 +0800
+++ gdb-7.7.50.20140124/gdb/dwarf2read.c 2014-01-24 13:26:48.445122774 +0800
@@ -6769,8 +6769,9 @@ add_partial_symbol (struct partial_die_i
  }
       else
  {
-  /* Static Variable.  Skip symbols without location descriptors.  */
-  if (pdi->d.locdesc == NULL)
+  /* Static Variable.  Skip symbols without location descriptors. or
+      has_type not set. */
+  if (pdi->d.locdesc == NULL && pdi->has_type == 0)
     {
       xfree (built_actual_name);
       return;

3. Change for gdb/testsuite/Changelog

2014-01-24  Jun Gong  <heixia108@gmail.com>

      * gdb.dwarf2/const-var.exp: New file.

4. Test case has been attached as const-var.exp.


Best Regards,

Jun

[-- Attachment #2: const-var.exp --]
[-- Type: application/octet-stream, Size: 1749 bytes --]

# Copyright 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

# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
    return 0
}

standard_testfile main.c .S

# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
    declare_labels int_label

    cu {} {
	compile_unit {{language @DW_LANG_C}} {
	    int_label: base_type {
		{name int}
		{byte_size 4 sdata}
		{encoding @DW_ATE_signed}
	    }

	    DW_TAG_variable {
		{name const_var}
		{type :$int_label}
		{const_value 6 data1}
	    }
	}
    }
}

if  { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
	   object {nodebug}] != "" } {
    return -1
}

if  { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
    return -1
}

if  { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
	   "${binfile}" executable {}] != "" } {
    return -1
}

clean_restart ${testfile}

if ![runto_main] {
    return -1
}

# Print const variable, test whether it has been added to partial
# symbol table.
gdb_test "print const_var" " = 6" "print const variable"

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH]Add symbol whose field 'has_type' has been set to partial symbol table
@ 2013-10-24  6:59 hex
  2013-10-24 20:31 ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: hex @ 2013-10-24  6:59 UTC (permalink / raw)
  To: gdb-patches

This patch intends to add symbol whose field 'has_type' has been set
to partial symbol table.

e.g.
// test.c
const int var = 3;

// 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.


2013-10-24  Jun Gong  <heixia108@gmail.com>

          * dwarf2read.c(add_partial_symbol): Add symbol whose field
'has_type' has been set to partial symbol table.


--- gdb-7.6.50.20131021.orig/gdb/dwarf2read.c 2013-10-16
10:55:27.000000000 +0800
+++ gdb-7.6.50.20131021/gdb/dwarf2read.c 2013-10-24 14:29:18.737067814 +0800
@@ -6733,8 +6733,9 @@ add_partial_symbol (struct partial_die_i
  }
       else
  {
-  /* Static Variable.  Skip symbols without location descriptors.  */
-  if (pdi->d.locdesc == NULL)
+  /* Static Variable.  Skip symbols without location descriptors or
+     has_type not set.  */
+  if (pdi->d.locdesc == NULL && pdi->has_type == 0)
     {
       xfree (built_actual_name);
       return;


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-26  9:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01  6:29 [PATCH]Add symbol whose field 'has_type' has been set to partial symbol table hex
2013-11-07 15:41 ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2014-01-24  6:19 Jun Gong
2014-01-26  9:15 ` Yao Qi
2013-10-24  6:59 hex
2013-10-24 20:31 ` Tom Tromey
2013-10-25  7:41   ` hex
2013-10-29 18:34     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox