From 4fa7d390970c4e558fc42b8d5ff4d42b60240db4 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Fri, 20 Sep 2013 21:47:06 +0000 Subject: [PATCH] * 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. --- gdb/testsuite/ChangeLog | 16 +++++++++++++++ gdb/testsuite/gdb.arch/altivec-abi.exp | 2 +- gdb/testsuite/gdb.base/attach-pie-misread.exp | 2 +- gdb/testsuite/gdb.base/comprdebug.exp | 2 +- gdb/testsuite/gdb.base/dup-sect.exp | 2 +- gdb/testsuite/gdb.base/gnu-debugdata.exp | 10 ++++++---- gdb/testsuite/gdb.base/step-symless.exp | 2 +- gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp | 2 +- .../gdb.dwarf2/dw2-skip-prologue.exp | 2 +- gdb/testsuite/gdb.dwarf2/gdb-index.exp | 2 +- gdb/testsuite/lib/future.exp | 20 +++++++++++++++++++ gdb/testsuite/lib/gdb.exp | 4 ++-- gdb/testsuite/lib/prelink-support.exp | 4 ++-- 13 files changed, 54 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9ea731c3ea7..9dcdaa52246 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2013-09-20 Doug Evans + + * 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 * gdb.dwarf2/dw2-reg-undefined.exp: Change pattern for info diff --git a/gdb/testsuite/gdb.arch/altivec-abi.exp b/gdb/testsuite/gdb.arch/altivec-abi.exp index 9b95867c616..dd602702769 100644 --- a/gdb/testsuite/gdb.arch/altivec-abi.exp +++ b/gdb/testsuite/gdb.arch/altivec-abi.exp @@ -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]} { diff --git a/gdb/testsuite/gdb.base/attach-pie-misread.exp b/gdb/testsuite/gdb.base/attach-pie-misread.exp index 443804d53b2..dfc39a9490c 100644 --- a/gdb/testsuite/gdb.base/attach-pie-misread.exp +++ b/gdb/testsuite/gdb.base/attach-pie-misread.exp @@ -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] diff --git a/gdb/testsuite/gdb.base/comprdebug.exp b/gdb/testsuite/gdb.base/comprdebug.exp index 69a46b76734..aea8b8a2ead 100644 --- a/gdb/testsuite/gdb.base/comprdebug.exp +++ b/gdb/testsuite/gdb.base/comprdebug.exp @@ -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] diff --git a/gdb/testsuite/gdb.base/dup-sect.exp b/gdb/testsuite/gdb.base/dup-sect.exp index fcc762e0efa..5270991d839 100644 --- a/gdb/testsuite/gdb.base/dup-sect.exp +++ b/gdb/testsuite/gdb.base/dup-sect.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.exp b/gdb/testsuite/gdb.base/gnu-debugdata.exp index e567ea8acda..4ed34382527 100644 --- a/gdb/testsuite/gdb.base/gnu-debugdata.exp +++ b/gdb/testsuite/gdb.base/gnu-debugdata.exp @@ -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 } diff --git a/gdb/testsuite/gdb.base/step-symless.exp b/gdb/testsuite/gdb.base/step-symless.exp index e0b4864a9f8..c4be15aecd6 100644 --- a/gdb/testsuite/gdb.base/step-symless.exp +++ b/gdb/testsuite/gdb.base/step-symless.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp index 400c9c1a81b..183e97b48f4 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp @@ -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] diff --git a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp index 6b09a7c534e..4c3dcd2fa5f 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp @@ -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 \ diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-index.exp index ac32b54fdaf..d1334b498f6 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-index.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-index.exp @@ -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} diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp index 422342b2f37..553f56232c7 100644 --- a/gdb/testsuite/lib/future.exp +++ b/gdb/testsuite/lib/future.exp @@ -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 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 05e66eff1c4..5e3331ad645 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -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" diff --git a/gdb/testsuite/lib/prelink-support.exp b/gdb/testsuite/lib/prelink-support.exp index bd10017d86c..887a58e9638 100644 --- a/gdb/testsuite/lib/prelink-support.exp +++ b/gdb/testsuite/lib/prelink-support.exp @@ -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] -- 2.30.2