testsuite, threads: fix LD_LIBRARY_PATH in 'tls-sepdebug.exp'
[binutils-gdb.git] / gdb / linux-fork.c
blobc457a90556d7e1e6d5b719a74760bd4276497e83
1 /* GNU/Linux native-dependent code for debugging multiple forks.
3 Copyright (C) 2005-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "arch-utils.h"
21 #include "event-top.h"
22 #include "inferior.h"
23 #include "infrun.h"
24 #include "regcache.h"
25 #include "cli/cli-cmds.h"
26 #include "infcall.h"
27 #include "objfiles.h"
28 #include "linux-fork.h"
29 #include "linux-nat.h"
30 #include "gdbthread.h"
31 #include "source.h"
33 #include "nat/gdb_ptrace.h"
34 #include "gdbsupport/gdb_wait.h"
35 #include "target/waitstatus.h"
36 #include <dirent.h>
37 #include <ctype.h>
39 #include <list>
41 /* Fork list data structure: */
42 struct fork_info
44 explicit fork_info (pid_t pid)
45 : ptid (pid, pid)
49 ~fork_info ()
51 /* Notes on step-resume breakpoints: since this is a concern for
52 threads, let's convince ourselves that it's not a concern for
53 forks. There are two ways for a fork_info to be created.
54 First, by the checkpoint command, in which case we're at a gdb
55 prompt and there can't be any step-resume breakpoint. Second,
56 by a fork in the user program, in which case we *may* have
57 stepped into the fork call, but regardless of whether we follow
58 the parent or the child, we will return to the same place and
59 the step-resume breakpoint, if any, will take care of itself as
60 usual. And unlike threads, we do not save a private copy of
61 the step-resume breakpoint -- so we're OK. */
63 if (savedregs)
64 delete savedregs;
66 xfree (filepos);
69 ptid_t ptid = null_ptid;
70 ptid_t parent_ptid = null_ptid;
72 /* Convenient handle (GDB fork id). */
73 int num = 0;
75 /* Convenient for info fork, saves having to actually switch
76 contexts. */
77 readonly_detached_regcache *savedregs = nullptr;
79 CORE_ADDR pc = 0;
81 /* Set of open file descriptors' offsets. */
82 off_t *filepos = nullptr;
84 int maxfd = 0;
87 static std::list<fork_info> fork_list;
88 static int highest_fork_num;
90 /* Fork list methods: */
92 int
93 forks_exist_p (void)
95 return !fork_list.empty ();
98 /* Return the last fork in the list. */
100 static struct fork_info *
101 find_last_fork (void)
103 if (fork_list.empty ())
104 return NULL;
106 return &fork_list.back ();
109 /* Return true iff there's one fork in the list. */
111 static bool
112 one_fork_p ()
114 return fork_list.size () == 1;
117 /* Add a new fork to the internal fork list. */
119 void
120 add_fork (pid_t pid)
122 fork_list.emplace_back (pid);
124 if (one_fork_p ())
125 highest_fork_num = 0;
127 fork_info *fp = &fork_list.back ();
128 fp->num = ++highest_fork_num;
131 static void
132 delete_fork (ptid_t ptid)
134 linux_target->low_forget_process (ptid.pid ());
136 for (auto it = fork_list.begin (); it != fork_list.end (); ++it)
137 if (it->ptid == ptid)
139 fork_list.erase (it);
141 /* Special case: if there is now only one process in the list,
142 and if it is (hopefully!) the current inferior_ptid, then
143 remove it, leaving the list empty -- we're now down to the
144 default case of debugging a single process. */
145 if (one_fork_p () && fork_list.front ().ptid == inferior_ptid)
147 /* Last fork -- delete from list and handle as solo
148 process (should be a safe recursion). */
149 delete_fork (inferior_ptid);
151 return;
155 /* Find a fork_info by matching PTID. */
156 static struct fork_info *
157 find_fork_ptid (ptid_t ptid)
159 for (fork_info &fi : fork_list)
160 if (fi.ptid == ptid)
161 return &fi;
163 return NULL;
166 /* Find a fork_info by matching ID. */
167 static struct fork_info *
168 find_fork_id (int num)
170 for (fork_info &fi : fork_list)
171 if (fi.num == num)
172 return &fi;
174 return NULL;
177 /* Find a fork_info by matching pid. */
178 extern struct fork_info *
179 find_fork_pid (pid_t pid)
181 for (fork_info &fi : fork_list)
182 if (pid == fi.ptid.pid ())
183 return &fi;
185 return NULL;
188 static ptid_t
189 fork_id_to_ptid (int num)
191 struct fork_info *fork = find_fork_id (num);
192 if (fork)
193 return fork->ptid;
194 else
195 return ptid_t (-1);
198 /* Fork list <-> gdb interface. */
200 /* Utility function for fork_load/fork_save.
201 Calls lseek in the (current) inferior process. */
203 static off_t
204 call_lseek (int fd, off_t offset, int whence)
206 char exp[80];
208 snprintf (&exp[0], sizeof (exp), "(long) lseek (%d, %ld, %d)",
209 fd, (long) offset, whence);
210 return (off_t) parse_and_eval_long (&exp[0]);
213 /* Load infrun state for the fork PTID. */
215 static void
216 fork_load_infrun_state (struct fork_info *fp)
218 int i;
220 linux_nat_switch_fork (fp->ptid);
222 if (fp->savedregs)
223 get_thread_regcache (inferior_thread ())->restore (fp->savedregs);
225 registers_changed ();
226 reinit_frame_cache ();
228 inferior_thread ()->set_stop_pc
229 (regcache_read_pc (get_thread_regcache (inferior_thread ())));
230 inferior_thread ()->set_executing (false);
231 inferior_thread ()->set_resumed (false);
232 nullify_last_target_wait_ptid ();
234 /* Now restore the file positions of open file descriptors. */
235 if (fp->filepos)
237 for (i = 0; i <= fp->maxfd; i++)
238 if (fp->filepos[i] != (off_t) -1)
239 call_lseek (i, fp->filepos[i], SEEK_SET);
240 /* NOTE: I can get away with using SEEK_SET and SEEK_CUR because
241 this is native-only. If it ever has to be cross, we'll have
242 to rethink this. */
246 /* Save infrun state for the fork FP. */
248 static void
249 fork_save_infrun_state (struct fork_info *fp)
251 char path[PATH_MAX];
252 struct dirent *de;
253 DIR *d;
255 if (fp->savedregs)
256 delete fp->savedregs;
258 fp->savedregs = new readonly_detached_regcache
259 (*get_thread_regcache (inferior_thread ()));
260 fp->pc = regcache_read_pc (get_thread_regcache (inferior_thread ()));
262 /* Now save the 'state' (file position) of all open file descriptors.
263 Unfortunately fork does not take care of that for us... */
264 snprintf (path, PATH_MAX, "/proc/%ld/fd", (long) fp->ptid.pid ());
265 if ((d = opendir (path)) != NULL)
267 long tmp;
269 fp->maxfd = 0;
270 while ((de = readdir (d)) != NULL)
272 /* Count open file descriptors (actually find highest
273 numbered). */
274 tmp = strtol (&de->d_name[0], NULL, 10);
275 if (fp->maxfd < tmp)
276 fp->maxfd = tmp;
278 /* Allocate array of file positions. */
279 fp->filepos = XRESIZEVEC (off_t, fp->filepos, fp->maxfd + 1);
281 /* Initialize to -1 (invalid). */
282 for (tmp = 0; tmp <= fp->maxfd; tmp++)
283 fp->filepos[tmp] = -1;
285 /* Now find actual file positions. */
286 rewinddir (d);
287 while ((de = readdir (d)) != NULL)
288 if (isdigit (de->d_name[0]))
290 tmp = strtol (&de->d_name[0], NULL, 10);
291 fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR);
293 closedir (d);
297 /* Kill 'em all, let God sort 'em out... */
299 void
300 linux_fork_killall (void)
302 /* Walk list and kill every pid. No need to treat the
303 current inferior_ptid as special (we do not return a
304 status for it) -- however any process may be a child
305 or a parent, so may get a SIGCHLD from a previously
306 killed child. Wait them all out. */
308 for (fork_info &fi : fork_list)
310 pid_t pid = fi.ptid.pid ();
311 int status;
312 pid_t ret;
313 do {
314 /* Use SIGKILL instead of PTRACE_KILL because the former works even
315 if the thread is running, while the later doesn't. */
316 kill (pid, SIGKILL);
317 ret = waitpid (pid, &status, 0);
318 /* We might get a SIGCHLD instead of an exit status. This is
319 aggravated by the first kill above - a child has just
320 died. MVS comment cut-and-pasted from linux-nat. */
321 } while (ret == pid && WIFSTOPPED (status));
324 /* Clear list, prepare to start fresh. */
325 fork_list.clear ();
328 /* The current inferior_ptid has exited, but there are other viable
329 forks to debug. Delete the exiting one and context-switch to the
330 first available. */
332 void
333 linux_fork_mourn_inferior (void)
335 struct fork_info *last;
336 int status;
338 /* Wait just one more time to collect the inferior's exit status.
339 Do not check whether this succeeds though, since we may be
340 dealing with a process that we attached to. Such a process will
341 only report its exit status to its original parent. */
342 waitpid (inferior_ptid.pid (), &status, 0);
344 /* OK, presumably inferior_ptid is the one who has exited.
345 We need to delete that one from the fork_list, and switch
346 to the next available fork. */
347 delete_fork (inferior_ptid);
349 /* There should still be a fork - if there's only one left,
350 delete_fork won't remove it, because we haven't updated
351 inferior_ptid yet. */
352 gdb_assert (!fork_list.empty ());
354 last = find_last_fork ();
355 fork_load_infrun_state (last);
356 gdb_printf (_("[Switching to %s]\n"),
357 target_pid_to_str (inferior_ptid).c_str ());
359 /* If there's only one fork, switch back to non-fork mode. */
360 if (one_fork_p ())
361 delete_fork (inferior_ptid);
364 /* The current inferior_ptid is being detached, but there are other
365 viable forks to debug. Detach and delete it and context-switch to
366 the first available. */
368 void
369 linux_fork_detach (int from_tty, lwp_info *lp)
371 gdb_assert (lp != nullptr);
372 gdb_assert (lp->ptid == inferior_ptid);
374 /* OK, inferior_ptid is the one we are detaching from. We need to
375 delete it from the fork_list, and switch to the next available
376 fork. But before doing the detach, do make sure that the lwp
377 hasn't exited or been terminated first. */
379 if (lp->waitstatus.kind () != TARGET_WAITKIND_EXITED
380 && lp->waitstatus.kind () != TARGET_WAITKIND_THREAD_EXITED
381 && lp->waitstatus.kind () != TARGET_WAITKIND_SIGNALLED)
383 if (ptrace (PTRACE_DETACH, inferior_ptid.pid (), 0, 0))
384 error (_("Unable to detach %s"),
385 target_pid_to_str (inferior_ptid).c_str ());
388 delete_fork (inferior_ptid);
390 /* There should still be a fork - if there's only one left,
391 delete_fork won't remove it, because we haven't updated
392 inferior_ptid yet. */
393 gdb_assert (!fork_list.empty ());
395 fork_load_infrun_state (&fork_list.front ());
397 if (from_tty)
398 gdb_printf (_("[Switching to %s]\n"),
399 target_pid_to_str (inferior_ptid).c_str ());
401 /* If there's only one fork, switch back to non-fork mode. */
402 if (one_fork_p ())
403 delete_fork (inferior_ptid);
406 /* Temporarily switch to the infrun state stored on the fork_info
407 identified by a given ptid_t. When this object goes out of scope,
408 restore the currently selected infrun state. */
410 class scoped_switch_fork_info
412 public:
413 /* Switch to the infrun state held on the fork_info identified by
414 PPTID. If PPTID is the current inferior then no switch is done. */
415 explicit scoped_switch_fork_info (ptid_t pptid)
416 : m_oldfp (nullptr)
418 if (pptid != inferior_ptid)
420 struct fork_info *newfp = nullptr;
422 /* Switch to pptid. */
423 m_oldfp = find_fork_ptid (inferior_ptid);
424 gdb_assert (m_oldfp != nullptr);
425 newfp = find_fork_ptid (pptid);
426 gdb_assert (newfp != nullptr);
427 fork_save_infrun_state (m_oldfp);
428 remove_breakpoints ();
429 fork_load_infrun_state (newfp);
430 insert_breakpoints ();
434 /* Restore the previously selected infrun state. If the constructor
435 didn't need to switch states, then nothing is done here either. */
436 ~scoped_switch_fork_info ()
438 if (m_oldfp != nullptr)
440 /* Switch back to inferior_ptid. */
443 remove_breakpoints ();
444 fork_load_infrun_state (m_oldfp);
445 insert_breakpoints ();
447 catch (const gdb_exception_quit &ex)
449 /* We can't throw from a destructor, so re-set the quit flag
450 for later QUIT checking. */
451 set_quit_flag ();
453 catch (const gdb_exception_forced_quit &ex)
455 /* Like above, but (eventually) cause GDB to terminate by
456 setting sync_quit_force_run. */
457 set_force_quit_flag ();
459 catch (const gdb_exception &ex)
461 warning (_("Couldn't restore checkpoint state in %s: %s"),
462 target_pid_to_str (m_oldfp->ptid).c_str (),
463 ex.what ());
468 DISABLE_COPY_AND_ASSIGN (scoped_switch_fork_info);
470 private:
471 /* The fork_info for the previously selected infrun state, or nullptr if
472 we were already in the desired state, and nothing needs to be
473 restored. */
474 struct fork_info *m_oldfp;
477 static int
478 inferior_call_waitpid (ptid_t pptid, int pid)
480 struct objfile *waitpid_objf;
481 struct value *waitpid_fn = NULL;
482 int ret = -1;
484 scoped_switch_fork_info switch_fork_info (pptid);
486 /* Get the waitpid_fn. */
487 if (lookup_minimal_symbol (current_program_space, "waitpid").minsym
488 != nullptr)
489 waitpid_fn = find_function_in_inferior ("waitpid", &waitpid_objf);
490 if (!waitpid_fn
491 && (lookup_minimal_symbol (current_program_space, "_waitpid").minsym
492 != nullptr))
493 waitpid_fn = find_function_in_inferior ("_waitpid", &waitpid_objf);
494 if (waitpid_fn != nullptr)
496 struct gdbarch *gdbarch = get_current_arch ();
497 struct value *argv[3], *retv;
499 /* Get the argv. */
500 argv[0] = value_from_longest (builtin_type (gdbarch)->builtin_int, pid);
501 argv[1] = value_from_pointer (builtin_type (gdbarch)->builtin_data_ptr, 0);
502 argv[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
504 retv = call_function_by_hand (waitpid_fn, NULL, argv);
506 if (value_as_long (retv) >= 0)
507 ret = 0;
510 return ret;
513 /* Fork list <-> user interface. */
515 static void
516 delete_checkpoint_command (const char *args, int from_tty)
518 ptid_t ptid, pptid;
519 struct fork_info *fi;
521 if (!args || !*args)
522 error (_("Requires argument (checkpoint id to delete)"));
524 ptid = fork_id_to_ptid (parse_and_eval_long (args));
525 if (ptid == minus_one_ptid)
526 error (_("No such checkpoint id, %s"), args);
528 if (ptid == inferior_ptid)
529 error (_("\
530 Please switch to another checkpoint before deleting the current one"));
532 if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0))
533 error (_("Unable to kill pid %s"), target_pid_to_str (ptid).c_str ());
535 fi = find_fork_ptid (ptid);
536 gdb_assert (fi);
537 pptid = fi->parent_ptid;
539 if (from_tty)
540 gdb_printf (_("Killed %s\n"), target_pid_to_str (ptid).c_str ());
542 delete_fork (ptid);
544 if (pptid == null_ptid)
546 int status;
547 /* Wait to collect the inferior's exit status. Do not check whether
548 this succeeds though, since we may be dealing with a process that we
549 attached to. Such a process will only report its exit status to its
550 original parent. */
551 waitpid (ptid.pid (), &status, 0);
552 return;
555 /* If fi->parent_ptid is not a part of lwp but it's a part of checkpoint
556 list, waitpid the ptid.
557 If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
558 ptid. */
559 thread_info *parent = linux_target->find_thread (pptid);
560 if ((parent == NULL && find_fork_ptid (pptid))
561 || (parent != NULL && parent->state == THREAD_STOPPED))
563 if (inferior_call_waitpid (pptid, ptid.pid ()))
564 warning (_("Unable to wait pid %s"),
565 target_pid_to_str (ptid).c_str ());
569 static void
570 detach_checkpoint_command (const char *args, int from_tty)
572 ptid_t ptid;
574 if (!args || !*args)
575 error (_("Requires argument (checkpoint id to detach)"));
577 ptid = fork_id_to_ptid (parse_and_eval_long (args));
578 if (ptid == minus_one_ptid)
579 error (_("No such checkpoint id, %s"), args);
581 if (ptid == inferior_ptid)
582 error (_("\
583 Please switch to another checkpoint before detaching the current one"));
585 if (ptrace (PTRACE_DETACH, ptid.pid (), 0, 0))
586 error (_("Unable to detach %s"), target_pid_to_str (ptid).c_str ());
588 if (from_tty)
589 gdb_printf (_("Detached %s\n"), target_pid_to_str (ptid).c_str ());
591 delete_fork (ptid);
594 /* Print information about currently known checkpoints. */
596 static void
597 info_checkpoints_command (const char *arg, int from_tty)
599 struct gdbarch *gdbarch = get_current_arch ();
600 int requested = -1;
601 bool printed = false;
603 if (arg && *arg)
604 requested = (int) parse_and_eval_long (arg);
606 for (const fork_info &fi : fork_list)
608 if (requested > 0 && fi.num != requested)
609 continue;
610 printed = true;
612 bool is_current = fi.ptid == inferior_ptid;
613 if (is_current)
614 gdb_printf ("* ");
615 else
616 gdb_printf (" ");
618 gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
619 if (fi.num == 0)
620 gdb_printf (_(" (main process)"));
622 if (is_current && inferior_thread ()->state == THREAD_RUNNING)
624 gdb_printf (_(" <running>\n"));
625 continue;
628 gdb_printf (_(" at "));
629 ULONGEST pc
630 = (is_current
631 ? regcache_read_pc (get_thread_regcache (inferior_thread ()))
632 : fi.pc);
633 gdb_puts (paddress (gdbarch, pc));
635 symtab_and_line sal = find_pc_line (pc, 0);
636 if (sal.symtab)
637 gdb_printf (_(", file %s"),
638 symtab_to_filename_for_display (sal.symtab));
639 if (sal.line)
640 gdb_printf (_(", line %d"), sal.line);
641 if (!sal.symtab && !sal.line)
643 bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (pc);
644 if (msym.minsym)
645 gdb_printf (", <%s>", msym.minsym->linkage_name ());
648 gdb_putc ('\n');
651 if (!printed)
653 if (requested > 0)
654 gdb_printf (_("No checkpoint number %d.\n"), requested);
655 else
656 gdb_printf (_("No checkpoints.\n"));
660 /* The PID of the process we're checkpointing. */
661 static int checkpointing_pid = 0;
664 linux_fork_checkpointing_p (int pid)
666 return (checkpointing_pid == pid);
669 /* Return true if the current inferior is multi-threaded. */
671 static bool
672 inf_has_multiple_threads ()
674 int count = 0;
676 /* Return true as soon as we see the second thread of the current
677 inferior. */
678 for (thread_info *tp ATTRIBUTE_UNUSED : current_inferior ()->threads ())
679 if (++count > 1)
680 return true;
682 return false;
685 static void
686 checkpoint_command (const char *args, int from_tty)
688 struct objfile *fork_objf;
689 struct gdbarch *gdbarch;
690 struct target_waitstatus last_target_waitstatus;
691 ptid_t last_target_ptid;
692 struct value *fork_fn = NULL, *ret;
693 struct fork_info *fp;
694 pid_t retpid;
696 if (!target_has_execution ())
697 error (_("The program is not being run."));
699 /* Ensure that the inferior is not multithreaded. */
700 update_thread_list ();
701 if (inf_has_multiple_threads ())
702 error (_("checkpoint: can't checkpoint multiple threads."));
704 /* Make the inferior fork, record its (and gdb's) state. */
706 if (lookup_minimal_symbol (current_program_space, "fork").minsym != nullptr)
707 fork_fn = find_function_in_inferior ("fork", &fork_objf);
708 if (!fork_fn)
709 if (lookup_minimal_symbol (current_program_space, "_fork").minsym
710 != nullptr)
711 fork_fn = find_function_in_inferior ("fork", &fork_objf);
712 if (!fork_fn)
713 error (_("checkpoint: can't find fork function in inferior."));
715 gdbarch = fork_objf->arch ();
716 ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
718 /* Tell linux-nat.c that we're checkpointing this inferior. */
720 scoped_restore save_pid
721 = make_scoped_restore (&checkpointing_pid, inferior_ptid.pid ());
723 ret = call_function_by_hand (fork_fn, NULL, {});
726 if (!ret) /* Probably can't happen. */
727 error (_("checkpoint: call_function_by_hand returned null."));
729 retpid = value_as_long (ret);
730 get_last_target_status (nullptr, &last_target_ptid, &last_target_waitstatus);
732 fp = find_fork_pid (retpid);
734 if (from_tty)
736 int parent_pid;
738 gdb_printf (_("checkpoint %d: fork returned pid %ld.\n"),
739 fp != NULL ? fp->num : -1, (long) retpid);
740 if (info_verbose)
742 parent_pid = last_target_ptid.lwp ();
743 if (parent_pid == 0)
744 parent_pid = last_target_ptid.pid ();
745 gdb_printf (_(" gdb says parent = %ld.\n"),
746 (long) parent_pid);
750 if (!fp)
751 error (_("Failed to find new fork"));
753 if (one_fork_p ())
755 /* Special case -- if this is the first fork in the list (the
756 list was hitherto empty), then add inferior_ptid first, as a
757 special zeroeth fork id. */
758 fork_list.emplace_front (inferior_ptid.pid ());
761 fork_save_infrun_state (fp);
762 fp->parent_ptid = last_target_ptid;
765 static void
766 linux_fork_context (struct fork_info *newfp, int from_tty)
768 /* Now we attempt to switch processes. */
769 struct fork_info *oldfp;
771 gdb_assert (newfp != NULL);
773 oldfp = find_fork_ptid (inferior_ptid);
774 gdb_assert (oldfp != NULL);
776 fork_save_infrun_state (oldfp);
777 remove_breakpoints ();
778 fork_load_infrun_state (newfp);
779 insert_breakpoints ();
781 gdb_printf (_("Switching to %s\n"),
782 target_pid_to_str (inferior_ptid).c_str ());
784 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
787 /* Switch inferior process (checkpoint) context, by checkpoint id. */
788 static void
789 restart_command (const char *args, int from_tty)
791 struct fork_info *fp;
793 if (!args || !*args)
794 error (_("Requires argument (checkpoint id to restart)"));
796 if ((fp = find_fork_id (parse_and_eval_long (args))) == NULL)
797 error (_("Not found: checkpoint id %s"), args);
799 linux_fork_context (fp, from_tty);
802 void _initialize_linux_fork ();
803 void
804 _initialize_linux_fork ()
806 /* Checkpoint command: create a fork of the inferior process
807 and set it aside for later debugging. */
809 add_com ("checkpoint", class_obscure, checkpoint_command, _("\
810 Fork a duplicate process (experimental)."));
812 /* Restart command: restore the context of a specified checkpoint
813 process. */
815 add_com ("restart", class_obscure, restart_command, _("\
816 Restore program context from a checkpoint.\n\
817 Usage: restart N\n\
818 Argument N is checkpoint ID, as displayed by 'info checkpoints'."));
820 /* Delete checkpoint command: kill the process and remove it from
821 the fork list. */
823 add_cmd ("checkpoint", class_obscure, delete_checkpoint_command, _("\
824 Delete a checkpoint (experimental)."),
825 &deletelist);
827 /* Detach checkpoint command: release the process to run independently,
828 and remove it from the fork list. */
830 add_cmd ("checkpoint", class_obscure, detach_checkpoint_command, _("\
831 Detach from a checkpoint (experimental)."),
832 &detachlist);
834 /* Info checkpoints command: list all forks/checkpoints
835 currently under gdb's control. */
837 add_info ("checkpoints", info_checkpoints_command,
838 _("IDs of currently known checkpoints."));