aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/future.exp11
-rw-r--r--gdb/testsuite/lib/gdb.exp53
2 files changed, 44 insertions, 20 deletions
diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index 2fb635b..a27e120 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -104,6 +104,17 @@ proc gdb_find_objcopy {} {
return $objcopy
}
+# find target objdump
+proc gdb_find_objdump {} {
+ global OBJDUMP_FOR_TARGET
+ if [info exists OBJDUMP_FOR_TARGET] {
+ set objdump $OBJDUMP_FOR_TARGET
+ } else {
+ set objdump [transform objdump]
+ }
+ return $objdump
+}
+
proc gdb_find_readelf {} {
global READELF_FOR_TARGET
if [info exists READELF_FOR_TARGET] {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 41797e7..21a4638 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4539,28 +4539,41 @@ gdb_caching_proc gdb_has_argv0 {
# Returns "" if there is none.
proc get_build_id { filename } {
- set tmp [standard_output_file "${filename}-tmp"]
- set objcopy_program [gdb_find_objcopy]
-
- set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $filename $tmp" output]
- verbose "result is $result"
- verbose "output is $output"
- if {$result == 1} {
- return ""
+ if { ([istarget "*-*-mingw*"]
+ || [istarget *-*-cygwin*]) } {
+ set objdump_program [gdb_find_objdump]
+ set result [catch {set data [exec $objdump_program -p $filename | grep signature | cut "-d " -f4]} output]
+ verbose "result is $result"
+ verbose "output is $output"
+ if {$result == 1} {
+ return ""
+ }
+ return $data
}
- set fi [open $tmp]
- fconfigure $fi -translation binary
- # Skip the NOTE header.
- read $fi 16
- set data [read $fi]
- close $fi
- file delete $tmp
- if ![string compare $data ""] then {
- return ""
+ else
+ {
+ set tmp [standard_output_file "${filename}-tmp"]
+ set objcopy_program [gdb_find_objcopy]
+ set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $filename $tmp" output]
+ verbose "result is $result"
+ verbose "output is $output"
+ if {$result == 1} {
+ return ""
+ }
+ set fi [open $tmp]
+ fconfigure $fi -translation binary
+ # Skip the NOTE header.
+ read $fi 16
+ set data [read $fi]
+ close $fi
+ file delete $tmp
+ if ![string compare $data ""] then {
+ return ""
+ }
+ # Convert it to hex.
+ binary scan $data H* data
+ return $data
}
- # Convert it to hex.
- binary scan $data H* data
- return $data
}
# Return the build-id hex string (usually 160 bits as 40 hex characters)