* lib/future.exp (gdb_find_objcopy, gdb_find_readelf): New procs.
authorDoug Evans <dje@google.com>
Fri, 20 Sep 2013 21:47:06 +0000 (21:47 +0000)
committerDoug Evans <dje@google.com>
Fri, 20 Sep 2013 21:47:06 +0000 (21:47 +0000)
* lib/gdb.exp (build_id_debug_filename_get): Update to use them.
(gdb_gnu_strip_debug): Ditto.
* lib/prelink-support.exp (section_get, prelink_no): Ditto.
* gdb.arch/altivec-abi.exp: Ditto.
* gdb.base/attach-pie-misread.exp: Ditto.
* gdb.base/comprdebug.exp: Ditto.
* gdb.base/dup-sect.exp: Ditto.
* gdb.base/gnu-debugdata.exp: Ditto.
* gdb.base/step-symless.exp: Ditto.
* gdb.dwarf2/dw2-inline-param.exp: Ditto.
* gdb.dwarf2/dw2-skip-prologue.exp: Ditto.
* gdb.dwarf2/gdb-index.exp: Ditto.

13 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/altivec-abi.exp
gdb/testsuite/gdb.base/attach-pie-misread.exp
gdb/testsuite/gdb.base/comprdebug.exp
gdb/testsuite/gdb.base/dup-sect.exp
gdb/testsuite/gdb.base/gnu-debugdata.exp
gdb/testsuite/gdb.base/step-symless.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp
gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp
gdb/testsuite/gdb.dwarf2/gdb-index.exp
gdb/testsuite/lib/future.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/prelink-support.exp

index 9ea731c..9dcdaa5 100644 (file)
@@ -1,3 +1,19 @@
+2013-09-20  Doug Evans  <dje@google.com>
+
+       * lib/future.exp (gdb_find_objcopy, gdb_find_readelf): New procs.
+       * lib/gdb.exp (build_id_debug_filename_get): Update to use them.
+       (gdb_gnu_strip_debug): Ditto.
+       * lib/prelink-support.exp (section_get, prelink_no): Ditto.
+       * gdb.arch/altivec-abi.exp: Ditto.
+       * gdb.base/attach-pie-misread.exp: Ditto.
+       * gdb.base/comprdebug.exp: Ditto.
+       * gdb.base/dup-sect.exp: Ditto.
+       * gdb.base/gnu-debugdata.exp: Ditto.
+       * gdb.base/step-symless.exp: Ditto.
+       * gdb.dwarf2/dw2-inline-param.exp: Ditto.
+       * gdb.dwarf2/dw2-skip-prologue.exp: Ditto.
+       * gdb.dwarf2/gdb-index.exp: Ditto.
+
 2013-09-18  Andrew Burgess  <aburgess@broadcom.com>
 
        * gdb.dwarf2/dw2-reg-undefined.exp: Change pattern for info
index 9b95867..dd60270 100644 (file)
@@ -48,7 +48,7 @@ proc altivec_abi_tests { extra_flags force_abi } {
 
     if { "$force_abi" == "auto" } {
        # If the toolchain does not record attributes, skip auto-ABI tests.
-       set readelf_program [transform readelf]
+       set readelf_program [gdb_find_readelf]
        set result [catch "exec $readelf_program -A $binfile" output]
 
        if {$result == 0 && ![regexp Tag_GNU_Power_ABI_Vector $output]} {
index 443804d..dfc39a9 100644 (file)
@@ -36,7 +36,7 @@ if {[build_executable_own_libs ${testfile}.exp $executable $srcfile [list additi
 #   DYNAMIC        0x134f618 0x000000000194f618 0x000000000194f618 0x000200 0x000200 RW  0x8
 #
 proc read_phdr {binfile test} {
-    set readelf_program [transform readelf]
+    set readelf_program [gdb_find_readelf]
     set command "exec $readelf_program -Wl $binfile"
     verbose -log "command is $command"
     set result [catch $command output]
index 69a46b7..aea8b8a 100644 (file)
@@ -22,7 +22,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $ofile \
     return
 }
 
-set objcopy_program [transform objcopy]
+set objcopy_program [gdb_find_objcopy]
 set cmd "$objcopy_program --compress-debug-sections $ofile"
 verbose "invoking $cmd"
 set result [catch "exec $cmd" output]
index fcc762e..5270991 100644 (file)
@@ -42,7 +42,7 @@ if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile
 }
 
 set test "rename section"
-set objcopy_program [transform objcopy]
+set objcopy_program [gdb_find_objcopy]
 set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
 verbose "result is $result"
 verbose "output is $output"
index e567ea8..4ed3438 100644 (file)
@@ -21,6 +21,8 @@ if [build_executable ${testfile}.exp $testfile] {
 
 set pipeline_counter 0
 
+set objcopy_program [gdb_find_objcopy]
+
 # Run a pipeline of processes through 'run_on_host'.
 # TEST is the base name of the test, it is modified and passed to 'run_on_host'.
 # Each subsequent argument is a list of the form {PROGRAM [ARG]...}.
@@ -98,7 +100,7 @@ if {[run_on_host "strip" [transform strip] \
 
 # Separate full debug info into ${binfile}.debug.
 remote_file host delete ${binfile}.debug
-if {[run_on_host "copydebug" [transform objcopy] \
+if {[run_on_host "copydebug" ${objcopy_program} \
         "--only-keep-debug ${binfile} ${binfile}.debug"]} {
     return -1
 }
@@ -106,7 +108,7 @@ if {[run_on_host "copydebug" [transform objcopy] \
 # Copy the full debuginfo, keeping only a minimal set of symbols and
 # removing some unnecessary sections.
 remote_file host delete ${binfile}.mini_debuginfo
-if {[run_on_host "objcopy 1" [transform objcopy] "-S --remove-section .gdb_index --remove-section .comment --keep-symbols=${binfile}.keep_symbols ${binfile}.debug ${binfile}.mini_debuginfo"]} {
+if {[run_on_host "objcopy 1" ${objcopy_program} "-S --remove-section .gdb_index --remove-section .comment --keep-symbols=${binfile}.keep_symbols ${binfile}.debug ${binfile}.mini_debuginfo"]} {
     return -1
 }
 
@@ -115,7 +117,7 @@ if {[run_on_host "objcopy 1" [transform objcopy] "-S --remove-section .gdb_index
 # some files there may be PT_NOTE with NT_GNU_BUILD_ID and GDB could look up
 # the .debug file from it.  This is only an additional test of GDB, such link
 # is not present in usual MiniDebugInfo sections.
-if {[run_on_host "addlink" [transform objcopy] \
+if {[run_on_host "addlink" ${objcopy_program} \
         "--add-gnu-debuglink=${binfile}.debug ${binfile}.mini_debuginfo ${binfile}.mini_debuginfo-debuglink"]} {
     return -1
 }
@@ -127,7 +129,7 @@ if {[run_on_host "xz" "xz" "-k ${binfile}.mini_debuginfo-debuglink"]} {
     return -1
 }
 remote_file host delete ${binfile}.test
-if {[run_on_host "objcopy 2" [transform objcopy] "--add-section .gnu_debugdata=${binfile}.mini_debuginfo-debuglink.xz ${binfile}.strip ${binfile}.test"]} {
+if {[run_on_host "objcopy 2" ${objcopy_program} "--add-section .gnu_debugdata=${binfile}.mini_debuginfo-debuglink.xz ${binfile}.strip ${binfile}.test"]} {
     return -1
 }
 
index e0b4864..c4be15a 100644 (file)
@@ -20,7 +20,7 @@ if {[build_executable ${testfile}.exp ${testfile} ${srcfile} {nodebug}] == -1} {
 
 # We need those symbols global to access them from the .S file.
 set test "strip stub symbols"
-set objcopy_program [transform objcopy]
+set objcopy_program [gdb_find_objcopy]
 set result [catch "exec $objcopy_program -N symless ${binfile}" output]
 verbose "result is $result"
 verbose "output is $output"
index 400c9c1..183e97b 100644 (file)
@@ -39,7 +39,7 @@ gdb_unload
 
 # Strip out any labels there as they could corrupt the `main' name.
 
-set objcopy_program [transform objcopy]
+set objcopy_program [gdb_find_objcopy]
 set command "$objcopy_program -N block_start -N block_end -N break_at ${binfile}"
 verbose -log "Executing: $command"
 set result [catch "exec $command" output]
index 6b09a7c..4c3dcd2 100644 (file)
@@ -45,7 +45,7 @@ if {[build_executable ${testfile}.exp ${executable} "${testfile}.c ${testfile}.S
 
 # We need those symbols global to access them from the .S file.
 set test "strip stub symbols"
-set objcopy_program [transform objcopy]
+set objcopy_program [gdb_find_objcopy]
 set result [catch "exec $objcopy_program                                                       \
                        -N func0 -N func1 -N func2 -N func3         -N func_start -N func_end   \
                        -N fund0 -N fund1 -N fund2 -N fund3 -N fund -N fund_start               \
index ac32b54..d1334b4 100644 (file)
@@ -52,7 +52,7 @@ proc add_gdb_index { program } {
     }
 
     set program_with_index ${program}.with-index
-    if {[run_on_host "objcopy" [transform objcopy] "--remove-section .gdb_index --add-section .gdb_index=$index_file --set-section-flags .gdb_index=readonly ${program} ${program_with_index}"]} {
+    if {[run_on_host "objcopy" [gdb_find_objcopy] "--remove-section .gdb_index --add-section .gdb_index=$index_file --set-section-flags .gdb_index=readonly ${program} ${program_with_index}"]} {
        return ""
     }
     return ${program_with_index}
index 422342b..553f562 100644 (file)
@@ -94,6 +94,26 @@ proc gdb_find_ldd {} {
     return $ldd
 }
 
+proc gdb_find_objcopy {} {
+    global OBJCOPY_FOR_TARGET
+    if [info exists OBJCOPY_FOR_TARGET] {
+       set objcopy $OBJCOPY_FOR_TARGET
+    } else {
+       set objcopy [transform objcopy]
+    }
+    return $objcopy
+}
+
+proc gdb_find_readelf {} {
+    global READELF_FOR_TARGET
+    if [info exists READELF_FOR_TARGET] {
+       set readelf $READELF_FOR_TARGET
+    } else {
+       set readelf [transform readelf]
+    }
+    return $readelf
+}
+
 proc gdb_default_target_compile {source destfile type options} {
     global target_triplet
     global tool_root_dir
index 05e66ef..5e3331a 100644 (file)
@@ -3944,7 +3944,7 @@ gdb_caching_proc gdb_skip_xml_test {
 # Return "" if no build-id found.
 proc build_id_debug_filename_get { exec } {
     set tmp [standard_output_file "${exec}-tmp"]
-    set objcopy_program [transform objcopy]
+    set objcopy_program [gdb_find_objcopy]
 
     set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $exec $tmp" output]
     verbose "result is $result"
@@ -3982,7 +3982,7 @@ proc gdb_gnu_strip_debug { dest args } {
     set debug_file "${dest}.debug"
 
     set strip_to_file_program [transform strip]
-    set objcopy_program [transform objcopy]
+    set objcopy_program [gdb_find_objcopy]
 
     set debug_link [file tail $debug_file]
     set stripped_file "${dest}.stripped"
index bd10017..887a58e 100644 (file)
@@ -20,7 +20,7 @@
 proc section_get {exec section} {
     global subdir
     set tmp [standard_output_file section_get.tmp]
-    set objcopy_program [transform objcopy]
+    set objcopy_program [gdb_find_objcopy]
 
     set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp"
     verbose -log "command is $command"
@@ -211,7 +211,7 @@ proc prelink_no {arg {name {}}} {
                # Skip prelink options.
                continue
            }
-           set readelf_program [transform readelf]
+           set readelf_program [gdb_find_readelf]
            set command "exec $readelf_program -WS $bin"
            verbose -log "command is $command"
            set result [catch $command output]