aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2007-04-11 16:03:59 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2007-04-11 16:03:59 +0000
commit0b49cb802f58299602d2201e22d58f93a50474c7 (patch)
tree8170c82ef89ce51020970ea87c822205f796780e /gdb/testsuite
parentc10564a99efa605e83810da5cdd58af7fe130a0d (diff)
downloadgdb-0b49cb802f58299602d2201e22d58f93a50474c7.zip
gdb-0b49cb802f58299602d2201e22d58f93a50474c7.tar.gz
gdb-0b49cb802f58299602d2201e22d58f93a50474c7.tar.bz2
* gdb.base/type-opaque-lib.c, gdb.base/type-opaque-main.c,
gdb.base/type-opaque.exp: New files.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/type-opaque-lib.c56
-rw-r--r--gdb/testsuite/gdb.base/type-opaque-main.c56
-rw-r--r--gdb/testsuite/gdb.base/type-opaque.exp134
4 files changed, 251 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3081730..a79ef0b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-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.
+
2007-04-01 Vladimir Prus <vladimir@codesourcery.com>
* gdb.mi/mi-var-child.c
diff --git a/gdb/testsuite/gdb.base/type-opaque-lib.c b/gdb/testsuite/gdb.base/type-opaque-lib.c
new file mode 100644
index 0000000..92e423c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/type-opaque-lib.c
@@ -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;
diff --git a/gdb/testsuite/gdb.base/type-opaque-main.c b/gdb/testsuite/gdb.base/type-opaque-main.c
new file mode 100644
index 0000000..a97fc47
--- /dev/null
+++ b/gdb/testsuite/gdb.base/type-opaque-main.c
@@ -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 (long) pointer_struct_opaque + (long) pointer_struct_empty
+ + (long) pointer_struct_filled + (long) pointer_union_opaque
+ + (long) pointer_union_empty + (long) pointer_union_filled;
+}
diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp
new file mode 100644
index 0000000..31b447c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/type-opaque.exp
@@ -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