aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2002-01-10 23:03:08 +0000
committerMichael Snyder <msnyder@vmware.com>2002-01-10 23:03:08 +0000
commit00546b04b221e63bf3307f5da6f2ca19c83d16ea (patch)
tree8c2466d28e270ecd8f396267e2295aca46e7a244 /gdb/main.c
parenta873495b9557914ff7d19b2707f5b59b88731d9c (diff)
downloadgdb-00546b04b221e63bf3307f5da6f2ca19c83d16ea.zip
gdb-00546b04b221e63bf3307f5da6f2ca19c83d16ea.tar.gz
gdb-00546b04b221e63bf3307f5da6f2ca19c83d16ea.tar.bz2
2002-01-10 Michael Snyder <msnyder@redhat.com>
* main.c (captured_main): Add new command line option "--pid". If the second command line argument (following the symbol-file) begins with a digit, try to attach to it before trying to open it as a corefile. (print_gdb_help): Document the "--pid" argument.
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/gdb/main.c b/gdb/main.c
index 0dbe83b..9b7a5f5 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1,6 +1,7 @@
/* Top level stuff for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -239,6 +240,8 @@ captured_main (void *data)
{"e", required_argument, 0, 'e'},
{"core", required_argument, 0, 'c'},
{"c", required_argument, 0, 'c'},
+ {"pid", required_argument, 0, 'p'},
+ {"p", required_argument, 0, 'p'},
{"command", required_argument, 0, 'x'},
{"version", no_argument, &print_version, 1},
{"x", required_argument, 0, 'x'},
@@ -320,6 +323,10 @@ captured_main (void *data)
case 'c':
corearg = optarg;
break;
+ case 'p':
+ /* "corearg" is shared by "--core" and "--pid" */
+ corearg = optarg;
+ break;
case 'x':
cmdarg[ncmd++] = optarg;
if (ncmd >= cmdsize)
@@ -463,8 +470,8 @@ extern int gdbtk_test (char *);
execarg = argv[optind];
break;
case 2:
- /* FIXME: The documentation says this can be a
- "ProcID". as well. */
+ /* The documentation says this can be a "ProcID" as well.
+ We will try it as both a corefile and a pid. */
corearg = argv[optind];
break;
case 3:
@@ -586,12 +593,20 @@ extern int gdbtk_test (char *);
if (corearg != NULL)
{
- if (catch_command_errors (core_file_command, corearg, !batch, RETURN_MASK_ALL) == 0)
+ /* corearg may be either a corefile or a pid.
+ If its first character is a digit, try attach first
+ and then corefile. Otherwise try corefile first. */
+
+ if (isdigit (corearg[0]))
{
- /* See if the core file is really a PID. */
- if (isdigit (corearg[0]))
- catch_command_errors (attach_command, corearg, !batch, RETURN_MASK_ALL);
+ if (catch_command_errors (attach_command, corearg,
+ !batch, RETURN_MASK_ALL) == 0)
+ catch_command_errors (core_file_command, corearg,
+ !batch, RETURN_MASK_ALL);
}
+ else /* Can't be a pid, better be a corefile. */
+ catch_command_errors (core_file_command, corearg,
+ !batch, RETURN_MASK_ALL);
}
if (ttyarg != NULL)
@@ -752,6 +767,7 @@ Options:\n\n\
--cd=DIR Change current directory to DIR.\n\
--command=FILE Execute GDB commands from FILE.\n\
--core=COREFILE Analyze the core dump COREFILE.\n\
+ --pid=PID Attach to running process PID.\n\
", stream);
fputs_unfiltered ("\
--dbx DBX compatibility mode.\n\