37 #ifdef PT_GET_PROCESS_STATE
43 inf_ptrace_follow_fork (
struct target_ops *ops,
int follow_child,
62 inf_ptrace_insert_fork_catchpoint (
struct target_ops *
self,
int pid)
68 inf_ptrace_remove_fork_catchpoint (
struct target_ops *
self,
int pid)
92 char *exec_file,
char *allargs,
char **env,
102 if (! ops_already_pushed)
121 #ifdef PT_GET_PROCESS_STATE
129 memset (&pe, 0,
sizeof pe);
130 pe.pe_set_event |= PTRACE_FORK;
171 if (pid == getpid ())
172 error (
_(
"I refuse to debug myself!"));
174 if (! ops_already_pushed)
202 error (
_(
"This system does not support attaching to a process"));
217 #ifdef PT_GET_PROCESS_STATE
220 inf_ptrace_post_attach (
struct target_ops *
self,
int pid)
225 memset (&pe, 0,
sizeof pe);
226 pe.pe_set_event |= PTRACE_FORK;
227 if (
ptrace (PT_SET_EVENT_MASK, pid,
265 error (
_(
"This system does not support detaching from a process"));
286 waitpid (pid, &status, 0);
326 ptid_t ptid,
int step,
enum gdb_signal signal)
382 while (pid == -1 && errno == EINTR);
389 _(
"Child process unexpectedly missing: %s.\n"),
394 ourstatus->
value.
sig = GDB_SIGNAL_UNKNOWN;
404 #ifdef PT_GET_PROCESS_STATE
410 if (
ptrace (PT_GET_PROCESS_STATE, pid,
414 switch (pe.pe_report_event)
421 fpid = waitpid (pe.pe_other_pid, &status, 0);
425 if (
ptrace (PT_GET_PROCESS_STATE, fpid,
429 gdb_assert (pe.pe_report_event == PTRACE_FORK);
450 const char *annex,
gdb_byte *readbuf,
464 struct ptrace_io_desc piod;
472 piod.piod_op = writebuf ? PIOD_WRITE_I : PIOD_READ_D;
473 piod.piod_addr = writebuf ? (
void *) writebuf : readbuf;
474 piod.piod_offs = (
void *) (
long)
offset;
478 if (
ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
481 *xfered_len = piod.piod_len;
510 if (partial_len > len)
518 if (rounded_offset < offset
519 || (offset + partial_len
528 memcpy (
buffer.byte + (offset - rounded_offset),
529 writebuf, partial_len);
557 memcpy (readbuf,
buffer.byte + (offset - rounded_offset),
561 *xfered_len = partial_len;
569 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
574 struct ptrace_io_desc piod;
578 piod.piod_op = PIOD_READ_AUXV;
579 piod.piod_addr = readbuf;
580 piod.piod_offs = (
void *) (
long)
offset;
584 if (
ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
587 *xfered_len = piod.piod_len;
629 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
642 const int sizeof_auxv_type =
TYPE_LENGTH (int_type);
643 const int sizeof_auxv_val =
TYPE_LENGTH (ptr_type);
650 if (endptr - ptr < 2 * sizeof_auxv_val)
654 ptr += sizeof_auxv_val;
656 ptr += sizeof_auxv_val;
679 #ifdef PT_GET_PROCESS_STATE
691 #if defined (PT_IO) && defined (PIOD_READ_AUXV)
739 error (
_(
"Couldn't read register %s (#%d): %s."),
798 error (
_(
"Couldn't write register %s (#%d): %s."),
struct gdbarch * target_gdbarch(void)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
int catch_syscall_enabled(void)
static void inf_ptrace_files_info(struct target_ops *ignore)
static void inf_ptrace_store_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static void inf_ptrace_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
struct target_waitstatus pending_follow
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
void push_target(struct target_ops *t)
static char * inf_ptrace_pid_to_str(struct target_ops *ops, ptid_t ptid)
struct ui_file * gdb_stdout
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
int(* to_follow_fork)(struct target_ops *, int, int) TARGET_DEFAULT_FUNC(default_follow_fork)
struct thread_info * inferior_thread(void)
static void inf_ptrace_create_inferior(struct target_ops *ops, char *exec_file, char *allargs, char **env, int from_tty)
void set_sigint_trap(void)
int gdbarch_num_regs(struct gdbarch *gdbarch)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_NORETURN(noprocess())
char * target_pid_to_str(ptid_t ptid)
struct target_ops * inf_ptrace_target(void)
void inf_child_maybe_unpush_target(struct target_ops *ops)
static void inf_ptrace_stop(struct target_ops *self, ptid_t ptid)
struct target_ops * inf_ptrace_trad_target(CORE_ADDR(*register_u_offset)(struct gdbarch *, int, int))
void printf_filtered(const char *format,...)
static int inf_ptrace_thread_alive(struct target_ops *ops, ptid_t ptid)
void(* to_files_info)(struct target_ops *) TARGET_DEFAULT_IGNORE()
struct cleanup * make_cleanup_unpush_target(struct target_ops *ops)
void null_cleanup(void *arg)
int(* to_remove_fork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
void startup_inferior(int ntraps)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
int gdbarch_cannot_store_register(struct gdbarch *gdbarch, int regnum)
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
int gdbarch_cannot_fetch_register(struct gdbarch *gdbarch, int regnum)
static void inf_ptrace_kill(struct target_ops *ops)
ptid_t pid_to_ptid(int pid)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static ptid_t inf_ptrace_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int options)
void store_waitstatus(struct target_waitstatus *ourstatus, int hoststatus)
static pid_t get_ptrace_pid(ptid_t ptid)
union target_waitstatus::@161 value
int gdb_signal_to_host(enum gdb_signal)
void target_mourn_inferior(void)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
int(* to_insert_fork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
static void inf_ptrace_detach(struct target_ops *ops, const char *args, int from_tty)
static enum target_xfer_status inf_ptrace_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
int fork_inferior(char *exec_file_arg, char *allargs, char **env, void(*traceme_fun)(void), void(*init_trace_fun)(int), void(*pre_trace_fun)(void), char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
struct thread_info * add_thread_silent(ptid_t ptid)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
void printf_unfiltered(const char *format,...)
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
void inf_child_mourn_inferior(struct target_ops *ops)
int target_is_pushed(struct target_ops *t)
char * normal_pid_to_str(ptid_t ptid)
int ptid_get_pid(ptid_t ptid)
int(* to_auxv_parse)(struct target_ops *ops, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) TARGET_DEFAULT_FUNC(default_auxv_parse)
static void inf_ptrace_store_register(const struct regcache *regcache, int regnum)
static void inf_ptrace_me(void)
const char const char int
struct target_ops * inf_child_target(void)
void discard_cleanups(struct cleanup *old_chain)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
static void inf_ptrace_mourn_inferior(struct target_ops *ops)
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
void(* to_stop)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
#define START_INFERIOR_TRAPS_EXPECTED
enum target_waitkind kind
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
struct ui_file * gdb_stderr
struct type * builtin_data_ptr
void detach_inferior(int pid)
char * safe_strerror(int)
static void inf_ptrace_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signal)
void(* to_post_attach)(struct target_ops *, int) TARGET_DEFAULT_IGNORE()
static void inf_ptrace_fetch_register(struct regcache *regcache, int regnum)
void(* to_create_inferior)(struct target_ops *, char *, char *, char **, int)
int parse_pid_to_attach(const char *args)
struct inferior * current_inferior(void)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
char * get_exec_file(int err)
unsigned long long ULONGEST
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
void clear_sigint_trap(void)
int register_size(struct gdbarch *gdbarch, int regnum)
long ptid_get_lwp(ptid_t ptid)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
static void inf_ptrace_attach(struct target_ops *ops, const char *args, int from_tty)
#define TYPE_LENGTH(thistype)
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
void(* to_attach)(struct target_ops *ops, const char *, int)
void gdb_flush(struct ui_file *file)
static CORE_ADDR(* inf_ptrace_register_u_offset)(struct gdbarch *, int, int)
PROCESS_GROUP_TYPE inferior_process_group(void)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
void error(const char *fmt,...)
#define target_post_startup_inferior(ptid)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
void inferior_appeared(struct inferior *inf, int pid)
void(* to_post_startup_inferior)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
struct type * builtin_int
const ULONGEST const LONGEST len