+2001-01-26 Fernando Nasser <fnasser@redhat.com>
+
+ Fix double parsing of filenames passed as command line arguments
+ to GDB (causes weird handling of escape characters).
+ Also, remove dependencies on the CLI from libgdb.
+ * call-cmds.h: Remove declaration of exec_file_command().
+ * gdbcore.h: Remove declaration of exec_file_command().
+ Add declarations for exec_open() and exec_file_clear().
+ * symfile.h: Add declarations for symbol_file_add_main() and
+ symbol_file_clear().
+ * exec.c (exec_open): New function. Implements to_open for exec
+ targets.
+ (exec_file_clear): New function. Makes GDB forget about a previously
+ specified executable file.
+ (exec_file_attach): Move parsing of arguments from here ...
+ (exec_file_command): ... to here.
+ (init_exec_ops): Use exec_open(), not exec_file_command() to
+ implement to_open for exec targets.
+ * symfile.c (symbol_file_add_main): New function. Call symbol_file_add()
+ with default values. Used when the file name has already been parsed.
+ (symbol_file_clear): New function. Makes GDB forget about previously
+ read symbols.
+ (symbol_file_command): Call the above function instead of inline code.
+ * main.c: Include "symfile.h" and "gdbcore.h" instead of the deprecated
+ "call-cmds.h".
+ (captured_main): Call exec_file_attach() and symbol_file_add_main()
+ instead of exec_file_command() and symbol_file_command().
+ (captured_main): Add comment.
+ * corefile.c: Include "symfile.h".
+ (core_file_command): Call symbol_file_add_main() instead of
+ symbol_file_command().
+ (reopen_exec_file): Call exec_open() instead of exec_file_command().
+ * infcmd.c: Include "symfile.h".
+ (attach_command): Call symbol_file_add_main() instead of
+ symbol_file_command().
+ * infrun.c: Remove comment about the inclusion of "symfile.h",
+ not any longer appropriate.
+ (follow_exec): Call symbol_file_add_main() instead of
+ symbol_file_command().
+ * remote-es.c: Include "symfile.h".
+ (es1800_load): Call symbol_file_add_main() instead of
+ symbol_file_command().
+ * remote-vx.c: Remove comment about the inclusion of "symfile.h",
+ not any longer appropriate.
+ (vx-wait): Call symbol_file_add_main() instead of
+ symbol_file_command().
+ * solib-svr4.c (open_symbol_file_object): Call symbol_file_add_main()
+ instead of symbol_file_command().
+ * v850ice.c (ice_file): Call exec_open(), exec_file_attach() and
+ symbol_file_add_main() instead of exec_file_command() and
+ symbol_file_command().
+ * Makefile.in: Update dependencies.
+
2001-01-26 Jeff Holcomb <jeffh@redhat.com>
* remote-udi.c (udi_open): Change strdup to xstrdup.
extern void initialize_all_files (void);
-extern void exec_file_command (char *, int);
-
extern void core_file_command (char *, int);
extern void break_command (char *, int);
#include "symtab.h"
#include "command.h"
#include "gdbcmd.h"
+#include "symfile.h"
#include "bfd.h"
#include "target.h"
#include "gdbcore.h"
char *symfile_copy = xstrdup (symfile);
make_cleanup (xfree, symfile_copy);
- symbol_file_command (symfile_copy, from_tty);
+ symbol_file_add_main (symfile_copy, from_tty);
}
else
warning ("Unknown symbols for '%s'; use the 'symbol-file' command.", filename);
res = stat (filename, &st);
if (mtime && mtime != st.st_mtime)
- exec_file_command (filename, 0);
+ {
+ exec_open (filename, 0);
+ }
#endif
}
\f
struct vmap *vmap;
+void
+exec_open (char *args, int from_tty)
+{
+ target_preopen (from_tty);
+ exec_file_attach (args, from_tty);
+}
+
/* ARGSUSED */
static void
exec_close (int quitting)
}
}
+void
+exec_file_clear (int from_tty)
+{
+ /* Remove exec file. */
+ unpush_target (&exec_ops);
+
+ if (from_tty)
+ printf_unfiltered ("No executable file now.\n");
+}
+
/* Process the first arg in ARGS as the new exec file.
This function is intended to be behave essentially the same
given a pid but not a exec pathname, and the attach command could
figure out the pathname from the pid. (In this case, we shouldn't
ask the user whether the current target should be shut down --
- we're supplying the exec pathname late for good reason.) */
+ we're supplying the exec pathname late for good reason.)
+
+ ARGS is assumed to be the filename. */
void
-exec_file_attach (char *args, int from_tty)
+exec_file_attach (char *filename, int from_tty)
{
- char **argv;
- char *filename;
-
/* Remove any previous exec file. */
unpush_target (&exec_ops);
/* Now open and digest the file the user requested, if any. */
- if (args)
+ if (!filename)
+ {
+ if (from_tty)
+ printf_unfiltered ("No executable file now.\n");
+ }
+ else
{
char *scratch_pathname;
int scratch_chan;
- /* Scan through the args and pick up the first non option arg
- as the filename. */
-
- argv = buildargv (args);
- if (argv == NULL)
- nomem (0);
-
- make_cleanup_freeargv (argv);
-
- for (; (*argv != NULL) && (**argv == '-'); argv++)
- {;
- }
- if (*argv == NULL)
- error ("No executable file name was specified");
-
- filename = tilde_expand (*argv);
- make_cleanup (xfree, filename);
-
scratch_chan = openp (getenv ("PATH"), 1, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0,
&scratch_pathname);
if (exec_file_display_hook)
(*exec_file_display_hook) (filename);
}
- else if (from_tty)
- printf_unfiltered ("No executable file now.\n");
}
/* Process the first arg in ARGS as the new exec file.
Note that we have to explicitly ignore additional args, since we can
be called from file_command(), which also calls symbol_file_command()
- which can take multiple args. */
+ which can take multiple args.
+
+ If ARGS is NULL, we just want to close the exec file. */
-void
+static void
exec_file_command (char *args, int from_tty)
{
+ char **argv;
+ char *filename;
+
target_preopen (from_tty);
- exec_file_attach (args, from_tty);
+
+ if (args)
+ {
+ /* Scan through the args and pick up the first non option arg
+ as the filename. */
+
+ argv = buildargv (args);
+ if (argv == NULL)
+ nomem (0);
+
+ make_cleanup_freeargv (argv);
+
+ for (; (*argv != NULL) && (**argv == '-'); argv++)
+ {;
+ }
+ if (*argv == NULL)
+ error ("No executable file name was specified");
+
+ filename = tilde_expand (*argv);
+ make_cleanup (xfree, filename);
+ exec_file_attach (filename, from_tty);
+ }
+ else
+ exec_file_attach (NULL, from_tty);
}
/* Set both the exec file and the symbol file, in one command.
exec_ops.to_longname = "Local exec file";
exec_ops.to_doc = "Use an executable file as a target.\n\
Specify the filename of the executable file.";
- exec_ops.to_open = exec_file_command;
+ exec_ops.to_open = exec_open;
exec_ops.to_close = exec_close;
exec_ops.to_attach = find_default_attach;
exec_ops.to_require_attach = find_default_require_attach;
extern void core_file_command (char *filename, int from_tty);
+extern void exec_open (char *filename, int from_tty);
+
extern void exec_file_attach (char *filename, int from_tty);
-extern void exec_file_command (char *filename, int from_tty);
+extern void exec_file_clear (int from_tty);
extern void validate_files (void);
#include "environ.h"
#include "value.h"
#include "gdbcmd.h"
+#include "symfile.h"
#include "gdbcore.h"
#include "target.h"
#include "language.h"
full_exec_path = savestring (exec_file, strlen (exec_file));
exec_file_attach (full_exec_path, from_tty);
- symbol_file_command (full_exec_path, from_tty);
+ symbol_file_add_main (full_exec_path, from_tty);
}
}
#include "target.h"
#include "gdbthread.h"
#include "annotate.h"
-#include "symfile.h" /* for overlay functions */
+#include "symfile.h"
#include "top.h"
#include <signal.h>
#include "inf-loop.h"
}
}
+/* EXECD_PATHNAME is assumed to be non-NULL. */
+
static void
follow_exec (int pid, char *execd_pathname)
{
exec_file_attach (execd_pathname, 0);
/* And also is where symbols can be found. */
- symbol_file_command (execd_pathname, 0);
+ symbol_file_add_main (execd_pathname, 0);
/* Reset the shared library package. This ensures that we get
a shlib event when the child reaches "_start", at which point
#include "top.h"
#include "target.h"
#include "inferior.h"
-#include "call-cmds.h"
+#include "symfile.h"
+#include "gdbcore.h"
#include "getopt.h"
execarg = argv[optind];
break;
case 2:
+ /* FIXME: The documentation says this can be a "ProcID". as well. */
corearg = argv[optind];
break;
case 3:
/* 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_command, execarg, !batch, RETURN_MASK_ALL))
- catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
+ if (catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL))
+ catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL);
}
else
{
if (execarg != NULL)
- catch_command_errors (exec_file_command, execarg, !batch, RETURN_MASK_ALL);
+ catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL);
if (symarg != NULL)
- catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
+ catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL);
}
/* After the symbol file has been read, print a newline to get us
#include "target.h"
#include "gdb_wait.h"
#include "command.h"
+#include "symfile.h"
#include "remote-utils.h"
#include "gdbcore.h"
#include "serial.h"
system (buf);
}
- symbol_file_command (filename, from_tty); /* reading symbol table */
+ symbol_file_add_main (filename, from_tty); /* reading symbol table */
immediate_quit--;
}
#include "complaints.h"
#include "gdbcmd.h"
#include "bfd.h" /* Required by objfiles.h. */
-#include "symfile.h" /* Required by objfiles.h. */
+#include "symfile.h"
#include "objfiles.h"
#include "gdb-stabs.h"
static int
symbol_stub (char *arg)
{
- symbol_file_command (arg, 0);
+ symbol_file_add_main (arg, 0);
return 1;
}
make_cleanup (xfree, filename);
/* Have a pathname: read the symbol file. */
- symbol_file_command (filename, from_tty);
+ symbol_file_add_main (filename, from_tty);
return 1;
}
return (objfile);
}
+/* Just call the above with default values.
+ Used when the file is supplied in the gdb command line. */
+
+void
+symbol_file_add_main (char *args, int from_tty)
+{
+ symbol_file_add (args, from_tty, NULL, 1, 0);
+}
+
+void
+symbol_file_clear (int from_tty)
+{
+ if ((have_full_symbols () || have_partial_symbols ())
+ && from_tty
+ && !query ("Discard symbol table from `%s'? ",
+ symfile_objfile->name))
+ error ("Not confirmed.");
+ free_all_objfiles ();
+
+ /* solib descriptors may have handles to objfiles. Since their
+ storage has just been released, we'd better wipe the solib
+ descriptors as well.
+ */
+#if defined(SOLIB_RESTART)
+ SOLIB_RESTART ();
+#endif
+
+ symfile_objfile = NULL;
+ if (from_tty)
+ printf_unfiltered ("No symbol file now.\n");
+#ifdef HPUXHPPA
+ RESET_HP_UX_GLOBALS ();
+#endif
+}
+
/* This is the symbol-file command. Read the file, analyze its
symbols, and add a struct symtab to a symtab list. The syntax of
the command is rather bizarre--(1) buildargv implements various
if (args == NULL)
{
- if ((have_full_symbols () || have_partial_symbols ())
- && from_tty
- && !query ("Discard symbol table from `%s'? ",
- symfile_objfile->name))
- error ("Not confirmed.");
- free_all_objfiles ();
-
- /* solib descriptors may have handles to objfiles. Since their
- storage has just been released, we'd better wipe the solib
- descriptors as well.
- */
-#if defined(SOLIB_RESTART)
- SOLIB_RESTART ();
-#endif
-
- symfile_objfile = NULL;
- if (from_tty)
- printf_unfiltered ("No symbol file now.\n");
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
+ symbol_file_clear (from_tty);
}
else
{
/* convert an address in an overlay section (force into VMA range) */
extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
+/* Load symbols from a file. */
+extern void symbol_file_add_main (char *args, int from_tty);
+
+/* Clear GDB symbol tables. */
+extern void symbol_file_clear (int from_tty);
+
/* From dwarfread.c */
extern void
/* Must supress from_tty, otherwise we could start asking if the
user really wants to load a new symbol table, etc... */
printf_unfiltered ("Reading symbols from %s...", arg);
- exec_file_command (arg, 0);
- symbol_file_command (arg, 0);
+ exec_open (arg, 0);
+ symbol_file_add_main (arg, 0);
printf_unfiltered ("done\n");
- /* exec_file_command will kill our target, so reinstall the ICE as
+ /* exec_open will kill our target, so reinstall the ICE as
the target. */
v850ice_open (NULL, 0);