--build-id use of elf_obj_tdata
Jan Kratochvil
jan.kratochvil@redhat.com
Mon Feb 18 15:19:00 GMT 2013
On Mon, 18 Feb 2013 01:18:36 +0100, Alan Modra wrote:
> gdb/
> * elfread.c (struct build_id): Delete. Use struct elf_build_id
> throughout file instead.
> (build_id_bfd_get): Update to use new elf_tdata build_id field.
> Don't xmalloc return value.
> (build_id_verify): Similarly. Don't xfree.
> (build_id_to_debug_filename): Update.
> (find_separate_debug_file_by_buildid): Update, don't xfree.
OK with the GDB part.
I will check in the attached constification cleanup afterwards which is
possible now with your change.
> --- gdb/elfread.c 1 Feb 2013 19:39:03 -0000 1.143
> +++ gdb/elfread.c 12 Feb 2013 03:23:11 -0000
[...]
> -static struct build_id *
> +static struct elf_build_id *
> build_id_bfd_get (bfd *abfd)
> {
> - struct build_id *retval;
> -
> if (!bfd_check_format (abfd, bfd_object)
> || bfd_get_flavour (abfd) != bfd_target_elf_flavour
> - || elf_tdata (abfd)->build_id == NULL)
> + || elf_tdata (abfd)->build_id == NULL
> + || elf_tdata (abfd)->build_id->u.i.size == 0)
Just here I do not see why the new condition 'u.i.size == 0' is needed, even
if (improbably) the build-id section is empty GDB can handle such 0-length
struct elf_build_id fine.
Thanks,
Jan
gdb/
2013-02-18 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* elfread.c (build_id_bfd_get): Make the return type const.
(build_id_verify): Make the check parameter const.
(build_id_to_debug_filename): Make the build_id parameter and variable
data const.
(find_separate_debug_file_by_buildid): Make the variable build_id const.
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 85e408f..f977f29 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1076,7 +1076,7 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
-static struct elf_build_id *
+static const struct elf_build_id *
build_id_bfd_get (bfd *abfd)
{
if (!bfd_check_format (abfd, bfd_object)
@@ -1091,10 +1091,10 @@ build_id_bfd_get (bfd *abfd)
/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
static int
-build_id_verify (const char *filename, struct elf_build_id *check)
+build_id_verify (const char *filename, const struct elf_build_id *check)
{
bfd *abfd;
- struct elf_build_id *found;
+ const struct elf_build_id *found;
int retval = 0;
/* We expect to be silent on the non-existing files. */
@@ -1119,7 +1119,7 @@ build_id_verify (const char *filename, struct elf_build_id *check)
}
static char *
-build_id_to_debug_filename (struct elf_build_id *build_id)
+build_id_to_debug_filename (const struct elf_build_id *build_id)
{
char *link, *debugdir, *retval = NULL;
VEC (char_ptr) *debugdir_vec;
@@ -1139,7 +1139,7 @@ build_id_to_debug_filename (struct elf_build_id *build_id)
for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
{
size_t debugdir_len = strlen (debugdir);
- gdb_byte *data = build_id->data;
+ const gdb_byte *data = build_id->data;
size_t size = build_id->size;
char *s;
@@ -1178,7 +1178,7 @@ build_id_to_debug_filename (struct elf_build_id *build_id)
static char *
find_separate_debug_file_by_buildid (struct objfile *objfile)
{
- struct elf_build_id *build_id;
+ const struct elf_build_id *build_id;
build_id = build_id_bfd_get (objfile->obfd);
if (build_id != NULL)
More information about the Gdb-patches
mailing list