* configure.ac (DEBUGDIR_RELOCATABLE): Define for debugdir inside
authorDaniel Jacobowitz <drow@false.org>
Tue, 9 Jan 2007 21:34:30 +0000 (21:34 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 9 Jan 2007 21:34:30 +0000 (21:34 +0000)
exec_prefix.
(TARGET_SYSTEM_ROOT_RELOCATABLE): Allow for exec_prefix being
'${prefix}'.
* configure, config.in: Regenerate.
* defs.h (debug_file_directory): Declare.
* main.c (captured_main): Canonicalize gdb_sysroot.  Assume
TARGET_SYSTEM_ROOT is defined.  Initialize debug_file_directory and
relocate it if DEBUGDIR_RELOCATABLE.
* symfile.c (debug_file_directory): Make non-static.
(find_separate_debug_file): Look for debug info for SYSROOT/PATH
in DEBUGDIR/PATH if DEBUGDIR is inside SYSROOT.
(_initialize_symfile): Don't initialize debug_file_directory here.

gdb/ChangeLog
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/defs.h
gdb/main.c
gdb/symfile.c

index 3cbfc6766c09712926775528ec1e88cf2dde59ed..eecf63952c92ca7ccc68c80fc945bf4156d2e141 100644 (file)
@@ -1,3 +1,19 @@
+2007-01-09  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * configure.ac (DEBUGDIR_RELOCATABLE): Define for debugdir inside
+       exec_prefix.
+       (TARGET_SYSTEM_ROOT_RELOCATABLE): Allow for exec_prefix being
+       '${prefix}'.
+       * configure, config.in: Regenerate.
+       * defs.h (debug_file_directory): Declare.
+       * main.c (captured_main): Canonicalize gdb_sysroot.  Assume
+       TARGET_SYSTEM_ROOT is defined.  Initialize debug_file_directory and
+       relocate it if DEBUGDIR_RELOCATABLE.
+       * symfile.c (debug_file_directory): Make non-static.
+       (find_separate_debug_file): Look for debug info for SYSROOT/PATH
+       in DEBUGDIR/PATH if DEBUGDIR is inside SYSROOT.
+       (_initialize_symfile): Don't initialize debug_file_directory here.
+
 2007-01-09  Jim Blandy  <jimb@codesourcery.com>
 
        * score-tdep.c (score_push_dummy_call): Don't mix declarations and
index 11647f1e7f1776b9daa7a160eff513f8d84bd85b..59793f5d6b8bb64d4c8e3fbe5c656f232ae7cf1a 100644 (file)
@@ -14,6 +14,9 @@
 /* Global directory for separate debug files. */
 #undef DEBUGDIR
 
+/* Define if the debug directory should be relocated when GDB is moved. */
+#undef DEBUGDIR_RELOCATABLE
+
 /* Define to BFD's default architecture. */
 #undef DEFAULT_BFD_ARCH
 
index 69cb9cd2a96edd3dc4d99494d1b51215968fbaa2..adbb231a5e134a328caad1785f2c6f2e2af36139 100755 (executable)
@@ -3053,6 +3053,26 @@ _ACEOF
 
 #AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"),
 
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+  if test "x$prefix" = xNONE; then
+    test_prefix=/usr/local
+  else
+    test_prefix=$prefix
+  fi
+else
+  test_prefix=$exec_prefix
+fi
+case ${debugdir} in
+"${test_prefix}"|"${test_prefix}/"*|\
+'${exec_prefix}'|'${exec_prefix}/'*)
+
+cat >>confdefs.h <<\_ACEOF
+#define DEBUGDIR_RELOCATABLE 1
+_ACEOF
+
+  ;;
+esac
+
 
 
 subdirs="$subdirs doc testsuite"
@@ -21172,7 +21192,7 @@ if test "${with_sysroot+set}" = set; then
 
  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
 
- if test "x$exec_prefix" = xNONE; then
+ if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
   if test "x$prefix" = xNONE; then
    test_prefix=/usr/local
   else
index 3a55c515735f07531afc0a704d28a8dc49193714..f0ce4629a672a99793579712af23c4bf4882da44 100644 (file)
@@ -75,6 +75,22 @@ AC_DEFINE_DIR(DEBUGDIR, debugdir,
               [Global directory for separate debug files. ])
 #AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"),
 
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+  if test "x$prefix" = xNONE; then
+    test_prefix=/usr/local
+  else
+    test_prefix=$prefix
+  fi
+else
+  test_prefix=$exec_prefix
+fi
+case ${debugdir} in
+"${test_prefix}"|"${test_prefix}/"*|\
+'${exec_prefix}'|'${exec_prefix}/'*)
+  AC_DEFINE(DEBUGDIR_RELOCATABLE, 1, [Define if the debug directory should be relocated when GDB is moved.])
+  ;;
+esac
+
 AC_CONFIG_SUBDIRS(doc testsuite)
 
 # Provide defaults for some variables set by the per-host and per-target
@@ -1102,7 +1118,7 @@ AC_ARG_WITH(sysroot,
 
  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
 
- if test "x$exec_prefix" = xNONE; then
+ if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
   if test "x$prefix" = xNONE; then
    test_prefix=/usr/local
   else
index 3ab633eb98c2d63b140f7c32b8313017c945f21c..c7e6d3a51be4964ed59cc95af50f619648e261a3 100644 (file)
@@ -167,6 +167,9 @@ extern int dbx_commands;
 /* System root path, used to find libraries etc.  */
 extern char *gdb_sysroot;
 
+/* Search path for separate debug files.  */
+extern char *debug_file_directory;
+
 extern int quit_flag;
 extern int immediate_quit;
 extern int sevenbit_strings;
index 7e25d77300b994d690f64eb2ad27080409dc1142..7cc14adc93852aa226fc799d3b05645d37e8d980 100644 (file)
@@ -221,19 +221,60 @@ captured_main (void *data)
       if (res == 0)
        {
          xfree (gdb_sysroot);
-         gdb_sysroot = TARGET_SYSTEM_ROOT;
+         gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT);
        }
     }
   else
-    gdb_sysroot = TARGET_SYSTEM_ROOT;
+    gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT);
 #else
-#if defined (TARGET_SYSTEM_ROOT)
-  gdb_sysroot = TARGET_SYSTEM_ROOT;
-#else
-  gdb_sysroot = "";
+  gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT);
 #endif
+
+  /* Canonicalize the sysroot path.  */
+  if (*gdb_sysroot)
+    {
+      char *canon_sysroot = lrealpath (gdb_sysroot);
+      if (canon_sysroot)
+       {
+         xfree (gdb_sysroot);
+         gdb_sysroot = canon_sysroot;
+       }
+    }
+
+#ifdef DEBUGDIR_RELOCATABLE
+  debug_file_directory = make_relative_prefix (argv[0], BINDIR, DEBUGDIR);
+  if (debug_file_directory)
+    {
+      struct stat s;
+      int res = 0;
+
+      if (stat (debug_file_directory, &s) == 0)
+       if (S_ISDIR (s.st_mode))
+         res = 1;
+
+      if (res == 0)
+       {
+         xfree (debug_file_directory);
+         debug_file_directory = xstrdup (DEBUGDIR);
+       }
+    }
+  else
+    debug_file_directory = xstrdup (DEBUGDIR);
+#else
+  debug_file_directory = xstrdup (DEBUGDIR);
 #endif
 
+  /* Canonicalize the debugfile path.  */
+  if (*debug_file_directory)
+    {
+      char *canon_debug = lrealpath (debug_file_directory);
+      if (canon_debug)
+       {
+         xfree (debug_file_directory);
+         debug_file_directory = canon_debug;
+       }
+    }
+
   /* There will always be an interpreter.  Either the one passed into
      this captured main, or one specified by the user at start up, or
      the console.  Initialize the interpreter to the one requested by 
index 99c965eede88c88f8d0bda2378af4d2ae6b855d6..37a57c86ab30ef8086569d430d0dce2416cadbea 100644 (file)
@@ -1156,7 +1156,7 @@ separate_debug_file_exists (const char *name, unsigned long crc)
   return crc == file_crc;
 }
 
-static char *debug_file_directory = NULL;
+char *debug_file_directory = NULL;
 static void
 show_debug_file_directory (struct ui_file *file, int from_tty,
                           struct cmd_list_element *c, const char *value)
@@ -1178,6 +1178,7 @@ find_separate_debug_file (struct objfile *objfile)
   char *dir;
   char *debugfile;
   char *name_copy;
+  char *canon_name;
   bfd_size_type debuglink_size;
   unsigned long crc32;
   int i;
@@ -1245,6 +1246,30 @@ find_separate_debug_file (struct objfile *objfile)
       return xstrdup (debugfile);
     }
 
+  /* If the file is in the sysroot, try using its base path in the
+     global debugfile directory.  */
+  canon_name = lrealpath (dir);
+  if (canon_name
+      && strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0
+      && IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)]))
+    {
+      strcpy (debugfile, debug_file_directory);
+      strcat (debugfile, canon_name + strlen (gdb_sysroot));
+      strcat (debugfile, "/");
+      strcat (debugfile, basename);
+
+      if (separate_debug_file_exists (debugfile, crc32))
+       {
+         xfree (canon_name);
+         xfree (basename);
+         xfree (dir);
+         return xstrdup (debugfile);
+       }
+    }
+  
+  if (canon_name)
+    xfree (canon_name);
+
   xfree (basename);
   xfree (dir);
   return NULL;
@@ -3857,7 +3882,6 @@ Usage: set extension-language .foo bar"),
   add_info ("extensions", info_ext_lang_command,
            _("All filename extensions associated with a source language."));
 
-  debug_file_directory = xstrdup (DEBUGDIR);
   add_setshow_optional_filename_cmd ("debug-file-directory", class_support,
                                     &debug_file_directory, _("\
 Set the directory where separate debug symbols are searched for."), _("\
This page took 0.040772 seconds and 4 git commands to generate.