From 7f062217672c13050f68eec1a6cd296d7b7f93be Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 8 Sep 2011 17:40:54 +0000 Subject: [PATCH] gdb/testsuite/ Fix compatibility with x32 arch. * testsuite/gdb.dwarf2/typeddwarf.exp: Check also is_lp64_target. * testsuite/gdb.trace/backtrace.exp: Use is_amd64_regs_target and is_x86_like_target. * testsuite/gdb.trace/collection.exp: Likewise. * testsuite/gdb.trace/report.exp: Likewise. * testsuite/gdb.trace/unavailable.exp: Likewise. * testsuite/gdb.trace/while-dyn.exp: Likewise. * testsuite/lib/gdb.exp (is_amd64_regs_target): New function. (is_x86_like_target): Check also is_amd64_regs_target. --- gdb/testsuite/ChangeLog | 13 +++++++ gdb/testsuite/gdb.dwarf2/typeddwarf.exp | 4 +-- gdb/testsuite/gdb.trace/backtrace.exp | 4 +-- gdb/testsuite/gdb.trace/collection.exp | 4 +-- gdb/testsuite/gdb.trace/report.exp | 4 +-- gdb/testsuite/gdb.trace/unavailable.exp | 8 ++--- gdb/testsuite/gdb.trace/while-dyn.exp | 4 +-- gdb/testsuite/lib/gdb.exp | 45 ++++++++++++++++++++++++- 8 files changed, 71 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f130a8316b..b875a0b6d5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2011-09-08 Jan Kratochvil + + Fix compatibility with x32 arch. + * testsuite/gdb.dwarf2/typeddwarf.exp: Check also is_lp64_target. + * testsuite/gdb.trace/backtrace.exp: Use is_amd64_regs_target and + is_x86_like_target. + * testsuite/gdb.trace/collection.exp: Likewise. + * testsuite/gdb.trace/report.exp: Likewise. + * testsuite/gdb.trace/unavailable.exp: Likewise. + * testsuite/gdb.trace/while-dyn.exp: Likewise. + * testsuite/lib/gdb.exp (is_amd64_regs_target): New function. + (is_x86_like_target): Check also is_amd64_regs_target. + 2011-09-08 Jan Kratochvil PR breakpoints/12435 diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp index 36a17e5372..ca0db06ec2 100644 --- a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp +++ b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp @@ -22,10 +22,10 @@ if ![dwarf2_support] { return 0 } -# This test can only be run on x86 and amd64 targets. +# This test can only be run on x86 and amd64 targets (and not x32). if { [is_x86_like_target] } { set sfile ${test}.S -} elseif {[istarget "x86_64-*-*"]} { +} elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} { set sfile ${test}-amd64.S } else { return 0 diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index 9b72d491e5..e2807c5686 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp +++ b/gdb/testsuite/gdb.trace/backtrace.exp @@ -150,10 +150,10 @@ gdb_trace_setactions "8.6: setup TP to collect regs, args, and locals" \ "$tdp4" \ "collect \$regs, \$args, \$locs" "^$" -if {([istarget "x86_64-*"] || [istarget "i?86-*"]) && [is_lp64_target]} then { +if [is_amd64_regs_target] { set fpreg "\$rbp" set spreg "\$rsp" -} elseif {[istarget "x86_64-*"] || [istarget "i?86-*"]} then { +} elseif [is_x86_like_target] { set fpreg "\$ebp" set spreg "\$esp" } else { diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp index 4917ea847d..4d57ad49b1 100644 --- a/gdb/testsuite/gdb.trace/collection.exp +++ b/gdb/testsuite/gdb.trace/collection.exp @@ -45,11 +45,11 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ set ws "\[\r\n\t \]+" set cr "\[\r\n\]+" -if {([istarget "x86_64-*"] || [istarget "i?86-*"]) && [is_lp64_target]} then { +if [is_amd64_regs_target] { set fpreg "rbp" set spreg "rsp" set pcreg "rip" -} elseif {[istarget "x86_64-*"] || [istarget "i?86-*"]} then { +} elseif [is_x86_like_target] { set fpreg "ebp" set spreg "esp" set pcreg "eip" diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp index 8bb678095c..f765a5742a 100644 --- a/gdb/testsuite/gdb.trace/report.exp +++ b/gdb/testsuite/gdb.trace/report.exp @@ -159,11 +159,11 @@ gdb_trace_setactions "9.x: setup TP to collect locals" \ "$tdp4" \ "collect \$locs" "^$" -if {([istarget "x86_64-*"] || [istarget "i?86-*"]) && [is_lp64_target]} then { +if [is_amd64_regs_target] { set fpreg "rbp" set spreg "rsp" set pcreg "rip" -} elseif {[istarget "x86_64-*"] || [istarget "i?86-*"]} then { +} elseif [is_x86_like_target] { set fpreg "ebp" set spreg "esp" set pcreg "eip" diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp index fce65cacb3..7278ebf855 100644 --- a/gdb/testsuite/gdb.trace/unavailable.exp +++ b/gdb/testsuite/gdb.trace/unavailable.exp @@ -30,11 +30,11 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ set ws "\[\r\n\t \]+" set cr "\[\r\n\]+" -if {([istarget "x86_64-*"] || [istarget "i?86-*"]) && [is_lp64_target]} then { +if [is_amd64_regs_target] { set fpreg "rbp" set spreg "rsp" set pcreg "rip" -} elseif {[istarget "x86_64-*"] || [istarget "i?86-*"]} then { +} elseif [is_x86_like_target] { set fpreg "ebp" set spreg "esp" set pcreg "eip" @@ -295,12 +295,12 @@ proc gdb_unavailable_registers_test { } { # Test reading uncollected pseudo-registers. The set of which # depends on target. - if {$pcreg == "rip"} then { + if [is_amd64_regs_target] { # Check the raw register first. test_register_unavailable "\$rax" test_register_unavailable "\$eax" test_register_unavailable "\$ax" - } elseif {$pcreg == "eip"} then { + } elseif [is_x86_like_target] { # Check the raw register first. test_register_unavailable "\$eax" test_register_unavailable "\$ax" diff --git a/gdb/testsuite/gdb.trace/while-dyn.exp b/gdb/testsuite/gdb.trace/while-dyn.exp index 6227f23d9d..58aa7103ad 100644 --- a/gdb/testsuite/gdb.trace/while-dyn.exp +++ b/gdb/testsuite/gdb.trace/while-dyn.exp @@ -52,9 +52,9 @@ if { ![gdb_target_supports_trace] } then { # test while-stepping dynamically (live target) # -if {([istarget "x86_64-*"] || [istarget "i?86-*"]) && [is_lp64_target]} then { +if [is_amd64_regs_target] { set fpreg "\$rbp" -} elseif {[istarget "x86_64-*"] || [istarget "i?86-*"]} then { +} elseif [is_x86_like_target] { set fpreg "\$ebp" } else { set fpreg "\$fp" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index ef5ad5cef5..b22e32262d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1604,6 +1604,49 @@ proc is_lp64_target {} { return [set is_lp64_target_saved($board) 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. +proc is_amd64_regs_target {} { + global is_amd64_regs_target_saved + + if {![istarget "x86_64-*-*"]} { + return 0 + } + + # Use the cached value, if it exists. Cache value per "board" to handle + # runs with multiple options (e.g. unix/{-m32,-64}) correctly. + set me "is_amd64_regs_target" + set board [target_info name] + if [info exists is_amd64_regs_target_saved($board)] { + verbose "$me: returning saved $is_amd64_regs_target_saved($board)" 2 + return $is_amd64_regs_target_saved($board) + } + + set src reg64[pid].s + set obj reg64[pid].o + + set f [open $src "w"] + foreach reg \ + {rax rbx rcx rdx rsi rdi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15} { + puts $f "\tincq %$reg" + } + 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 [set is_amd64_regs_target_saved($board) 0] + } + + verbose "$me: returning 1" 2 + return [set is_amd64_regs_target_saved($board) 1] +} + # Return 1 if this target is an x86 or x86-64 with -m32. proc is_x86_like_target {} { if {[istarget i?86-*]} { @@ -1612,7 +1655,7 @@ proc is_x86_like_target {} { if {![istarget "x86_64-*-*"]} { return 0 } - return [is_ilp32_target] + return [expr [is_ilp32_target] && ![is_amd64_regs_target]] } # Return 1 if displaced stepping is supported on target, otherwise, return 0. -- 2.34.1