aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/gdb.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r--gdb/testsuite/lib/gdb.exp45
1 files changed, 44 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ef5ad5c..b22e322 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.