This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Automatically replace shared library extensions on Symbian


SymbianOS' debug info files are elf files.  These are post-linker
processed into PE-ish dlls, and its these that are actually ran
on the target, so symbian stubs report dll filenames as loaded
to GDB.  This patch makes it so that GDB automatically finds
the symbol files on the host's filesystem, as they'll be called
FOO.sym, not FOO.dll.

In course of preparing this for upstream, I've made it a
gdbarch setting, so that a multi-arch gdb doesn't do the
replacing for other archs not symbian.  I've resisted
making this tweakable via a user visible setting, as we
did't find a need for it yet, thought I could see that
possibly being useful to other post-linker processed
targets.  Something that can always be added on top, I
think.

What do you think of this?

-- 
Pedro Alves

2010-03-05  Daniel Jacobowitz  <dan@codesourcery.com>
	   Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* solib.c (solib_find): Replace extension if
	solib_symbols_extension 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/arm-symbian-tdep.c |    1 +
 gdb/gdbarch.c          |   29 +++++++++++++++++++++++++++++
 gdb/gdbarch.h          |    6 ++++++
 gdb/gdbarch.sh         |   12 ++++++++++++
 gdb/solib.c            |   24 ++++++++++++++++++++++++
 5 files changed, 72 insertions(+)

Index: src/gdb/solib.c
===================================================================
--- src.orig/gdb/solib.c	2010-03-05 18:00:39.000000000 +0000
+++ src/gdb/solib.c	2010-03-05 18:05:44.000000000 +0000
@@ -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);
 
Index: src/gdb/arm-symbian-tdep.c
===================================================================
--- src.orig/gdb/arm-symbian-tdep.c	2010-03-05 18:00:39.000000000 +0000
+++ src/gdb/arm-symbian-tdep.c	2010-03-05 18:00:53.000000000 +0000
@@ -68,6 +68,7 @@ arm_symbian_init_abi (struct gdbarch_inf
 
   /* Shared library handling.  */
   set_gdbarch_skip_trampoline_code (gdbarch, arm_symbian_skip_trampoline_code);
+  set_gdbarch_solib_symbols_extension (gdbarch, "sym");
 
   set_solib_ops (gdbarch, &solib_target_so_ops);
 }
Index: src/gdb/gdbarch.sh
===================================================================
--- src.orig/gdb/gdbarch.sh	2010-03-05 18:00:39.000000000 +0000
+++ src/gdb/gdbarch.sh	2010-03-05 18:00:53.000000000 +0000
@@ -769,6 +769,10 @@ m:int:fast_tracepoint_valid_at:CORE_ADDR
 
 # Not NULL if a target has additonal field for qSupported.
 v:const char *:qsupported:::0:0::0:gdbarch->qsupported
+
+# If non-empty, this is a file extension that will be opened in place
+# of the file extension reported by the shared library list.
+v:const char *:solib_symbols_extension:::::::pstring (gdbarch->solib_symbols_extension)
 EOF
 }
 
@@ -1240,6 +1244,14 @@ pformat (const struct floatformat **form
     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: src/gdb/gdbarch.c
===================================================================
--- src.orig/gdb/gdbarch.c	2010-03-05 18:00:39.000000000 +0000
+++ src/gdb/gdbarch.c	2010-03-05 18:00:53.000000000 +0000
@@ -77,6 +77,14 @@ pformat (const struct floatformat **form
     return format[0]->name;
 }
 
+static const char *
+pstring (const char *string)
+{
+  if (string == NULL)
+    return "(null)";
+  return string;
+}
+
 
 /* Maintain the struct gdbarch object */
 
@@ -253,6 +261,7 @@ struct gdbarch
   gdbarch_has_shared_address_space_ftype *has_shared_address_space;
   gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
   const char * qsupported;
+  const char * solib_symbols_extension;
 };
 
 
@@ -397,6 +406,7 @@ struct gdbarch startup_gdbarch =
   default_has_shared_address_space,  /* has_shared_address_space */
   default_fast_tracepoint_valid_at,  /* fast_tracepoint_valid_at */
   0,  /* qsupported */
+  0,  /* solib_symbols_extension */
   /* startup_gdbarch() */
 };
 
@@ -1134,6 +1144,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s
                       "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));
   fprintf_unfiltered (file,
@@ -3599,6 +3612,22 @@ set_gdbarch_qsupported (struct gdbarch *
   gdbarch->qsupported = qsupported;
 }
 
+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: src/gdb/gdbarch.h
===================================================================
--- src.orig/gdb/gdbarch.h	2010-03-05 18:00:39.000000000 +0000
+++ src/gdb/gdbarch.h	2010-03-05 18:00:53.000000000 +0000
@@ -928,6 +928,12 @@ extern void set_gdbarch_fast_tracepoint_
 extern const char * gdbarch_qsupported (struct gdbarch *gdbarch);
 extern void set_gdbarch_qsupported (struct gdbarch *gdbarch, const char * qsupported);
 
+/* If non-empty, this is a file extension that will be opened in place
+   of the file extension reported by the shared library list. */
+
+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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]