* [PATCH] Differentiate empty vs. opaque types
@ 2007-03-11 22:55 Jan Kratochvil
2007-03-12 3:35 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2007-03-11 22:55 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 676 bytes --]
Hi,
attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
the DWARF flag `DW_AT_declaration':
# DWARF3: An incomplete structure, union or class type is represented by
# a structure, union or class entry that does not have a byte size attribute
# and that has a DW_AT_declaration attribute.
The attachment then fixes GDB to make the testcase pass.
Patch goes the regression-safe way by introducing OBJF_HAVE_TYPE_STUB currently
being set only by DWARF/DWARF2. It should be probably also set at least by
STABS but I tested the code only on DWARF2. Unaware how feasible would be
unconditional TYPE_STUB() dependency nowadays.
Regards,
Jan
[-- Attachment #2: gdb-empty-is-not-opaque.patch --]
[-- Type: text/plain, Size: 9119 bytes --]
2007-03-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbtypes.h (TYPE_IS_OPAQUE): Empty vs. opaque structures are now
distinct on the OBJF_HAVE_TYPE_STUB-supported debug targets.
* objfiles.h (OBJF_HAVE_TYPE_STUB): New flag.
* dwarf2read.c (dwarf2_build_psymtabs): Set OBJF_HAVE_TYPE_STUB.
* dwarfread.c (dwarf_build_psymtabs): Likewise.
2007-03-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/type-opaque-lib.c, gdb.base/type-opaque-main.c,
gdb.base/type-opaque.exp: New files.
--- gdb/dwarf2read.c 12 Feb 2007 15:19:31 -0000 1.215
+++ gdb/dwarf2read.c 11 Mar 2007 22:35:36 -0000
@@ -1196,6 +1196,8 @@ dwarf2_build_psymtabs (struct objfile *o
{
/* We definitely need the .debug_info and .debug_abbrev sections */
+ objfile->flags |= OBJF_HAVE_TYPE_STUB;
+
dwarf2_per_objfile->info_buffer = dwarf2_read_section (objfile, dwarf_info_section);
dwarf2_per_objfile->abbrev_buffer = dwarf2_read_section (objfile, dwarf_abbrev_section);
--- gdb/dwarfread.c 12 Feb 2007 15:19:31 -0000 1.47
+++ gdb/dwarfread.c 11 Mar 2007 22:35:38 -0000
@@ -684,6 +684,8 @@ dwarf_build_psymtabs (struct objfile *ob
}
back_to = make_cleanup (xfree, dbbase);
+ objfile->flags |= OBJF_HAVE_TYPE_STUB;
+
/* If we are reinitializing, or if we have never loaded syms yet, init.
Since we have no idea how many DIES we are looking at, we just guess
some arbitrary value. */
--- gdb/gdbtypes.h 29 Jan 2007 17:31:06 -0000 1.68
+++ gdb/gdbtypes.h 11 Mar 2007 22:35:38 -0000
@@ -969,7 +969,9 @@ extern void allocate_cplus_struct_type (
#define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
(TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
(TYPE_NFIELDS (thistype) == 0) && \
- (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
+ (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)) && \
+ (TYPE_STUB (thistype) \
+ || !(TYPE_OBJFILE(thistype)->flags & OBJF_HAVE_TYPE_STUB)))
struct builtin_type
{
--- gdb/objfiles.h 21 Jan 2007 16:55:49 -0000 1.44
+++ gdb/objfiles.h 11 Mar 2007 22:35:48 -0000
@@ -480,6 +480,10 @@ struct objfile
#define OBJF_USERLOADED (1 << 5) /* User loaded */
+/* We can depend TYPE_STUB(t) will be set appropriately. */
+
+#define OBJF_HAVE_TYPE_STUB (1 << 6) /* TYPE_FLAGS_STUB supported */
+
/* The object file that the main symbol table was loaded from (e.g. the
argument to the "symbol-file" or "file" command). */
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque-lib.c 11 Mar 2007 22:35:49 -0000
@@ -0,0 +1,38 @@
+/* Test resolving of an opaque type from the loaded shared library.
+
+ Copyright 2007, Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+struct libtype_opaque
+{
+ int libfield_opaque;
+};
+struct libtype_opaque libtype_opaque_use;
+
+struct libtype_empty
+{
+ int libfield_empty;
+};
+struct libtype_empty libtype_empty_use;
+
+struct libtype_filled
+{
+ int libfield_filled;
+};
+struct libtype_filled libtype_filled_use;
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque-main.c 11 Mar 2007 22:35:49 -0000
@@ -0,0 +1,41 @@
+/* Test resolving of an opaque type from the loaded shared library.
+
+ Copyright 2007, Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+struct libtype_opaque;
+
+struct libtype_empty
+ {
+ };
+
+struct libtype_filled
+ {
+ long mainfield_filled;
+ };
+
+int main (void)
+{
+ volatile struct libtype_opaque *pointer_opaque = (void *) 0;
+ volatile struct libtype_empty *pointer_empty = (void *) 0;
+ volatile struct libtype_filled *pointer_filled = (void *) 0;
+
+ return (int) pointer_opaque + (int) pointer_empty
+ + (int) pointer_filled;
+}
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque.exp 11 Mar 2007 22:35:49 -0000
@@ -0,0 +1,123 @@
+# Copyright 2004, 2007 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# Test resolving of an opaque type from the loaded shared library.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile type-opaque-main
+set libfile type-opaque-lib
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+set libsrc "${srcdir}/${subdir}/${libfile}.c"
+set libobj "${objdir}/${subdir}/${libfile}.so"
+set execsrc "${srcdir}/${subdir}/${srcfile}"
+
+remote_exec build "rm -f ${binfile}"
+
+# Are we on a target board? No support for downloading shared libraries
+# to a target yet.
+if ![isnative] then {
+ return 0
+}
+
+# get the value of gcc_compiled
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
+ || [gdb_compile $execsrc ${binfile} executable \
+ [list debug shlib=${libobj}]] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+
+# DWARF3: An incomplete structure, union or class type is represented by
+# a structure, union or class entry that does not have a byte size attribute
+# and that has a DW_AT_declaration attribute.
+
+
+# <1><15f>: Abbrev Number: 8 (DW_TAG_structure_type)
+# DW_AT_name : libtype_opaque
+# DW_AT_declaration : 1
+
+set name "opaque type resolving"
+gdb_test_multiple "ptype pointer_opaque" $name \
+{
+ -re "libfield_opaque.*$gdb_prompt $" {
+ pass $name
+ }
+}
+
+
+# <1><9e>: Abbrev Number: 2 (DW_TAG_structure_type)
+# DW_AT_name : libtype_empty
+# DW_AT_byte_size : 0
+# DW_AT_decl_file : 1
+# DW_AT_decl_line : 25
+
+set name "empty type resolving"
+gdb_test_multiple "ptype pointer_empty" $name \
+{
+ -re "\\{\[ \t\r\n\]*<no data fields>\[ \t\r\n\]*\\}.*$gdb_prompt $" {
+ pass $name
+ }
+ -re "libfield_empty.*$gdb_prompt $" {
+ fail $name
+ }
+}
+
+
+# <1><b0>: Abbrev Number: 3 (DW_TAG_structure_type)
+# DW_AT_sibling : <e3>
+# DW_AT_name : libtype_filled
+# DW_AT_byte_size : 4
+# DW_AT_decl_file : 1
+# DW_AT_decl_line : 29
+# <2><c7>: Abbrev Number: 4 (DW_TAG_member)
+# DW_AT_name : mainfield_filled
+# DW_AT_decl_file : 1
+# DW_AT_decl_line : 30
+# DW_AT_type : <e3>
+# DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
+
+set name "filled type resolving"
+gdb_test_multiple "ptype pointer_filled" $name \
+{
+ -re "mainfield_filled.*$gdb_prompt $" {
+ pass $name
+ }
+ -re "libfield_filled.*$gdb_prompt $" {
+ fail $name
+ }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Differentiate empty vs. opaque types
2007-03-11 22:55 [PATCH] Differentiate empty vs. opaque types Jan Kratochvil
@ 2007-03-12 3:35 ` Daniel Jacobowitz
2007-03-12 21:36 ` Jan Kratochvil
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-03-12 3:35 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On Sun, Mar 11, 2007 at 11:55:19PM +0100, Jan Kratochvil wrote:
> Hi,
>
> attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
> the DWARF flag `DW_AT_declaration':
> # DWARF3: An incomplete structure, union or class type is represented by
> # a structure, union or class entry that does not have a byte size attribute
> # and that has a DW_AT_declaration attribute.
>
> The attachment then fixes GDB to make the testcase pass.
Does this happen in HEAD? It sounds just like the problem Joel fixed
for Ada:
2007-01-05 Joel Brobecker <brobecker@adacore.com>
* dwarf2read.c (partial_die_info): Add field has_byte_size.
(add_partial_symbol): Correct identification of external
references.
(process_structure_scope): Likewise.
(read_partial_die): Handle DW_AT_byte_size attribute.
There's an Ada testcase for this, and it passes now.
> Patch goes the regression-safe way by introducing OBJF_HAVE_TYPE_STUB currently
> being set only by DWARF/DWARF2.
An objfile flag is usually not right - this is per-compilation-unit,
not per objfile.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Differentiate empty vs. opaque types
2007-03-12 3:35 ` Daniel Jacobowitz
@ 2007-03-12 21:36 ` Jan Kratochvil
2007-04-10 21:19 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2007-03-12 21:36 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]
On Mon, 12 Mar 2007 04:35:29 +0100, Daniel Jacobowitz wrote:
> On Sun, Mar 11, 2007 at 11:55:19PM +0100, Jan Kratochvil wrote:
> > attached testcase targets the difference of `struct x;' vs. `struct {} x;' by checking
> > the DWARF flag `DW_AT_declaration':
...
> Does this happen in HEAD?
Yes.
> It sounds just like the problem Joel fixed
> for Ada:
>
> 2007-01-05 Joel Brobecker <brobecker@adacore.com>
>
> * dwarf2read.c (partial_die_info): Add field has_byte_size.
> (add_partial_symbol): Correct identification of external
> references.
> (process_structure_scope): Likewise.
> (read_partial_die): Handle DW_AT_byte_size attribute.
>
> There's an Ada testcase for this, and it passes now.
I was not aware of it, I checked it now, it looks really related.
But that patch / testcase is orthogonal to my patch / testcase below.
Joel's patch targets DWARF->symbols phase while my patch targets symbols found
in different object files (executable vs. shared library).
...
> An objfile flag is usually not right - this is per-compilation-unit,
> not per objfile.
You are right. Updated, as there is no compilation-unit info reachable from
`struct type *' I had to use a new flag in each type there.
Regards,
Jan
[-- Attachment #2: gdb-empty-is-not-opaque-v2.patch --]
[-- Type: text/plain, Size: 10504 bytes --]
2007-03-12 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbtypes.h (TYPE_FLAG_STUB_SUPPORTED, TYPE_STUB_SUPPORTED): New
macros.
(TYPE_IS_OPAQUE): Empty vs. opaque structures are now
distinct on the TYPE_STUB_SUPPORTED debug targets.
* dwarf2read.c (read_structure_type): Set TYPE_FLAG_STUB_SUPPORTED.
* dwarfread.c (struct_type): New comment on TYPE_FLAG_STUB_SUPPORTED.
2007-03-12 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/type-opaque-lib.c, gdb.base/type-opaque-main.c,
gdb.base/type-opaque.exp: New files.
--- gdb/dwarf2read.c 12 Feb 2007 15:19:31 -0000 1.215
+++ gdb/dwarf2read.c 12 Mar 2007 21:33:06 -0000
@@ -3879,6 +3879,7 @@ read_structure_type (struct die_info *di
TYPE_LENGTH (type) = 0;
}
+ TYPE_FLAGS (type) |= TYPE_FLAG_STUB_SUPPORTED;
if (die_is_declaration (die, cu))
TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
--- gdb/dwarfread.c 12 Feb 2007 15:19:31 -0000 1.47
+++ gdb/dwarfread.c 12 Mar 2007 21:33:07 -0000
@@ -1083,7 +1083,10 @@ struct_type (struct dieinfo *dip, char *
not even have any fields, if this DIE was generated due to a reference
to an anonymous structure or union. In this case, TYPE_FLAG_STUB is
set, which clues gdb in to the fact that it needs to search elsewhere
- for the full structure definition. */
+ for the full structure definition.
+ As such opaque reference is not distinguishable from an empty STRUCT
+ definition as DWARF1 is missing DW_AT_declaration we cannot set
+ TYPE_FLAG_STUB_SUPPORTED here. */
if (nfields == 0)
{
TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
--- gdb/gdbtypes.h 29 Jan 2007 17:31:06 -0000 1.68
+++ gdb/gdbtypes.h 12 Mar 2007 21:33:08 -0000
@@ -319,6 +319,14 @@ enum type_code
#define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
+/* This debug target supports TYPE_STUB(t). In the unsupported case we have to
+ rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE ().
+ TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only guessed
+ the TYPE_STUB(t) value (see dwarfread.c). */
+
+#define TYPE_FLAG_STUB_SUPPORTED (1 << 16)
+#define TYPE_STUB_SUPPORTED(t) (TYPE_FLAGS (t) & TYPE_FLAG_STUB_SUPPORTED)
+
/* Array bound type. */
enum array_bound_type
{
@@ -969,7 +977,8 @@ extern void allocate_cplus_struct_type (
#define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
(TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
(TYPE_NFIELDS (thistype) == 0) && \
- (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
+ (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)) && \
+ (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
struct builtin_type
{
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque-lib.c 12 Mar 2007 21:33:09 -0000
@@ -0,0 +1,56 @@
+/* Test resolving of an opaque type from the loaded shared library.
+
+ Copyright 2007, Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+struct struct_libtype_opaque
+{
+ int libfield_opaque;
+};
+struct struct_libtype_opaque struct_libtype_opaque_use;
+
+struct struct_libtype_empty
+{
+ int libfield_empty;
+};
+struct struct_libtype_empty struct_libtype_empty_use;
+
+struct struct_libtype_filled
+{
+ int libfield_filled;
+};
+struct struct_libtype_filled struct_libtype_filled_use;
+
+union union_libtype_opaque
+{
+ int libfield_opaque;
+};
+union union_libtype_opaque union_libtype_opaque_use;
+
+union union_libtype_empty
+{
+ int libfield_empty;
+};
+union union_libtype_empty union_libtype_empty_use;
+
+union union_libtype_filled
+{
+ int libfield_filled;
+};
+union union_libtype_filled union_libtype_filled_use;
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque-main.c 12 Mar 2007 21:33:09 -0000
@@ -0,0 +1,56 @@
+/* Test resolving of an opaque type from the loaded shared library.
+
+ Copyright 2007, Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+struct struct_libtype_opaque;
+
+struct struct_libtype_empty
+ {
+ };
+
+struct struct_libtype_filled
+ {
+ long mainfield_filled;
+ };
+
+union union_libtype_opaque;
+
+union union_libtype_empty
+ {
+ };
+
+union union_libtype_filled
+ {
+ long mainfield_filled;
+ };
+
+int main (void)
+{
+ volatile struct struct_libtype_opaque *pointer_struct_opaque = (void *) 0;
+ volatile struct struct_libtype_empty *pointer_struct_empty = (void *) 0;
+ volatile struct struct_libtype_filled *pointer_struct_filled = (void *) 0;
+ volatile union union_libtype_opaque *pointer_union_opaque = (void *) 0;
+ volatile union union_libtype_empty *pointer_union_empty = (void *) 0;
+ volatile union union_libtype_filled *pointer_union_filled = (void *) 0;
+
+ return (int) pointer_struct_opaque + (int) pointer_struct_empty
+ + (int) pointer_struct_filled + (int) pointer_union_opaque
+ + (int) pointer_union_empty + (int) pointer_union_filled;
+}
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/type-opaque.exp 12 Mar 2007 21:33:09 -0000
@@ -0,0 +1,134 @@
+# Copyright 2004, 2007 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# Test resolving of an opaque type from the loaded shared library.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile type-opaque-main
+set libfile type-opaque-lib
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+set libsrc "${srcdir}/${subdir}/${libfile}.c"
+set libobj "${objdir}/${subdir}/${libfile}.so"
+set execsrc "${srcdir}/${subdir}/${srcfile}"
+
+remote_exec build "rm -f ${binfile}"
+
+# Are we on a target board? No support for downloading shared libraries
+# to a target yet.
+if ![isnative] then {
+ return 0
+}
+
+# get the value of gcc_compiled
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
+ || [gdb_compile $execsrc ${binfile} executable \
+ [list debug shlib=${libobj}]] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+
+# DWARF3: An incomplete structure, union or class type is represented by
+# a structure, union or class entry that does not have a byte size attribute
+# and that has a DW_AT_declaration attribute.
+
+
+proc body { struct } {
+ global gdb_prompt
+
+
+ # <1><15f>: Abbrev Number: 8 (DW_TAG_structure_type)
+ # DW_AT_name : libtype_opaque
+ # DW_AT_declaration : 1
+
+ set name "opaque $struct type resolving"
+ gdb_test_multiple "ptype pointer_${struct}_opaque" $name \
+ {
+ -re "libfield_opaque.*$gdb_prompt $" {
+ pass $name
+ }
+ }
+
+
+ # <1><9e>: Abbrev Number: 2 (DW_TAG_structure_type)
+ # DW_AT_name : libtype_empty
+ # DW_AT_byte_size : 0
+ # DW_AT_decl_file : 1
+ # DW_AT_decl_line : 25
+
+ set name "empty $struct type resolving"
+ gdb_test_multiple "ptype pointer_${struct}_empty" $name \
+ {
+ -re "\\{\[ \t\r\n\]*<no data fields>\[ \t\r\n\]*\\}.*$gdb_prompt $" {
+ pass $name
+ }
+ -re "libfield_empty.*$gdb_prompt $" {
+ fail $name
+ }
+ }
+
+
+ # <1><b0>: Abbrev Number: 3 (DW_TAG_structure_type)
+ # DW_AT_sibling : <e3>
+ # DW_AT_name : libtype_filled
+ # DW_AT_byte_size : 4
+ # DW_AT_decl_file : 1
+ # DW_AT_decl_line : 29
+ # <2><c7>: Abbrev Number: 4 (DW_TAG_member)
+ # DW_AT_name : mainfield_filled
+ # DW_AT_decl_file : 1
+ # DW_AT_decl_line : 30
+ # DW_AT_type : <e3>
+ # DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
+
+ set name "filled $struct type resolving"
+ gdb_test_multiple "ptype pointer_${struct}_filled" $name \
+ {
+ -re "mainfield_filled.*$gdb_prompt $" {
+ pass $name
+ }
+ -re "libfield_filled.*$gdb_prompt $" {
+ fail $name
+ }
+ }
+
+
+}
+
+
+body struct
+body union
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Differentiate empty vs. opaque types
2007-03-12 21:36 ` Jan Kratochvil
@ 2007-04-10 21:19 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-04-10 21:19 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On Mon, Mar 12, 2007 at 10:36:12PM +0100, Jan Kratochvil wrote:
> 2007-03-12 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdbtypes.h (TYPE_FLAG_STUB_SUPPORTED, TYPE_STUB_SUPPORTED): New
> macros.
> (TYPE_IS_OPAQUE): Empty vs. opaque structures are now
> distinct on the TYPE_STUB_SUPPORTED debug targets.
> * dwarf2read.c (read_structure_type): Set TYPE_FLAG_STUB_SUPPORTED.
> * dwarfread.c (struct_type): New comment on TYPE_FLAG_STUB_SUPPORTED.
>
> 2007-03-12 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.base/type-opaque-lib.c, gdb.base/type-opaque-main.c,
> gdb.base/type-opaque.exp: New files.
Sorry I didn't get back to you; I wanted to finish deleting
dwarfread.c first.
This is OK, without the bit for dwarfread.c, which is now gone.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-10 21:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11 22:55 [PATCH] Differentiate empty vs. opaque types Jan Kratochvil
2007-03-12 3:35 ` Daniel Jacobowitz
2007-03-12 21:36 ` Jan Kratochvil
2007-04-10 21:19 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox