This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] New functions gdb_find_readelf, gdb_find_objcopy for testsuite


Hi.
[transform objcopy] and [transform readelf] aren't always sufficient
to find the right copy to use.
Akin to most other tools that have FOO_FOR_TARGET this patch
adds support for READELF_FOR_TARGET and OBJCOPY_FOR_TARGET.

Regression tested on amd64-linux.
I will commit this in a few days if there are no objections.

2013-09-17  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.

Index: testsuite/lib/future.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/future.exp,v
retrieving revision 1.8
diff -u -p -r1.8 future.exp
--- testsuite/lib/future.exp	9 Aug 2013 17:58:38 -0000	1.8
+++ testsuite/lib/future.exp	17 Sep 2013 20:34:58 -0000
@@ -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: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.245
diff -u -p -r1.245 gdb.exp
--- testsuite/lib/gdb.exp	16 Sep 2013 23:59:02 -0000	1.245
+++ testsuite/lib/gdb.exp	17 Sep 2013 20:34:58 -0000
@@ -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: testsuite/lib/prelink-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/prelink-support.exp,v
retrieving revision 1.10
diff -u -p -r1.10 prelink-support.exp
--- testsuite/lib/prelink-support.exp	16 Aug 2013 17:44:22 -0000	1.10
+++ testsuite/lib/prelink-support.exp	17 Sep 2013 20:34:58 -0000
@@ -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 +214,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]
 
Index: testsuite/gdb.arch/altivec-abi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-abi.exp,v
retrieving revision 1.32
diff -u -p -r1.32 altivec-abi.exp
--- testsuite/gdb.arch/altivec-abi.exp	1 Jan 2013 06:33:24 -0000	1.32
+++ testsuite/gdb.arch/altivec-abi.exp	17 Sep 2013 20:34:58 -0000
@@ -48,7 +48,7 @@ proc altivec_abi_tests { extra_flags for
 
     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: testsuite/gdb.base/attach-pie-misread.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/attach-pie-misread.exp,v
retrieving revision 1.11
diff -u -p -r1.11 attach-pie-misread.exp
--- testsuite/gdb.base/attach-pie-misread.exp	27 Jun 2013 18:47:53 -0000	1.11
+++ testsuite/gdb.base/attach-pie-misread.exp	17 Sep 2013 20:34:58 -0000
@@ -36,7 +36,7 @@ if {[build_executable_own_libs ${testfil
 #   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: testsuite/gdb.base/comprdebug.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/comprdebug.exp,v
retrieving revision 1.2
diff -u -p -r1.2 comprdebug.exp
--- testsuite/gdb.base/comprdebug.exp	1 Jan 2013 06:33:25 -0000	1.2
+++ testsuite/gdb.base/comprdebug.exp	17 Sep 2013 20:34:58 -0000
@@ -22,7 +22,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfil
     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: testsuite/gdb.base/dup-sect.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/dup-sect.exp,v
retrieving revision 1.6
diff -u -p -r1.6 dup-sect.exp
--- testsuite/gdb.base/dup-sect.exp	27 Jun 2013 18:49:03 -0000	1.6
+++ testsuite/gdb.base/dup-sect.exp	17 Sep 2013 20:34:58 -0000
@@ -42,7 +42,7 @@ if {[build_executable ${testfile}.exp $e
 }
 
 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: testsuite/gdb.base/gnu-debugdata.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/gnu-debugdata.exp,v
retrieving revision 1.8
diff -u -p -r1.8 gnu-debugdata.exp
--- testsuite/gdb.base/gnu-debugdata.exp	11 Sep 2013 08:31:44 -0000	1.8
+++ testsuite/gdb.base/gnu-debugdata.exp	17 Sep 2013 20:34:58 -0000
@@ -21,6 +21,8 @@ if [build_executable ${testfile}.exp $te
 
 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 stri
 
 # 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 
 # 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 
 # 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
     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: testsuite/gdb.base/step-symless.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/step-symless.exp,v
retrieving revision 1.2
diff -u -p -r1.2 step-symless.exp
--- testsuite/gdb.base/step-symless.exp	1 Jan 2013 06:33:26 -0000	1.2
+++ testsuite/gdb.base/step-symless.exp	17 Sep 2013 20:34:58 -0000
@@ -20,7 +20,7 @@ if {[build_executable ${testfile}.exp ${
 
 # 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: testsuite/gdb.dwarf2/dw2-inline-param.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp,v
retrieving revision 1.9
diff -u -p -r1.9 dw2-inline-param.exp
--- testsuite/gdb.dwarf2/dw2-inline-param.exp	1 Jan 2013 06:33:28 -0000	1.9
+++ testsuite/gdb.dwarf2/dw2-inline-param.exp	17 Sep 2013 20:34:58 -0000
@@ -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: testsuite/gdb.dwarf2/dw2-skip-prologue.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp,v
retrieving revision 1.4
diff -u -p -r1.4 dw2-skip-prologue.exp
--- testsuite/gdb.dwarf2/dw2-skip-prologue.exp	1 Jan 2013 06:41:22 -0000	1.4
+++ testsuite/gdb.dwarf2/dw2-skip-prologue.exp	17 Sep 2013 20:34:58 -0000
@@ -45,7 +45,7 @@ if {[build_executable ${testfile}.exp ${
 
 # 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: testsuite/gdb.dwarf2/gdb-index.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/gdb-index.exp,v
retrieving revision 1.2
diff -u -p -r1.2 gdb-index.exp
--- testsuite/gdb.dwarf2/gdb-index.exp	28 Aug 2013 14:20:43 -0000	1.2
+++ testsuite/gdb.dwarf2/gdb-index.exp	17 Sep 2013 20:34:58 -0000
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]