aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/gdb.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r--gdb/testsuite/lib/gdb.exp21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index bfaf311..193a076 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2482,6 +2482,27 @@ proc separate_debug_filename { exec } {
return $debug_file
}
+# Return the build-id hex string (usually 160 bits as 40 hex characters)
+# converted to the form: .build-id/ab/cdef1234...89.debug
+# Return "" if no build-id found.
+proc build_id_debug_filename_get { exec } {
+ set tmp "${exec}-tmp"
+ exec objcopy -j .note.gnu.build-id -O binary $exec $tmp
+ set fi [open $tmp]
+ # Skip the NOTE header.
+ read $fi 16
+ set data [read $fi]
+ close $fi
+ file delete $tmp
+ if {$data eq ""} {
+ return ""
+ }
+ # Convert it to hex.
+ binary scan $data H* data
+ set data [regsub {^..} $data {\0/}]
+ return ".build-id/${data}.debug";
+}
+
# Create stripped files for DEST, replacing it. If ARGS is passed, it is a
# list of optional flags. The only currently supported flag is no-main,
# which removes the symbol entry for main from the separate debug file.