aboutsummaryrefslogtreecommitdiff
path: root/gdb
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
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')
-rw-r--r--gdb/ChangeLog53
-rw-r--r--gdb/call-cmds.h2
-rw-r--r--gdb/corefile.c7
-rw-r--r--gdb/exec.c89
-rw-r--r--gdb/gdbcore.h4
-rw-r--r--gdb/infcmd.c3
-rw-r--r--gdb/infrun.c6
-rw-r--r--gdb/main.c12
-rw-r--r--gdb/remote-es.c3
-rw-r--r--gdb/remote-vx.c4
-rw-r--r--gdb/solib-svr4.c2
-rw-r--r--gdb/symfile.c57
-rw-r--r--gdb/symfile.h6
-rw-r--r--gdb/v850ice.c6
14 files changed, 183 insertions, 71 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 96ca6d2..e8afaf5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,56 @@
+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.
diff --git a/gdb/call-cmds.h b/gdb/call-cmds.h
index b8673fa..d8e9358 100644
--- a/gdb/call-cmds.h
+++ b/gdb/call-cmds.h
@@ -25,8 +25,6 @@
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);
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 4447f77..cc51109 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -29,6 +29,7 @@
#include "symtab.h"
#include "command.h"
#include "gdbcmd.h"
+#include "symfile.h"
#include "bfd.h"
#include "target.h"
#include "gdbcore.h"
@@ -92,7 +93,7 @@ core_file_command (char *filename, int from_tty)
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);
@@ -188,7 +189,9 @@ reopen_exec_file (void)
res = stat (filename, &st);
if (mtime && mtime != st.st_mtime)
- exec_file_command (filename, 0);
+ {
+ exec_open (filename, 0);
+ }
#endif
}
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;
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index bdf14c2..c3db1da 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -98,9 +98,11 @@ extern int write_files;
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);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 91c6fac..bdc120a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -29,6 +29,7 @@
#include "environ.h"
#include "value.h"
#include "gdbcmd.h"
+#include "symfile.h"
#include "gdbcore.h"
#include "target.h"
#include "language.h"
@@ -1701,7 +1702,7 @@ attach_command (char *args, int from_tty)
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);
}
}
diff --git a/gdb/infrun.c b/gdb/infrun.c
index e934c9d..58ebfdd 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -31,7 +31,7 @@
#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"
@@ -650,6 +650,8 @@ follow_vfork (int parent_pid, int child_pid)
}
}
+/* EXECD_PATHNAME is assumed to be non-NULL. */
+
static void
follow_exec (int pid, char *execd_pathname)
{
@@ -727,7 +729,7 @@ 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
diff --git a/gdb/main.c b/gdb/main.c
index bf98ffa..185b46e 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -22,7 +22,8 @@
#include "top.h"
#include "target.h"
#include "inferior.h"
-#include "call-cmds.h"
+#include "symfile.h"
+#include "gdbcore.h"
#include "getopt.h"
@@ -474,6 +475,7 @@ extern int gdbtk_test (char *);
execarg = argv[optind];
break;
case 2:
+ /* FIXME: The documentation says this can be a "ProcID". as well. */
corearg = argv[optind];
break;
case 3:
@@ -592,15 +594,15 @@ extern int gdbtk_test (char *);
/* 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
diff --git a/gdb/remote-es.c b/gdb/remote-es.c
index 2d879c1..97b1263 100644
--- a/gdb/remote-es.c
+++ b/gdb/remote-es.c
@@ -106,6 +106,7 @@
#include "target.h"
#include "gdb_wait.h"
#include "command.h"
+#include "symfile.h"
#include "remote-utils.h"
#include "gdbcore.h"
#include "serial.h"
@@ -1318,7 +1319,7 @@ es1800_load (char *filename, int from_tty)
system (buf);
}
- symbol_file_command (filename, from_tty); /* reading symbol table */
+ symbol_file_add_main (filename, from_tty); /* reading symbol table */
immediate_quit--;
}
diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c
index 4503e77..8f03268 100644
--- a/gdb/remote-vx.c
+++ b/gdb/remote-vx.c
@@ -30,7 +30,7 @@
#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"
@@ -1039,7 +1039,7 @@ vx_wait (int pid_to_wait_for, struct target_waitstatus *status)
static int
symbol_stub (char *arg)
{
- symbol_file_command (arg, 0);
+ symbol_file_add_main (arg, 0);
return 1;
}
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 603c69c..c8183c7 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -940,7 +940,7 @@ open_symbol_file_object (void *from_ttyp)
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;
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b0ae6e2..abeca3c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -897,6 +897,41 @@ symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs,
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
@@ -923,27 +958,7 @@ symbol_file_command (char *args, int from_tty)
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
{
diff --git a/gdb/symfile.h b/gdb/symfile.h
index fb5fd17..467961b 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -273,6 +273,12 @@ extern CORE_ADDR overlay_unmapped_address (CORE_ADDR, asection *);
/* 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
diff --git a/gdb/v850ice.c b/gdb/v850ice.c
index 6ce875a..8973138 100644
--- a/gdb/v850ice.c
+++ b/gdb/v850ice.c
@@ -794,11 +794,11 @@ ice_file (char *arg)
/* 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);