]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* solib.c (solib_find): Replace extension if
authorPedro Alves <palves@redhat.com>
Mon, 8 Mar 2010 19:28:27 +0000 (19:28 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 8 Mar 2010 19:28:27 +0000 (19:28 +0000)
solib_symbols_extension is set in the target gdbarch.
* arm-symbian-tdep.c (arm_symbian_init_abi): Set
solib_symbols_extension to "sym".
* gdbarch.sh (solib_symbols_extension): New variable.
(pstring): New function.
* gdbarch.h, gdbarch.c: Regenerate.

gdb/ChangeLog
gdb/arm-symbian-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/solib.c

index 4fed3ff5d03f577232fc645786da571570cdc035..6d6691ac173a3d0f156a48e0b245b734e7e5d5c1 100644 (file)
@@ -1,3 +1,14 @@
+2010-03-08  Daniel Jacobowitz  <dan@codesourcery.com>
+           Pedro Alves  <pedro@codesourcery.com>
+
+       * solib.c (solib_find): Replace extension if
+       solib_symbols_extension is set in the target gdbarch.
+       * arm-symbian-tdep.c (arm_symbian_init_abi): Set
+       solib_symbols_extension to "sym".
+       * gdbarch.sh (solib_symbols_extension): New variable.
+       (pstring): New function.
+       * gdbarch.h, gdbarch.c: Regenerate.
+
 2010-03-08  Tom Tromey  <tromey@redhat.com>
 
        PR cli/9591:
index 264c00f50fb3b6fe4aa689d6f82dde8865648cdb..32f65f40a50aeccc8dc3ed894188dbd376f8050d 100644 (file)
@@ -69,6 +69,15 @@ arm_symbian_init_abi (struct gdbarch_info info,
   /* Shared library handling.  */
   set_gdbarch_skip_trampoline_code (gdbarch, arm_symbian_skip_trampoline_code);
 
+  /* On this target, the toolchain outputs ELF files, with `sym' for
+     filename extension (e.g., `FOO.sym'); these are post-linker
+     processed into PE-ish DLLs (e.g., `FOO.dll'), and it's these that
+     are actually copied to and run on the target.  Naturally, when
+     listing shared libraries, Symbian stubs report the DLL filenames.
+     Setting this makes it so that GDB automatically looks for the
+     corresponding ELF files on the host's filesystem.  */
+  set_gdbarch_solib_symbols_extension (gdbarch, "sym");
+
   set_solib_ops (gdbarch, &solib_target_so_ops);
 }
 
index f482572cfe8ab6d5cf2f1a23bf48daabc5a16b6e..9aa6111c6f3bda6d33680dcf89e52552445f7987 100644 (file)
@@ -77,6 +77,14 @@ pformat (const struct floatformat **format)
     return format[0]->name;
 }
 
+static const char *
+pstring (const char *string)
+{
+  if (string == NULL)
+    return "(null)";
+  return string;
+}
+
 
 /* Maintain the struct gdbarch object */
 
@@ -255,6 +263,7 @@ struct gdbarch
   const char * qsupported;
   gdbarch_auto_charset_ftype *auto_charset;
   gdbarch_auto_wide_charset_ftype *auto_wide_charset;
+  const char * solib_symbols_extension;
 };
 
 
@@ -401,6 +410,7 @@ struct gdbarch startup_gdbarch =
   0,  /* qsupported */
   default_auto_charset,  /* auto_charset */
   default_auto_wide_charset,  /* auto_wide_charset */
+  0,  /* solib_symbols_extension */
   /* startup_gdbarch() */
 };
 
@@ -1147,6 +1157,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: sofun_address_maybe_missing = %s\n",
                       plongest (gdbarch->sofun_address_maybe_missing));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: solib_symbols_extension = %s\n",
+                      pstring (gdbarch->solib_symbols_extension));
   fprintf_unfiltered (file,
                       "gdbarch_dump: sp_regnum = %s\n",
                       plongest (gdbarch->sp_regnum));
@@ -3647,6 +3660,22 @@ set_gdbarch_auto_wide_charset (struct gdbarch *gdbarch,
   gdbarch->auto_wide_charset = auto_wide_charset;
 }
 
+const char *
+gdbarch_solib_symbols_extension (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_solib_symbols_extension called\n");
+  return gdbarch->solib_symbols_extension;
+}
+
+void
+set_gdbarch_solib_symbols_extension (struct gdbarch *gdbarch,
+                                     const char * solib_symbols_extension)
+{
+  gdbarch->solib_symbols_extension = solib_symbols_extension;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
index 83281f46f64f55299b7248d15e7b11d6fe2b0305..ec5f9d8d282980b325975f102962b50d49084bd7 100644 (file)
@@ -940,6 +940,16 @@ typedef const char * (gdbarch_auto_wide_charset_ftype) (void);
 extern const char * gdbarch_auto_wide_charset (struct gdbarch *gdbarch);
 extern void set_gdbarch_auto_wide_charset (struct gdbarch *gdbarch, gdbarch_auto_wide_charset_ftype *auto_wide_charset);
 
+/* If non-empty, this is a file extension that will be opened in place
+   of the file extension reported by the shared library list.
+  
+   This is most useful for toolchains that use a post-linker tool,
+   where the names of the files run on the target differ in extension
+   compared to the names of the files GDB should load for debug info. */
+
+extern const char * gdbarch_solib_symbols_extension (struct gdbarch *gdbarch);
+extern void set_gdbarch_solib_symbols_extension (struct gdbarch *gdbarch, const char * solib_symbols_extension);
+
 /* Definition for an unknown syscall, used basically in error-cases.  */
 #define UNKNOWN_SYSCALL (-1)
 
index 441c515966c1967f772e271740b4d0834ada2446..28851675c517149d9dedefece728f7bc50dc4e4c 100755 (executable)
@@ -774,6 +774,14 @@ v:const char *:qsupported:::0:0::0:gdbarch->qsupported
 f:const char *:auto_charset:void::default_auto_charset:default_auto_charset::0
 # Return the "auto" target wide charset.
 f:const char *:auto_wide_charset:void::default_auto_wide_charset:default_auto_wide_charset::0
+
+# If non-empty, this is a file extension that will be opened in place
+# of the file extension reported by the shared library list.
+#
+# This is most useful for toolchains that use a post-linker tool,
+# where the names of the files run on the target differ in extension
+# compared to the names of the files GDB should load for debug info.
+v:const char *:solib_symbols_extension:::::::pstring (gdbarch->solib_symbols_extension)
 EOF
 }
 
@@ -1245,6 +1253,14 @@ pformat (const struct floatformat **format)
     return format[0]->name;
 }
 
+static const char *
+pstring (const char *string)
+{
+  if (string == NULL)
+    return "(null)";
+  return string;
+}
+
 EOF
 
 # gdbarch open the gdbarch object
index 842b27c3c2123650ef274250f606765c1bb6f98b..40a7a1ca62fec8cd754e29ed325cca16b745e0c8 100644 (file)
@@ -150,6 +150,30 @@ solib_find (char *in_pathname, int *fd)
   int found_file = -1;
   char *temp_pathname = NULL;
   int gdb_sysroot_is_empty;
+  const char *solib_symbols_extension
+    = gdbarch_solib_symbols_extension (target_gdbarch);
+
+  /* If solib_symbols_extension is set, replace the file's
+     extension.  */
+  if (solib_symbols_extension)
+    {
+      char *p = in_pathname + strlen (in_pathname);
+      while (p > in_pathname && *p != '.')
+       p--;
+
+      if (*p == '.')
+       {
+         char *new_pathname;
+
+         new_pathname = alloca (p - in_pathname + 1
+                                + strlen (solib_symbols_extension) + 1);
+         memcpy (new_pathname, in_pathname, p - in_pathname + 1);
+         strcpy (new_pathname + (p - in_pathname) + 1,
+                 solib_symbols_extension);
+
+         in_pathname = new_pathname;
+       }
+    }
 
   gdb_sysroot_is_empty = (gdb_sysroot == NULL || *gdb_sysroot == 0);