27#include "gdbsupport/gdb_wait.h"
44 return ptrace (request, ptid.pid (), addr, data);
76 const std::string &allargs,
77 char **env,
int from_tty)
83 int ops_already_pushed =
inf->target_is_pushed (
this);
86 if (! ops_already_pushed)
89 inf->push_target (
this);
90 unpusher.reset (
this);
138 int ops_already_pushed =
inf->target_is_pushed (
this);
142 if (
pid == getpid ())
143 error (_(
"I refuse to debug myself!"));
146 if (! ops_already_pushed)
150 inf->push_target (
this);
151 unpusher.reset (
this);
160 perror_with_name ((
"ptrace"));
162 error (_(
"This system does not support attaching to a process"));
166 inf->attach_flag =
true;
197 perror_with_name ((
"ptrace"));
199 error (_(
"This system does not support detaching from a process"));
260 if (minus_one_ptid == ptid)
286 perror_with_name ((
"ptrace"));
295 target_wait_flags target_options)
298 int options,
status, save_errno;
310 pid = waitpid (ptid.pid (), &
status, options);
313 while (
pid == -1 && errno == EINTR);
321 return minus_one_ptid;
330 if (ptid == minus_one_ptid && save_errno == ECHILD)
333 return minus_one_ptid;
337 _(
"Child process unexpectedly missing: %s.\n"),
338 safe_strerror (save_errno));
341 return minus_one_ptid;
362 const gdb_byte *writebuf,
363 ULONGEST addr, ULONGEST len)
397 memcpy (readbuf + n, buf.byte + skip, chunk);
399 if (writebuf != NULL)
401 memcpy (buf.byte + skip, writebuf + n, chunk);
425 const char *annex, gdb_byte *readbuf,
426 const gdb_byte *writebuf,
427 ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
439 struct ptrace_io_desc piod;
447 piod.piod_op = writebuf ? PIOD_WRITE_I : PIOD_READ_D;
448 piod.piod_addr = writebuf ? (
void *) writebuf : readbuf;
449 piod.piod_offs = (
void *) (
long) offset;
453 if (
gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0)
456 *xfered_len = piod.piod_len;
474#if defined (PT_IO) && defined (PIOD_READ_AUXV)
479 struct ptrace_io_desc piod;
483 piod.piod_op = PIOD_READ_AUXV;
484 piod.piod_addr = readbuf;
485 piod.piod_offs = (
void *) (
long) offset;
489 if (
gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0)
492 *xfered_len = piod.piod_len;
513 return (
::kill (ptid.pid (), 0) != -1);
523 gdb_printf (_(
"\tUsing the running image of %s %s.\n"),
524 inf->attach_flag ?
"attached" :
"child",
static PTRACE_TYPE_RET gdb_ptrace(PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr, PTRACE_TYPE_ARG4 data)
int catch_syscall_enabled(void)
void mourn_inferior() override
void maybe_unpush_target()
const std::string & args() const
ptid_t gdb_startup_inferior(pid_t pid, int num_traps)
void trace_start_error_with_name(const char *string)
pid_t fork_inferior(const char *exec_file_arg, const std::string &allargs, char **env, void(*traceme_fun)(), gdb::function_view< void(int)> init_trace_fun, void(*pre_trace_fun)(), const char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
#define START_INFERIOR_TRAPS_EXPECTED
#define ptrace(request, pid, addr, data)
struct thread_info * add_thread_silent(process_stratum_target *targ, ptid_t ptid)
void set_executing(process_stratum_target *targ, ptid_t ptid, bool executing)
void switch_to_thread(struct thread_info *thr)
void switch_to_no_thread()
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
target_waitstatus host_status_to_waitstatus(int hoststatus)
static PTRACE_TYPE_RET gdb_ptrace(PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr, PTRACE_TYPE_ARG4 data)
static ULONGEST inf_ptrace_peek_poke(ptid_t ptid, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST addr, ULONGEST len)
pid_t get_ptrace_pid(ptid_t ptid)
static void inf_ptrace_me(void)
void inferior_appeared(struct inferior *inf, int pid)
struct inferior * find_inferior_pid(process_stratum_target *targ, int pid)
void detach_inferior(inferior *inf)
struct inferior * current_inferior(void)
void set_sigint_trap(void)
void clear_sigint_trap(void)
void create_inferior(const char *, const std::string &, char **, int) override
virtual void post_startup_inferior(ptid_t ptid)=0
~inf_ptrace_target() override=0
void detach_success(inferior *inf)
bool is_async_p() override
void resume(ptid_t, int, enum gdb_signal) override
void mourn_inferior() override
void files_info() override
bool thread_alive(ptid_t ptid) override
static event_pipe m_event_pipe
void attach(const char *, int) override
void detach(inferior *inf, int) override
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
std::string pid_to_str(ptid_t) override
virtual void async(bool) TARGET_DEFAULT_NORETURN(tcomplain())
target_waitstatus & set_no_resumed()
target_waitstatus & set_ignore()
void target_announce_detach(int from_tty)
void target_announce_attach(int from_tty, int pid)
std::string target_pid_to_str(ptid_t ptid)
std::string normal_pid_to_str(ptid_t ptid)
void target_mourn_inferior(ptid_t ptid)
std::unique_ptr< struct target_ops, target_unpusher > target_unpush_up
@ TARGET_OBJECT_UNWIND_TABLE
void gdb_printf(struct ui_file *stream, const char *format,...)
int parse_pid_to_attach(const char *args)