34#include "gdbsupport/gdb_wait.h"
136 if (it->ptid ==
ptid)
181 if (
pid == fi.ptid.pid ())
207 snprintf (&exp[0],
sizeof (exp),
"(long) lseek (%d, %ld, %d)",
208 fd, (
long) offset, whence);
233 for (i = 0; i <= fp->
maxfd; i++)
234 if (fp->
filepos[i] != (off_t) -1)
259 snprintf (path, PATH_MAX,
"/proc/%ld/fd", (
long) fp->
ptid.pid ());
260 if ((d = opendir (path)) != NULL)
265 while ((de = readdir (d)) != NULL)
269 tmp = strtol (&de->d_name[0], NULL, 10);
277 for (tmp = 0; tmp <= fp->
maxfd; tmp++)
282 while ((de = readdir (d)) != NULL)
283 if (isdigit (de->d_name[0]))
285 tmp = strtol (&de->d_name[0], NULL, 10);
305 pid_t
pid = fi.ptid.pid ();
316 }
while (ret ==
pid && WIFSTOPPED (
status));
371 error (_(
"Unable to detach %s"),
410 gdb_assert (
m_oldfp !=
nullptr);
412 gdb_assert (newfp !=
nullptr);
433 catch (
const gdb_exception_quit &ex)
439 catch (
const gdb_exception_forced_quit &ex)
445 catch (
const gdb_exception &ex)
447 warning (_(
"Couldn't restore checkpoint state in %s: %s"),
467 struct value *waitpid_fn = NULL;
478 if (waitpid_fn !=
nullptr)
481 struct value *argv[3], *retv;
506 error (_(
"Requires argument (checkpoint id to delete)"));
509 if (
ptid == minus_one_ptid)
510 error (_(
"No such checkpoint id, %s"), args);
514Please switch to another checkpoint before deleting the current one"));
537 warning (_(
"Unable to wait pid %s"),
548 error (_(
"Requires argument (checkpoint id to detach)"));
551 if (
ptid == minus_one_ptid)
552 error (_(
"No such checkpoint id, %s"), args);
556Please switch to another checkpoint before detaching the current one"));
558 if (
ptrace (PTRACE_DETACH,
ptid.pid (), 0, 0))
581 if (requested > 0 && fi.num != requested)
617 gdb_printf (_(
"No checkpoint number %d.\n"), requested);
654 ptid_t last_target_ptid;
655 struct value *fork_fn = NULL, *ret;
660 error (_(
"The program is not being run."));
665 error (_(
"checkpoint: can't checkpoint multiple threads."));
675 error (_(
"checkpoint: can't find fork function in inferior."));
682 scoped_restore save_pid
689 error (_(
"checkpoint: call_function_by_hand returned null."));
700 gdb_printf (_(
"checkpoint %d: fork returned pid %ld.\n"),
701 fp != NULL ? fp->
num : -1, (long) retpid);
704 parent_pid = last_target_ptid.lwp ();
706 parent_pid = last_target_ptid.pid ();
713 error (_(
"Failed to find new fork"));
733 gdb_assert (newfp != NULL);
736 gdb_assert (oldfp != NULL);
756 error (_(
"Requires argument (checkpoint id to restart)"));
759 error (_(
"Not found: checkpoint id %s"), args);
772Fork a duplicate process (experimental)."));
778Restore program context from a checkpoint.\n\
780Argument N is checkpoint ID, as displayed by 'info checkpoints'."));
786Delete a checkpoint (experimental)."),
793Detach from a checkpoint (experimental)."),
800 _(
"IDs of currently known checkpoints."));
struct gdbarch * get_current_arch(void)
int remove_breakpoints(void)
void insert_breakpoints(void)
inf_threads_range threads()
virtual void low_forget_process(pid_t pid)
thread_info * find_thread(ptid_t ptid)
void restore(readonly_detached_regcache *src)
~scoped_switch_fork_info()
scoped_switch_fork_info(ptid_t pptid)
DISABLE_COPY_AND_ASSIGN(scoped_switch_fork_info)
struct fork_info * m_oldfp
void set_stop_pc(CORE_ADDR stop_pc)
struct cmd_list_element * deletelist
struct cmd_list_element * detachlist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
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)
void set_force_quit_flag()
LONGEST parse_and_eval_long(const char *exp)
void reinit_frame_cache(void)
frame_info_ptr get_selected_frame(const char *message)
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
#define ptrace(request, pid, addr, data)
void update_thread_list(void)
struct thread_info * inferior_thread(void)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
struct value * call_function_by_hand(struct value *function, type *default_return_type, gdb::array_view< value * > args)
struct inferior * current_inferior(void)
void nullify_last_target_wait_ptid(void)
void get_last_target_status(process_stratum_target **target, ptid_t *ptid, target_waitstatus *status)
static off_t call_lseek(int fd, off_t offset, int whence)
int linux_fork_checkpointing_p(int pid)
static bool inf_has_multiple_threads()
void linux_fork_killall(void)
static int highest_fork_num
static void info_checkpoints_command(const char *arg, int from_tty)
static struct fork_info * find_fork_id(int num)
static void delete_checkpoint_command(const char *args, int from_tty)
static ptid_t fork_id_to_ptid(int num)
static std::list< fork_info > fork_list
static void fork_load_infrun_state(struct fork_info *fp)
static void delete_fork(ptid_t ptid)
static int checkpointing_pid
static int inferior_call_waitpid(ptid_t pptid, int pid)
static void checkpoint_command(const char *args, int from_tty)
void _initialize_linux_fork()
static void restart_command(const char *args, int from_tty)
static void detach_checkpoint_command(const char *args, int from_tty)
void linux_fork_mourn_inferior(void)
static struct fork_info * find_last_fork(void)
struct fork_info * find_fork_pid(pid_t pid)
static void linux_fork_context(struct fork_info *newfp, int from_tty)
void linux_fork_detach(int from_tty)
static struct fork_info * find_fork_ptid(ptid_t ptid)
static void fork_save_infrun_state(struct fork_info *fp)
struct linux_nat_target * linux_target
void linux_nat_switch_fork(ptid_t new_ptid)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
struct regcache * get_current_regcache(void)
void registers_changed(void)
const char * symtab_to_filename_for_display(struct symtab *symtab)
struct minimal_symbol * minsym
readonly_detached_regcache * savedregs
const char * linkage_name() const
struct gdbarch * arch() const
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
bool target_has_execution(inferior *inf)
std::string target_pid_to_str(ptid_t ptid)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct value * find_function_in_inferior(const char *name, struct objfile **objf_p)
struct value * value_from_longest(struct type *type, LONGEST num)
LONGEST value_as_long(struct value *val)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)