From 5ad9dba7519caa3e6193c87699ae37e24d0fe05c Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Thu, 13 Oct 2016 16:08:17 +0100 Subject: 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 * 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. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.base/code_elim.exp | 21 --------------------- gdb/testsuite/gdb.base/relocate.exp | 23 ----------------------- gdb/testsuite/gdb.base/shreloc.exp | 22 ---------------------- gdb/testsuite/lib/gdb.exp | 24 ++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 66 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 18dd701..ac2d05d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2016-10-13 Yao Qi + * 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. + +2016-10-13 Yao Qi + * gdb.base/structs.exp: Invoke gdb_skip_float_test, and do floating point tests if $skip_float_test is false. diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp index 6badbcc..9ace1df 100644 --- a/gdb/testsuite/gdb.base/code_elim.exp +++ b/gdb/testsuite/gdb.base/code_elim.exp @@ -41,27 +41,6 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $op return -1 } -proc get_var_address { var } { - global gdb_prompt hex - - # Match output like: - # $1 = (int *) 0x0 - # $5 = (int (*)()) 0 - # $6 = (int (*)()) 0x24 - - 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 "" -} - proc not_null_var_address { var } { # Same as get_var_address, expect that it reports a failure if a null diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp index 1212d0f..52fc3ce 100644 --- a/gdb/testsuite/gdb.base/relocate.exp +++ b/gdb/testsuite/gdb.base/relocate.exp @@ -25,29 +25,6 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] return -1 } -proc get_var_address { var } { - global gdb_prompt hex - - # Match output like: - # $1 = (int *) 0x0 - # $5 = (int (*)()) 0 - # $6 = (int (*)()) 0x24 - - 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 "" -} - - - gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index 548568e..1d3ed8b 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -81,28 +81,6 @@ if ![runto_main] then { return 0 } -proc get_var_address { var } { - global gdb_prompt hex - - # Match output like: - # $1 = (int *) 0x0 - # $5 = (int (*)()) 0 - # $6 = (int (*)()) 0x24 - - 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 "" -} - # # Check debugging symbol relocations # diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index ab661ce..378eea0 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 + + 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 -- cgit v1.1