summaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2016-10-13 16:08:17 +0100
committerYao Qi <yao.qi@linaro.org>2016-10-13 16:08:17 +0100
commit5ad9dba7519caa3e6193c87699ae37e24d0fe05c (patch)
tree35dc98a9a393e58867c36e61cdec360c72430adf /gdb/testsuite/lib
parent62df7e210ebf096dc09ad14d9316fcda0f6217f7 (diff)
Share proc get_var_address
This patch moves proc get_var_address into lib/gdb.exp, and remove the duplicate copy in gdb.base/*.exp files. gdb/testsuite: 2016-10-13 Yao Qi <yao.qi@linaro.org> * gdb.base/code_elim.exp (get_var_address): Remove. * gdb.base/relocate.exp: Likewise. * gdb.base/shreloc.exp: Likewise. * lib/gdb.exp (get_var_address): New.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp24
1 files changed, 24 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ab661ce0ff..378eea04ce 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5586,6 +5586,30 @@ proc get_target_charset { } {
return "UTF-8"
}
+# Get the address of VAR.
+
+proc get_var_address { var } {
+ global gdb_prompt hex
+
+ # Match output like:
+ # $1 = (int *) 0x0
+ # $5 = (int (*)()) 0
+ # $6 = (int (*)()) 0x24 <function_bar>
+
+ gdb_test_multiple "print &${var}" "get address of ${var}" {
+ -re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
+ {
+ pass "get address of ${var}"
+ if { $expect_out(1,string) == "0" } {
+ return "0x0"
+ } else {
+ return $expect_out(1,string)
+ }
+ }
+ }
+ return ""
+}
+
# Get the current value for remotetimeout and return it.
proc get_remotetimeout { } {
global gdb_prompt