Revert "Do not overwrite so_list's so_name in solib_map_sections"
authorJoel Brobecker <brobecker@adacore.com>
Fri, 13 Dec 2013 17:21:37 +0000 (18:21 +0100)
committerJoel Brobecker <brobecker@adacore.com>
Sun, 15 Dec 2013 09:59:18 +0000 (10:59 +0100)
This reverts commit 07293be44859c607a36c313e51bec2dcdcd3c243, as it
causes an unintended change of behavior with GDB/MI's =library-loaded
events: The host-name="<path>" part of the event is now showing the
target-side path instead of the host-side path.

This revert affects Darwin and AIX systems, however, where the BFD
is either artificial or icomplete, leading to the outputt of
"info shared" not containing the information we'd like. For instance,
on Darwin, we would see:

    (top-gdb) info shared
    From                To                  Syms Read   Shared Object Library
    0x00007fff8d060de4  0x00007fff8d09ce1f  Yes (*)     i386:x86-64
    0x00007fff8af08b10  0x00007fff8b1c6f73  Yes (*)     i386:x86-64

To compensate for that, we overwrite the filename of the associated bfd.

gdb/ChangeLog:

Revert the following commit:
* solib.c (solib_map_sections): Remove code overwriting
SO->SO_NAME with the bfd's filename.

Make the following changes required after the revert above:
* solib-aix.c (solib_aix_bfd_open): Set the filename of the
returned bfd to a copy of the synthetic pathname.
* solib-darwin.c (darwin_bfd_open): Set the filename of the
returned bfd to a copy of PATHNAME.

gdb/ChangeLog
gdb/solib-aix.c
gdb/solib-darwin.c
gdb/solib.c

index 2af71e3707d2d7a39fb1b114d71368999bdcb415..b9b37b0a550b0ead4c430ba4e4e9994127f654db 100644 (file)
@@ -1,3 +1,15 @@
+2013-12-15  Joel Brobecker  <brobecker@adacore.com>
+
+       Revert the following commit:
+       * solib.c (solib_map_sections): Remove code overwriting
+       SO->SO_NAME with the bfd's filename.
+
+       Make the following changes required after the revert above:
+       * solib-aix.c (solib_aix_bfd_open): Set the filename of the
+       returned bfd to a copy of the synthetic pathname.
+       * solib-darwin.c (darwin_bfd_open): Set the filename of the
+       returned bfd to a copy of PATHNAME.
+
 2013-12-13  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (ada_array_bound_from_type): Move the declaration
index 8fc516ab4d7d4869fc3faf75350ffd999dade36b..7bcb8ee949237a27cb2da199af106ba4143bfcd8 100644 (file)
@@ -724,6 +724,17 @@ solib_aix_bfd_open (char *pathname)
       return NULL;
     }
 
+  /* Override the returned bfd's name with our synthetic name in order
+     to allow commands listing all shared libraries to display that
+     synthetic name.  Otherwise, we would only be displaying the name
+     of the archive member object.  */
+    {
+      char *data = bfd_alloc (object_bfd, path_len + 1);
+
+      strcpy (data, pathname);
+      object_bfd->filename = data;
+    }
+
   gdb_bfd_unref (archive_bfd);
   do_cleanups (cleanup);
   return object_bfd;
index c37049abf25070d3d018f8d7a6c8c352f373765a..4de8cb4d8a6b9c766e7e6b4c90b23326b0631e37 100644 (file)
@@ -618,6 +618,16 @@ darwin_bfd_open (char *pathname)
             bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
     }
 
+  /* The current filename for fat-binary BFDs is a name generated
+     by BFD, usually a string containing the name of the architecture.
+     Reset its value to the actual filename.  */
+    {
+      char *data = bfd_alloc (res, strlen (pathname) + 1);
+
+      strcpy (data, pathname);
+      res->filename = data;
+    }
+
   gdb_bfd_unref (abfd);
   return res;
 }
index 1a9215a2605a79a051de1d40e2a5637b67bfd515..7956455139240a6dc5bfe849618aff0aaff3b866 100644 (file)
@@ -486,6 +486,16 @@ solib_map_sections (struct so_list *so)
   /* Leave bfd open, core_xfer_memory and "info files" need it.  */
   so->abfd = abfd;
 
+  /* Copy the full path name into so_name, allowing symbol_file_add
+     to find it later.  This also affects the =library-loaded GDB/MI
+     event, and in particular the part of that notification providing
+     the library's host-side path.  If we let the target dictate
+     that objfile's path, and the target is different from the host,
+     GDB/MI will not provide the correct host-side path.  */
+  if (strlen (bfd_get_filename (abfd)) >= SO_NAME_MAX_PATH_SIZE)
+    error (_("Shared library file name is too long."));
+  strcpy (so->so_name, bfd_get_filename (abfd));
+
   if (build_section_table (abfd, &so->sections, &so->sections_end))
     {
       error (_("Can't find the file sections in `%s': %s"),
This page took 0.039766 seconds and 4 git commands to generate.