aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorFernando Nasser <fnasser@redhat.com>2001-01-27 00:43:26 +0000
committerFernando Nasser <fnasser@redhat.com>2001-01-27 00:43:26 +0000
commit1adeb98a32c1291fbc8cb812bdc8d39d221c6fe5 (patch)
treec96024e9e9e3afd2a63965e62dfa45c5b988078d /gdb/exec.c
parent8fb35fedd531db95117ec2571f74a8dac1cf5844 (diff)
downloadgdb-1adeb98a32c1291fbc8cb812bdc8d39d221c6fe5.zip
gdb-1adeb98a32c1291fbc8cb812bdc8d39d221c6fe5.tar.gz
gdb-1adeb98a32c1291fbc8cb812bdc8d39d221c6fe5.tar.bz2
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.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c89
1 files changed, 59 insertions, 30 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index e39062b..29da0cc 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -94,6 +94,13 @@ CORE_ADDR text_end = 0;
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)
@@ -150,6 +157,16 @@ 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
@@ -165,42 +182,28 @@ exec_close (int quitting)
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);
@@ -298,21 +301,47 @@ exec_file_attach (char *args, int from_tty)
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.
@@ -666,7 +695,7 @@ init_exec_ops (void)
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;