summaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2007-01-09 21:34:30 +0000
committerDaniel Jacobowitz <dan@debian.org>2007-01-09 21:34:30 +0000
commit91549c1328ffaba50c1992c9e48ce149502e05d3 (patch)
tree77686b3d2790efc103b6921c70982005968a449f /gdb/main.c
parentafac92b60e4b887653003e619d6fcf5afface874 (diff)
downloadgdb-91549c1328ffaba50c1992c9e48ce149502e05d3.tar.gz
* 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.
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/gdb/main.c b/gdb/main.c
index 7e25d77300b..7cc14adc938 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -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