[v12,26/32] solib_bfd_open: Optimize opening twice

Message ID 20150821212336.6673.18922.stgit@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Aug. 21, 2015, 9:23 p.m. UTC
  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
  

Patch

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))