aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2013-04-17 21:07:09 +0000
committerDoug Evans <dje@google.com>2013-04-17 21:07:09 +0000
commit4f22ed5caccc66d3e68903443ef3b36dd24c6e6d (patch)
treeabb2cbb17e7e438dcfbc04c148d92aacffd5fdb1 /gdb/testsuite
parentac9ec31b3eacf623c0800e6243a12539921240e9 (diff)
downloadgdb-4f22ed5caccc66d3e68903443ef3b36dd24c6e6d.zip
gdb-4f22ed5caccc66d3e68903443ef3b36dd24c6e6d.tar.gz
gdb-4f22ed5caccc66d3e68903443ef3b36dd24c6e6d.tar.bz2
* lib/dwarf.exp (Dwarf): New proc "tu".
* gdb.dwarf2/missing-sig-type.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.dwarf2/missing-sig-type.exp68
-rw-r--r--gdb/testsuite/lib/dwarf.exp73
3 files changed, 146 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b51758a..5845464 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-17 Doug Evans <dje@google.com>
+
+ * lib/dwarf.exp (Dwarf): New proc "tu".
+ * gdb.dwarf2/missing-sig-type.exp: New file.
+
2013-04-15 Siva Chandra Reddy <sivachandra@google.com>
Add option to link testcases with Pthreads library when
diff --git a/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp b/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp
new file mode 100644
index 0000000..32a0843
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp
@@ -0,0 +1,68 @@
+# 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
+}
+
+if { [skip_cplus_tests] } { continue }
+
+standard_testfile main.c missing-sig-type-dw4.S
+
+# Make some DWARF for the test.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ cu 0 4 8 {
+ compile_unit {} {
+ declare_labels typedef_label
+
+ # This signature is intentionally wrong.
+ typedef_label: typedef {
+ {name foo}
+ {type 0xee22334455667788 ref_sig8 }
+ }
+ }
+ }
+
+ tu 0 4 8 0x1122334455667788 the_type {
+ type_unit {} {
+ the_type: base_type {
+ {name int}
+ {encoding @DW_ATE_signed}
+ {byte_size 4 sdata}
+ }
+ }
+ }
+}
+
+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 {c++}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+gdb_test "ptype foo" "type = <unknown type .*>"
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index bb58997..5b3a1ac 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -109,6 +109,9 @@ namespace eval Dwarf {
# The current output file.
variable _output_file
+ # Note: The _cu_ values here also apply to type units (TUs).
+ # Think of a TU as a special kind of CU.
+
# Current CU count.
variable _cu_count
@@ -699,6 +702,76 @@ namespace eval Dwarf {
define_label $end_label
}
+ # Emit a DWARF TU.
+ # IS_64 is a boolean which is true if you want to emit 64-bit
+ # DWARF, and false for 32-bit DWARF.
+ # VERSION is the DWARF version number to emit.
+ # ADDR_SIZE is the size of addresses in bytes.
+ # SIGNATURE is the 64-bit signature of the type.
+ # TYPE_LABEL is the label of the type defined by this TU.
+ # BODY is Tcl code that emits the DIEs which make up the body of
+ # the CU. It is evaluated in the caller's context.
+ proc tu {is_64 version addr_size signature type_label body} {
+ variable _cu_count
+ variable _abbrev_num
+ variable _cu_label
+ variable _cu_version
+ variable _cu_addr_size
+ variable _cu_offset_size
+
+ set _cu_version $version
+ if {$is_64} {
+ set _cu_offset_size 8
+ } else {
+ set _cu_offset_size 4
+ }
+ set _cu_addr_size $addr_size
+
+ _section .debug_types
+
+ set cu_num [incr _cu_count]
+ set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
+ set _abbrev_num 1
+
+ set _cu_label [_compute_label "cu${cu_num}_begin"]
+ set start_label [_compute_label "cu${cu_num}_start"]
+ set end_label [_compute_label "cu${cu_num}_end"]
+
+ define_label $_cu_label
+ if {$is_64} {
+ _op .4byte 0xffffffff
+ _op .8byte "$end_label - $start_label"
+ } else {
+ _op .4byte "$end_label - $start_label"
+ }
+ define_label $start_label
+ _op .2byte $version Version
+ _op .4byte $my_abbrevs Abbrevs
+ _op .byte $addr_size "Pointer size"
+ _op .8byte $signature Signature
+ uplevel declare_labels $type_label
+ upvar $type_label my_type_label
+ if {$is_64} {
+ _op .8byte "$my_type_label - $_cu_label"
+ } else {
+ _op .4byte "$my_type_label - $_cu_label"
+ }
+
+ _defer_output .debug_abbrev {
+ define_label $my_abbrevs
+ }
+
+ uplevel $body
+
+ _defer_output .debug_abbrev {
+ # Emit the terminator.
+ _op .byte 0x0 Terminator
+ _op .byte 0x0 Terminator
+ }
+
+ define_label $end_label
+ }
+
proc _empty_array {name} {
upvar $name the_array