This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v12 26/32] solib_bfd_open: Optimize opening twice
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 21 Aug 2015 23:23:36 +0200
- Subject: [PATCH v12 26/32] solib_bfd_open: Optimize opening twice
- Authentication-results: sourceware.org; auth=none
- References: <20150821212006 dot 6673 dot 35100 dot stgit at host1 dot jankratochvil dot net>
Hi,
this is one of the optimizations allowed by file_location that prevents opening
file twice when target build-id is known and it needs to be verified.
Jan
gdb/ChangeLog
2015-08-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* solib.c (solib_bfd_fopen): Replace solib_find and solib_bfd_fopen by
solib_find_file.
---
0 files changed
diff --git a/gdb/solib.c b/gdb/solib.c
index a425e4d..906cc5c 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -620,25 +620,30 @@ solib_bfd_fopen (char *pathname, int fd)
bfd *
solib_bfd_open (char *pathname, size_t build_idsz, const gdb_byte *build_id)
{
- char *found_pathname;
- int found_file;
+ struct file_location file;
bfd *abfd;
const struct bfd_arch_info *b;
/* Search for shared library file. */
- found_pathname = solib_find (pathname, build_idsz, build_id, &found_file);
- if (found_pathname == NULL)
+ file = solib_find_file (pathname, OPF_IS_BFD, build_idsz, build_id);
+ if (!file_location_is_valid (&file))
{
/* Return failure if the file could not be found, so that we can
accumulate messages about missing libraries. */
- if (errno == ENOENT)
- return NULL;
+ if (file.file_errno == ENOENT)
+ {
+ file_location_free (&file);
+ return NULL;
+ }
+ file_location_free (&file);
perror_with_name (pathname);
}
/* Open bfd for shared library. */
- abfd = solib_bfd_fopen (found_pathname, found_file);
+ gdb_bfd_ref (file.abfd);
+ abfd = file.abfd;
+ file_location_free (&file);
/* Check bfd format. */
if (!bfd_check_format (abfd, bfd_object))