This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Testcase for missing type signature
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 15 Apr 2013 18:34:00 -0700
- Subject: [patch] Testcase for missing type signature
Hi.
I forgot to include the testcase for this patch:
http://sourceware.org/ml/gdb-patches/2013-04/msg00438.html
I will check this in as well in a few days if there are no objections.
2013-04-15 Doug Evans <dje@google.com>
* lib/dwarf.exp (Dwarf): New proc "tu".
* gdb.dwarf2/missing-sig-type.exp: New file.
Index: testsuite/lib/dwarf.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/dwarf.exp,v
retrieving revision 1.6
diff -u -p -r1.6 dwarf.exp
--- testsuite/lib/dwarf.exp 1 Feb 2013 18:08:52 -0000 1.6
+++ testsuite/lib/dwarf.exp 16 Apr 2013 01:29:26 -0000
@@ -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
Index: testsuite/gdb.dwarf2/missing-sig-type.exp
===================================================================
RCS file: testsuite/gdb.dwarf2/missing-sig-type.exp
diff -N testsuite/gdb.dwarf2/missing-sig-type.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.dwarf2/missing-sig-type.exp 16 Apr 2013 01:29:26 -0000
@@ -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 .*>"