summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2005-11-29 19:23:46 +0000
committerMichael Snyder <msnyder@specifix.com>2005-11-29 19:23:46 +0000
commitd1a7185a2a5a66bc22970d13e8be41a174e8aaaa (patch)
treee655aeb2f0cded61e682cf3e84590ad6ce84bbd3
parentaff8fda554845dd8cf96369ea5ef0f282f6b9f34 (diff)
downloadgdb-d1a7185a2a5a66bc22970d13e8be41a174e8aaaa.tar.gz
2005-11-29 Michael Snyder <msnyder@redhat.com>
* linux-fork.c (process_command): New command, new function. Switch fork contexts by process id, rather than fork id. (linux_fork_context): New function. Abstract out the guts of restart_command, to be called by process_command and fork_command. (fork_command): New function. Look up a fork id, call linux_fork_context. (_initialize_linux_fork): Add new "process" command.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/linux-fork.c67
2 files changed, 67 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 76e02c6c920..50ccc9f6aa0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2005-11-29 Michael Snyder <msnyder@redhat.com>
+
+ * linux-fork.c (process_command): New command, new function.
+ Switch fork contexts by process id, rather than fork id.
+ (linux_fork_context): New function. Abstract out the guts
+ of restart_command, to be called by process_command and
+ fork_command.
+ (fork_command): New function. Look up a fork id, call
+ linux_fork_context.
+ (_initialize_linux_fork): Add new "process" command.
+
2005-11-28 Michael Snyder <msnyder@redhat.com>
* linux-fork.c: New file. Move fork list and fork commands here.
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index a2622389bf9..f9bd7a6dbbb 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -429,21 +429,15 @@ checkpoint_command (char *args, int from_tty)
static int restart_auto_finish;
static void
-restart_command (char *args, int from_tty)
+linux_fork_context (struct fork_info *newfp, int from_tty)
{
/* Now we attempt to switch processes. */
struct fork_info *oldfp = find_fork_ptid (inferior_ptid);
- struct fork_info *newfp;
ptid_t ptid;
int id, i;
- if (!args || !*args)
- error ("Requires argument (checkpoint or fork id, see info checkpoint)");
-
- id = strtol (args, NULL, 0);
- newfp = find_fork_id (id);
if (!newfp)
- error ("No such checkpoint id: %d\n", id);
+ error ("No such fork/process");
if (!oldfp)
{
@@ -472,6 +466,50 @@ restart_command (char *args, int from_tty)
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
}
+/* Switch inferior process (fork) context, by process id. */
+static void
+process_command (char *args, int from_tty)
+{
+ struct fork_info *fp;
+
+ if (!args || !*args)
+ error ("Requires argument (process id, see info forks)");
+
+ if ((fp = find_fork_pid (parse_and_eval_long (args))) == NULL)
+ error ("Not found: process id %s", args);
+
+ linux_fork_context (fp, from_tty);
+}
+
+/* Switch inferior process (fork) context, by fork id. */
+static void
+fork_command (char *args, int from_tty)
+{
+ struct fork_info *fp;
+
+ if (!args || !*args)
+ error ("Requires argument (fork id, see info forks)");
+
+ if ((fp = find_fork_id (parse_and_eval_long (args))) == NULL)
+ error ("Not found: fork id %s", args);
+
+ linux_fork_context (fp, from_tty);
+}
+
+/* Switch inferior process (fork) context, by checkpoint id. */
+static void
+restart_command (char *args, int from_tty)
+{
+ struct fork_info *fp;
+
+ if (!args || !*args)
+ error ("Requires argument (checkpoint id, see info checkpoints)");
+
+ if ((find_fork_id (parse_and_eval_long (args))) == NULL)
+ error ("Not found: checkpoint id %s", args);
+
+ linux_fork_context (fp, from_tty);
+}
/* Extern because called from core gdb. */
extern void
@@ -512,7 +550,8 @@ Fork a duplicate process (experimental)."));
"debugger forks" (checkpoints). */
add_com ("restart", class_obscure, restart_command, _("\
-Switch between parent and child fork (experimental)."));
+restart <n>: restore program context from a checkpoint.\n\
+Argument 'n' is checkpoint ID, as displayed by 'info checkpoints'."));
/* Delete-checkpoint command: kill the process and remove it from
fork list. */
@@ -540,6 +579,12 @@ Detach from a fork/checkpoint (experimental)."));
add_info_alias ("forks", "checkpoints", 0);
/* "fork <n>" (by analogy to "thread <n>"). */
-
- add_com_alias ("fork", "restart", class_obscure, 1);
+ add_com ("fork", class_obscure, fork_command, _("\
+fork <n>: Switch between forked processes.\n\
+Argument 'n' is fork ID, as displayed by 'info forks'."));
+
+ /* "process <proc id>" as opposed to "fork <fork id>". */
+ add_com ("process", class_obscure, process_command, _("\
+process <pid>: Switch between forked processes.\n\
+Argument 'pid' is process ID, as displayed by 'info forks' or 'shell ps'."));
}