public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] fix dwz.exp on 32-bit targets
@ 2013-08-21 15:33 Tom Tromey
  2013-08-22 13:54 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2013-08-21 15:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes dwz.exp on 32-bit targets.  It does so by introducing a new
"default" setting for the address size in the DWARF assembler.

Built and regtested on x86-64 Fedora 18.
I also ran the gdb.dwarf2 tests on an x86 machine (gcc45).

	* lib/dwarf.exp (cu, tu): Handle addr_size of "default".  Change
	default addr_size.
	* lib/gdb.exp (is_64_target): New gdb_caching_proc.
---
 gdb/testsuite/lib/dwarf.exp | 26 ++++++++++++++++++++------
 gdb/testsuite/lib/gdb.exp   | 28 ++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 5b19bb8..1d3eb03 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -684,8 +684,8 @@ namespace eval Dwarf {
     #                default = 0 (32-bit)
     # version n    - DWARF version number to emit
     #                default = 4
-    # addr_size n  - the size of addresses, 32 or 64
-    #                default = 64
+    # addr_size n  - the size of addresses, 32, 64, or default
+    #                default = default
     # fission 0|1  - boolean indicating if generating Fission debug info
     #                default = 0
     # BODY is Tcl code that emits the DIEs which make up the body of
@@ -702,7 +702,7 @@ namespace eval Dwarf {
 	# Establish the defaults.
 	set is_64 0
 	set _cu_version 4
-	set _cu_addr_size 8
+	set _cu_addr_size default
 	set fission 0
 	set section ".debug_info"
 	set _abbrev_section ".debug_abbrev"
@@ -716,6 +716,13 @@ namespace eval Dwarf {
 		default { error "unknown option $name" }
 	    }
 	}
+	if {$_cu_addr_size == "default"} {
+	    if {[is_64_target]} {
+		set _cu_addr_size 8
+	    } else {
+		set _cu_addr_size 4
+	    }
+	}
 	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
 	if { $fission } {
 	    set section ".debug_info.dwo"
@@ -767,8 +774,8 @@ namespace eval Dwarf {
     #                default = 0 (32-bit)
     # version n    - DWARF version number to emit
     #                default = 4
-    # addr_size n  - the size of addresses, 32 or 64
-    #                default = 64
+    # addr_size n  - the size of addresses, 32, 64, or default
+    #                default = default
     # fission 0|1  - boolean indicating if generating Fission debug info
     #                default = 0
     # SIGNATURE is the 64-bit signature of the type.
@@ -788,7 +795,7 @@ namespace eval Dwarf {
 	# Establish the defaults.
 	set is_64 0
 	set _cu_version 4
-	set _cu_addr_size 8
+	set _cu_addr_size default
 	set fission 0
 	set section ".debug_types"
 	set _abbrev_section ".debug_abbrev"
@@ -802,6 +809,13 @@ namespace eval Dwarf {
 		default { error "unknown option $name" }
 	    }
 	}
+	if {$_cu_addr_size == "default"} {
+	    if {[is_64_target]} {
+		set _cu_addr_size 8
+	    } else {
+		set _cu_addr_size 4
+	    }
+	}
 	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
 	if { $fission } {
 	    set section ".debug_types.dwo"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1a1fac2..ab41da0 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1854,6 +1854,34 @@ gdb_caching_proc is_lp64_target {
     return 1
 }
 
+# Return 1 if target has 64 bit addresses.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+gdb_caching_proc is_64_target {
+    set me "is_64_target"
+
+    set src [standard_temp_file is64[pid].c]
+    set obj [standard_temp_file is64[pid].o]
+
+    set f [open $src "w"]
+    puts $f "int function(void) { return 3; }"
+    puts $f "int dummy\[sizeof (&function) == 8 ? 1 : -1\];"
+    close $f
+
+    verbose "$me:  compiling testfile $src" 2
+    set lines [gdb_compile $src $obj object {quiet}]
+    file delete $src
+    file delete $obj
+
+    if ![string match "" $lines] then {
+        verbose "$me:  testfile compilation failed, returning 0" 2
+        return 0
+    }
+
+    verbose "$me:  returning 1" 2
+    return 1
+}
+
 # Return 1 if target has x86_64 registers - either amd64 or x32.
 # x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
 # just from the target string.
-- 
1.8.1.4

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

* Re: [PATCH] fix dwz.exp on 32-bit targets
  2013-08-21 15:33 [PATCH] fix dwz.exp on 32-bit targets Tom Tromey
@ 2013-08-22 13:54 ` Tom Tromey
  2013-08-27 14:36   ` dwz.exp FAIL on CentOS-5-i386 [Re: [PATCH] fix dwz.exp on 32-bit targets] Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2013-08-22 13:54 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This fixes dwz.exp on 32-bit targets.  It does so by introducing a new
Tom> "default" setting for the address size in the DWARF assembler.

This is blocking Yao, so I'm putting it in now.

Tom

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

* dwz.exp FAIL on CentOS-5-i386  [Re: [PATCH] fix dwz.exp on 32-bit targets]
  2013-08-22 13:54 ` Tom Tromey
@ 2013-08-27 14:36   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2013-08-27 14:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, 22 Aug 2013 15:54:02 +0200, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
> 
> Tom> This fixes dwz.exp on 32-bit targets.  It does so by introducing a new
> Tom> "default" setting for the address size in the DWARF assembler.
> 
> This is blocking Yao, so I'm putting it in now.

Only on CentOS-5 (not on CentOS-6) in x86_64-m32 or i386 mode I get:

+PASS: gdb.dwarf2/dwz.exp: p other_int
+FAIL: gdb.dwarf2/dwz.exp: p the_int

p the_int^M
Expected: $2 = 23^M
Expected: (gdb) PASS: gdb.dwarf2/dwz.exp: p the_int
Actual:   $2 = 99^M
Actual:   (gdb) FAIL: gdb.dwarf2/dwz.exp: p the_int


Jan

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

end of thread, other threads:[~2013-08-27 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-21 15:33 [PATCH] fix dwz.exp on 32-bit targets Tom Tromey
2013-08-22 13:54 ` Tom Tromey
2013-08-27 14:36   ` dwz.exp FAIL on CentOS-5-i386 [Re: [PATCH] fix dwz.exp on 32-bit targets] Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).