aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2005-12-06 19:35:16 +0000
committerMichael Snyder <msnyder@vmware.com>2005-12-06 19:35:16 +0000
commitf071905c7b5fbaf0b8fe59c7fbd0013cedd2f39d (patch)
treeec9d21085638ef1cde97ff05965db5c71d63be9c
parent0f5d61cbd17273466abee679801ef291c23add8c (diff)
downloadgdb-f071905c7b5fbaf0b8fe59c7fbd0013cedd2f39d.zip
gdb-f071905c7b5fbaf0b8fe59c7fbd0013cedd2f39d.tar.gz
gdb-f071905c7b5fbaf0b8fe59c7fbd0013cedd2f39d.tar.bz2
2005-12-06 Michael Snyder <msnyder@redhat.com>
* linux-fork.c (linux_fork_mourn_inferior): Guard against null. (delete_fork_command): Guard against not-found. Replace strtol with parse_and_eval_long. Announce result. (detach_fork_command): Ditto.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/linux-fork.c31
2 files changed, 27 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a498e50..972ff4a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-06 Michael Snyder <msnyder@redhat.com>
+
+ * linux-fork.c (linux_fork_mourn_inferior): Guard against null.
+ (delete_fork_command): Guard against not-found. Replace strtol
+ with parse_and_eval_long. Announce result.
+ (detach_fork_command): Ditto.
+
2005-12-01 Michael Snyder <msnyder@redhat.com>
* linux-fork.c (fork_save_infrun_state): Close the DIR.
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index ba83923..8ce9a4e 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -184,13 +184,11 @@ fork_id_to_ptid (int num)
return pid_to_ptid (-1);
}
-/* FIXME: */
static void
init_fork_list (void)
{
struct fork_info *fp, *fpnext;
- highest_fork_num = 0;
if (!fork_list)
return;
@@ -342,9 +340,12 @@ linux_fork_mourn_inferior (void)
We need to delete that one from the fork_list, and switch
to the next available fork. FIXME safety? */
delete_fork (inferior_ptid);
- inferior_ptid = fork_list[0].ptid;
- printf_filtered ("[Switching to %s]\n",
- target_pid_to_str (inferior_ptid));
+ if (fork_list) /* Paranoia, shouldn't happen. */
+ {
+ inferior_ptid = fork_list[0].ptid;
+ printf_filtered ("[Switching to %s]\n",
+ target_pid_to_str (inferior_ptid));
+ }
}
/*
@@ -359,12 +360,19 @@ delete_fork_command (char *args, int from_tty)
if (!args || !*args)
error ("Requires argument (checkpoint id to delete, see info checkpoint)");
- /* FIXME: check for not-found! */
- /* FIXME: we can do better than strtol, too... */
- ptid = fork_id_to_ptid (strtol (args, NULL, 0));
+ ptid = fork_id_to_ptid (parse_and_eval_long (args));
+ if (ptid_equal (ptid, minus_one_ptid))
+ error ("No such fork id, %s", args);
+
+ if (ptid_equal (ptid, inferior_ptid))
+ error ("Please switch to another fork before deleting the current fork");
+
if (ptrace (PTRACE_KILL, ptid, 0, 0))
error ("Unable to kill pid %s", target_tid_to_str (ptid));
+ if (from_tty)
+ printf_filtered ("Killed %s\n", target_pid_to_str (ptid));
+
delete_fork (ptid);
}
@@ -376,9 +384,10 @@ detach_fork_command (char *args, int from_tty)
if (!args || !*args)
error ("Requires argument (fork id to delete, see info fork)");
- /* FIXME: check for not-found! */
- /* FIXME: we can do better than strtol, too... */
- ptid = fork_id_to_ptid (strtol (args, NULL, 0));
+ ptid = fork_id_to_ptid (parse_and_eval_long (args));
+ if (ptid_equal (ptid, minus_one_ptid))
+ error ("No such fork id, %s", args);
+
if (ptid_equal (ptid, inferior_ptid))
error ("Please switch to another fork before detaching the current fork");