diff options
author | Doug Evans <dje@google.com> | 2014-12-04 11:32:24 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2014-12-04 11:32:24 -0800 |
commit | 7c50a93137df660f7b2d9d68c0db748a9cb7868f (patch) | |
tree | b47c96bea08c023b78798039c98e18c9dafbd632 /gdb/testsuite | |
parent | fbad6518c1397939ea2d832eea7e53f2147759a8 (diff) | |
download | gdb-7c50a93137df660f7b2d9d68c0db748a9cb7868f.zip gdb-7c50a93137df660f7b2d9d68c0db748a9cb7868f.tar.gz gdb-7c50a93137df660f7b2d9d68c0db748a9cb7868f.tar.bz2 |
New python attribute gdb.Objfile.build_id.
gdb/ChangeLog:
* NEWS: Mention gdb.Objfile.build_id.
* build-id.c (build_id_bfd_get): Make non-static.
* build-id.h (build_id_bfd_get): Add declaration.
* python/py-objfile.c: #include "build-id.h", "elf-bfd.h".
(OBJFPY_REQUIRE_VALID): New macro.
(objfpy_get_build_id): New function.
(objfile_getset): Add "build_id".
* utils.c (make_hex_string): New function.
* utils.h (make_hex_string): Add declaration.
gdb/doc/ChangeLog:
* python.texi (Objfiles In Python): Document Objfile.build_id.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (get_build_id): New function.
(build_id_debug_filename_get): Rewrite to use it.
* gdb.python/py-objfile.exp: Add test for objfile.build_id.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.exp | 10 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 23 |
3 files changed, 33 insertions, 6 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f1584e0..b19a5c0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-12-04 Doug Evans <dje@google.com> + + * lib/gdb.exp (get_build_id): New function. + (build_id_debug_filename_get): Rewrite to use it. + * gdb.python/py-objfile.exp: Add test for objfile.build_id. + 2014-12-04 Maciej W. Rozycki <macro@codesourcery.com> * gdb.cp/expand-psymtabs-cxx.exp: Accept any address of diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp index 7bf41ed..74384ed 100644 --- a/gdb/testsuite/gdb.python/py-objfile.exp +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -39,6 +39,16 @@ gdb_py_test_silent_cmd "python objfile = sym\[0\].symtab.objfile" \ gdb_test "python print (objfile.filename)" ".*py-objfile.*" \ "Get objfile file name" + +set binfile_build_id [get_build_id $binfile] +if [string compare $binfile_build_id ""] { + verbose -log "binfile_build_id = $binfile_build_id" + gdb_test "python print (objfile.build_id)" "$binfile_build_id" \ + "Get objfile build id" +} else { + unsupported "build-id is not supported by the compiler" +} + gdb_test "python print (objfile.progspace)" "<gdb\.Progspace object at .*>" \ "Get objfile program space" gdb_test "python print (objfile.is_valid())" "True" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 2c79bc1..a29b661 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4330,14 +4330,14 @@ gdb_caching_proc gdb_has_argv0 { # foo.debug --> foo's debug info # foo --> like foo, but with a new .gnu_debuglink section pointing to foo.debug. -# 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 [standard_output_file "${exec}-tmp"] +# Fetch the build id from the file. +# 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 $exec $tmp" output] + 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} { @@ -4355,6 +4355,17 @@ proc build_id_debug_filename_get { exec } { } # Convert it to hex. binary scan $data H* data + return $data +} + +# 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 { filename } { + set data [get_build_id $filename] + if { $data == "" } { + return "" + } regsub {^..} $data {\0/} data return ".build-id/${data}.debug" } |