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 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
/* 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
#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"
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
[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
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
/* 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;
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
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)
char *dir;
char *debugfile;
char *name_copy;
+ char *canon_name;
bfd_size_type debuglink_size;
unsigned long crc32;
int i;
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;
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."), _("\