GDB (xrefs)
Loading...
Searching...
No Matches
linux-fork.c
Go to the documentation of this file.
1/* GNU/Linux native-dependent code for debugging multiple forks.
2
3 Copyright (C) 2005-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "arch-utils.h"
22#include "inferior.h"
23#include "infrun.h"
24#include "regcache.h"
25#include "gdbcmd.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"
32
33#include "nat/gdb_ptrace.h"
34#include "gdbsupport/gdb_wait.h"
35#include <dirent.h>
36#include <ctype.h>
37
38#include <list>
39
40/* Fork list data structure: */
42{
43 explicit fork_info (pid_t pid)
44 : ptid (pid, pid)
45 {
46 }
47
49 {
50 /* Notes on step-resume breakpoints: since this is a concern for
51 threads, let's convince ourselves that it's not a concern for
52 forks. There are two ways for a fork_info to be created.
53 First, by the checkpoint command, in which case we're at a gdb
54 prompt and there can't be any step-resume breakpoint. Second,
55 by a fork in the user program, in which case we *may* have
56 stepped into the fork call, but regardless of whether we follow
57 the parent or the child, we will return to the same place and
58 the step-resume breakpoint, if any, will take care of itself as
59 usual. And unlike threads, we do not save a private copy of
60 the step-resume breakpoint -- so we're OK. */
61
62 if (savedregs)
63 delete savedregs;
64
65 xfree (filepos);
66 }
67
68 ptid_t ptid = null_ptid;
69 ptid_t parent_ptid = null_ptid;
70
71 /* Convenient handle (GDB fork id). */
72 int num = 0;
73
74 /* Convenient for info fork, saves having to actually switch
75 contexts. */
77
78 CORE_ADDR pc = 0;
79
80 /* Set of open file descriptors' offsets. */
81 off_t *filepos = nullptr;
82
83 int maxfd = 0;
84};
85
86static std::list<fork_info> fork_list;
88
89/* Fork list methods: */
90
91int
93{
94 return !fork_list.empty ();
95}
96
97/* Return the last fork in the list. */
98
99static struct fork_info *
101{
102 if (fork_list.empty ())
103 return NULL;
104
105 return &fork_list.back ();
106}
107
108/* Return true iff there's one fork in the list. */
109
110static bool
112{
113 return fork_list.size () == 1;
114}
115
116/* Add a new fork to the internal fork list. */
117
118void
120{
121 fork_list.emplace_back (pid);
122
123 if (one_fork_p ())
125
126 fork_info *fp = &fork_list.back ();
127 fp->num = ++highest_fork_num;
128}
129
130static void
132{
134
135 for (auto it = fork_list.begin (); it != fork_list.end (); ++it)
136 if (it->ptid == ptid)
137 {
138 fork_list.erase (it);
139
140 /* Special case: if there is now only one process in the list,
141 and if it is (hopefully!) the current inferior_ptid, then
142 remove it, leaving the list empty -- we're now down to the
143 default case of debugging a single process. */
144 if (one_fork_p () && fork_list.front ().ptid == inferior_ptid)
145 {
146 /* Last fork -- delete from list and handle as solo
147 process (should be a safe recursion). */
149 }
150 return;
151 }
152}
153
154/* Find a fork_info by matching PTID. */
155static struct fork_info *
157{
158 for (fork_info &fi : fork_list)
159 if (fi.ptid == ptid)
160 return &fi;
161
162 return NULL;
163}
164
165/* Find a fork_info by matching ID. */
166static struct fork_info *
168{
169 for (fork_info &fi : fork_list)
170 if (fi.num == num)
171 return &fi;
172
173 return NULL;
174}
175
176/* Find a fork_info by matching pid. */
177extern struct fork_info *
179{
180 for (fork_info &fi : fork_list)
181 if (pid == fi.ptid.pid ())
182 return &fi;
183
184 return NULL;
185}
186
187static ptid_t
189{
190 struct fork_info *fork = find_fork_id (num);
191 if (fork)
192 return fork->ptid;
193 else
194 return ptid_t (-1);
195}
196
197/* Fork list <-> gdb interface. */
198
199/* Utility function for fork_load/fork_save.
200 Calls lseek in the (current) inferior process. */
201
202static off_t
203call_lseek (int fd, off_t offset, int whence)
204{
205 char exp[80];
206
207 snprintf (&exp[0], sizeof (exp), "(long) lseek (%d, %ld, %d)",
208 fd, (long) offset, whence);
209 return (off_t) parse_and_eval_long (&exp[0]);
210}
211
212/* Load infrun state for the fork PTID. */
213
214static void
216{
217 int i;
218
220
221 if (fp->savedregs)
223
226
229
230 /* Now restore the file positions of open file descriptors. */
231 if (fp->filepos)
232 {
233 for (i = 0; i <= fp->maxfd; i++)
234 if (fp->filepos[i] != (off_t) -1)
235 call_lseek (i, fp->filepos[i], SEEK_SET);
236 /* NOTE: I can get away with using SEEK_SET and SEEK_CUR because
237 this is native-only. If it ever has to be cross, we'll have
238 to rethink this. */
239 }
240}
241
242/* Save infrun state for the fork FP. */
243
244static void
246{
247 char path[PATH_MAX];
248 struct dirent *de;
249 DIR *d;
250
251 if (fp->savedregs)
252 delete fp->savedregs;
253
256
257 /* Now save the 'state' (file position) of all open file descriptors.
258 Unfortunately fork does not take care of that for us... */
259 snprintf (path, PATH_MAX, "/proc/%ld/fd", (long) fp->ptid.pid ());
260 if ((d = opendir (path)) != NULL)
261 {
262 long tmp;
263
264 fp->maxfd = 0;
265 while ((de = readdir (d)) != NULL)
266 {
267 /* Count open file descriptors (actually find highest
268 numbered). */
269 tmp = strtol (&de->d_name[0], NULL, 10);
270 if (fp->maxfd < tmp)
271 fp->maxfd = tmp;
272 }
273 /* Allocate array of file positions. */
274 fp->filepos = XRESIZEVEC (off_t, fp->filepos, fp->maxfd + 1);
275
276 /* Initialize to -1 (invalid). */
277 for (tmp = 0; tmp <= fp->maxfd; tmp++)
278 fp->filepos[tmp] = -1;
279
280 /* Now find actual file positions. */
281 rewinddir (d);
282 while ((de = readdir (d)) != NULL)
283 if (isdigit (de->d_name[0]))
284 {
285 tmp = strtol (&de->d_name[0], NULL, 10);
286 fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR);
287 }
288 closedir (d);
289 }
290}
291
292/* Kill 'em all, let God sort 'em out... */
293
294void
296{
297 /* Walk list and kill every pid. No need to treat the
298 current inferior_ptid as special (we do not return a
299 status for it) -- however any process may be a child
300 or a parent, so may get a SIGCHLD from a previously
301 killed child. Wait them all out. */
302
303 for (fork_info &fi : fork_list)
304 {
305 pid_t pid = fi.ptid.pid ();
306 int status;
307 pid_t ret;
308 do {
309 /* Use SIGKILL instead of PTRACE_KILL because the former works even
310 if the thread is running, while the later doesn't. */
311 kill (pid, SIGKILL);
312 ret = waitpid (pid, &status, 0);
313 /* We might get a SIGCHLD instead of an exit status. This is
314 aggravated by the first kill above - a child has just
315 died. MVS comment cut-and-pasted from linux-nat. */
316 } while (ret == pid && WIFSTOPPED (status));
317 }
318
319 /* Clear list, prepare to start fresh. */
320 fork_list.clear ();
321}
322
323/* The current inferior_ptid has exited, but there are other viable
324 forks to debug. Delete the exiting one and context-switch to the
325 first available. */
326
327void
329{
330 struct fork_info *last;
331 int status;
332
333 /* Wait just one more time to collect the inferior's exit status.
334 Do not check whether this succeeds though, since we may be
335 dealing with a process that we attached to. Such a process will
336 only report its exit status to its original parent. */
337 waitpid (inferior_ptid.pid (), &status, 0);
338
339 /* OK, presumably inferior_ptid is the one who has exited.
340 We need to delete that one from the fork_list, and switch
341 to the next available fork. */
343
344 /* There should still be a fork - if there's only one left,
345 delete_fork won't remove it, because we haven't updated
346 inferior_ptid yet. */
347 gdb_assert (!fork_list.empty ());
348
349 last = find_last_fork ();
351 gdb_printf (_("[Switching to %s]\n"),
353
354 /* If there's only one fork, switch back to non-fork mode. */
355 if (one_fork_p ())
357}
358
359/* The current inferior_ptid is being detached, but there are other
360 viable forks to debug. Detach and delete it and context-switch to
361 the first available. */
362
363void
364linux_fork_detach (int from_tty)
365{
366 /* OK, inferior_ptid is the one we are detaching from. We need to
367 delete it from the fork_list, and switch to the next available
368 fork. */
369
370 if (ptrace (PTRACE_DETACH, inferior_ptid.pid (), 0, 0))
371 error (_("Unable to detach %s"),
373
375
376 /* There should still be a fork - if there's only one left,
377 delete_fork won't remove it, because we haven't updated
378 inferior_ptid yet. */
379 gdb_assert (!fork_list.empty ());
380
382
383 if (from_tty)
384 gdb_printf (_("[Switching to %s]\n"),
386
387 /* If there's only one fork, switch back to non-fork mode. */
388 if (one_fork_p ())
390}
391
392/* Temporarily switch to the infrun state stored on the fork_info
393 identified by a given ptid_t. When this object goes out of scope,
394 restore the currently selected infrun state. */
395
397{
398public:
399 /* Switch to the infrun state held on the fork_info identified by
400 PPTID. If PPTID is the current inferior then no switch is done. */
401 explicit scoped_switch_fork_info (ptid_t pptid)
402 : m_oldfp (nullptr)
403 {
404 if (pptid != inferior_ptid)
405 {
406 struct fork_info *newfp = nullptr;
407
408 /* Switch to pptid. */
410 gdb_assert (m_oldfp != nullptr);
411 newfp = find_fork_ptid (pptid);
412 gdb_assert (newfp != nullptr);
417 }
418 }
419
420 /* Restore the previously selected infrun state. If the constructor
421 didn't need to switch states, then nothing is done here either. */
423 {
424 if (m_oldfp != nullptr)
425 {
426 /* Switch back to inferior_ptid. */
427 try
428 {
432 }
433 catch (const gdb_exception &ex)
434 {
435 warning (_("Couldn't restore checkpoint state in %s: %s"),
436 target_pid_to_str (m_oldfp->ptid).c_str (),
437 ex.what ());
438 }
439 }
440 }
441
443
444private:
445 /* The fork_info for the previously selected infrun state, or nullptr if
446 we were already in the desired state, and nothing needs to be
447 restored. */
449};
450
451static int
452inferior_call_waitpid (ptid_t pptid, int pid)
453{
454 struct objfile *waitpid_objf;
455 struct value *waitpid_fn = NULL;
456 int ret = -1;
457
458 scoped_switch_fork_info switch_fork_info (pptid);
459
460 /* Get the waitpid_fn. */
461 if (lookup_minimal_symbol ("waitpid", NULL, NULL).minsym != NULL)
462 waitpid_fn = find_function_in_inferior ("waitpid", &waitpid_objf);
463 if (!waitpid_fn
464 && lookup_minimal_symbol ("_waitpid", NULL, NULL).minsym != NULL)
465 waitpid_fn = find_function_in_inferior ("_waitpid", &waitpid_objf);
466 if (waitpid_fn != nullptr)
467 {
468 struct gdbarch *gdbarch = get_current_arch ();
469 struct value *argv[3], *retv;
470
471 /* Get the argv. */
472 argv[0] = value_from_longest (builtin_type (gdbarch)->builtin_int, pid);
473 argv[1] = value_from_pointer (builtin_type (gdbarch)->builtin_data_ptr, 0);
474 argv[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
475
476 retv = call_function_by_hand (waitpid_fn, NULL, argv);
477
478 if (value_as_long (retv) >= 0)
479 ret = 0;
480 }
481
482 return ret;
483}
484
485/* Fork list <-> user interface. */
486
487static void
488delete_checkpoint_command (const char *args, int from_tty)
489{
490 ptid_t ptid, pptid;
491 struct fork_info *fi;
492
493 if (!args || !*args)
494 error (_("Requires argument (checkpoint id to delete)"));
495
497 if (ptid == minus_one_ptid)
498 error (_("No such checkpoint id, %s"), args);
499
500 if (ptid == inferior_ptid)
501 error (_("\
502Please switch to another checkpoint before deleting the current one"));
503
504 if (ptrace (PTRACE_KILL, ptid.pid (), 0, 0))
505 error (_("Unable to kill pid %s"), target_pid_to_str (ptid).c_str ());
506
507 fi = find_fork_ptid (ptid);
508 gdb_assert (fi);
509 pptid = fi->parent_ptid;
510
511 if (from_tty)
512 gdb_printf (_("Killed %s\n"), target_pid_to_str (ptid).c_str ());
513
515
516 /* If fi->parent_ptid is not a part of lwp but it's a part of checkpoint
517 list, waitpid the ptid.
518 If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
519 ptid. */
520 thread_info *parent = find_thread_ptid (linux_target, pptid);
521 if ((parent == NULL && find_fork_ptid (pptid))
522 || (parent != NULL && parent->state == THREAD_STOPPED))
523 {
524 if (inferior_call_waitpid (pptid, ptid.pid ()))
525 warning (_("Unable to wait pid %s"),
526 target_pid_to_str (ptid).c_str ());
527 }
528}
529
530static void
531detach_checkpoint_command (const char *args, int from_tty)
532{
533 ptid_t ptid;
534
535 if (!args || !*args)
536 error (_("Requires argument (checkpoint id to detach)"));
537
539 if (ptid == minus_one_ptid)
540 error (_("No such checkpoint id, %s"), args);
541
542 if (ptid == inferior_ptid)
543 error (_("\
544Please switch to another checkpoint before detaching the current one"));
545
546 if (ptrace (PTRACE_DETACH, ptid.pid (), 0, 0))
547 error (_("Unable to detach %s"), target_pid_to_str (ptid).c_str ());
548
549 if (from_tty)
550 gdb_printf (_("Detached %s\n"), target_pid_to_str (ptid).c_str ());
551
553}
554
555/* Print information about currently known checkpoints. */
556
557static void
558info_checkpoints_command (const char *arg, int from_tty)
559{
560 struct gdbarch *gdbarch = get_current_arch ();
561 int requested = -1;
562 const fork_info *printed = NULL;
563
564 if (arg && *arg)
565 requested = (int) parse_and_eval_long (arg);
566
567 for (const fork_info &fi : fork_list)
568 {
569 if (requested > 0 && fi.num != requested)
570 continue;
571
572 printed = &fi;
573 if (fi.ptid == inferior_ptid)
574 gdb_printf ("* ");
575 else
576 gdb_printf (" ");
577
578 ULONGEST pc = fi.pc;
579 gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
580 if (fi.num == 0)
581 gdb_printf (_(" (main process)"));
582 gdb_printf (_(" at "));
583 gdb_puts (paddress (gdbarch, pc));
584
585 symtab_and_line sal = find_pc_line (pc, 0);
586 if (sal.symtab)
587 gdb_printf (_(", file %s"),
589 if (sal.line)
590 gdb_printf (_(", line %d"), sal.line);
591 if (!sal.symtab && !sal.line)
592 {
593 struct bound_minimal_symbol msym;
594
595 msym = lookup_minimal_symbol_by_pc (pc);
596 if (msym.minsym)
597 gdb_printf (", <%s>", msym.minsym->linkage_name ());
598 }
599
600 gdb_putc ('\n');
601 }
602 if (printed == NULL)
603 {
604 if (requested > 0)
605 gdb_printf (_("No checkpoint number %d.\n"), requested);
606 else
607 gdb_printf (_("No checkpoints.\n"));
608 }
609}
610
611/* The PID of the process we're checkpointing. */
612static int checkpointing_pid = 0;
613
614int
616{
617 return (checkpointing_pid == pid);
618}
619
620/* Return true if the current inferior is multi-threaded. */
621
622static bool
624{
625 int count = 0;
626
627 /* Return true as soon as we see the second thread of the current
628 inferior. */
629 for (thread_info *tp ATTRIBUTE_UNUSED : current_inferior ()->threads ())
630 if (++count > 1)
631 return true;
632
633 return false;
634}
635
636static void
637checkpoint_command (const char *args, int from_tty)
638{
639 struct objfile *fork_objf;
640 struct gdbarch *gdbarch;
641 struct target_waitstatus last_target_waitstatus;
642 ptid_t last_target_ptid;
643 struct value *fork_fn = NULL, *ret;
644 struct fork_info *fp;
645 pid_t retpid;
646
647 if (!target_has_execution ())
648 error (_("The program is not being run."));
649
650 /* Ensure that the inferior is not multithreaded. */
653 error (_("checkpoint: can't checkpoint multiple threads."));
654
655 /* Make the inferior fork, record its (and gdb's) state. */
656
657 if (lookup_minimal_symbol ("fork", NULL, NULL).minsym != NULL)
658 fork_fn = find_function_in_inferior ("fork", &fork_objf);
659 if (!fork_fn)
660 if (lookup_minimal_symbol ("_fork", NULL, NULL).minsym != NULL)
661 fork_fn = find_function_in_inferior ("fork", &fork_objf);
662 if (!fork_fn)
663 error (_("checkpoint: can't find fork function in inferior."));
664
665 gdbarch = fork_objf->arch ();
666 ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
667
668 /* Tell linux-nat.c that we're checkpointing this inferior. */
669 {
670 scoped_restore save_pid
671 = make_scoped_restore (&checkpointing_pid, inferior_ptid.pid ());
672
673 ret = call_function_by_hand (fork_fn, NULL, {});
674 }
675
676 if (!ret) /* Probably can't happen. */
677 error (_("checkpoint: call_function_by_hand returned null."));
678
679 retpid = value_as_long (ret);
680 get_last_target_status (nullptr, &last_target_ptid, &last_target_waitstatus);
681
682 fp = find_fork_pid (retpid);
683
684 if (from_tty)
685 {
686 int parent_pid;
687
688 gdb_printf (_("checkpoint %d: fork returned pid %ld.\n"),
689 fp != NULL ? fp->num : -1, (long) retpid);
690 if (info_verbose)
691 {
692 parent_pid = last_target_ptid.lwp ();
693 if (parent_pid == 0)
694 parent_pid = last_target_ptid.pid ();
695 gdb_printf (_(" gdb says parent = %ld.\n"),
696 (long) parent_pid);
697 }
698 }
699
700 if (!fp)
701 error (_("Failed to find new fork"));
702
703 if (one_fork_p ())
704 {
705 /* Special case -- if this is the first fork in the list (the
706 list was hitherto empty), then add inferior_ptid first, as a
707 special zeroeth fork id. */
708 fork_list.emplace_front (inferior_ptid.pid ());
709 }
710
712 fp->parent_ptid = last_target_ptid;
713}
714
715static void
716linux_fork_context (struct fork_info *newfp, int from_tty)
717{
718 /* Now we attempt to switch processes. */
719 struct fork_info *oldfp;
720
721 gdb_assert (newfp != NULL);
722
724 gdb_assert (oldfp != NULL);
725
730
731 gdb_printf (_("Switching to %s\n"),
733
735}
736
737/* Switch inferior process (checkpoint) context, by checkpoint id. */
738static void
739restart_command (const char *args, int from_tty)
740{
741 struct fork_info *fp;
742
743 if (!args || !*args)
744 error (_("Requires argument (checkpoint id to restart)"));
745
746 if ((fp = find_fork_id (parse_and_eval_long (args))) == NULL)
747 error (_("Not found: checkpoint id %s"), args);
748
749 linux_fork_context (fp, from_tty);
750}
751
753void
755{
756 /* Checkpoint command: create a fork of the inferior process
757 and set it aside for later debugging. */
758
759 add_com ("checkpoint", class_obscure, checkpoint_command, _("\
760Fork a duplicate process (experimental)."));
761
762 /* Restart command: restore the context of a specified checkpoint
763 process. */
764
765 add_com ("restart", class_obscure, restart_command, _("\
766Restore program context from a checkpoint.\n\
767Usage: restart N\n\
768Argument N is checkpoint ID, as displayed by 'info checkpoints'."));
769
770 /* Delete checkpoint command: kill the process and remove it from
771 the fork list. */
772
774Delete a checkpoint (experimental)."),
775 &deletelist);
776
777 /* Detach checkpoint command: release the process to run independently,
778 and remove it from the fork list. */
779
781Detach from a checkpoint (experimental)."),
782 &detachlist);
783
784 /* Info checkpoints command: list all forks/checkpoints
785 currently under gdb's control. */
786
787 add_info ("checkpoints", info_checkpoints_command,
788 _("IDs of currently known checkpoints."));
789}
void xfree(void *)
struct gdbarch * get_current_arch(void)
Definition arch-utils.c:846
int remove_breakpoints(void)
void insert_breakpoints(void)
inf_threads_range threads()
Definition inferior.h:442
virtual void low_forget_process(pid_t pid)
Definition linux-nat.h:167
void restore(readonly_detached_regcache *src)
Definition regcache.c:276
scoped_switch_fork_info(ptid_t pptid)
Definition linux-fork.c:401
DISABLE_COPY_AND_ASSIGN(scoped_switch_fork_info)
struct fork_info * m_oldfp
Definition linux-fork.c:448
enum thread_state state
Definition gdbthread.h:336
void set_stop_pc(CORE_ADDR stop_pc)
Definition gdbthread.h:369
struct cmd_list_element * deletelist
Definition cli-cmds.c:105
struct cmd_list_element * detachlist
Definition cli-cmds.c:109
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
@ class_obscure
Definition command.h:64
#define SEEK_SET
Definition defs.h:103
bool info_verbose
Definition top.c:2022
#define SEEK_CUR
Definition defs.h:106
LONGEST parse_and_eval_long(const char *exp)
Definition eval.c:62
void reinit_frame_cache(void)
Definition frame.c:2006
frame_info_ptr get_selected_frame(const char *message)
Definition frame.c:1813
@ SRC_AND_LOC
Definition frame.h:594
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
Definition stack.c:356
#define ptrace(request, pid, addr, data)
Definition gdb_ptrace.h:141
thread_info * find_thread_ptid(inferior *inf, ptid_t ptid)
Definition thread.c:528
@ THREAD_STOPPED
Definition gdbthread.h:72
void update_thread_list(void)
Definition thread.c:2037
struct thread_info * inferior_thread(void)
Definition thread.c:83
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition gnu-nat.c:1792
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition gnu-nat.c:1791
struct value * call_function_by_hand(struct value *function, type *default_return_type, gdb::array_view< value * > args)
Definition infcall.c:781
ptid_t inferior_ptid
Definition infcmd.c:91
struct inferior * current_inferior(void)
Definition inferior.c:54
void nullify_last_target_wait_ptid(void)
Definition infrun.c:4359
void get_last_target_status(process_stratum_target **target, ptid_t *ptid, target_waitstatus *status)
Definition infrun.c:4345
static off_t call_lseek(int fd, off_t offset, int whence)
Definition linux-fork.c:203
int linux_fork_checkpointing_p(int pid)
Definition linux-fork.c:615
static bool inf_has_multiple_threads()
Definition linux-fork.c:623
void linux_fork_killall(void)
Definition linux-fork.c:295
static int highest_fork_num
Definition linux-fork.c:87
static void info_checkpoints_command(const char *arg, int from_tty)
Definition linux-fork.c:558
static struct fork_info * find_fork_id(int num)
Definition linux-fork.c:167
static void delete_checkpoint_command(const char *args, int from_tty)
Definition linux-fork.c:488
static ptid_t fork_id_to_ptid(int num)
Definition linux-fork.c:188
void add_fork(pid_t pid)
Definition linux-fork.c:119
static std::list< fork_info > fork_list
Definition linux-fork.c:86
static void fork_load_infrun_state(struct fork_info *fp)
Definition linux-fork.c:215
static void delete_fork(ptid_t ptid)
Definition linux-fork.c:131
static int checkpointing_pid
Definition linux-fork.c:612
static int inferior_call_waitpid(ptid_t pptid, int pid)
Definition linux-fork.c:452
static void checkpoint_command(const char *args, int from_tty)
Definition linux-fork.c:637
void _initialize_linux_fork()
Definition linux-fork.c:754
static void restart_command(const char *args, int from_tty)
Definition linux-fork.c:739
static bool one_fork_p()
Definition linux-fork.c:111
static void detach_checkpoint_command(const char *args, int from_tty)
Definition linux-fork.c:531
void linux_fork_mourn_inferior(void)
Definition linux-fork.c:328
int forks_exist_p(void)
Definition linux-fork.c:92
static struct fork_info * find_last_fork(void)
Definition linux-fork.c:100
struct fork_info * find_fork_pid(pid_t pid)
Definition linux-fork.c:178
static void linux_fork_context(struct fork_info *newfp, int from_tty)
Definition linux-fork.c:716
void linux_fork_detach(int from_tty)
Definition linux-fork.c:364
static struct fork_info * find_fork_ptid(ptid_t ptid)
Definition linux-fork.c:156
static void fork_save_infrun_state(struct fork_info *fp)
Definition linux-fork.c:245
struct linux_nat_target * linux_target
Definition linux-nat.c:190
void linux_nat_switch_fork(ptid_t new_ptid)
Definition linux-nat.c:869
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition minsyms.c:363
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition minsyms.c:977
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition regcache.c:1324
struct regcache * get_current_regcache(void)
Definition regcache.c:426
void registers_changed(void)
Definition regcache.c:577
const char * symtab_to_filename_for_display(struct symtab *symtab)
Definition source.c:1287
struct minimal_symbol * minsym
Definition minsyms.h:49
CORE_ADDR pc
Definition linux-fork.c:78
readonly_detached_regcache * savedregs
Definition linux-fork.c:76
off_t * filepos
Definition linux-fork.c:81
ptid_t parent_ptid
Definition linux-fork.c:69
ptid_t ptid
Definition linux-fork.c:68
fork_info(pid_t pid)
Definition linux-fork.c:43
const char * linkage_name() const
Definition symtab.h:459
struct gdbarch * arch() const
Definition objfiles.h:482
struct symtab * symtab
Definition symtab.h:2263
Definition value.c:181
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition symtab.c:3297
bool target_has_execution(inferior *inf)
Definition target.c:202
std::string target_pid_to_str(ptid_t ptid)
Definition target.c:2602
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition utils.c:3114
void gdb_putc(int c)
Definition utils.c:1841
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1865
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1788
struct value * find_function_in_inferior(const char *name, struct objfile **objf_p)
Definition valops.c:117
struct value * value_from_longest(struct type *type, LONGEST num)
Definition value.c:3625
LONGEST value_as_long(struct value *val)
Definition value.c:2791
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
Definition value.c:3651