Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
- 2009, 2010 Free Software Foundation, Inc.
+ 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
file or directory. FLAG is true if the value is relocatable, false
otherwise. Returns a newly allocated string; this may return NULL
under the same conditions as make_relative_prefix. */
+
static char *
relocate_path (const char *progname, const char *initial, int flag)
{
the result is a directory, it is used; otherwise, INITIAL is used.
The chosen directory is then canonicalized using lrealpath. This
function always returns a newly-allocated string. */
-static char *
-relocate_directory (const char *progname, const char *initial, int flag)
+
+char *
+relocate_gdb_directory (const char *initial, int flag)
{
char *dir;
- dir = relocate_path (progname, initial, flag);
+ dir = relocate_path (gdb_program_name, initial, flag);
if (dir)
{
struct stat s;
/* If the .gdbinit file in the current directory is the same as
the $HOME/.gdbinit file, it should not be sourced. homebuf
- and cwdbuf are used in that purpose. Make sure that the stats
+ and cwdbuf are used in that purpose. Make sure that the stats
are zero in case one of them fails (this guarantees that they
won't match if either exists). */
check to detect bad FUNCs code. */
do_cleanups (ALL_CLEANUPS);
/* If the command_loop returned, normally (rather than threw an
- error) we try to quit. If the quit is aborted, catch_errors()
+ error) we try to quit. If the quit is aborted, catch_errors()
which called this catch the signal and restart the command
loop. */
quit_command (NULL, instream == stdin);
ndir = 0;
quit_flag = 0;
- line = (char *) xmalloc (linesize);
- line[0] = '\0'; /* Terminate saved (now empty) cmd line. */
+ saved_command_line = (char *) xmalloc (saved_command_line_size);
+ saved_command_line[0] = '\0';
instream = stdin;
gdb_stdout = stdio_fileopen (stdout);
/* Don't use *_filtered or warning() (which relies on
current_target) until after initialize_all_files(). */
fprintf_unfiltered (gdb_stderr,
- _("%s: warning: error finding working directory: %s\n"),
+ _("%s: warning: error finding "
+ "working directory: %s\n"),
argv[0], safe_strerror (errno));
current_directory = gdb_dirbuf;
/* Set the sysroot path. */
- gdb_sysroot = relocate_directory (argv[0], TARGET_SYSTEM_ROOT,
- TARGET_SYSTEM_ROOT_RELOCATABLE);
+ gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
+ TARGET_SYSTEM_ROOT_RELOCATABLE);
- debug_file_directory = relocate_directory (argv[0], DEBUGDIR,
- DEBUGDIR_RELOCATABLE);
+ debug_file_directory = relocate_gdb_directory (DEBUGDIR,
+ DEBUGDIR_RELOCATABLE);
- gdb_datadir = relocate_directory (argv[0], GDB_DATADIR,
- GDB_DATADIR_RELOCATABLE);
+ gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
+ GDB_DATADIR_RELOCATABLE);
#ifdef WITH_PYTHON_PATH
- /* For later use in helping Python find itself. */
- python_libdir = relocate_directory (argv[0],
- concat (WITH_PYTHON_PATH,
- SLASH_STRING, "lib", NULL),
- PYTHON_PATH_RELOCATABLE);
+ {
+ /* For later use in helping Python find itself. */
+ char *tmp = concat (WITH_PYTHON_PATH, SLASH_STRING, "lib", NULL);
+
+ python_libdir = relocate_gdb_directory (tmp, PYTHON_PATH_RELOCATABLE);
+ xfree (tmp);
+ }
#endif
#ifdef RELOC_SRCDIR
break;
case 'f':
annotation_level = 1;
-/* We have probably been invoked from emacs. Disable window interface. */
+ /* We have probably been invoked from emacs. Disable
+ window interface. */
use_windows = 0;
break;
case 's':
if (!gdbtk_test (optarg))
{
- fprintf_unfiltered (gdb_stderr,
- _("%s: unable to load tclcommand file \"%s\""),
+ fprintf_unfiltered (gdb_stderr,
+ _("%s: unable to load "
+ "tclcommand file \"%s\""),
argv[0], optarg);
exit (1);
}
/* Don't use *_filtered or warning() (which relies on
current_target) until after initialize_all_files(). */
- fprintf_unfiltered
- (gdb_stderr,
- _("warning: could not set timeout limit to `%s'.\n"), optarg);
+ fprintf_unfiltered (gdb_stderr,
+ _("warning: could not set "
+ "timeout limit to `%s'.\n"), optarg);
else
remote_timeout = i;
}
case '?':
fprintf_unfiltered (gdb_stderr,
- _("Use `%s --help' for a complete list of options.\n"),
+ _("Use `%s --help' for a "
+ "complete list of options.\n"),
argv[0]);
exit (1);
}
if (optind >= argc)
{
fprintf_unfiltered (gdb_stderr,
- _("%s: `--args' specified but no program specified\n"),
+ _("%s: `--args' specified but "
+ "no program specified\n"),
argv[0]);
exit (1);
}
/* Any argument left on the command line is unexpected and
will be ignored. Inform the user. */
if (optind < argc)
- fprintf_unfiltered (gdb_stderr, _("\
-Excess command line arguments ignored. (%s%s)\n"),
+ fprintf_unfiltered (gdb_stderr,
+ _("Excess command line "
+ "arguments ignored. (%s%s)\n"),
argv[optind],
(optind == argc - 1) ? "" : " ...");
}
- /* Lookup gdbinit files. Note that the gdbinit file name may be
+ /* Lookup gdbinit files. Note that the gdbinit file name may be
overriden during file initialization, so get_init_files should be
called after gdb_init. */
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
/* The exec file and the symbol-file are the same. If we can't
open it, better only print one error message.
catch_command_errors returns non-zero on success! */
- if (catch_command_errors (exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL))
- catch_command_errors (symbol_file_add_main, symarg, !batch_flag, RETURN_MASK_ALL);
+ if (catch_command_errors (exec_file_attach, execarg,
+ !batch_flag, RETURN_MASK_ALL))
+ catch_command_errors (symbol_file_add_main, symarg,
+ !batch_flag, RETURN_MASK_ALL);
}
else
{
if (execarg != NULL)
- catch_command_errors (exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL);
+ catch_command_errors (exec_file_attach, execarg,
+ !batch_flag, RETURN_MASK_ALL);
if (symarg != NULL)
- catch_command_errors (symbol_file_add_main, symarg, !batch_flag, RETURN_MASK_ALL);
+ catch_command_errors (symbol_file_add_main, symarg,
+ !batch_flag, RETURN_MASK_ALL);
}
if (corearg && pidarg)
- error (_("\
-Can't attach to process and specify a core file at the same time."));
+ error (_("Can't attach to process and specify "
+ "a core file at the same time."));
if (corearg != NULL)
catch_command_errors (core_file_command, corearg,