From 7c50a93137df660f7b2d9d68c0db748a9cb7868f Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 4 Dec 2014 11:32:24 -0800 Subject: 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. --- gdb/utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gdb/utils.c') diff --git a/gdb/utils.c b/gdb/utils.c index 1f5f4f4..1ab183c 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1112,6 +1112,23 @@ gdb_print_host_address (const void *addr, struct ui_file *stream) { fprintf_filtered (stream, "%s", host_address_to_string (addr)); } + +/* See utils.h. */ + +char * +make_hex_string (const gdb_byte *data, size_t length) +{ + char *result = xmalloc (length * 2 + 1); + char *p; + size_t i; + + p = result; + for (i = 0; i < length; ++i) + p += sprintf (p, "%02x", data[i]); + *p = '\0'; + return result; +} + /* A cleanup function that calls regfree. */ -- cgit v1.1