GDB (xrefs)

Classes | Functions | Variables
/tmp/gdb-8.1/gdb/linux-fork.c File Reference
`#include "defs.h"`
`#include "arch-utils.h"`
`#include "inferior.h"`
`#include "infrun.h"`
`#include "regcache.h"`
`#include "gdbcmd.h"`
`#include "infcall.h"`
`#include "objfiles.h"`
`#include "linux-fork.h"`
`#include "linux-nat.h"`
`#include "gdbthread.h"`
`#include "source.h"`
`#include "nat/gdb_ptrace.h"`
`#include "gdb_wait.h"`
`#include <dirent.h>`
`#include <ctype.h>`

Go to the source code of this file.

## Classes
struct | fork_info

## Functions
int | forks_exist_p (void)
static struct fork_info * | find_last_fork (void)
struct fork_info * | add_fork (pid_t pid)
static void | free_fork (struct fork_info *fp)
static void | delete_fork (ptid_t ptid)
static struct fork_info * | find_fork_ptid (ptid_t ptid)
static struct fork_info * | find_fork_id (int num)
struct fork_info * | find_fork_pid (pid_t pid)
static ptid_t | fork_id_to_ptid (int num)
static void | init_fork_list (void)
static off_t | call_lseek (int fd, off_t offset, int whence)
static void | fork_load_infrun_state (struct fork_info *fp)
static void | fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
void | linux_fork_killall (void)
void | linux_fork_mourn_inferior (void)
void | linux_fork_detach (const char *args, int from_tty)
static void | inferior_call_waitpid_cleanup (void *fp)
static int | inferior_call_waitpid (ptid_t pptid, int pid)
static void | delete_checkpoint_command (const char *args, int from_tty)
static void | detach_checkpoint_command (const char *args, int from_tty)
static void | info_checkpoints_command (const char *arg, int from_tty)
int | linux_fork_checkpointing_p (int pid)
static int | inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
static int | inf_has_multiple_threads (void)
static void | checkpoint_command (const char *args, int from_tty)
static void | linux_fork_context (struct fork_info *newfp, int from_tty)
static void | restart_command (const char *args, int from_tty)
void | _initialize_linux_fork (void)

## Variables
struct fork_info * | fork_list
static int | highest_fork_num
static int | checkpointing_pid = 0

## Function Documentation

## ◆ _initialize_linux_fork()

void _initialize_linux_fork | ( | void |  | ) |

Definition at line 778 of file linux-fork.c.

References _, add_cmd(), add_com(), add_info(), checkpoint_command(), class_obscure, delete_checkpoint_command(), deletelist, detach_checkpoint_command(), detachlist, info_checkpoints_command(), init_fork_list(), and restart_command().

## ◆ add_fork()

struct fork_info* add_fork | ( | pid_t | pid | ) |

Definition at line 81 of file linux-fork.c.

References add_fork(), find_last_fork(), fork_list, highest_fork_num, inferior_ptid, fork_info::next, fork_info::num, pid, fork_info::ptid, ptid_build(), ptid_get_pid(), and XCNEW.

Referenced by add_fork(), and linux_handle_extended_wait().

## ◆ call_lseek()

static off_t call_lseek | ( | int | fd,
|  | off_t | offset,
|  | int | whence
| ) |  |
| static

Definition at line 244 of file linux-fork.c.

References offset, and parse_and_eval_long().

Referenced by fork_load_infrun_state(), and fork_save_infrun_state().

## ◆ checkpoint_command()

static void checkpoint_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 671 of file linux-fork.c.

References _, call_function_by_hand(), checkpointing_pid, error(), find_fork_pid(), find_function_in_inferior(), fork_save_infrun_state(), get_last_target_status(), get_objfile_arch(), inf_has_multiple_threads(), inferior_ptid, info_verbose, lookup_minimal_symbol(), make_scoped_restore(), fork_info::num, fork_info::parent_ptid, printf_filtered(), ptid_get_lwp(), ptid_get_pid(), target_has_execution, update_thread_list(), value_as_long(), and value_from_longest().

Referenced by _initialize_linux_fork().

## ◆ delete_checkpoint_command()

static void delete_checkpoint_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 506 of file linux-fork.c.

References _, delete_fork(), error(), find_fork_ptid(), find_thread_ptid(), fork_id_to_ptid(), gdb_assert, inferior_call_waitpid(), inferior_ptid, is_stopped(), minus_one_ptid, fork_info::parent_ptid, parse_and_eval_long(), printf_filtered(), fork_info::ptid, ptid_equal(), ptid_get_pid(), ptrace(), target_pid_to_str(), and warning().

Referenced by _initialize_linux_fork().

## ◆ delete_fork()

static void delete_fork | ( | ptid_t | ptid | ) |
| static

Definition at line 137 of file linux-fork.c.

References fork_list, free_fork(), inferior_ptid, linux_nat_forget_process(), fork_info::next, fork_info::ptid, ptid_equal(), and ptid_get_pid().

Referenced by delete_checkpoint_command(), detach_checkpoint_command(), linux_fork_detach(), and linux_fork_mourn_inferior().

## ◆ detach_checkpoint_command()

static void detach_checkpoint_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 547 of file linux-fork.c.

References _, delete_fork(), error(), fork_id_to_ptid(), inferior_ptid, minus_one_ptid, parse_and_eval_long(), printf_filtered(), fork_info::ptid, ptid_equal(), ptid_get_pid(), ptrace(), and target_pid_to_str().

Referenced by _initialize_linux_fork().

## ◆ find_fork_id()

static struct fork_info* find_fork_id | ( | int | num | ) |
| static

Definition at line 187 of file linux-fork.c.

References fork_list, fork_info::next, and fork_info::num.

Referenced by fork_id_to_ptid(), and restart_command().

## ◆ find_fork_pid()

struct fork_info* find_fork_pid | ( | pid_t | pid | ) |

Definition at line 200 of file linux-fork.c.

References fork_list, fork_info::next, pid, fork_info::ptid, and ptid_get_pid().

Referenced by checkpoint_command(), and linux_handle_extended_wait().

## ◆ find_fork_ptid()

static struct fork_info* find_fork_ptid | ( | ptid_t | ptid | ) |
| static

Definition at line 174 of file linux-fork.c.

References fork_list, fork_info::next, fork_info::ptid, and ptid_equal().

Referenced by delete_checkpoint_command(), inferior_call_waitpid(), and linux_fork_context().

## ◆ find_last_fork()

static struct fork_info* find_last_fork | ( | void |  | ) |
| static

Definition at line 66 of file linux-fork.c.

References fork_list, and fork_info::next.

Referenced by add_fork(), and linux_fork_mourn_inferior().

## ◆ fork_id_to_ptid()

static ptid_t fork_id_to_ptid | ( | int | num | ) |
| static

Definition at line 212 of file linux-fork.c.

References find_fork_id(), fork_info::num, pid_to_ptid(), and fork_info::ptid.

Referenced by delete_checkpoint_command(), and detach_checkpoint_command().

## ◆ fork_load_infrun_state()

static void fork_load_infrun_state | ( | struct fork_info * | fp | ) |
| static

Definition at line 256 of file linux-fork.c.

References call_lseek(), fork_info::clobber_regs, fork_info::filepos, get_current_regcache(), linux_nat_switch_fork(), fork_info::maxfd, nullify_last_target_wait_ptid(), fork_info::ptid, regcache_cpy(), regcache_read_pc(), registers_changed(), reinit_frame_cache(), fork_info::savedregs, SEEK_SET, and stop_pc.

Referenced by inferior_call_waitpid(), inferior_call_waitpid_cleanup(), linux_fork_context(), linux_fork_detach(), and linux_fork_mourn_inferior().

## ◆ fork_save_infrun_state()

static void fork_save_infrun_state | ( | struct fork_info * | fp,
|  | int | clobber_regs
| ) |  |
| static

Definition at line 288 of file linux-fork.c.

References call_lseek(), fork_info::clobber_regs, fork_info::filepos, get_current_regcache(), fork_info::maxfd, fork_info::ptid, ptid_get_pid(), regcache_dup(), fork_info::savedregs, SEEK_CUR, and XRESIZEVEC.

Referenced by checkpoint_command(), inferior_call_waitpid(), and linux_fork_context().

## ◆ forks_exist_p()

int forks_exist_p | ( | void |  | ) |

Definition at line 58 of file linux-fork.c.

References fork_list.

Referenced by linux_nat_detach(), linux_nat_kill(), and linux_nat_mourn_inferior().

## ◆ free_fork()

static void free_fork | ( | struct fork_info * | fp | ) |
| static

Definition at line 112 of file linux-fork.c.

References fork_info::filepos, fork_info::savedregs, and xfree().

Referenced by delete_fork(), and init_fork_list().

## ◆ inf_has_multiple_thread_cb()

static int inf_has_multiple_thread_cb | ( | struct thread_info * | tp,
|  | void * | data
| ) |  |
| static

Definition at line 648 of file linux-fork.c.

References current_inferior(), inferior::pid, thread_info::ptid, and ptid_get_pid().

Referenced by inf_has_multiple_threads().

## ◆ inf_has_multiple_threads()

static int inf_has_multiple_threads | ( | void |  | ) |
| static

Definition at line 662 of file linux-fork.c.

References inf_has_multiple_thread_cb(), and iterate_over_threads().

Referenced by checkpoint_command().

## ◆ inferior_call_waitpid()

static int inferior_call_waitpid | ( | ptid_t | pptid,
|  | int | pid
| ) |  |
| static

Definition at line 452 of file linux-fork.c.

References gdb::argv, call_function_by_hand(), do_cleanups(), find_fork_ptid(), find_function_in_inferior(), fork_load_infrun_state(), fork_save_infrun_state(), gdb_assert, get_current_arch(), inferior_call_waitpid_cleanup(), inferior_ptid, insert_breakpoints(), lookup_minimal_symbol(), make_cleanup(), pid, ptid_equal(), remove_breakpoints(), value_as_long(), value_from_longest(), and value_from_pointer().

Referenced by delete_checkpoint_command().

## ◆ inferior_call_waitpid_cleanup()

static void inferior_call_waitpid_cleanup | ( | void * | fp | ) |
| static

Definition at line 438 of file linux-fork.c.

References fork_load_infrun_state(), insert_breakpoints(), and remove_breakpoints().

Referenced by inferior_call_waitpid().

## ◆ info_checkpoints_command()

static void info_checkpoints_command | ( | const char * | arg,
|  | int | from_tty
| ) |  |
| static

Definition at line 574 of file linux-fork.c.

References _, find_pc_line(), fork_list, fputs_filtered(), gdb_stdout, get_current_arch(), get_current_regcache(), inferior_ptid, symtab_and_line::line, lookup_minimal_symbol_by_pc(), MSYMBOL_LINKAGE_NAME, fork_info::next, fork_info::num, paddress(), parse_and_eval_long(), printf_filtered(), fork_info::ptid, ptid_equal(), putchar_filtered(), regcache_read_pc(), fork_info::savedregs, symtab_and_line::symtab, symtab_to_filename_for_display(), and target_pid_to_str().

Referenced by _initialize_linux_fork().

## ◆ init_fork_list()

static void init_fork_list | ( | void |  | ) |
| static

Definition at line 222 of file linux-fork.c.

References fork_list, free_fork(), and fork_info::next.

Referenced by _initialize_linux_fork(), and linux_fork_killall().

## ◆ linux_fork_checkpointing_p()

int linux_fork_checkpointing_p | ( | int | pid | ) |

Definition at line 638 of file linux-fork.c.

References checkpointing_pid, and pid.

Referenced by linux_handle_extended_wait().

## ◆ linux_fork_context()

static void linux_fork_context | ( | struct fork_info * | newfp,
|  | int | from_tty
| ) |  |
| static

Definition at line 741 of file linux-fork.c.

References _, find_fork_ptid(), fork_load_infrun_state(), fork_save_infrun_state(), gdb_assert, get_selected_frame(), inferior_ptid, insert_breakpoints(), print_stack_frame(), printf_filtered(), remove_breakpoints(), SRC_AND_LOC, and target_pid_to_str().

Referenced by restart_command().

## ◆ linux_fork_detach()

void linux_fork_detach | ( | const char * | args,
|  | int | from_tty
| ) |  |

Definition at line 410 of file linux-fork.c.

References _, delete_fork(), error(), fork_list, fork_load_infrun_state(), gdb_assert, inferior_ptid, fork_info::next, printf_filtered(), ptid_get_pid(), ptrace(), and target_pid_to_str().

Referenced by linux_nat_detach().

## ◆ linux_fork_killall()

void linux_fork_killall | ( | void |  | ) |

Definition at line 342 of file linux-fork.c.

References fork_list, init_fork_list(), fork_info::next, pid, fork_info::ptid, ptid_get_pid(), status, and WIFSTOPPED.

Referenced by linux_nat_kill().

## ◆ linux_fork_mourn_inferior()

void linux_fork_mourn_inferior | ( | void |  | ) |

Definition at line 374 of file linux-fork.c.

References _, delete_fork(), find_last_fork(), fork_list, fork_load_infrun_state(), gdb_assert, inferior_ptid, fork_info::next, printf_filtered(), ptid_get_pid(), status, and target_pid_to_str().

Referenced by linux_nat_mourn_inferior().

## ◆ restart_command()

static void restart_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 764 of file linux-fork.c.

References _, error(), find_fork_id(), linux_fork_context(), and parse_and_eval_long().

Referenced by _initialize_linux_fork().

## Variable Documentation

## ◆ checkpointing_pid

int checkpointing_pid = 0
| static

Definition at line 635 of file linux-fork.c.

Referenced by checkpoint_command(), and linux_fork_checkpointing_p().

## ◆ fork_list

struct fork_info* fork_list

Definition at line 38 of file linux-fork.c.

Referenced by add_fork(), delete_fork(), find_fork_id(), find_fork_pid(), find_fork_ptid(), find_last_fork(), forks_exist_p(), info_checkpoints_command(), init_fork_list(), linux_fork_detach(), linux_fork_killall(), and linux_fork_mourn_inferior().

## ◆ highest_fork_num

int highest_fork_num
| static

Definition at line 39 of file linux-fork.c.

Referenced by add_fork().