33 #include <sys/ptrace.h>
63 return (fork_list != NULL);
125 for (fp = fork_list; fp; fpprev = fp, fp = fp->
next)
135 fork_list = fp->
next;
143 if (fork_list != NULL && fork_list->
next == NULL &&
158 for (fp = fork_list; fp; fp = fp->
next)
171 for (fp = fork_list; fp; fp = fp->
next)
184 for (fp = fork_list; fp; fp = fp->
next)
209 for (fp = fork_list; fp; fp = fpnext)
228 snprintf (&exp[0],
sizeof (exp),
"lseek (%d, %ld, %d)",
229 fd, (
long) offset, whence);
255 for (i = 0; i <= fp->
maxfd; i++)
256 if (fp->
filepos[i] != (off_t) -1)
284 snprintf (path, PATH_MAX,
"/proc/%ld/fd",
286 if ((d = opendir (path)) != NULL)
291 while ((de = readdir (d)) != NULL)
295 tmp = strtol (&de->d_name[0], NULL, 10);
304 for (tmp = 0; tmp <= fp->
maxfd; tmp++)
309 while ((de = readdir (d)) != NULL)
310 if (isdigit (de->d_name[0]))
312 tmp = strtol (&de->d_name[0], NULL, 10);
334 for (fp = fork_list; fp; fp = fp->
next)
341 ret = waitpid (pid, &status, 0);
380 if (fork_list->
next == NULL)
412 if (fork_list->
next == NULL)
434 struct value *waitpid_fn = NULL;
435 struct value *argv[4], *retv;
437 struct fork_info *oldfp = NULL, *newfp = NULL;
491 error (
_(
"Requires argument (checkpoint id to delete)"));
495 error (
_(
"No such checkpoint id, %s"), args);
499 Please switch to another checkpoint before deleting the current one"));
531 error (
_(
"Requires argument (checkpoint id to detach)"));
535 error (
_(
"No such checkpoint id, %s"), args);
539 Please switch to another checkpoint before detaching the current one"));
565 for (fp = fork_list; fp; fp = fp->
next)
567 if (requested > 0 && fp->
num != requested)
629 int *count_p = (
int *) data;
656 struct value *fork_fn = NULL, *ret;
662 error (
_(
"The program is not being run."));
667 error (
_(
"checkpoint: can't checkpoint multiple threads."));
677 error (
_(
"checkpoint: can't find fork function in inferior."));
689 error (
_(
"checkpoint: call_function_by_hand returned null."));
701 fp != NULL ? fp->
num : -1, (
long) retpid);
713 error (
_(
"Failed to find new fork"));
747 error (
_(
"Requires argument (checkpoint id to restart)"));
750 error (
_(
"Not found: checkpoint id %s"), args);
764 Fork a duplicate process (experimental)."));
770 restart <n>: restore program context from a checkpoint.\n\
771 Argument 'n' is checkpoint ID, as displayed by 'info checkpoints'."));
777 Delete a checkpoint (experimental)."),
784 Detach from a checkpoint (experimental)."),
791 _(
"IDs of currently known checkpoints."));
void get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status)
const char * symtab_to_filename_for_display(struct symtab *symtab)
struct value * call_function_by_hand(struct value *function, int nargs, struct value **args)
struct thread_info * find_thread_ptid(ptid_t ptid)
struct frame_info * get_selected_frame(const char *message)
#define MSYMBOL_LINKAGE_NAME(symbol)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
void insert_breakpoints(void)
int linux_fork_checkpointing_p(int pid)
static void checkpoint_command(char *args, int from_tty)
LONGEST value_as_long(struct value *val)
void warning(const char *fmt,...)
struct ui_file * gdb_stdout
void linux_fork_killall(void)
struct regcache * savedregs
struct cmd_list_element * deletelist
static ptid_t fork_id_to_ptid(int num)
static void info_checkpoints_command(char *arg, int from_tty)
void nullify_last_target_wait_ptid(void)
void linux_fork_mourn_inferior(void)
char * target_pid_to_str(ptid_t ptid)
static void fork_load_infrun_state(struct fork_info *fp)
struct regcache * get_current_regcache(void)
void printf_filtered(const char *format,...)
static void delete_checkpoint_command(char *args, int from_tty)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
static int highest_fork_num
ptid_t ptid_build(int pid, long lwp, long tid)
struct regcache * regcache_dup(struct regcache *src)
struct thread_info * iterate_over_threads(thread_callback_func, void *)
int is_stopped(ptid_t ptid)
static struct fork_info * find_fork_ptid(ptid_t ptid)
void _initialize_linux_fork(void)
struct cleanup * make_cleanup_restore_integer(int *variable)
static void detach_checkpoint_command(char *args, int from_tty)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
struct fork_info * add_fork(pid_t pid)
void linux_fork_detach(const char *args, int from_tty)
struct value * find_function_in_inferior(const char *name, struct objfile **objf_p)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
ptid_t pid_to_ptid(int pid)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
static off_t call_lseek(int fd, off_t offset, int whence)
struct cmd_list_element * add_info(const char *name, cmd_cfunc_ftype *fun, const char *doc)
struct gdbarch * get_current_arch(void)
void regcache_cpy(struct regcache *dst, struct regcache *src)
struct value * value_from_longest(struct type *type, LONGEST num)
static int inf_has_multiple_thread_cb(struct thread_info *tp, void *data)
struct fork_info * fork_list
#define target_has_execution
int putchar_filtered(int c)
int ptid_get_pid(ptid_t ptid)
PTR xrealloc(PTR ptr, size_t size)
static void init_fork_list(void)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
const char const char int
struct cmd_list_element * detachlist
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
static int inf_has_multiple_threads(void)
void update_thread_list(void)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
int remove_breakpoints(void)
void registers_changed(void)
static void linux_fork_context(struct fork_info *newfp, int from_tty)
static void delete_fork(ptid_t ptid)
void regcache_xfree(struct regcache *regcache)
struct inferior * current_inferior(void)
static void restart_command(char *args, int from_tty)
unsigned long long ULONGEST
static void free_fork(struct fork_info *fp)
long ptid_get_lwp(ptid_t ptid)
static int checkpointing_pid
void linux_nat_switch_fork(ptid_t new_ptid)
struct fork_info * find_fork_pid(pid_t pid)
static struct fork_info * find_fork_id(int num)
void reinit_frame_cache(void)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static void fork_save_infrun_state(struct fork_info *fp, int clobber_regs)
static void inferior_call_waitpid_cleanup(void *fp)
void error(const char *fmt,...)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
static int inferior_call_waitpid(ptid_t pptid, int pid)
void do_cleanups(struct cleanup *old_chain)
void linux_nat_forget_process(pid_t pid)
LONGEST parse_and_eval_long(const char *exp)