]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Share proc get_var_address
authorYao Qi <yao.qi@linaro.org>
Thu, 13 Oct 2016 15:08:17 +0000 (16:08 +0100)
committerYao Qi <yao.qi@linaro.org>
Thu, 13 Oct 2016 15:08:17 +0000 (16:08 +0100)
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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/code_elim.exp
gdb/testsuite/gdb.base/relocate.exp
gdb/testsuite/gdb.base/shreloc.exp
gdb/testsuite/lib/gdb.exp

index 18dd70129f17c020d06970df17d2d00633daab59..ac2d05dc059644a6e1dd1dfad712f2d2520df8a2 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2016-10-13  Yao Qi  <yao.qi@linaro.org>
 
        * gdb.base/structs.exp: Invoke gdb_skip_float_test, and do
index 6badbcc4227ca41454cf3f2f1bb810f3fe09bb23..9ace1dfb3fcfce8471612e88f18d3c53d5edd30e 100644 (file)
@@ -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 <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 ""
-}
-
 proc not_null_var_address { var } {
 
     # Same as get_var_address, expect that it reports a failure if a null
index 1212d0fbd70a30bfcd9bf5d410a78e4eb4cdaafe..52fc3ceccaff05c1b65baf1e9889242f05968965 100644 (file)
@@ -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 <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 ""
-}
-
-
-
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
index 548568ef2ebec9a87f3e93d6e3766a663b0b1966..1d3ed8b26f16e6cb468c265dd45577bb527b7ac8 100644 (file)
@@ -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 <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 ""
-}
-
 #
 # Check debugging symbol relocations
 #
index ab661ce0ff838992dbed7997f834898151abbe01..378eea04ced79c5b8b3626984e1f7a6ec9666c7c 100644 (file)
@@ -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