[PATCH 2/3] gdb: Add soname to build-id mapping for corefiles

Simon Marchi simon.marchi@polymtl.ca
Sun Nov 14 02:36:28 GMT 2021


> @@ -1183,8 +1201,23 @@ linux_read_core_file_mappings
>        descdata += addr_size;
>        char * filename = filenames;
>        filenames += strlen ((char *) filenames) + 1;
> +      const bfd_build_id *build_id = nullptr;
> +      auto vma_map_it = vma_map.find (start);
> +
> +      /* Map filename to the build-id associated with this start vma,
> +	 if such a build-id was found.  Otherwise use the build-id
> +	 already associated with this filename if it exists. */
> +      if (vma_map_it != vma_map.end ())
> +	filename_map[filename] = build_id = vma_map_it->second;

Please avoid doing two assignments in one statement.

> @@ -1586,6 +1587,40 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr,
>    return 0;
>  }
>  
> +/* See solib.h.  */
> +
> +gdb::optional<std::string>
> +gdb_bfd_read_elf_soname (struct bfd *bfd)
> +{
> +  gdb_assert (bfd != nullptr);
> +
> +  gdb_bfd_ref_ptr abfd = gdb_bfd_open (bfd->filename, gnutarget);

Can you explain why we are opening bfd->filename?  Doesn't "abfd"
represent the exact same thing than "bfd"?  So why can't we use "bfd"
directly to look up the soname?

Simon


More information about the Gdb-patches mailing list