28 #include <sys/syscall.h> 42 #include <sys/procfs.h> 53 #include <sys/types.h> 71 #define SPUFS_MAGIC 0x23c9b64e 186 #define O_LARGEFILE 0 255 #define linux_is_async_p() (linux_nat_event_pipe[0] != -1) 269 while (ret >= 0 || (ret == -1 && errno == EINTR));
290 while (ret == -1 && errno == EINTR);
296 static int kill_lwp (
int lwpid,
int signo);
334 lwp->arch_private = info;
342 return lwp->arch_private;
358 return lwp->stop_reason;
379 new_pid->
next = *listp;
388 for (p = listp; *p != NULL; p = &(*p)->
next)
389 if ((*p)->pid ==
pid)
484 ptid_t parent_ptid, child_ptid;
485 int parent_pid, child_pid;
495 child_lp =
add_lwp (child_ptid);
523 if (
ptrace (PTRACE_SINGLESTEP, child_pid, 0, 0) < 0)
537 ptrace (PTRACE_DETACH, child_pid, 0, signo);
563 "LCFF: waiting for VFORK_DONE on %d\n",
605 "LCFF: no VFORK_DONE " 606 "support, sleeping a bit\n");
679 int pid,
bool needed,
int any_count,
706 return iterative_hash_object (
pid, 0);
765 if (lp->
next != NULL)
767 if (lp->
prev != NULL)
807 sigprocmask (SIG_SETMASK, prev_mask, NULL);
816 int numsigs,
unsigned char *pass_signals)
822 for (signo = 1; signo < NSIG; signo++)
825 if (target_signo < numsigs && pass_signals[target_signo])
860 int pid = *(
int *) info;
996 for (lp =
lwp_list; lp; lp = lpnext)
1002 if ((*callback) (lp, data) != 0)
1067 "LNPAW: Attaching to a stopped process\n");
1109 "LNPAW: Received %s after attaching\n",
1118 const char *exec_file,
const std::string &allargs,
1119 char **env,
int from_tty)
1148 if (
ptrace (PTRACE_ATTACH, lwpid, 0, 0) < 0)
1163 "Cannot attach to lwp %d: " 1164 "thread is gone (%d: %s)\n",
1170 warning (
_(
"Cannot attach to lwp %d: %s"),
1180 "PTRACE_ATTACH %s, 0, 0 (OK)\n",
1227 char *message, *buffer_s;
1229 message = xstrdup (ex.message);
1239 if (*buffer_s !=
'\0')
1240 throw_error (ex.error,
"warning: %s\n%s", buffer_s, message);
1266 error (
_(
"Unable to attach: program exited normally."));
1268 error (
_(
"Unable to attach: program exited with code %d."),
1273 enum gdb_signal signo;
1279 error (
_(
"Unable to attach: program terminated with signal " 1286 _(
"unexpected status %d for PID %ld"),
1296 "LNA: waitpid %ld, saving status %s\n",
1323 enum gdb_signal signo = GDB_SIGNAL_0;
1347 signo = GDB_SIGNAL_0;
1374 if (signo == GDB_SIGNAL_0)
1378 "GPT: lwp %s has no pending signal\n",
1385 "GPT: lwp %s had signal %s, " 1386 "but it is in no pass state\n",
1394 "GPT: lwp %s has pending signal %s\n",
1426 "DC: Sending SIGCONT to %s\n",
1433 if (signo_p == NULL)
1456 if (
ptrace (PTRACE_DETACH, lwpid, 0, signo) < 0)
1458 int save_errno = errno;
1464 if (save_errno == ESRCH)
1471 warning (
_(
"Couldn't reap LWP %d while detaching: %s"),
1472 lwpid, strerror (errno));
1476 warning (
_(
"Reaping LWP %d while detaching " 1477 "returned unexpected status 0x%x"),
1490 "PTRACE_DETACH (%s, %s, 0) (OK)\n",
1552 signo = atoi (args);
1567 enum gdb_signal signo)
1658 if (
inf->vfork_child != NULL)
1662 "RC: Not resuming %s (vfork parent)\n",
1669 "RC: Resuming sibling %s, %s, %s\n",
1671 (signo != GDB_SIGNAL_0
1674 step ?
"step" :
"resume");
1682 "RC: Not resuming sibling %s (has pending)\n",
1690 "RC: Not resuming sibling %s (not stopped)\n",
1701 enum gdb_signal signo = GDB_SIGNAL_0;
1740 ptid_t ptid,
int step,
enum gdb_signal signo)
1747 "LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
1748 step ?
"step" :
"resume",
1750 (signo != GDB_SIGNAL_0
1788 "LLR: Not short circuiting for ignored " 1789 "status 0x%x\n", lp->
status);
1807 "LLR: Short circuiting for status 0x%x\n",
1824 "LLR: %s %s, %s (resume event thread)\n",
1825 step ?
"PTRACE_SINGLESTEP" :
"PTRACE_CONT",
1827 (signo != GDB_SIGNAL_0
1844 ret =
syscall (__NR_tkill, lwpid, signo);
1845 if (errno == ENOSYS)
1891 "LHST: ignoring syscall %d " 1892 "for LWP %ld (stopping threads), " 1893 "resuming with PTRACE_CONT for SIGSTOP\n",
1922 "LHST: stopping for %s of syscall %d" 1926 ?
"entry" :
"return",
1934 "LHST: ignoring %s of syscall %d " 1937 ?
"entry" :
"return",
1961 "LHST: caught syscall event " 1962 "with no syscall catchpoints." 1963 " %d for LWP %ld, ignoring\n",
2001 unsigned long new_pid;
2014 else if (ret != new_pid)
2016 _(
"wait returned unexpected PID %d"), ret);
2019 _(
"wait returned unexpected status 0x%x"),
status);
2069 "LHEW: Got clone event " 2070 "from LWP %d, new child is LWP %ld\n",
2112 "LHEW: waitpid of new LWP %ld, " 2113 "saving status %s\n",
2134 "LHEW: Got exec event from LWP %ld\n",
2154 "LHEW: Got expected PTRACE_EVENT_" 2155 "VFORK_DONE from LWP %ld: stopping\n",
2164 "LHEW: Got PTRACE_EVENT_VFORK_DONE " 2165 "from LWP %ld: ignoring\n",
2171 _(
"unknown ptrace event %d"), event);
2182 int thread_dead = 0;
2194 if (
pid == -1 && errno == ECHILD)
2228 "WL: Thread group leader %s vanished.\n",
2254 "WL: waitpid %s received %s\n",
2326 "WL: Handling extended status 0x%06x\n",
2347 "SC: kill %s **<SIGSTOP>**\n",
2355 "SC: lwp kill %d %s\n",
2402 sigset_t
pending, blocked, ignored;
2406 if (sigismember (&
pending, SIGINT)
2407 && !sigismember (&ignored, SIGINT))
2445 "MCIS: Clearing bogus flag for %s\n",
2528 int (*status_is_event) (
int status))
2542 if (
inf->vfork_child != NULL)
2563 "PTRACE_CONT %s, 0, 0 (%s) " 2564 "(discarding SIGINT)\n",
2579 "SWC: Pending event %s in %s\n",
2595 "SWC: Expected SIGSTOP caught for %s.\n",
2635 "SC: PC of %s changed. was=%s, now=%s\n",
2642 #if !USE_SIGTRAP_SIGINFO 2647 "SC: previous breakpoint of %s, at %s gone\n",
2659 "SC: pending event of %s cancelled.\n",
2676 int *count = (
int *) data;
2740 #if USE_SIGTRAP_SIGINFO 2756 #if USE_SIGTRAP_SIGINFO 2759 if (siginfo.si_signo == SIGTRAP)
2785 else if (siginfo.si_code == TRAP_TRACE)
2789 "CSBB: %s stopped by trace\n",
2822 "CSBB: %s stopped by software breakpoint\n",
2836 "CSBB: %s stopped by hardware breakpoint\n",
2843 "CSBB: %s stopped by hardware watchpoint\n",
2898 int random_selector;
2917 if (event_lp != NULL)
2921 "SEL: Select single-step %s\n",
2926 if (event_lp == NULL)
2936 random_selector = (int)
2937 ((num_events * (
double) rand ()) / (RAND_MAX + 1.0));
2941 "SEL: Found %d events, selecting #%d\n",
2942 num_events, random_selector);
2949 if (event_lp != NULL)
2952 *orig_lp = event_lp;
2957 (*orig_lp)->status = 0;
2998 "LLW: Re-adding thread group leader LWP %d.\n",
3011 "LHEW: saving LWP %ld status %s in stopped_pids list\n",
3061 "LLW: Handling extended status 0x%06x\n",
3075 "LLW: %s exited.\n",
3091 "LWP %ld exited (resumed=%d)\n",
3114 "LLW: resume_stop SIGSTOP caught for %s.\n",
3123 "LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
3125 "PTRACE_SINGLESTEP" :
"PTRACE_CONT",
3141 "LLW: Delayed SIGINT caught for %s.\n",
3150 "LLW: %s %s, 0, 0 (discard SIGINT)\n",
3152 "PTRACE_SINGLESTEP" :
"PTRACE_CONT",
3200 "LLW: %s %s, %s (preempt 'handle')\n",
3202 "PTRACE_SINGLESTEP" :
"PTRACE_CONT",
3204 (signo != GDB_SIGNAL_0
3234 if (leader_lp != NULL
3242 "CZL: Thread group leader %d zombie " 3243 "(it exited, or another thread execd).\n",
3266 "CZL: Thread group leader %d vanished.\n",
3333 "LLW: Using pending wait status %s for %s.\n",
3364 "LNW: waitpid(-1, ...) returned %d, %s\n",
3372 "LLW: waitpid %ld received %s\n",
3493 "LLW: trap ptid is %s.\n",
3517 ourstatus->
value.
sig = GDB_SIGNAL_0;
3544 "RSRL: NOT resuming LWP %s, not stopped\n",
3551 "RSRL: NOT resuming LWP %s, not resumed\n",
3558 "RSRL: NOT resuming LWP %s, has pending status\n",
3569 int leave_stopped = 0;
3583 "RSRL: resuming stopped-resumed LWP %s at " 3612 char *options_string;
3616 "linux_nat_wait: [%s], [%s]\n",
3619 xfree (options_string);
3661 int save_errno = errno;
3664 "KC: kill (SIGKILL) %ld, 0, 0 (%s)\n", (
long)
pid,
3674 int save_errno = errno;
3677 "KC: PTRACE_KILL %ld, 0, 0 (%s)\n", (
long)
pid,
3696 if (res != (pid_t) -1)
3700 "KWC: wait %ld received unknown.\n",
3829 memcpy (siginfo, inf_siginfo,
sizeof (siginfo_t));
3831 memcpy (inf_siginfo, siginfo,
sizeof (siginfo_t));
3837 const char *annex,
gdb_byte *readbuf,
3843 gdb_byte inf_siginfo[
sizeof (siginfo_t)];
3852 if (
offset >
sizeof (siginfo))
3868 if (
offset + len >
sizeof (siginfo))
3869 len =
sizeof (siginfo) -
offset;
3871 if (readbuf != NULL)
3872 memcpy (readbuf, inf_siginfo +
offset, len);
3875 memcpy (inf_siginfo +
offset, writebuf, len);
3892 const char *annex,
gdb_byte *readbuf,
3900 offset, len, xfered_len);
3909 offset, len, xfered_len);
3941 if (
lwp->core == -1)
3949 static char buf[64];
3983 const char *annex,
gdb_byte *readbuf,
3995 if (len < 3 *
sizeof (
long))
4000 xsnprintf (filename,
sizeof filename,
"/proc/%ld/mem",
4011 ret = (readbuf ? pread64 (fd, readbuf, len,
offset)
4012 : pwrite64 (fd, writebuf, len,
offset));
4016 ret = (readbuf ?
read (fd, readbuf, len)
4017 : write (fd, writebuf, len));
4022 if (ret == -1 || ret == 0)
4041 struct dirent *entry;
4044 dir = opendir (path);
4049 while ((entry = readdir (dir)) != NULL)
4055 fd = atoi (entry->d_name);
4059 xsnprintf (path,
sizeof path,
"/proc/%d/fd/%d",
pid, fd);
4060 if (stat (path, &st) != 0)
4062 if (!S_ISDIR (st.st_mode))
4065 if (statfs (path, &stfs) != 0)
4087 const char *annex,
gdb_byte *readbuf,
4116 xsnprintf (buf,
sizeof buf,
"/proc/%d/fd/%s",
pid, annex);
4129 ret = write (fd, writebuf, (
size_t) len);
4131 ret =
read (fd, readbuf, (
size_t) len);
4152 int len = strlen (line) - 1;
4156 if (line[len] !=
'\n')
4157 error (
_(
"Could not parse signal set: %s"), line);
4165 if (*p >=
'0' && *p <=
'9')
4167 else if (*p >=
'a' && *p <=
'f')
4168 digit = *p -
'a' + 10;
4170 error (
_(
"Could not parse signal set: %s"), line);
4175 sigaddset (sigs, signum + 1);
4177 sigaddset (sigs, signum + 2);
4179 sigaddset (sigs, signum + 3);
4181 sigaddset (sigs, signum + 4);
4192 sigset_t *blocked, sigset_t *ignored)
4194 char buffer[PATH_MAX], fname[PATH_MAX];
4197 sigemptyset (blocked);
4198 sigemptyset (ignored);
4199 xsnprintf (fname,
sizeof fname,
"/proc/%d/status",
pid);
4201 if (procfile == NULL)
4202 error (
_(
"Could not open %s"), fname);
4204 while (fgets (
buffer, PATH_MAX, procfile.get ()) != NULL)
4227 const char *annex,
gdb_byte *readbuf,
4234 if (*xfered_len == 0)
4242 const char *annex,
gdb_byte *readbuf,
4250 offset, len, xfered_len);
4254 offset, len, xfered_len);
4258 offset, len, xfered_len);
4275 offset, len, xfered_len);
4280 offset, len, xfered_len);
4295 linux_child_static_tracepoint_markers_by_strid (
struct target_ops *
self,
4309 memcpy (s,
"qTfSTM",
sizeof (
"qTfSTM"));
4310 s[
sizeof (
"qTfSTM")] = 0;
4326 if (strid == NULL || strcmp (strid, marker->
str_id) == 0)
4335 memset (marker, 0,
sizeof (*marker));
4338 while (*p++ ==
',');
4340 memcpy (s,
"qTsSTM",
sizeof (
"qTsSTM"));
4341 s[
sizeof (
"qTsSTM")] = 0;
4372 t->to_static_tracepoint_markers_by_strid
4373 = linux_child_static_tracepoint_markers_by_strid;
4444 #ifdef HAVE_PERSONALITY 4502 int old_errno = errno;
4506 "sigchld\n",
sizeof (
"sigchld\n") - 1);
4508 if (signo == SIGCHLD
4543 "creating event pipe failed.");
4596 "LNSL: running -> suspending %s\n",
4604 "linux-nat: already stopping LWP %ld at " 4621 "LNSL: already stopped/stop_requested %s\n",
4625 "LNSL: already stopped/no " 4626 "stop_requested yet %s\n",
4731 int flags,
int mode,
int warn_if_slow,
4741 *target_errno = FILEIO_EINVAL;
4746 filename, nat_flags, nat_mode);
4765 filename, buf,
sizeof (buf));
4772 ret = (
char *)
xmalloc (len + 1);
4773 memcpy (ret, buf, len);
4939 void (*prepare_to_resume) (
struct lwp_info *))
4960 memset (siginfo, 0,
sizeof (*siginfo));
4980 Set debugging of GNU/Linux lwp module."),
_(
"\ 4981 Show debugging of GNU/Linux lwp module."),
_(
"\ 4982 Enables printf debugging output."),
4989 Set debugging of GNU/Linux namespaces module."),
_(
"\ 4990 Show debugging of GNU/Linux namespaces module."),
_(
"\ 4991 Enables printf debugging output."),
void get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status)
struct gdbarch * target_gdbarch(void)
static void linux_nat_thread_events(struct target_ops *ops, int enable)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
void linux_unstop_all_lwps(void)
#define target_can_async_p()
int gdbarch_software_single_step_p(struct gdbarch *gdbarch)
struct address_space *(* to_thread_address_space)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_thread_address_space)
struct arch_lwp_info * arch_private
void add_target(struct target_ops *t)
ssize_t read(int fd, void *buf, size_t count)
int breakpoint_inserted_here_p(const address_space *aspace, CORE_ADDR pc)
#define PTRACE_GETEVENTMSG
void release_static_tracepoint_marker(struct static_tracepoint_marker *marker)
struct thread_info * add_thread(ptid_t ptid)
struct thread_info * find_thread_ptid(ptid_t ptid)
int(* to_supports_stopped_by_hw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
int catch_syscall_enabled(void)
int(* to_supports_disable_randomization)(struct target_ops *)
static sigset_t blocked_mask
static void delete_lwp_cleanup(void *lp_voidp)
int(* to_is_async_p)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
static void sigchld_handler(int signo)
int ptid_is_pid(const ptid_t &ptid)
void target_stop(ptid_t ptid)
static void lwp_lwpid_htab_add_lwp(struct lwp_info *lp)
static enum target_xfer_status linux_proc_xfer_spu(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)
struct arch_lwp_info * lwp_arch_private_info(struct lwp_info *lwp)
static int linux_child_remove_fork_catchpoint(struct target_ops *self, int pid)
void target_announce_detach(int from_tty)
void lin_thread_get_thread_signals(sigset_t *set)
static struct lwp_info * add_lwp(ptid_t ptid)
void linux_proc_pending_signals(int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored)
static void lwp_list_add(struct lwp_info *lp)
struct lwp_info * lwp_list
static struct target_ops linux_ops_saved
int ptid_get_pid(const ptid_t &ptid)
struct regcache * get_thread_regcache(ptid_t ptid)
void linux_stop_lwp(struct lwp_info *lwp)
void delete_thread(ptid_t)
static void block_child_signals(sigset_t *prev_mask)
int linux_fork_checkpointing_p(int pid)
static int kill_wait_callback(struct lwp_info *lp, void *data)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
void set_running(ptid_t ptid, int running)
static int linux_nat_event_pipe[2]
static int linux_nat_resume_callback(struct lwp_info *lp, void *except)
#define PTRACE_EVENT_EXEC
static sigset_t normal_mask
static int get_detach_signal(struct lwp_info *lp)
static int lwp_lwpid_htab_remove_pid(void **slot, void *info)
void linux_nat_set_new_thread(struct target_ops *t, void(*new_thread)(struct lwp_info *))
void warning(const char *fmt,...)
struct sigaction sigchld_action
static int resume_stopped_resumed_lwps(struct lwp_info *lp, void *data)
regcache(gdbarch *gdbarch)
int fileio_to_host_mode(int fileio_mode, mode_t *mode_p)
static void add_line_to_sigset(const char *line, sigset_t *sigs)
static hashval_t lwp_info_hash(const void *ap)
static void linux_nat_attach(struct target_ops *ops, const char *args, int from_tty)
int linux_wstatus_maybe_breakpoint(int wstat)
int disable_randomization
static struct address_space * linux_nat_thread_address_space(struct target_ops *t, ptid_t ptid)
static void linux_nat_create_inferior(struct target_ops *ops, const char *exec_file, const std::string &allargs, char **env, int from_tty)
int gdb_pipe_cloexec(int filedes[2])
static int linux_child_remove_vfork_catchpoint(struct target_ops *self, int pid)
int linux_is_extended_waitstatus(int wstat)
static int pull_pid_from_list(struct simple_pid_list **listp, int pid, int *statusp)
static void linux_nat_detach(struct target_ops *ops, const char *args, int from_tty)
int thread_db_notice_clone(ptid_t parent, ptid_t child)
void linux_fork_killall(void)
static linux_nat_forget_process_ftype * linux_nat_forget_process_hook
static void add_to_pid_list(struct simple_pid_list **listp, int pid, int status)
int(* to_core_of_thread)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(-1)
static void linux_nat_mourn_inferior(struct target_ops *ops)
int(* to_follow_fork)(struct target_ops *, int, int) TARGET_DEFAULT_FUNC(default_follow_fork)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
struct thread_info * inferior_thread(void)
int(* to_set_syscall_catchpoint)(struct target_ops *, int, bool, int, gdb::array_view< const int >) TARGET_DEFAULT_RETURN(1)
static ptid_t filter_exit_event(struct lwp_info *event_child, struct target_waitstatus *ourstatus)
static int linux_nat_has_pending_sigint(int pid)
void(* to_close)(struct target_ops *)
void() linux_nat_new_fork_ftype(struct lwp_info *parent, pid_t child_pid)
static int linux_nat_stopped_by_hw_breakpoint(struct target_ops *ops)
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
union target_waitstatus::@174 value
enum target_stop_reason lwp_stop_reason(struct lwp_info *lwp)
#define linux_is_async_p()
static void lwp_list_remove(struct lwp_info *lp)
static enum target_xfer_status linux_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)
static enum target_xfer_status linux_xfer_siginfo(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)
void linux_fork_mourn_inferior(void)
static sigset_t pass_mask
void set_sigint_trap(void)
void child_terminal_inferior(struct target_ops *self)
static void lwp_lwpid_htab_create(void)
void target_async(int enable)
#define VEC_safe_push(T, V, O)
#define target_post_attach(pid)
struct inferior * find_inferior_ptid(ptid_t ptid)
static const char * linux_nat_thread_name(struct target_ops *self, struct thread_info *thr)
const char * linux_proc_tid_get_name(ptid_t ptid)
static void resume_lwp(struct lwp_info *lp, int step, enum gdb_signal signo)
static int attach_proc_task_lwp_callback(ptid_t ptid)
static int linux_nat_core_of_thread(struct target_ops *ops, ptid_t ptid)
enum gdb_signal stop_signal
struct target_ops * inf_ptrace_target(void)
static int set_ignore_sigint(struct lwp_info *lp, void *data)
static struct target_ops * linux_ops
static int resume_clear_callback(struct lwp_info *lp, void *data)
int linux_nat_get_siginfo(ptid_t ptid, siginfo_t *siginfo)
static void linux_nat_terminal_inferior(struct target_ops *self)
static void kill_unfollowed_fork_children(struct inferior *inf)
void regcache_write_pc(struct regcache *regcache, CORE_ADDR pc)
static int select_singlestep_lwp_callback(struct lwp_info *lp, void *data)
static void handle_target_event(int error, gdb_client_data client_data)
void linux_nat_set_new_fork(struct target_ops *t, linux_nat_new_fork_ftype *new_fork)
#define GDB_ARCH_IS_TRAP_HWBKPT(X)
void child_terminal_ours(struct target_ops *self)
struct target_ops * inf_ptrace_trad_target(CORE_ADDR(*register_u_offset)(struct gdbarch *, int, int))
static void(* linux_nat_delete_thread)(struct arch_lwp_info *)
static int resumed_callback(struct lwp_info *lp, void *data)
static int select_event_lwp_callback(struct lwp_info *lp, void *data)
static target_xfer_partial_ftype * super_xfer_partial
static void linux_nat_stop(struct target_ops *self, ptid_t ptid)
ptid_t ptid_of_lwp(struct lwp_info *lwp)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
#define PTRACE_EVENT_VFORK_DONE
static void linux_nat_close(struct target_ops *self)
void add_file_handler(int fd, handler_func *proc, gdb_client_data client_data)
int(* to_remove_exec_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
void linux_ptrace_attach_fail_reason(pid_t pid, struct buffer *buffer)
ptid_t ptid_build(int pid, long lwp, long tid)
struct target_waitstatus waitstatus
int must_set_ptrace_flags
static int detach_callback(struct lwp_info *lp, void *data)
int debug_linux_namespaces
int fileio_to_host_openflags(int fileio_open_flags, int *open_flags_p)
scoped_restore_tmpl< T > make_scoped_restore(T *var)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
void(* to_thread_events)(struct target_ops *, int) TARGET_DEFAULT_IGNORE()
const char * normal_pid_to_str(ptid_t ptid)
static int linux_nat_filesystem_is_local(struct target_ops *ops)
static void linux_nat_pass_signals(struct target_ops *self, int numsigs, unsigned char *pass_signals)
static int linux_handle_extended_wait(struct lwp_info *lp, int status)
#define PTRACE_EVENT_FORK
int(* to_remove_fork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
static struct lwp_info * linux_nat_filter_event(int lwpid, int status)
CORE_ADDR gdbarch_decr_pc_after_break(struct gdbarch *gdbarch)
static void(* super_close)(struct target_ops *)
static char * linux_child_pid_to_exec_file(struct target_ops *self, int pid)
static int linux_nat_fileio_unlink(struct target_ops *self, struct inferior *inf, const char *filename, int *target_errno)
static void linux_resume_one_lwp_throw(struct lwp_info *lp, int step, enum gdb_signal signo)
static int linux_child_remove_exec_catchpoint(struct target_ops *self, int pid)
void linux_ptrace_init_warnings(void)
static int linux_nat_fileio_open(struct target_ops *self, struct inferior *inf, const char *filename, int flags, int mode, int warn_if_slow, int *target_errno)
#define CATCH(EXCEPTION, MASK)
char * target_options_to_string(int target_options)
std::unique_ptr< FILE, gdb_file_deleter > gdb_file_up
enum tribool have_ptrace_getregset
thread_suspend_state suspend
char * linux_ptrace_attach_fail_reason_string(ptid_t ptid, int err)
void _initialize_linux_nat(void)
static void linux_nat_async(struct target_ops *ops, int enable)
static void async_file_mark(void)
static void cleanup_target_stop(void *arg)
void inferior_event_handler(enum inferior_event_type event_type, gdb_client_data client_data)
struct target_ops current_target
int detach_breakpoints(ptid_t ptid)
static void(* linux_nat_prepare_to_resume)(struct lwp_info *)
struct fork_info * add_fork(pid_t pid)
static enum target_xfer_status linux_nat_xfer_osdata(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 linux_ns_same(pid_t pid, enum linux_ns_type type)
void linux_fork_detach(const char *args, int from_tty)
static int status_callback(struct lwp_info *lp, void *data)
int target_is_non_stop_p(void)
void() linux_nat_forget_process_ftype(pid_t pid)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void free_current_marker(void *arg)
void ui_file_write_async_safe(struct ui_file *file, const char *buf, long length_buf)
#define PTRACE_O_TRACEVFORKDONE
static void(* linux_nat_new_thread)(struct lwp_info *)
static void linux_init_ptrace(pid_t pid, int attached)
struct simple_pid_list * next
static LONGEST spu_enumerate_spu_ids(int pid, gdb_byte *buf, ULONGEST offset, ULONGEST len)
#define PTRACE_O_TRACEVFORK
int(* to_remove_vfork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
int(* to_supports_stopped_by_sw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
int linux_ptrace_get_extended_event(int wstat)
static int linux_nat_can_async_p(struct target_ops *ops)
static int linux_async_pipe(int enable)
static int report_thread_events
enum resume_kind last_resume_kind
static int num_lwps(int pid)
static void linux_resume_one_lwp(struct lwp_info *lp, int step, enum gdb_signal signo)
static char * linux_nat_fileio_readlink(struct target_ops *self, struct inferior *inf, const char *filename, int *target_errno)
#define PTRACE_EVENT_CLONE
ptid_t pid_to_ptid(int pid)
int host_to_fileio_error(int error)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
static int linux_child_set_syscall_catchpoint(struct target_ops *self, int pid, bool needed, int any_count, gdb::array_view< const int > syscall_counts)
int(* to_insert_exec_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
void linux_nat_set_prepare_to_resume(struct target_ops *t, void(*prepare_to_resume)(struct lwp_info *))
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
int software_breakpoint_inserted_here_p(const address_space *aspace, CORE_ADDR pc)
void store_waitstatus(struct target_waitstatus *ourstatus, int hoststatus)
int catching_syscall_number(int syscall_number)
ptid_t current_lwp_ptid(void)
static pid_t linux_nat_fileio_pid_of(struct inferior *inf)
static int(* linux_nat_status_is_event)(int status)
static void async_file_flush(void)
struct inferior * find_inferior_pid(int pid)
static void purge_lwp_list(int pid)
int gdb_signal_to_host(enum gdb_signal)
enum gdb_signal gdb_signal_from_host(int)
int linux_proc_pid_is_stopped(pid_t pid)
char * linux_proc_pid_to_exec_file(int pid)
static void maybe_clear_ignore_sigint(struct lwp_info *lp)
static int linux_nat_supports_stopped_by_hw_breakpoint(struct target_ops *ops)
struct target_waitstatus pending_follow
static sigset_t suspend_mask
void target_mourn_inferior(ptid_t ptid)
enum target_xfer_status target_xfer_partial_ftype(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)
static VEC(static_tracepoint_marker_p)
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
static int linux_child_follow_fork(struct target_ops *ops, int follow_child, int detach_fork)
int linux_common_core_of_thread(ptid_t ptid)
gdb_file_up gdb_fopen_cloexec(const char *filename, const char *opentype)
int(* to_insert_fork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
#define target_is_async_p()
static int startswith(const char *string, const char *pattern)
void linux_nat_add_target(struct target_ops *t)
int agent_run_command(int pid, const char *cmd, int len)
static unsigned int debug_linux_nat
int gdbarch_addr_bit(struct gdbarch *gdbarch)
const char * gdb_signal_to_name(enum gdb_signal)
static int linux_nat_stopped_by_sw_breakpoint(struct target_ops *ops)
static enum target_xfer_status linux_nat_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)
void linux_stop_and_wait_all_lwps(void)
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)
static int linux_nat_stopped_data_address(struct target_ops *ops, CORE_ADDR *addr_p)
#define PTRACE_O_TRACEFORK
static int(* linux_nat_siginfo_fixup)(siginfo_t *, gdb_byte *, int)
static struct thread_info * new_thread(struct inferior *inf, ptid_t ptid)
void printf_unfiltered(const char *format,...)
struct cmd_list_element * setdebuglist
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
char * status_to_str(int status)
#define PTRACE_O_TRACEEXEC
void(* to_async)(struct target_ops *, int) TARGET_DEFAULT_NORETURN(tcomplain())
static ptid_t linux_nat_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int target_options)
struct target_ops * linux_target(void)
static int linux_child_insert_fork_catchpoint(struct target_ops *self, int pid)
long ptid_get_lwp(const ptid_t &ptid)
static int sigtrap_is_event(int status)
static void check_zombie_leaders(void)
const address_space * aspace() const
char *(* to_pid_to_exec_file)(struct target_ops *, int pid) TARGET_DEFAULT_RETURN(NULL)
int linux_supports_tracefork(void)
void linux_nat_set_siginfo_fixup(struct target_ops *t, int(*siginfo_fixup)(siginfo_t *, gdb_byte *, int))
int lwp_is_stopped(struct lwp_info *lwp)
enum target_waitkind syscall_state
int linux_mntns_unlink(pid_t pid, const char *filename)
CORE_ADDR stopped_data_address
static int linux_nat_ptrace_options(int attached)
LONGEST linux_common_xfer_osdata(const char *annex, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static int linux_nat_supports_multi_process(struct target_ops *self)
static int linux_nat_stop_lwp(struct lwp_info *lwp, void *data)
int(* to_always_non_stop_p)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
#define PTRACE_GETSIGINFO
static ptid_t linux_nat_wait_1(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int target_options)
int signal_pass_state(int signo)
#define USE_SIGTRAP_SIGINFO
static void kill_one_lwp(pid_t pid)
int(* to_fileio_open)(struct target_ops *, struct inferior *inf, const char *filename, int flags, int mode, int warn_if_slow, int *target_errno)
static void siginfo_fixup(siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
static void linux_nat_kill(struct target_ops *ops)
void throw_exception(struct gdb_exception exception)
#define buffer_grow_str0(BUFFER, STRING)
static enum target_xfer_status linux_proc_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len)
void linux_nat_set_status_is_event(struct target_ops *t, int(*status_is_event)(int status))
int ptid_lwp_p(const ptid_t &ptid)
#define GDB_ARCH_IS_TRAP_BRKPT(X)
static int lwp_status_pending_p(struct lwp_info *lp)
int linux_proc_pid_is_gone(pid_t pid)
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
static htab_t lwp_lwpid_htab
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
void buffer_init(struct buffer *buffer)
struct simple_pid_list * stopped_pids
static void show_debug_linux_nat(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
#define ALL_NON_EXITED_THREADS(T)
static int linux_nat_supports_stopped_by_sw_breakpoint(struct target_ops *ops)
static int linux_child_insert_vfork_catchpoint(struct target_ops *self, int pid)
void(* to_pass_signals)(struct target_ops *, int, unsigned char *TARGET_DEBUG_PRINTER(target_debug_print_signals)) TARGET_DEFAULT_IGNORE()
void(* to_stop)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
static int linux_nat_supports_non_stop(struct target_ops *self)
void registers_changed_ptid(ptid_t ptid)
int xsnprintf(char *str, size_t size, const char *format,...)
static int linux_nat_is_async_p(struct target_ops *ops)
int target_async_permitted
static struct lwp_info * add_initial_lwp(ptid_t ptid)
enum target_waitkind kind
static const char * linux_nat_pid_to_str(struct target_ops *ops, ptid_t ptid)
static int linux_nat_thread_alive(struct target_ops *ops, ptid_t ptid)
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
#define PTRACE_SETSIGINFO
static void linux_target_install_ops(struct target_ops *t)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
void linux_enable_event_reporting(pid_t pid, int options)
#define PTRACE_EVENT_VFORK
static int check_ptrace_stopped_lwp_gone(struct lwp_info *lp)
char * safe_strerror(int)
int(* to_stopped_by_sw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
void linux_disable_event_reporting(pid_t pid)
const char * target_pid_to_str(ptid_t ptid)
int linux_supports_tracevforkdone(void)
int hardware_breakpoint_inserted_here_p(const address_space *aspace, CORE_ADDR pc)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void registers_changed(void)
void(* to_post_attach)(struct target_ops *, int) TARGET_DEFAULT_IGNORE()
int(* to_can_async_p)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
static void linux_nat_update_thread_list(struct target_ops *ops)
static constexpr ptid_t lwp
static void linux_child_post_attach(struct target_ops *self, int pid)
static struct lwp_info * find_lwp_pid(ptid_t ptid)
LONGEST gdbarch_get_syscall_number(struct gdbarch *gdbarch, ptid_t ptid)
int parse_pid_to_attach(const char *args)
static int kill_callback(struct lwp_info *lp, void *data)
int(* to_stopped_by_watchpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
int linux_proc_pid_is_zombie(pid_t pid)
static int linux_nat_stopped_by_watchpoint(struct target_ops *ops)
static int linux_handle_syscall_trap(struct lwp_info *lp, int stopping)
void(* to_terminal_ours)(struct target_ops *) TARGET_DEFAULT_IGNORE()
int gdb_open_cloexec(const char *filename, int flags, unsigned long mode)
int(* to_stopped_by_hw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
enum target_stop_reason stop_reason
struct inferior * current_inferior(void)
static int linux_nat_post_attach_wait(ptid_t ptid, int *signalled)
void(* to_terminal_inferior)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static void linux_nat_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signo)
static void restore_child_signals_mask(sigset_t *prev_mask)
void delete_exited_threads(void)
int ptid_match(const ptid_t &ptid, const ptid_t &filter)
unsigned long long ULONGEST
static void linux_nat_terminal_ours(struct target_ops *self)
static int kill_lwp(int lwpid, int signo)
static void lwp_free(struct lwp_info *lp)
int my_waitpid(int pid, int *status, int flags)
void clear_sigint_trap(void)
#define PTRACE_O_TRACESYSGOOD
int linux_mntns_open_cloexec(pid_t pid, const char *filename, int flags, mode_t mode)
static int linux_nat_always_non_stop_p(struct target_ops *self)
static int async_terminal_is_ours
static void delete_lwp(ptid_t ptid)
int(* to_supports_non_stop)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
const char * gdb_signal_to_string(enum gdb_signal)
void linux_nat_switch_fork(ptid_t new_ptid)
static int check_stopped_by_watchpoint(struct lwp_info *lp)
void lwp_set_arch_private_info(struct lwp_info *lwp, struct arch_lwp_info *info)
struct cmd_list_element * showdebuglist
int(* to_fileio_unlink)(struct target_ops *, struct inferior *inf, const char *filename, int *target_errno)
void linux_proc_attach_tgid_threads(pid_t pid, linux_proc_attach_lwp_func attach_lwp)
static void exit_lwp(struct lwp_info *lp)
static int wait_lwp(struct lwp_info *lp)
ssize_t linux_mntns_readlink(pid_t pid, const char *filename, char *buf, size_t bufsiz)
struct fork_info * find_fork_pid(pid_t pid)
struct target_waitstatus waitstatus
int lwp_is_stepping(struct lwp_info *lwp)
void(* to_create_inferior)(struct target_ops *, const char *, const std::string &, char **, int)
static void kill_wait_one_lwp(pid_t pid)
int(* to_insert_vfork_catchpoint)(struct target_ops *, int) TARGET_DEFAULT_RETURN(1)
int to_has_thread_control
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
static int stop_callback(struct lwp_info *lp, void *data)
static int linux_nat_supports_disable_randomization(struct target_ops *self)
void linux_nat_set_forget_process(struct target_ops *t, linux_nat_forget_process_ftype *fn)
void(* to_attach)(struct target_ops *ops, const char *, int)
int() iterate_over_lwps_ftype(struct lwp_info *lwp, void *arg)
static linux_nat_new_fork_ftype * linux_nat_new_fork
int(* to_stopped_data_address)(struct target_ops *, CORE_ADDR *) TARGET_DEFAULT_RETURN(0)
static int linux_child_insert_exec_catchpoint(struct target_ops *self, int pid)
static void select_event_lwp(ptid_t filter, struct lwp_info **orig_lp, int *status)
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
void inf_ptrace_detach_success(struct target_ops *ops)
struct lwp_info * iterate_over_lwps(ptid_t filter, iterate_over_lwps_ftype callback, void *data)
int stopped_data_address_p
#define target_thread_architecture(ptid)
char * buffer_finish(struct buffer *buffer)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_FUNC(default_target_wait)
void linux_nat_set_delete_thread(struct target_ops *t, void(*delete_thread)(struct arch_lwp_info *))
#define PTRACE_O_EXITKILL
static void detach_one_lwp(struct lwp_info *lp, int *signo_p)
void parse_static_tracepoint_marker_definition(const char *line, const char **pp, struct static_tracepoint_marker *marker)
void set_executing(ptid_t ptid, int executing)
static int count_events_callback(struct lwp_info *lp, void *data)
void error(const char *fmt,...)
const char *(* to_thread_name)(struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN(NULL)
void delete_file_handler(int fd)
int linux_supports_tracesysgood(void)
char *(* to_fileio_readlink)(struct target_ops *, struct inferior *inf, const char *filename, int *target_errno)
static int stop_wait_callback(struct lwp_info *lp, void *data)
void target_continue_no_signal(ptid_t ptid)
void throw_error(enum errors error, const char *fmt,...)
static int lwp_lwpid_htab_eq(const void *a, const void *b)
void do_cleanups(struct cleanup *old_chain)
int is_executing(ptid_t ptid)
void linux_nat_forget_process(pid_t pid)
int(* to_filesystem_is_local)(struct target_ops *) TARGET_DEFAULT_RETURN(1)
target_xfer_partial_ftype memory_xfer_auxv
int(* to_supports_multi_process)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
void(* to_post_startup_inferior)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
struct target_ops * linux_trad_target(CORE_ADDR(*register_u_offset)(struct gdbarch *, int, int))
static void save_stop_reason(struct lwp_info *lp)
static int resume_set_callback(struct lwp_info *lp, void *data)
int linux_proc_pid_is_trace_stopped_nowarn(pid_t pid)
static void linux_child_post_startup_inferior(struct target_ops *self, ptid_t ptid)
void check_for_thread_db(void)