29 #include <sys/ptrace.h>
34 #include <sys/ioctl.h>
37 #include <sys/syscall.h>
59 #define SPUFS_MAGIC 0x23c9b64e
62 #ifdef HAVE_PERSONALITY
63 # include <sys/personality.h>
64 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
65 # define ADDR_NO_RANDOMIZE 0x0040000
74 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
86 #if !(defined(PT_TEXT_ADDR) \
87 || defined(PT_DATA_ADDR) \
88 || defined(PT_TEXT_END_ADDR))
89 #if defined(__mcoldfire__)
91 #define PT_TEXT_ADDR 49*4
92 #define PT_DATA_ADDR 50*4
93 #define PT_TEXT_END_ADDR 51*4
96 #define PT_TEXT_ADDR 220
97 #define PT_TEXT_END_ADDR 224
98 #define PT_DATA_ADDR 228
100 #elif defined(__TMS320C6X__)
101 #define PT_TEXT_ADDR (0x10000*4)
102 #define PT_DATA_ADDR (0x10004*4)
103 #define PT_TEXT_END_ADDR (0x10008*4)
107 #ifdef HAVE_LINUX_BTRACE
112 #ifndef HAVE_ELF32_AUXV_T
127 #ifndef HAVE_ELF64_AUXV_T
179 enum target_stop_reason
212 new_pid->
next = *listp;
221 for (p = listp; *p != NULL; p = &(*p)->
next)
222 if ((*p)->pid == pid)
257 int step,
int signal, siginfo_t *info);
262 int *wstat,
int options);
270 static int kill_lwp (
unsigned long lwpid,
int signo);
328 #define target_is_async_p() (linux_event_pipe[0] != -1)
338 if (header->e_ident[EI_MAG0] == ELFMAG0
339 && header->e_ident[EI_MAG1] == ELFMAG1
340 && header->e_ident[EI_MAG2] == ELFMAG2
341 && header->e_ident[EI_MAG3] == ELFMAG3)
343 *machine = header->e_machine;
344 return header->e_ident[EI_CLASS] == ELFCLASS64;
361 fd = open (file, O_RDONLY);
365 if (read (fd, &header,
sizeof (header)) !=
sizeof (header))
383 sprintf (file,
"/proc/%d/exe", pid);
437 unsigned long new_pid;
454 else if (ret != new_pid)
455 warning (
"wait returned unexpected PID %d", ret);
457 warning (
"wait returned unexpected status 0x%x", status);
492 child_thr->
last_status.kind = TARGET_WAITKIND_STOPPED;
511 child_proc->
tdesc = tdesc;
519 event_lwp->
waitstatus.kind = TARGET_WAITKIND_FORKED;
521 event_lwp->
waitstatus.kind = TARGET_WAITKIND_VFORKED;
523 event_lwp->
waitstatus.value.related_pid = ptid;
537 "from LWP %ld, new child is LWP %ld\n",
569 event_lwp->
waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
575 internal_error (__FILE__, __LINE__,
_(
"unknown ptrace event %d"), event);
585 struct regcache *regcache;
634 #if USE_SIGTRAP_SIGINFO
648 #if USE_SIGTRAP_SIGINFO
652 if (siginfo.si_signo == SIGTRAP)
660 debug_printf (
"CSBB: %s stopped by software breakpoint\n",
665 if (pc != sw_breakpoint_pc)
667 struct regcache *regcache
672 lwp->
stop_pc = sw_breakpoint_pc;
673 lwp->
stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
684 "breakpoint/watchpoint\n",
689 lwp->
stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
693 else if (siginfo.si_code == TRAP_TRACE)
719 debug_printf (
"CSBB: %s stopped by software breakpoint\n",
724 if (pc != sw_breakpoint_pc)
726 struct regcache *regcache
731 lwp->
stop_pc = sw_breakpoint_pc;
732 lwp->
stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
743 debug_printf (
"CSBB: %s stopped by hardware breakpoint\n",
748 lwp->
stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
765 lwp->
waitstatus.kind = TARGET_WAITKIND_IGNORE;
784 struct cleanup *restore_personality
787 #if defined(__UCLIBC__) && defined(HAS_NOMMU)
812 open (
"/dev/null", O_RDONLY);
814 if (write (2,
"stdin/stdout redirected\n",
815 sizeof (
"stdin/stdout redirected\n") - 1) < 0)
821 execv (program, allargs);
823 execvp (program, allargs);
825 fprintf (stderr,
"Cannot exec %s: %s.\n", program,
955 "thread is gone (%d: %s)\n",
961 warning (
_(
"Cannot attach to lwp %d: %s"),
984 error (
"Cannot attach to process %ld: %s",
1025 if (++counter->
count > 1)
1067 int save_errno =
errno;
1069 debug_printf (
"LKL: kill_lwp (SIGKILL) %s, 0, 0 (%s)\n",
1071 save_errno ?
strerror (save_errno) :
"OK");
1078 int save_errno =
errno;
1082 save_errno ?
strerror (save_errno) :
"OK");
1098 debug_printf (
"kwl: killing lwp %d, for pid: %d\n", lwpid, pid);
1119 if (res == -1 &&
errno == ECHILD)
1125 if (res < 0 &&
errno != ECHILD)
1137 int pid = * (
int *) args;
1166 if (process == NULL)
1203 enum gdb_signal signo = GDB_SIGNAL_0;
1214 if (thread->
last_status.kind != TARGET_WAITKIND_STOPPED
1226 debug_printf (
"GPS: lwp %s hasn't stopped: no pending signal\n",
1236 "status: no pending signal\n",
1246 debug_printf (
"GPS: lwp %s had signal %s, but it is in nopass state\n",
1255 && (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
1259 "but we don't know if we should pass it. "
1260 "Default to not.\n",
1268 debug_printf (
"GPS: lwp %s has pending signal %s: delivering it.\n",
1281 int pid = * (
int *) args;
1309 error (
_(
"Can't detach %s: %s"),
1323 if (process == NULL)
1337 #ifdef USE_THREAD_DB
1374 #ifdef USE_THREAD_DB
1381 priv = process->
priv;
1384 process->
priv = NULL;
1398 }
while (ret != -1 ||
errno != ECHILD);
1431 && thread->
last_status.kind != TARGET_WAITKIND_IGNORE)
1435 && (lp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
1436 || lp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
1457 #if !USE_SIGTRAP_SIGINFO
1458 else if (lp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
1466 else if (lp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT
1481 debug_printf (
"discarding pending breakpoint status\n");
1623 pid_t leader_pid =
pid_of (proc);
1630 "num_lwps=%d, zombie=%d\n",
1631 leader_pid, leader_lp!= NULL,
num_lwps (leader_pid),
1634 if (leader_lp != NULL
1670 "CZL: Thread group leader %d zombie "
1671 "(it exited, or another thread execd).\n",
1710 debug_printf (
"LWP %ld has a suspiciously high suspend count,"
1727 "unsuspend LWP %ld, suspended=%d\n",
lwpid_of (thread),
1741 int tpoint_related_event = 0;
1770 if (tpoint_related_event)
1825 debug_printf (
"Checking whether LWP %ld needs to move out of the "
1851 debug_printf (
"Checking whether LWP %ld needs to move out of "
1852 "the jump pad...it does\n",
1874 struct regcache *regcache;
1887 && (uintptr_t) info.si_addr == lwp->
stop_pc)
1889 info.si_addr = (
void *) (uintptr_t) status.
tpoint_addr;
1906 debug_printf (
"Cancelling fast exit-jump-pad: removing bkpt. "
1907 "stopping all threads momentarily.\n");
1922 debug_printf (
"Checking whether LWP %ld needs to move out of the "
1953 debug_printf (
" (no more currently queued signals)\n");
1970 debug_printf (
"Not requeuing already queued non-RT signal %d"
1979 p_sig =
xmalloc (
sizeof (*p_sig));
1982 memset (&p_sig->
info, 0, sizeof (siginfo_t));
2002 while ((*p_sig)->prev != NULL)
2003 p_sig = &(*p_sig)->
prev;
2006 if ((*p_sig)->info.si_signo != 0)
2013 debug_printf (
"Reporting deferred signal %d for LWP %ld.\n",
2062 child->
stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
2074 return child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
2105 int have_stop_pc = 0;
2118 else if (child == NULL)
2221 && child->
stop_reason != TARGET_STOPPED_BY_SW_BREAKPOINT)
2239 debug_printf (
"LLW: resume_stop SIGSTOP caught for %s.\n",
2248 "while stopping threads.\n",
2256 debug_printf (
"LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
2257 child->
stepping ?
"step" :
"continue",
2283 && thread->
last_status.kind == TARGET_WAITKIND_IGNORE)
2288 debug_printf (
"RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n",
2308 int *wstatp,
int options)
2311 struct lwp_info *event_child, *requested_child;
2312 sigset_t block_mask, prev_mask;
2317 event_thread = NULL;
2319 requested_child = NULL;
2327 if (event_thread != NULL)
2351 "requesting an event out of a"
2352 " suspended child?");
2357 event_child = requested_child;
2362 if (event_child != NULL)
2365 debug_printf (
"Got an event from pending child %ld (%04x)\n",
2383 sigfillset (&block_mask);
2384 sigprocmask (SIG_BLOCK, &block_mask, &prev_mask);
2389 while (event_child == NULL)
2410 debug_printf (
"LWFE: waitpid(-1, ...) returned %d, %s\n",
2439 if (event_thread != NULL)
2461 &wait_ptid) == NULL))
2465 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2475 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2483 sigsuspend (&prev_mask);
2484 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2488 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2499 "Process %ld exiting.\n",
2533 if (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2548 if (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2563 int *selector = data;
2568 if (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2570 if ((*selector)-- == 0)
2582 int random_selector;
2599 if (event_thread != NULL)
2606 if (event_thread == NULL)
2617 random_selector = (int)
2618 ((num_events * (
double) rand ()) / (RAND_MAX + 1.0));
2621 debug_printf (
"SEL: Found %d SIGTRAP events, selecting #%d\n",
2622 num_events, random_selector);
2630 if (event_thread != NULL)
2635 *orig_lp = event_lp;
2669 struct target_waitstatus *ourstatus,
2670 int target_options);
2712 if (thread_stuck != NULL)
2715 debug_printf (
"can't stabilize, LWP %ld is stuck in jump pad\n",
2722 stabilizing_threads = 1;
2730 struct target_waitstatus ourstatus;
2739 if (ourstatus.kind == TARGET_WAITKIND_STOPPED)
2746 if (ourstatus.value.sig != GDB_SIGNAL_0
2757 stabilizing_threads = 0;
2767 if (thread_stuck != NULL)
2768 debug_printf (
"couldn't stabilize, LWP %ld got stuck in jump pad\n",
2786 ourstatus->kind = TARGET_WAITKIND_IGNORE;
2794 struct target_waitstatus *ourstatus,
int target_options)
2800 int step_over_finished;
2801 int bp_explains_trap;
2802 int maybe_internal_trap;
2815 if (target_options & TARGET_WNOHANG)
2818 bp_explains_trap = 0;
2821 ourstatus->kind = TARGET_WAITKIND_IGNORE;
2828 debug_printf (
"step_over_bkpt set [%s], doing a blocking wait\n",
2835 gdb_assert (target_options & TARGET_WNOHANG);
2840 "TARGET_WAITKIND_IGNORE\n");
2844 ourstatus->kind = TARGET_WAITKIND_IGNORE;
2852 "TARGET_WAITKIND_NO_RESUMED\n");
2856 ourstatus->kind = TARGET_WAITKIND_NO_RESUMED;
2868 ourstatus->kind = TARGET_WAITKIND_EXITED;
2882 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
2887 debug_printf (
"linux_wait_1 ret = %s, terminated with "
2905 && event_child->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
2911 debug_printf (
"step-over for %s executed software breakpoint\n",
2915 if (increment_pc != 0)
2917 struct regcache *regcache
2920 event_child->
stop_pc += increment_pc;
2924 event_child->
stop_reason = TARGET_STOPPED_BY_NO_REASON;
2940 if (maybe_internal_trap)
2965 if (bp_explains_trap)
2997 debug_printf (
"Got signal %d for LWP %ld. Check if we need "
2998 "to defer or adjust it.\n",
3008 debug_printf (
"Signal %d for LWP %ld deferred (in jump pad)\n",
3020 debug_printf (
"LWP %ld was trying to move out of the jump pad (%d). "
3021 "Check if we're already there.\n",
3036 debug_printf (
"No longer need exit-jump-pad bkpt; removing it."
3037 "stopping all threads momentarily.\n");
3061 "collecting successfully.\n");
3074 if (stabilizing_threads)
3076 ourstatus->kind = TARGET_WAITKIND_STOPPED;
3077 ourstatus->value.sig = GDB_SIGNAL_0;
3082 "while stabilizing threads\n",
3119 siginfo_t info, *info_p;
3131 if (step_over_finished)
3169 report_to_gdb = (!maybe_internal_trap
3172 || event_child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT
3174 && !bp_explains_trap
3176 && !step_over_finished
3178 && event_child->
stop_reason == TARGET_STOPPED_BY_SINGLE_STEP))
3182 || event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE);
3193 if (bp_explains_trap)
3195 if (step_over_finished)
3200 debug_printf (
"Range stepping pc 0x%s [0x%s, 0x%s).\n",
3212 struct regcache *regcache
3225 if (step_over_finished)
3234 if (event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE)
3238 str = target_waitstatus_to_string (&event_child->
waitstatus);
3239 debug_printf (
"LWP %ld: extended event with waitstatus %s\n",
3246 debug_printf (
"GDB wanted to single-step, reporting event.\n");
3248 debug_printf (
"Out of step range, reporting event.\n");
3250 if (event_child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
3260 if (!stabilizing_threads)
3284 if (step_over_finished)
3318 if (step_over_finished)
3322 if (event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE)
3328 event_child->
waitstatus.kind = TARGET_WAITKIND_IGNORE;
3331 ourstatus->kind = TARGET_WAITKIND_STOPPED;
3336 if (event_child->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
3343 struct regcache *regcache
3355 ourstatus->value.sig = GDB_SIGNAL_0;
3364 else if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
3375 ourstatus->kind, ourstatus->value.sig);
3390 ret = read (linux_event_pipe[0], &buf, 1);
3391 while (ret >= 0 || (ret == -1 &&
errno == EINTR));
3403 ret = write (linux_event_pipe[1],
"+", 1);
3404 while (ret == 0 || (ret == -1 &&
errno == EINTR));
3412 struct target_waitstatus *ourstatus,
int target_options)
3422 event_ptid =
linux_wait_1 (ptid, ourstatus, target_options);
3424 while ((target_options & TARGET_WNOHANG) == 0
3426 && ourstatus->kind == TARGET_WAITKIND_IGNORE);
3431 && (target_options & TARGET_WNOHANG) != 0
3448 static int tkill_failed;
3455 ret = syscall (__NR_tkill, lwpid, signo);
3456 if (
errno != ENOSYS)
3463 return kill (lwpid, signo);
3484 debug_printf (
"Have pending sigstop for lwp %d\n", pid);
3542 lwp->
waitstatus.kind = TARGET_WAITKIND_EXITED;
3547 lwp->
waitstatus.kind = TARGET_WAITKIND_SIGNALLED;
3580 if (saved_thread != NULL)
3581 saved_tid = saved_thread->
entry.
id;
3631 "LWP %ld is suspended, suspended=%d\n",
3640 || lwp->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT
3656 "LWP %ld is suspended, suspended=%d\n",
3669 && lwp->
stop_reason != TARGET_STOPPED_BY_WATCHPOINT
3674 debug_printf (
"LWP %ld needs stabilizing (in jump pad)\n",
3723 suspend ?
"stop-and-suspend" :
"stop",
3729 stopping_threads = (suspend
3742 debug_printf (
"stop_all_lwps done, setting stopping_threads "
3743 "back to !stopping\n");
3756 p_sig =
xmalloc (
sizeof (*p_sig));
3760 memset (&p_sig->
info, 0, sizeof (siginfo_t));
3762 memcpy (&p_sig->
info, info, sizeof (siginfo_t));
3771 int step,
int signal, siginfo_t *info)
3775 int fast_tp_collecting;
3782 gdb_assert (!stabilizing_threads || fast_tp_collecting);
3800 || fast_tp_collecting))
3803 p_sig =
xmalloc (
sizeof (*p_sig));
3807 memset (&p_sig->
info, 0, sizeof (siginfo_t));
3809 memcpy (&p_sig->
info, info, sizeof (siginfo_t));
3816 debug_printf (
"Not resuming lwp %ld (%s, signal %d, stop %s);"
3817 " has pending status\n",
3818 lwpid_of (thread), step ?
"step" :
"continue", signal,
3827 debug_printf (
"Resuming lwp %ld (%s, signal %d, stop %s)\n",
3828 lwpid_of (thread), step ?
"step" :
"continue", signal,
3849 if (fast_tp_collecting == 0)
3852 fprintf (stderr,
"BAD - reinserting but not stepping.\n");
3854 fprintf (stderr,
"BAD - reinserting and suspended(%d).\n",
3865 if (fast_tp_collecting == 1)
3868 debug_printf (
"lwp %ld wants to get out of fast tracepoint jump pad"
3869 " (exit-jump-pad-bkpt)\n",
3875 else if (fast_tp_collecting == 2)
3878 debug_printf (
"lwp %ld wants to get out of fast tracepoint jump pad"
3879 " single-stepping\n",
3887 "moving out of jump pad single-stepping"
3888 " not implemented on this target");
3907 debug_printf (
"lwp %ld has a while-stepping action -> forcing step.\n",
3920 debug_printf (
" %s from pc 0x%lx\n", step ?
"step" :
"continue",
3930 && fast_tp_collecting == 0)
3935 while ((*p_sig)->prev != NULL)
3936 p_sig = &(*p_sig)->
prev;
3938 signal = (*p_sig)->
signal;
3939 if ((*p_sig)->info.si_signo != 0)
3953 ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT,
lwpid_of (thread),
4011 int step,
int signal, siginfo_t *info)
4050 for (ndx = 0; ndx < r->
n; ndx++)
4067 == TARGET_WAITKIND_STOPPED)
4091 debug_printf (
"Dequeueing deferred signal %d for LWP %ld, "
4092 "leaving status pending.\n",
4122 * (
int *) flag_p = 1;
4146 debug_printf (
"Need step over [LWP %ld]? Ignoring, not stopped\n",
4154 debug_printf (
"Need step over [LWP %ld]? Ignoring, should remain"
4165 debug_printf (
"Need step over [LWP %ld]? Ignoring, suspended\n",
4179 debug_printf (
"Need step over [LWP %ld]? Ignoring, has pending"
4197 debug_printf (
"Need step over [LWP %ld]? Cancelling, PC was changed. "
4198 "Old stop_pc was 0x%s, PC is now 0x%s\n",
4220 debug_printf (
"Need step over [LWP %ld]? yes, but found"
4221 " GDB breakpoint at 0x%s; skipping step over\n",
4231 "found breakpoint at 0x%s\n",
4247 debug_printf (
"Need step over [LWP %ld]? No, no breakpoint found"
4281 debug_printf (
"Starting step-over on LWP %ld. Stopping all threads\n",
4289 "LWP %ld suspended=%d\n",
lwpid_of (thread),
4294 debug_printf (
"Done stopping all threads for step-over.\n");
4325 step_over_bkpt = thread->
entry.
id;
4379 debug_printf (
"detach: step over in progress, finish it first\n");
4415 int leave_all_stopped = * (
int *) arg;
4465 thread->
last_status.kind = TARGET_WAITKIND_IGNORE;
4479 || leave_all_stopped);
4498 p_sig =
xmalloc (
sizeof (*p_sig));
4501 memset (&p_sig->
info, 0, sizeof (siginfo_t));
4516 thread->
last_status.kind = TARGET_WAITKIND_IGNORE;
4527 int leave_all_stopped;
4558 leave_all_stopped = (need_step_over != NULL || any_pending);
4562 if (need_step_over != NULL)
4564 else if (any_pending)
4566 "an LWP with pending status\n");
4568 debug_printf (
"Resuming, no pending status or step over needed\n");
4615 && thread->
last_status.kind != TARGET_WAITKIND_IGNORE)
4618 debug_printf (
" client wants LWP to remain %ld stopped\n",
4626 debug_printf (
" LWP %ld has pending status, leaving stopped\n",
4656 "Making sure it has a SIGSTOP pending\n",
4665 debug_printf (
" stepping LWP %ld, client wants it stepping\n",
4717 if (need_step_over != NULL)
4721 "thread %ld needing a step-over\n",
4746 debug_printf (
"unstopping all lwps, except=(LWP %ld)\n",
4765 #ifdef HAVE_LINUX_REGSETS
4767 #define use_linux_regsets 1
4772 regset_disabled (
struct regsets_info *info,
struct regset_info *regset)
4774 return (info->disabled_regsets != NULL
4775 && info->disabled_regsets[regset - info->regsets]);
4781 disable_regset (
struct regsets_info *info,
struct regset_info *regset)
4785 dr_offset = regset - info->regsets;
4786 if (info->disabled_regsets == NULL)
4787 info->disabled_regsets =
xcalloc (1, info->num_regsets);
4788 info->disabled_regsets[dr_offset] = 1;
4793 struct regcache *regcache)
4795 struct regset_info *regset;
4796 int saw_general_regs = 0;
4801 for (regset = regsets_info->regsets; regset->size >= 0; regset++)
4806 if (regset->size == 0 || regset_disabled (regsets_info, regset))
4811 nt_type = regset->nt_type;
4815 iov.iov_len = regset->size;
4816 data = (
void *) &iov;
4822 res = ptrace (regset->get_request, pid,
4825 res = ptrace (regset->get_request, pid, data, nt_type);
4833 disable_regset (regsets_info, regset);
4835 else if (
errno == ENODATA)
4844 sprintf (s,
"ptrace(regsets_fetch_inferior_registers) PID=%d",
4851 if (regset->type == GENERAL_REGS)
4852 saw_general_regs = 1;
4853 regset->store_function (regcache, buf);
4857 if (saw_general_regs)
4865 struct regcache *regcache)
4867 struct regset_info *regset;
4868 int saw_general_regs = 0;
4873 for (regset = regsets_info->regsets; regset->size >= 0; regset++)
4878 if (regset->size == 0 || regset_disabled (regsets_info, regset)
4879 || regset->fill_function == NULL)
4888 nt_type = regset->nt_type;
4892 iov.iov_len = regset->size;
4893 data = (
void *) &iov;
4899 res = ptrace (regset->get_request, pid,
4902 res = ptrace (regset->get_request, pid, data, nt_type);
4908 regset->fill_function (regcache, buf);
4912 res = ptrace (regset->set_request, pid,
4915 res = ptrace (regset->set_request, pid, data, nt_type);
4925 disable_regset (regsets_info, regset);
4927 else if (
errno == ESRCH)
4938 perror (
"Warning: ptrace(regsets_store_inferior_registers)");
4941 else if (regset->type == GENERAL_REGS)
4942 saw_general_regs = 1;
4945 if (saw_general_regs)
4953 #define use_linux_regsets 0
4954 #define regsets_fetch_inferior_registers(regsets_info, regcache) 1
4955 #define regsets_store_inferior_registers(regsets_info, regcache) 1
4965 unsigned char mask = 1 << (regno % 8);
4966 size_t index = regno / 8;
4973 #ifdef HAVE_LINUX_USRREGS
4976 register_addr (
const struct usrregs_info *usrregs,
int regnum)
4981 error (
"Invalid register number %d.", regnum);
4991 struct regcache *regcache,
int regno)
5003 regaddr = register_addr (usrregs, regno);
5017 ptrace (PTRACE_PEEKUSER, pid,
5035 struct regcache *regcache,
int regno)
5047 regaddr = register_addr (usrregs, regno);
5055 memset (buf, 0, size);
5066 ptrace (PTRACE_POKEUSER, pid,
5094 struct regcache *regcache,
int regno,
int all)
5100 for (regno = 0; regno < usr->
num_regs; regno++)
5102 fetch_register (usr, regcache, regno);
5105 fetch_register (usr, regcache, regno);
5115 struct regcache *regcache,
int regno,
int all)
5121 for (regno = 0; regno < usr->
num_regs; regno++)
5123 store_register (usr, regcache, regno);
5126 store_register (usr, regcache, regno);
5131 #define usr_fetch_inferior_registers(regs_info, regcache, regno, all) do {} while (0)
5132 #define usr_store_inferior_registers(regs_info, regcache, regno, all) do {} while (0)
5147 && regs_info->
usrregs != NULL)
5152 if (regs_info->
usrregs != NULL)
5165 if ((!use_regsets || all) && regs_info->
usrregs != NULL)
5181 if (regs_info->
usrregs != NULL)
5190 if ((!use_regsets || all) && regs_info->
usrregs != NULL)
5212 if (len >= 3 *
sizeof (
long))
5218 sprintf (filename,
"/proc/%d/mem", pid);
5228 bytes = pread64 (fd, myaddr, len, memaddr);
5231 if (lseek (fd, memaddr, SEEK_SET) != -1)
5232 bytes = read (fd, myaddr, len);
5263 buffer[i] = ptrace (PTRACE_PEEKTEXT, pid,
5314 char str[4 * 2 + 1];
5316 int dump = len < 4 ? len : 4;
5318 for (i = 0; i < dump; i++)
5320 sprintf (p,
"%02x", myaddr[i]);
5326 str, (
long) memaddr, pid);
5334 buffer[0] = ptrace (PTRACE_PEEKTEXT, pid,
5344 = ptrace (PTRACE_PEEKTEXT, pid,
5364 ptrace (PTRACE_POKETEXT, pid,
5379 #ifdef USE_THREAD_DB
5399 kill (-signal_pid, SIGINT);
5408 char filename[PATH_MAX];
5412 xsnprintf (filename,
sizeof filename,
"/proc/%d/auxv", pid);
5414 fd = open (filename, O_RDONLY);
5419 && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
5422 n = read (fd, myaddr, len);
5474 return (lwp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT);
5494 return (lwp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT);
5524 return lwp->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
5535 #if defined(__UCLIBC__) && defined(HAS_NOMMU) \
5536 && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
5537 && defined(PT_TEXT_END_ADDR)
5550 unsigned long text, text_end, data;
5557 text_end = ptrace (PTRACE_PEEKUSER, pid, (
PTRACE_TYPE_ARG3) PT_TEXT_END_ADDR,
5574 *data_p = data - (text_end - text);
5584 unsigned char *readbuf,
unsigned const char *writebuf,
5606 memcpy (siginfo, inf_siginfo,
sizeof (siginfo_t));
5608 memcpy (inf_siginfo, siginfo,
sizeof (siginfo_t));
5614 unsigned const char *writebuf,
CORE_ADDR offset,
int len)
5618 char inf_siginfo[
sizeof (siginfo_t)];
5627 readbuf != NULL ?
"Reading" :
"Writing",
5630 if (offset >=
sizeof (siginfo))
5642 if (offset + len >
sizeof (siginfo))
5643 len =
sizeof (siginfo) - offset;
5645 if (readbuf != NULL)
5646 memcpy (readbuf, inf_siginfo + offset, len);
5649 memcpy (inf_siginfo + offset, writebuf, len);
5668 int old_errno =
errno;
5676 if (write (2,
"sigchld_handler\n",
5677 sizeof (
"sigchld_handler\n") - 1) < 0)
5703 if (previous != enable)
5706 sigemptyset (&mask);
5707 sigaddset (&mask, SIGCHLD);
5709 sigprocmask (SIG_BLOCK, &mask, NULL);
5713 if (pipe (linux_event_pipe) == -1)
5715 linux_event_pipe[0] = -1;
5716 linux_event_pipe[1] = -1;
5717 sigprocmask (SIG_UNBLOCK, &mask, NULL);
5719 warning (
"creating event pipe failed.");
5723 fcntl (linux_event_pipe[0], F_SETFL, O_NONBLOCK);
5724 fcntl (linux_event_pipe[1], F_SETFL, O_NONBLOCK);
5737 close (linux_event_pipe[0]);
5738 close (linux_event_pipe[1]);
5739 linux_event_pipe[0] = -1;
5740 linux_event_pipe[1] = -1;
5743 sigprocmask (SIG_UNBLOCK, &mask, NULL);
5828 #ifdef HAVE_PERSONALITY
5858 struct dirent *entry;
5860 sprintf (path,
"/proc/%ld/fd", pid);
5861 dir = opendir (path);
5866 while ((entry = readdir (dir)) != NULL)
5872 fd = atoi (entry->d_name);
5876 sprintf (path,
"/proc/%ld/fd/%d", pid, fd);
5877 if (stat (path, &st) != 0)
5882 if (statfs (path, &stfs) != 0)
5887 if (pos >= offset && pos + 4 <= offset + len)
5889 *(
unsigned int *)(buf + pos - offset) = fd;
5903 unsigned const char *writebuf,
5911 if (!writebuf && !readbuf)
5922 sprintf (buf,
"/proc/%ld/fd/%s", pid, annex);
5923 fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
5928 && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
5935 ret = write (fd, writebuf, (
size_t) len);
5937 ret = read (fd, readbuf, (
size_t) len);
5943 #if defined PT_GETDSBT || defined PTRACE_GETFDPIC
5944 struct target_loadseg
5954 # if defined PT_GETDSBT
5955 struct target_loadmap
5960 unsigned *dsbt_table;
5961 unsigned dsbt_size, dsbt_index;
5965 struct target_loadseg segs[];
5967 # define LINUX_LOADMAP PT_GETDSBT
5968 # define LINUX_LOADMAP_EXEC PTRACE_GETDSBT_EXEC
5969 # define LINUX_LOADMAP_INTERP PTRACE_GETDSBT_INTERP
5971 struct target_loadmap
5978 struct target_loadseg segs[];
5980 # define LINUX_LOADMAP PTRACE_GETFDPIC
5981 # define LINUX_LOADMAP_EXEC PTRACE_GETFDPIC_EXEC
5982 # define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP
5987 unsigned char *myaddr,
unsigned int len)
5991 struct target_loadmap *data = NULL;
5992 unsigned int actual_length, copy_length;
5994 if (strcmp (annex,
"exec") == 0)
5995 addr = (int) LINUX_LOADMAP_EXEC;
5996 else if (strcmp (annex,
"interp") == 0)
5997 addr = (
int) LINUX_LOADMAP_INTERP;
6001 if (ptrace (LINUX_LOADMAP, pid, addr, &data) != 0)
6007 actual_length =
sizeof (
struct target_loadmap)
6008 + sizeof (struct target_loadseg) * data->nsegs;
6010 if (offset < 0 || offset > actual_length)
6013 copy_length = actual_length - offset < len ? actual_length - offset : len;
6014 memcpy (myaddr, (
char *) data + offset, copy_length);
6018 # define linux_read_loadmap NULL
6104 unsigned char *jjump_pad_insn,
6111 (tpoint, tpaddr, collector, lockaddr, orig_size,
6112 jump_entry, trampoline, trampoline_size,
6113 jjump_pad_insn, jjump_pad_insn_size,
6114 adjusted_insn_addr, adjusted_insn_addr_end,
6139 char filename[PATH_MAX];
6141 const int auxv_size = is_elf64
6145 xsnprintf (filename,
sizeof filename,
"/proc/%d/auxv", pid);
6147 fd = open (filename, O_RDONLY);
6153 while (read (fd, buf, auxv_size) == auxv_size
6154 && (*phdr_memaddr == 0 || *num_phdr == 0))
6188 if (*phdr_memaddr == 0 || *num_phdr == 0)
6190 warning (
"Unexpected missing AT_PHDR and/or AT_PHNUM: "
6191 "phdr_memaddr = %ld, phdr_num = %d",
6192 (
long) *phdr_memaddr, *num_phdr);
6206 unsigned char *phdr_buf;
6207 const int phdr_size = is_elf64 ?
sizeof (Elf64_Phdr) :
sizeof (Elf32_Phdr);
6213 phdr_buf =
alloca (num_phdr * phdr_size);
6221 for (i = 0; relocation == -1 && i < num_phdr; i++)
6224 Elf64_Phdr *
const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
6226 if (p->p_type == PT_PHDR)
6227 relocation = phdr_memaddr - p->p_vaddr;
6231 Elf32_Phdr *
const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
6233 if (p->p_type == PT_PHDR)
6234 relocation = phdr_memaddr - p->p_vaddr;
6237 if (relocation == -1)
6252 for (i = 0; i < num_phdr; i++)
6256 Elf64_Phdr *
const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
6258 if (p->p_type == PT_DYNAMIC)
6259 return p->p_vaddr + relocation;
6263 Elf32_Phdr *
const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
6265 if (p->p_type == PT_DYNAMIC)
6266 return p->p_vaddr + relocation;
6282 const int dyn_size = is_elf64 ?
sizeof (Elf64_Dyn) :
sizeof (Elf32_Dyn);
6283 unsigned char buf[
sizeof (Elf64_Dyn)];
6287 if (dynamic_memaddr == 0)
6294 Elf64_Dyn *
const dyn = (Elf64_Dyn *) buf;
6295 #ifdef DT_MIPS_RLD_MAP
6299 unsigned char buf[
sizeof (Elf64_Xword)];
6303 if (dyn->d_tag == DT_MIPS_RLD_MAP)
6306 rld_map.buf, sizeof (rld_map.buf)) == 0)
6313 if (dyn->d_tag == DT_DEBUG && map == -1)
6314 map = dyn->d_un.d_val;
6316 if (dyn->d_tag == DT_NULL)
6321 Elf32_Dyn *
const dyn = (Elf32_Dyn *) buf;
6322 #ifdef DT_MIPS_RLD_MAP
6326 unsigned char buf[
sizeof (Elf32_Word)];
6330 if (dyn->d_tag == DT_MIPS_RLD_MAP)
6333 rld_map.buf, sizeof (rld_map.buf)) == 0)
6340 if (dyn->d_tag == DT_DEBUG && map == -1)
6341 map = dyn->d_un.d_val;
6343 if (dyn->d_tag == DT_NULL)
6347 dynamic_memaddr += dyn_size;
6375 *ptr = addr.core_addr;
6376 else if (ptr_size ==
sizeof (
unsigned int))
6412 unsigned const char *writebuf,
6416 unsigned document_len;
6418 char filename[PATH_MAX];
6443 unsigned int machine;
6446 int allocated = 1024;
6448 CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
6449 int header_done = 0;
6451 if (writebuf != NULL)
6453 if (readbuf == NULL)
6457 xsnprintf (filename,
sizeof filename,
"/proc/%d/exe", pid);
6459 lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets;
6460 ptr_size = is_elf64 ? 8 : 4;
6462 while (annex[0] !=
'\0')
6468 sep = strchr (annex,
'=');
6475 else if (len == 4 &&
startswith (annex,
"prev"))
6479 annex = strchr (sep,
';');
6505 (
unsigned char *) &r_version,
6506 sizeof (r_version)) != 0
6509 warning (
"unexpected r_debug version %d", r_version);
6512 &lm_addr, ptr_size) != 0)
6514 warning (
"unable to read r_map from 0x%lx",
6520 document =
xmalloc (allocated);
6521 strcpy (document,
"<library-list-svr4 version=\"1.0\"");
6522 p = document + strlen (document);
6526 &l_name, ptr_size) == 0
6528 &l_addr, ptr_size) == 0
6530 &l_ld, ptr_size) == 0
6532 &l_prev, ptr_size) == 0
6534 &l_next, ptr_size) == 0)
6536 unsigned char libname[PATH_MAX];
6538 if (lm_prev != l_prev)
6540 warning (
"Corrupted shared library list: 0x%lx != 0x%lx",
6541 (
long) lm_prev, (
long) l_prev);
6553 sprintf (p,
" main-lm=\"0x%lx\"", (
unsigned long) lm_addr);
6562 libname[
sizeof (libname) - 1] =
'\0';
6563 if (libname[0] !=
'\0')
6566 size_t len = 6 * strlen ((
char *) libname);
6576 while (allocated < p - document + len + 200)
6579 uintptr_t document_len = p - document;
6581 document =
xrealloc (document, 2 * allocated);
6583 p = document + document_len;
6587 p += sprintf (p,
"<library name=\"%s\" lm=\"0x%lx\" "
6588 "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
6589 name, (
unsigned long) lm_addr,
6590 (
unsigned long) l_addr, (
unsigned long) l_ld);
6605 strcpy (p,
"</library-list-svr4>");
6607 document_len = strlen (document);
6608 if (offset < document_len)
6612 if (len > document_len)
6615 memcpy (readbuf, document + offset, len);
6621 #ifdef HAVE_LINUX_BTRACE
6632 if (tinfo != NULL && tinfo->
ptr_bits == 0)
6657 linux_low_encode_pt_config (
struct buffer *buffer,
6666 "model=\"%u\" stepping=\"%u\"/>\n",
6681 linux_low_encode_raw (
struct buffer *buffer,
const gdb_byte *data,
6694 elem[0] =
tohex ((*data >> 4) & 0xf);
6695 elem[1] =
tohex (*data++ & 0xf);
6727 switch (btrace.format)
6734 buffer_grow_str (buffer,
"<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
6747 buffer_grow_str (buffer,
"<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
6751 linux_low_encode_pt_config (buffer, &btrace.variant.pt.config);
6753 linux_low_encode_raw (buffer, btrace.variant.pt.data,
6754 btrace.variant.pt.size);
6777 struct buffer *buffer)
6781 buffer_grow_str (buffer,
"<!DOCTYPE btrace-conf SYSTEM \"btrace-conf.dtd\">\n");
6848 #if defined(__UCLIBC__) && defined(HAS_NOMMU) \
6849 && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
6850 && defined(PT_TEXT_END_ADDR)
6855 #ifdef USE_THREAD_DB
6871 #ifdef USE_THREAD_DB
6893 #ifdef HAVE_LINUX_BTRACE
6895 linux_low_enable_btrace,
6896 linux_low_disable_btrace,
6897 linux_low_read_btrace,
6898 linux_low_btrace_conf,
6923 #ifdef HAVE_LINUX_REGSETS
6925 initialize_regsets_info (
struct regsets_info *info)
6927 for (info->num_regsets = 0;
6928 info->regsets[info->num_regsets].size >= 0;
6929 info->num_regsets++)
6937 struct sigaction sigchld_action;
6938 memset (&sigchld_action, 0,
sizeof (sigchld_action));
6946 sigemptyset (&sigchld_action.sa_mask);
6947 sigchld_action.sa_flags = SA_RESTART;
6948 sigaction (SIGCHLD, &sigchld_action, NULL);
const struct target_desc * tdesc
struct arch_lwp_info * arch_private
static int linux_supports_stopped_by_sw_breakpoint(void)
static void proceed_all_lwps(void)
static struct process_info * linux_add_process(int pid, int attached)
static void sigchld_handler(int signo)
#define regsets_fetch_inferior_registers(regsets_info, regcache)
struct btrace_config_bts bts
int( iterate_over_lwps_ftype)(struct lwp_info *lwp, void *arg)
ptid_t ptid_of_lwp(struct lwp_info *lwp)
static int linux_async(int enable)
void initialize_low_arch(void)
static int finish_step_over(struct lwp_info *lwp)
struct thread_info * current_thread
#define PTRACE_GETEVENTMSG
int handle_target_event(int err, gdb_client_data client_data)
void collect_register(struct regcache *regcache, int n, void *buf)
static int iterate_over_lwps_filter(struct inferior_list_entry *entry, void *args_p)
struct process_info * add_process(int pid, int attached)
struct thread_info * find_thread_ptid(ptid_t ptid)
int gdb_condition_true_at_breakpoint(CORE_ADDR where)
static int can_hardware_single_step(void)
static int linux_read_auxv(CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
static void linux_resume_one_lwp(struct lwp_info *lwp, int step, int signal, siginfo_t *info)
int ptid_is_pid(ptid_t ptid)
struct usrregs_info * usrregs
static void select_event_lwp(struct lwp_info **orig_lp)
#define linux_read_loadmap
static void kill_wait_lwp(struct lwp_info *lwp)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static int elf_64_file_p(const char *file, unsigned int *machine)
void(* new_fork)(struct process_info *parent, struct process_info *child)
void set_desired_thread(int use_general)
static int linux_insert_point(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
static int linux_attach(unsigned long pid)
int(* cannot_store_register)(int)
int(* supports_z_point_type)(char z_type)
void thread_db_mourn(struct process_info *)
void clone_all_breakpoints(struct breakpoint **new_list, struct raw_breakpoint **new_raw_list, const struct breakpoint *src_list)
static void enqueue_one_deferred_signal(struct lwp_info *lwp, int *wstat)
void warning(const char *fmt,...)
int linux_wstatus_maybe_breakpoint(int wstat)
static int not_stopped_callback(struct inferior_list_entry *entry, void *arg)
static void move_out_of_jump_pad_callback(struct inferior_list_entry *entry)
static void linux_resume_one_lwp_throw(struct lwp_info *lwp, int step, int signal, siginfo_t *info)
void btrace_data_fini(struct btrace_data *data)
union Elf64_auxv_t::@3 a_un
struct lwp_info * find_lwp_pid(ptid_t ptid)
struct inferior_list_entry entry
static int linux_supports_disable_randomization(void)
int linux_is_extended_waitstatus(int wstat)
static int select_event_lwp_callback(struct inferior_list_entry *entry, void *data)
struct pending_signals * prev
static int supports_breakpoints(void)
static void linux_pause_all(int freeze)
static int lwp_in_step_range(struct lwp_info *lwp)
static int linux_stopped_by_sw_breakpoint(void)
static CORE_ADDR get_dynamic(const int pid, const int is_elf64)
static void linux_process_qsupported(const char *query)
CORE_ADDR adjusted_insn_addr_end
int ptid_match(ptid_t ptid, ptid_t filter)
void internal_error(const char *file, int line, const char *fmt,...)
struct process_info * get_thread_process(struct thread_info *thread)
struct raw_breakpoint * raw_breakpoints
static int unsuspend_one_lwp(struct inferior_list_entry *entry, void *except)
static void linux_join(int pid)
struct process_info * find_process_pid(int pid)
static int linux_supports_fork_events(void)
enum target_stop_reason lwp_stop_reason(struct lwp_info *lwp)
static ptid_t ignore_event(struct target_waitstatus *ourstatus)
static int linux_supports_range_stepping(void)
#define usr_store_inferior_registers(regs_info, regcache, regno, all)
#define GDB_ARCH_TRAP_BRKPT
static ptid_t linux_wait(ptid_t ptid, struct target_waitstatus *ourstatus, int target_options)
static void linux_done_accessing_memory(void)
char * paddress(CORE_ADDR addr)
static int linux_fast_tracepoint_collecting(struct lwp_info *lwp, struct fast_tpoint_collect_status *status)
int collecting_fast_tracepoint
static int elf_64_header_p(const Elf64_Ehdr *header, unsigned int *machine)
void for_each_inferior(struct inferior_list *list, void(*action)(struct inferior_list_entry *))
void linux_check_ptrace_features(void)
const struct regs_info *(* regs_info)(void)
int(* stopped_by_watchpoint)(void)
static void linux_stabilize_threads(void)
void set_breakpoint_data(const unsigned char *bp_data, int bp_len)
enum btrace_error linux_read_btrace(struct btrace_data *btrace, struct btrace_target_info *tinfo, enum btrace_read_type type)
struct wstep_state * while_stepping
void(* mourn)(struct process_info *proc)
struct linux_target_ops the_low_target
static int stuck_in_jump_pad_callback(struct inferior_list_entry *entry, void *data)
int thread_db_init(int use_events)
static int second_thread_of_pid_p(struct inferior_list_entry *entry, void *args)
#define get_thread_lwp(thr)
struct target_ops * the_target
char * xml_escape_text(const char *text)
const struct target_desc * tdesc
static int maybe_move_out_of_jump_pad(struct lwp_info *lwp, int *wstat)
CORE_ADDR step_range_start
int(* breakpoint_at)(CORE_ADDR pc)
static int resume_status_pending_p(struct inferior_list_entry *entry, void *flag_p)
static void wait_for_sigstop(void)
static void unstop_all_lwps(int unsuspend, struct lwp_info *except)
void perror(const char *)
const unsigned char * breakpoint
int(* fetch_register)(struct regcache *regcache, int regno)
int fast_tracepoint_jump_here(CORE_ADDR where)
static CORE_ADDR get_pc(struct lwp_info *lwp)
static int unsuspend_and_proceed_one_lwp(struct inferior_list_entry *entry, void *except)
union Elf32_auxv_t::@2 a_un
enum resume_kind last_resume_kind
struct inferior_list_entry entry
iterate_over_lwps_ftype * callback
#define PTRACE_EVENT_VFORK_DONE
static int get_detach_signal(struct thread_info *thread)
ptid_t ptid_build(int pid, long lwp, long tid)
struct target_waitstatus waitstatus
static int linux_supports_tracepoints(void)
int tracepoint_was_hit(struct thread_info *tinfo, CORE_ADDR stop_pc)
int must_set_ptrace_flags
struct arch_process_info * arch_private
int lwp_is_stopped(struct lwp_info *lwp)
enum btrace_cpu_vendor vendor
static int check_stopped_by_breakpoint(struct lwp_info *lwp)
static struct lwp_info * linux_low_filter_event(int lwpid, int wstat)
static int proceed_one_lwp(struct inferior_list_entry *entry, void *except)
static void async_file_mark(void)
#define PTRACE_EVENT_FORK
static int linux_supports_conditional_breakpoints(void)
void(* set_pc)(struct regcache *regcache, CORE_ADDR newpc)
int hardware_breakpoint_inserted_here(CORE_ADDR addr)
static int linux_stopped_by_hw_breakpoint(void)
static struct lwp_info * add_lwp(ptid_t ptid)
static int linux_qxfer_spu(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static void linux_mourn(struct process_info *process)
#define VEC_iterate(T, V, I, P)
static int linux_remove_point(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
int linux_supports_btrace(struct target_ops *ops, enum btrace_format format)
int handle_tracepoint_bkpts(struct thread_info *tinfo, CORE_ADDR stop_pc)
void set_reinsert_breakpoint(CORE_ADDR stop_at)
unsigned char * regset_bitmap
static void linux_kill_one_lwp(struct lwp_info *lwp)
static int linux_thread_stopped(struct thread_info *thread)
int remote_connection_is_stdio(void)
void linux_ptrace_init_warnings(void)
static int linux_supports_vfork_events(void)
#define CATCH(EXCEPTION, MASK)
void uninsert_breakpoints_at(CORE_ADDR pc)
void delete_file_handler(gdb_fildes_t fd)
int fast_tracepoint_collecting(CORE_ADDR thread_area, CORE_ADDR stop_pc, struct fast_tpoint_collect_status *status)
static int last_thread_of_process_p(int pid)
static int linux_supports_multi_process(void)
char * linux_ptrace_attach_fail_reason_string(ptid_t ptid, int err)
void release_while_stepping_state_list(struct thread_info *tinfo)
int linux_supports_traceclone(void)
void uninsert_fast_tracepoint_jumps_at(CORE_ADDR pc)
static void add_to_pid_list(struct simple_pid_list **listp, int pid, int status)
int(* get_thread_area)(int lwpid, CORE_ADDR *addrp)
struct thread_db * thread_db
static int start_step_over(struct lwp_info *lwp)
static int linux_create_inferior(char *program, char **allargs)
int disable_randomization
void buffer_xml_printf(struct buffer *buffer, const char *format,...)
#define ALL_PROCESSES(cur, tmp)
void copy_target_description(struct target_desc *dest, const struct target_desc *src)
int(* cannot_fetch_register)(int)
static int linux_install_fast_tracepoint_jump_pad(CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline, ULONGEST *trampoline_size, unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end, char *err)
int program_signals[GDB_SIGNAL_LAST]
#define PTRACE_O_TRACEVFORKDONE
const char * decode_address_to_semicolon(CORE_ADDR *addrp, const char *start)
struct simple_pid_list * next
#define PTRACE_O_TRACEVFORK
#define regsets_store_inferior_registers(regsets_info, regcache)
void linux_store_registers(struct regcache *regcache, int regno)
int linux_ptrace_get_extended_event(int wstat)
static void linux_init_signals()
static int kill_one_lwp_callback(struct inferior_list_entry *entry, void *args)
#define PTRACE_EVENT_CLONE
#define gdb_assert_not_reached(message)
static void unsuspend_all_lwps(struct lwp_info *except)
static int linux_read_memory(CORE_ADDR memaddr, unsigned char *myaddr, int len)
struct thread_resume * resume
static int linux_supports_stopped_by_hw_breakpoint(void)
const struct btrace_config * linux_btrace_conf(const struct btrace_target_info *tinfo)
ptid_t pid_to_ptid(int pid)
static void async_file_flush(void)
static int linux_detach_one_lwp(struct inferior_list_entry *entry, void *args)
static int attach_proc_task_lwp_callback(ptid_t ptid)
static int check_stopped_by_watchpoint(struct lwp_info *child)
int gdb_signal_to_host(enum gdb_signal)
#define get_lwp_thread(lwp)
int register_size(const struct target_desc *tdesc, int n)
int breakpoint_here(CORE_ADDR addr)
CORE_ADDR step_range_start
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 int delete_lwp_callback(struct inferior_list_entry *entry, void *proc)
int thread_db_get_tls_address(struct thread_info *thread, CORE_ADDR offset, CORE_ADDR load_module, CORE_ADDR *address)
static int linux_resume_one_thread(struct inferior_list_entry *entry, void *arg)
static int handle_tracepoints(struct lwp_info *lwp)
void(* collect_ptrace_register)(struct regcache *regcache, int regno, char *buf)
int linux_common_core_of_thread(ptid_t ptid)
static int linux_qxfer_osdata(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static int startswith(const char *string, const char *pattern)
struct cleanup * maybe_disable_address_space_randomization(int disable_randomization)
static int linux_qxfer_libraries_svr4(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static int linux_wait_for_event(ptid_t ptid, int *wstat, int options)
CORE_ADDR(* stopped_data_address)(void)
void(* process_qsupported)(const char *)
void check_breakpoints(CORE_ADDR stop_pc)
static int linux_register_in_regsets(const struct regs_info *regs_info, int regno)
void remove_process(struct process_info *process)
int gdb_no_commands_at_breakpoint(CORE_ADDR where)
static int num_lwps(int pid)
void set_target_ops(struct target_ops *target)
static int linux_low_ptrace_options(int attached)
#define PTRACE_O_TRACEFORK
struct process_info * current_process(void)
static void complete_ongoing_step_over(void)
static int thread_still_has_status_pending_p(struct thread_info *thread)
void linux_fetch_registers(struct regcache *regcache, int regno)
static int same_lwp(struct inferior_list_entry *entry, void *data)
static void enqueue_pending_signal(struct lwp_info *lwp, int signal, siginfo_t *info)
static int lwp_running(struct inferior_list_entry *entry, void *data)
char * status_to_str(int status)
struct process_info_private * priv
#define buffer_grow_str(BUFFER, STRING)
struct inferior_list all_threads
static int stabilizing_threads
static int reset_lwp_ptrace_options_callback(struct inferior_list_entry *entry, void *args)
void thread_db_detach(struct process_info *)
static int supports_fast_tracepoints(void)
void close_most_fds(void)
void reinsert_fast_tracepoint_jumps_at(CORE_ADDR where)
static int read_one_ptr(CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
int linux_supports_tracefork(void)
struct arch_process_info *(* new_process)(void)
struct pending_signals * pending_signals
static int linux_supports_non_stop(void)
int(* insert_point)(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
struct simple_pid_list * stopped_pids
void run_breakpoint_commands(CORE_ADDR where)
int linux_pid_exe_is_elf_64_file(int pid, unsigned int *machine)
int linux_mntns_unlink(pid_t pid, const char *filename)
CORE_ADDR stopped_data_address
LONGEST linux_common_xfer_osdata(const char *annex, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static ptid_t linux_wait_1(ptid_t ptid, struct target_waitstatus *ourstatus, int target_options)
static int lwp_is_marked_dead(struct lwp_info *lwp)
#define stabilize_threads()
int(* remove_point)(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
int ptid_get_pid(ptid_t ptid)
#define PTRACE_GETSIGINFO
#define target_is_async_p()
struct btrace_config_pt pt
#define USE_SIGTRAP_SIGINFO
struct emit_ops *(* emit_ops)(void)
static int check_ptrace_stopped_lwp_gone(struct lwp_info *lp)
PTR xrealloc(PTR ptr, size_t size)
int linux_attach_lwp(ptid_t ptid)
void add_file_handler(gdb_fildes_t fd, handler_func *proc, gdb_client_data client_data)
void(* prepare_to_resume)(struct lwp_info *)
void throw_exception(struct gdb_exception exception)
static int linux_get_min_fast_tracepoint_insn_len(void)
int(* supports_tracepoints)(void)
#define buffer_grow_str0(BUFFER, STRING)
static int linux_thread_alive(ptid_t ptid)
static void stop_all_lwps(int suspend, struct lwp_info *except)
enum stopping_threads_kind stopping_threads
int linux_proc_pid_is_gone(pid_t pid)
static int need_step_over_p(struct inferior_list_entry *entry, void *dummy)
static void linux_handle_new_gdb_connection(void)
int(* siginfo_fixup)(siginfo_t *native, void *inf, int direction)
void force_unlock_trace_buffer(void)
int(* install_fast_tracepoint_jump_pad)(CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline, ULONGEST *trampoline_size, unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end, char *err)
ptid_t current_lwp_ptid(void)
static int status_pending_p_callback(struct inferior_list_entry *entry, void *arg)
static int spu_enumerate_spu_ids(long pid, unsigned char *buf, CORE_ADDR offset, int len)
static void lwp_suspended_inc(struct lwp_info *lwp)
void reinsert_breakpoints_at(CORE_ADDR pc)
int tracepoint_finished_step(struct thread_info *tinfo, CORE_ADDR stop_pc)
int xsnprintf(char *str, size_t size, const char *format,...)
static int linux_stopped_by_watchpoint(void)
enum btrace_error linux_disable_btrace(struct btrace_target_info *tinfo)
#define PTRACE_SETSIGINFO
void linux_enable_event_reporting(pid_t pid, int options)
static void lwp_suspended_decr(struct lwp_info *lwp)
#define PTRACE_EVENT_VFORK
static int handle_extended_wait(struct lwp_info *event_lwp, int wstat)
static int send_sigstop_callback(struct inferior_list_entry *entry, void *except)
struct thread_resume * resume
void regcache_invalidate_thread(struct thread_info *thread)
void delete_reinsert_breakpoints(void)
const char * target_pid_to_str(ptid_t ptid)
int(* supports_range_stepping)(void)
struct pending_signals * pending_signals_to_report
void(* new_thread)(struct lwp_info *)
void hostio_last_error_from_errno(char *buf)
static void send_sigstop(struct lwp_info *lwp)
static struct emit_ops * linux_emit_ops(void)
static void resume_stopped_resumed_lwps(struct inferior_list_entry *entry)
static void mark_lwp_dead(struct lwp_info *lwp, int wstat)
static int linux_detach(int pid)
struct regcache * get_thread_regcache(struct thread_info *thread, int fetch)
struct target_waitstatus last_status
CORE_ADDR adjusted_insn_addr
static void linux_unpause_all(int unfreeze)
int thread_db_handle_monitor_command(char *)
int linux_proc_pid_is_zombie(pid_t pid)
void perror_with_name(const char *string)
void remove_thread(struct thread_info *thread)
int insert_memory_breakpoint(struct raw_breakpoint *bp)
static int suspend_and_send_sigstop_callback(struct inferior_list_entry *entry, void *except)
enum target_stop_reason stop_reason
int breakpoint_inserted_here(CORE_ADDR addr)
static CORE_ADDR linux_read_pc(struct regcache *regcache)
static int dequeue_one_deferred_signal(struct lwp_info *lwp, int *wstat)
static int linux_kill(int pid)
static void linux_write_pc(struct regcache *regcache, CORE_ADDR pc)
unsigned long long ULONGEST
static CORE_ADDR get_r_debug(const int pid, const int is_elf64)
int my_waitpid(int pid, int *status, int flags)
static int linux_supports_agent(void)
struct breakpoint * set_breakpoint_at(CORE_ADDR where, int(*handler)(CORE_ADDR))
int linux_mntns_open_cloexec(pid_t pid, const char *filename, int flags, mode_t mode)
static int linux_prepare_to_access_memory(void)
static void check_zombie_leaders(void)
long ptid_get_lwp(ptid_t ptid)
const char * gdb_signal_to_string(enum gdb_signal)
struct breakpoint * breakpoints
static int linux_xfer_siginfo(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static int linux_set_resume_request(struct inferior_list_entry *entry, void *arg)
static int linux_supports_z_point_type(char z_type)
struct breakpoint * exit_jump_pad_bkpt
void linux_proc_attach_tgid_threads(pid_t pid, linux_proc_attach_lwp_func attach_lwp)
static void delete_lwp(struct lwp_info *lwp)
ssize_t linux_mntns_readlink(pid_t pid, const char *filename, char *buf, size_t bufsiz)
void(* supply_ptrace_register)(struct regcache *regcache, int regno, const char *buf)
struct lwp_info * iterate_over_lwps(ptid_t filter, iterate_over_lwps_ftype callback, void *data)
static CORE_ADDR linux_stopped_data_address(void)
struct btrace_target_info * linux_enable_btrace(ptid_t ptid, const struct btrace_config *conf)
enum btrace_format format
int(* get_min_fast_tracepoint_insn_len)(void)
void lwp_set_arch_private_info(struct lwp_info *lwp, struct arch_lwp_info *info)
static int linux_event_pipe[2]
CORE_ADDR(* breakpoint_reinsert_addr)(void)
void initialize_low(void)
void debug_printf(const char *fmt,...)
static void linux_request_interrupt(void)
static void linux_resume(struct thread_resume *resume_info, size_t n)
void btrace_data_init(struct btrace_data *data)
void linux_stop_lwp(struct lwp_info *lwp)
static void siginfo_fixup(siginfo_t *siginfo, void *inf_siginfo, int direction)
static int linux_start_non_stop(int nonstop)
static int linux_write_memory(CORE_ADDR memaddr, const unsigned char *myaddr, int len)
void supply_register(struct regcache *regcache, int n, const void *buf)
int remove_memory_breakpoint(struct raw_breakpoint *bp)
static int get_phdr_phnum_from_proc_auxv(const int pid, const int is_elf64, CORE_ADDR *phdr_memaddr, int *num_phdr)
struct thread_info * add_thread(ptid_t ptid, void *target_data)
PTR xcalloc(size_t number, size_t size)
static int select_singlestep_lwp_callback(struct inferior_list_entry *entry, void *data)
static int kill_lwp(unsigned long lwpid, int signo)
#define PTRACE_O_EXITKILL
struct arch_lwp_info * lwp_arch_private_info(struct lwp_info *lwp)
static int count_events_callback(struct inferior_list_entry *entry, void *data)
void error(const char *fmt,...)
int delete_breakpoint(struct breakpoint *todel)
#define ALL_INFERIORS(list, cur, tmp)
static int pull_pid_from_list(struct simple_pid_list **listp, int pid, int *statusp)
#define use_linux_regsets
int pass_signals[GDB_SIGNAL_LAST]
void do_cleanups(struct cleanup *old_chain)
int gdb_breakpoint_here(CORE_ADDR where)
void buffer_grow(struct buffer *buffer, const char *data, size_t size)
struct inferior_list_entry * find_inferior(struct inferior_list *list, int(*func)(struct inferior_list_entry *, void *), void *arg)
struct thread_info * thread
CORE_ADDR(* get_pc)(struct regcache *regcache)
static void linux_look_up_symbols(void)
#define usr_fetch_inferior_registers(regs_info, regcache, regno, all)
int linux_proc_pid_is_trace_stopped_nowarn(pid_t pid)
static int linux_wait_for_event_filtered(ptid_t wait_ptid, ptid_t filter_ptid, int *wstat, int options)