34 #include <sys/ioctl.h> 37 #include <sys/syscall.h> 63 #define SPUFS_MAGIC 0x23c9b64e 66 #ifdef HAVE_PERSONALITY 67 # include <sys/personality.h> 68 # if !HAVE_DECL_ADDR_NO_RANDOMIZE 69 # define ADDR_NO_RANDOMIZE 0x0040000 80 #if !(defined(PT_TEXT_ADDR) \ 81 || defined(PT_DATA_ADDR) \ 82 || defined(PT_TEXT_END_ADDR)) 83 #if defined(__mcoldfire__) 85 #define PT_TEXT_ADDR 49*4 86 #define PT_DATA_ADDR 50*4 87 #define PT_TEXT_END_ADDR 51*4 90 #define PT_TEXT_ADDR 220 91 #define PT_TEXT_END_ADDR 224 92 #define PT_DATA_ADDR 228 94 #elif defined(__TMS320C6X__) 95 #define PT_TEXT_ADDR (0x10000*4) 96 #define PT_DATA_ADDR (0x10004*4) 97 #define PT_TEXT_END_ADDR (0x10008*4) 101 #ifdef HAVE_LINUX_BTRACE 106 #ifndef HAVE_ELF32_AUXV_T 121 #ifndef HAVE_ELF64_AUXV_T 176 enum target_stop_reason
217 new_pid->
next = *listp;
226 for (p = listp; *p != NULL; p = &(*p)->
next)
227 if ((*p)->pid ==
pid)
262 int step,
int signal, siginfo_t *info);
268 int *wstat,
int options);
277 static int kill_lwp (
unsigned long lwpid,
int signo);
349 #define target_is_async_p() (linux_event_pipe[0] != -1) 359 if (header->e_ident[EI_MAG0] == ELFMAG0
360 && header->e_ident[EI_MAG1] == ELFMAG1
361 && header->e_ident[EI_MAG2] == ELFMAG2
362 && header->e_ident[EI_MAG3] == ELFMAG3)
364 *machine = header->e_machine;
365 return header->e_ident[EI_CLASS] == ELFCLASS64;
382 fd = open (file, O_RDONLY);
386 if (read (fd, &header,
sizeof (header)) !=
sizeof (header))
404 sprintf (file,
"/proc/%d/exe", pid);
477 struct lwp_info *event_lwp = *orig_event_lwp;
493 unsigned long new_pid;
510 else if (ret != new_pid)
511 warning (
"wait returned unexpected PID %d", ret);
513 warning (
"wait returned unexpected status 0x%x", status);
548 child_thr->
last_status.kind = TARGET_WAITKIND_STOPPED;
580 child_proc->
tdesc = tdesc;
588 event_lwp->
waitstatus.kind = TARGET_WAITKIND_FORKED;
590 event_lwp->
waitstatus.kind = TARGET_WAITKIND_VFORKED;
592 event_lwp->
waitstatus.value.related_pid = ptid;
628 "from LWP %ld, new child is LWP %ld\n",
659 new_lwp->
waitstatus.kind = TARGET_WAITKIND_THREAD_CREATED;
671 event_lwp->
waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
697 event_ptid =
ptid_of (event_thr);
710 event_lwp =
add_lwp (event_ptid);
716 event_lwp->
waitstatus.kind = TARGET_WAITKIND_EXECD;
725 event_thr->
last_status.kind = TARGET_WAITKIND_IGNORE;
736 *orig_event_lwp = event_lwp;
740 internal_error (__FILE__, __LINE__,
_(
"unknown ptrace event %d"), event);
793 debug_printf (
"get_syscall_trapinfo sysno %d\n", *sysno);
812 #if USE_SIGTRAP_SIGINFO 826 #if USE_SIGTRAP_SIGINFO 830 if (siginfo.si_signo == SIGTRAP)
838 lwp->
stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
847 lwp->
stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
854 lwp->
stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
856 else if (siginfo.si_code == TRAP_TRACE)
875 lwp->
stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
878 lwp->
stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
880 if (lwp->
stop_reason == TARGET_STOPPED_BY_NO_REASON)
884 if (lwp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
890 debug_printf (
"CSBB: %s stopped by software breakpoint\n",
895 if (pc != sw_breakpoint_pc)
903 pc = sw_breakpoint_pc;
905 else if (lwp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
911 debug_printf (
"CSBB: %s stopped by hardware breakpoint\n",
915 else if (lwp->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
921 debug_printf (
"CSBB: %s stopped by hardware watchpoint\n",
925 else if (lwp->
stop_reason == TARGET_STOPPED_BY_SINGLE_STEP)
948 lwp->
waitstatus.kind = TARGET_WAITKIND_IGNORE;
968 if (setpgid (0, 0) < 0)
978 if (open (
"/dev/null", O_RDONLY) < 0)
982 if (write (2,
"stdin/stdout redirected\n",
983 sizeof (
"stdin/stdout redirected\n") - 1) < 0)
1008 str_program_args.c_str (),
1010 NULL, NULL, NULL, NULL);
1156 "thread is gone (%d: %s)\n",
1162 warning (
_(
"Cannot attach to lwp %d: %s"),
1189 error (
"Cannot attach to process %ld: %s",
1247 bool seen_one =
false;
1292 int save_errno =
errno;
1294 debug_printf (
"LKL: kill_lwp (SIGKILL) %s, 0, 0 (%s)\n",
1296 save_errno ?
strerror (save_errno) :
"OK");
1303 int save_errno =
errno;
1307 save_errno ?
strerror (save_errno) :
"OK");
1323 debug_printf (
"kwl: killing lwp %d, for pid: %d\n", lwpid, pid);
1344 if (res == -1 &&
errno == ECHILD)
1350 if (res < 0 &&
errno != ECHILD)
1385 if (process == NULL)
1425 enum gdb_signal signo = GDB_SIGNAL_0;
1448 debug_printf (
"GPS: lwp %s hasn't stopped: no pending signal\n",
1458 "status: no pending signal\n",
1468 debug_printf (
"GPS: lwp %s had signal %s, but it is in nopass state\n",
1477 && (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
1481 "but we don't know if we should pass it. " 1482 "Default to not.\n",
1490 debug_printf (
"GPS: lwp %s has pending signal %s: delivering it.\n",
1544 int save_errno =
errno;
1550 if (save_errno == ESRCH)
1557 warning (
_(
"Couldn't reap LWP %d while detaching: %s"),
1562 warning (
_(
"Reaping LWP %d while detaching " 1563 "returned unexpected status 0x%x"),
1569 error (
_(
"Can't detach %s: %s"),
1607 if (process == NULL)
1621 #ifdef USE_THREAD_DB 1651 #ifdef USE_THREAD_DB 1657 delete_lwp (get_thread_lwp (thread));
1661 priv = process->
priv;
1667 process->
priv = NULL;
1681 }
while (ret != -1 ||
errno != ECHILD);
1712 && (lp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
1713 || lp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
1734 #if !USE_SIGTRAP_SIGINFO 1735 else if (lp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
1743 else if (lp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT
1758 debug_printf (
"discarding pending breakpoint status\n");
1781 && thread->
last_status.kind == TARGET_WAITKIND_IGNORE)
1816 int lwp = ptid.
lwp () != 0 ? ptid.
lwp () : ptid.
pid ();
1852 return callback (lwp, data);
1868 pid_t leader_pid =
pid_of (proc);
1875 "num_lwps=%d, zombie=%d\n",
1876 leader_pid, leader_lp!= NULL,
num_lwps (leader_pid),
1879 if (leader_lp != NULL && !leader_lp->
stopped 1915 "(it exited, or another thread execd).\n",
1948 debug_printf (
"LWP %ld has a suspiciously high suspend count," 1965 "unsuspend LWP %ld, suspended=%d\n",
lwpid_of (thread),
1979 int tpoint_related_event = 0;
2010 if (tpoint_related_event)
2064 debug_printf (
"Checking whether LWP %ld needs to move out of the " 2092 debug_printf (
"Checking whether LWP %ld needs to move out of " 2093 "the jump pad...it does\n",
2129 && (uintptr_t) info.si_addr == lwp->
stop_pc)
2131 info.si_addr = (
void *) (uintptr_t) status.
tpoint_addr;
2148 debug_printf (
"Cancelling fast exit-jump-pad: removing bkpt. " 2149 "stopping all threads momentarily.\n");
2164 debug_printf (
"Checking whether LWP %ld needs to move out of the " 2195 debug_printf (
" (no more currently queued signals)\n");
2212 debug_printf (
"Not requeuing already queued non-RT signal %d" 2244 while ((*p_sig)->prev != NULL)
2245 p_sig = &(*p_sig)->
prev;
2248 if ((*p_sig)->info.si_signo != 0)
2255 debug_printf (
"Reporting deferred signal %d for LWP %ld.\n",
2304 child->
stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
2316 return child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
2352 int have_stop_pc = 0;
2378 debug_printf (
"LLW: Re-adding thread group leader LWP %d" 2379 "after exec.\n", lwpid);
2397 else if (child == NULL)
2445 if (proc->
tdesc == NULL)
2480 ? TARGET_WAITKIND_SYSCALL_RETURN
2481 : TARGET_WAITKIND_SYSCALL_ENTRY);
2525 debug_printf (
"LLW: resume_stop SIGSTOP caught for %s.\n",
2534 "while stopping threads.\n",
2542 debug_printf (
"LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
2543 child->
stepping ?
"step" :
"continue",
2591 debug_printf (
"RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n",
2611 int *wstatp,
int options)
2614 struct lwp_info *event_child, *requested_child;
2615 sigset_t block_mask, prev_mask;
2620 event_thread = NULL;
2622 requested_child = NULL;
2633 if (event_thread != NULL)
2658 "requesting an event out of a" 2659 " suspended child?");
2664 event_child = requested_child;
2669 if (event_child != NULL)
2672 debug_printf (
"Got an event from pending child %ld (%04x)\n",
2690 sigfillset (&block_mask);
2691 sigprocmask (SIG_BLOCK, &block_mask, &prev_mask);
2696 while (event_child == NULL)
2716 debug_printf (
"LWFE: waitpid(-1, ...) returned %d, %s\n",
2748 if (event_thread != NULL)
2777 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2787 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2795 sigsuspend (&prev_mask);
2796 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2800 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
2826 int random_selector;
2843 return (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2848 if (event_thread != NULL)
2855 if (event_thread == NULL)
2867 if (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2875 random_selector = (int)
2876 ((num_events * (
double) rand ()) / (RAND_MAX + 1.0));
2879 debug_printf (
"SEL: Found %d SIGTRAP events, selecting #%d\n",
2880 num_events, random_selector);
2887 if (thread->
last_status.kind == TARGET_WAITKIND_IGNORE
2889 if (random_selector-- == 0)
2896 if (event_thread != NULL)
2901 *orig_lp = event_lp;
2924 struct target_waitstatus *ourstatus,
2925 int target_options);
2962 if (thread_stuck != NULL)
2965 debug_printf (
"can't stabilize, LWP %ld is stuck in jump pad\n",
2980 struct target_waitstatus ourstatus;
2989 if (ourstatus.kind == TARGET_WAITKIND_STOPPED)
2996 if (ourstatus.value.sig != GDB_SIGNAL_0
3015 if (thread_stuck != NULL)
3016 debug_printf (
"couldn't stabilize, LWP %ld got stuck in jump pad\n",
3032 ourstatus->kind = TARGET_WAITKIND_IGNORE;
3043 struct target_waitstatus *ourstatus)
3051 ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
3053 ourstatus->kind = TARGET_WAITKIND_IGNORE;
3100 struct target_waitstatus *ourstatus,
int target_options)
3106 int step_over_finished;
3107 int bp_explains_trap;
3108 int maybe_internal_trap;
3122 if (target_options & TARGET_WNOHANG)
3125 bp_explains_trap = 0;
3128 ourstatus->kind = TARGET_WAITKIND_IGNORE;
3153 debug_printf (
"step_over_bkpt set [%s], doing a blocking wait\n",
3158 if (pid == 0 || (pid == -1 && !any_resumed))
3160 gdb_assert (target_options & TARGET_WNOHANG);
3165 "TARGET_WAITKIND_IGNORE\n");
3169 ourstatus->kind = TARGET_WAITKIND_IGNORE;
3177 "TARGET_WAITKIND_NO_RESUMED\n");
3181 ourstatus->kind = TARGET_WAITKIND_NO_RESUMED;
3193 ourstatus->kind = TARGET_WAITKIND_EXITED;
3207 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
3212 debug_printf (
"linux_wait_1 ret = %s, terminated with " 3220 if (ourstatus->kind == TARGET_WAITKIND_EXITED)
3238 && event_child->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
3242 int increment_pc = 0;
3243 int breakpoint_kind = 0;
3252 debug_printf (
"step-over for %s executed software breakpoint\n",
3256 if (increment_pc != 0)
3261 event_child->
stop_pc += increment_pc;
3265 event_child->
stop_reason = TARGET_STOPPED_BY_NO_REASON;
3281 if (maybe_internal_trap)
3306 if (bp_explains_trap)
3332 debug_printf (
"Got signal %d for LWP %ld. Check if we need " 3333 "to defer or adjust it.\n",
3343 debug_printf (
"Signal %d for LWP %ld deferred (in jump pad)\n",
3358 debug_printf (
"LWP %ld was trying to move out of the jump pad (%d). " 3359 "Check if we're already there.\n",
3375 debug_printf (
"No longer need exit-jump-pad bkpt; removing it." 3376 "stopping all threads momentarily.\n");
3401 "collecting successfully.\n");
3416 ourstatus->kind = TARGET_WAITKIND_STOPPED;
3417 ourstatus->value.sig = GDB_SIGNAL_0;
3422 "while stabilizing threads\n",
3476 siginfo_t info, *info_p;
3488 if (step_over_finished)
3530 report_to_gdb = (!maybe_internal_trap
3533 || event_child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT
3535 && !bp_explains_trap
3537 && !step_over_finished
3539 && event_child->
stop_reason == TARGET_STOPPED_BY_SINGLE_STEP))
3543 || event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE);
3554 if (bp_explains_trap)
3556 if (step_over_finished)
3561 debug_printf (
"Range stepping pc 0x%s [0x%s, 0x%s).\n",
3578 if (step_over_finished)
3613 if (event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE)
3616 = target_waitstatus_to_string (&event_child->
waitstatus);
3618 debug_printf (
"LWP %ld: extended event with waitstatus %s\n",
3624 debug_printf (
"GDB wanted to single-step, reporting event.\n");
3626 debug_printf (
"Out of step range, reporting event.\n");
3628 if (event_child->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
3644 int remove_single_step_breakpoints_p = 0;
3648 remove_single_step_breakpoints_p
3659 remove_single_step_breakpoints_p = 1;
3667 if (remove_single_step_breakpoints_p)
3697 if (step_over_finished)
3750 if (step_over_finished)
3754 if (event_child->
waitstatus.kind != TARGET_WAITKIND_IGNORE)
3760 if (event_child->
waitstatus.kind == TARGET_WAITKIND_FORKED
3761 || event_child->
waitstatus.kind == TARGET_WAITKIND_VFORKED)
3769 event_child->
waitstatus.kind = TARGET_WAITKIND_IGNORE;
3772 ourstatus->kind = TARGET_WAITKIND_STOPPED;
3777 if (event_child->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
3793 &ourstatus->value.syscall_number);
3802 ourstatus->value.sig = GDB_SIGNAL_0;
3811 else if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
3822 ourstatus->kind, ourstatus->value.sig);
3826 if (ourstatus->kind == TARGET_WAITKIND_EXITED)
3841 while (ret >= 0 || (ret == -1 &&
errno == EINTR));
3854 while (ret == 0 || (ret == -1 &&
errno == EINTR));
3862 struct target_waitstatus *ourstatus,
int target_options)
3872 event_ptid =
linux_wait_1 (ptid, ourstatus, target_options);
3874 while ((target_options & TARGET_WNOHANG) == 0
3876 && ourstatus->kind == TARGET_WAITKIND_IGNORE);
3881 && (target_options & TARGET_WNOHANG) != 0
3896 ret = syscall (__NR_tkill, lwpid, signo);
3897 if (
errno == ENOSYS)
3924 debug_printf (
"Have pending sigstop for lwp %d\n", pid);
3978 lwp->
waitstatus.kind = TARGET_WAITKIND_EXITED;
3983 lwp->
waitstatus.kind = TARGET_WAITKIND_SIGNALLED;
4016 if (saved_thread != NULL)
4017 saved_tid = saved_thread->
id;
4058 "LWP %ld is suspended, suspended=%d\n",
4067 || lwp->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT
4083 "LWP %ld is suspended, suspended=%d\n",
4096 && lwp->
stop_reason != TARGET_STOPPED_BY_WATCHPOINT
4101 debug_printf (
"LWP %ld needs stabilizing (in jump pad)\n",
4148 suspend ?
"stop-and-suspend" :
"stop",
4174 debug_printf (
"stop_all_lwps done, setting stopping_threads " 4175 "back to !stopping\n");
4191 memset (&p_sig->
info, 0, sizeof (siginfo_t));
4193 memcpy (&p_sig->
info,
info, sizeof (siginfo_t));
4236 debug_printf (
"stepping is not implemented on this target");
4260 int step,
int signal, siginfo_t *info)
4283 || (fast_tp_collecting
4313 " has pending status\n",
4314 lwpid_of (thread), step ?
"step" :
"continue",
4343 warning (
"BAD - reinserting but not stepping.");
4345 warning (
"BAD - reinserting and suspended(%d).",
4356 debug_printf (
"lwp %ld wants to get out of fast tracepoint jump pad" 4357 " (exit-jump-pad-bkpt)\n",
4363 debug_printf (
"lwp %ld wants to get out of fast tracepoint jump pad" 4364 " single-stepping\n",
4372 "moving out of jump pad single-stepping" 4373 " not implemented on this target");
4388 debug_printf (
"lwp %ld has a while-stepping action -> forcing step.\n",
4402 debug_printf (
" %s from pc 0x%lx\n", step ?
"step" :
"continue",
4414 while ((*p_sig)->prev != NULL)
4415 p_sig = &(*p_sig)->
prev;
4417 signal = (*p_sig)->signal;
4418 if ((*p_sig)->info.si_signo != 0)
4427 debug_printf (
"Resuming lwp %ld (%s, signal %d, stop %s)\n",
4438 ptrace_request = PTRACE_SINGLESTEP;
4440 ptrace_request = PTRACE_SYSCALL;
4442 ptrace_request = PTRACE_CONT;
4502 int step,
int signal, siginfo_t *info)
4529 for (
int ndx = 0; ndx < n; ndx++)
4540 if (
resume[ndx].kind == resume_stop
4546 == TARGET_WAITKIND_STOPPED)
4556 if (
resume[ndx].kind != resume_stop
4576 && (rel->
waitstatus.kind == TARGET_WAITKIND_FORKED
4577 || rel->
waitstatus.kind == TARGET_WAITKIND_VFORKED))
4580 debug_printf (
"not resuming LWP %ld: has queued stop reply\n",
4593 debug_printf (
"not resuming LWP %ld: has queued stop reply\n",
4614 debug_printf (
"Dequeueing deferred signal %d for LWP %ld, " 4615 "leaving status pending.\n",
4659 if (proc->
tdesc == NULL)
4668 debug_printf (
"Need step over [LWP %ld]? Ignoring, not stopped\n",
4676 debug_printf (
"Need step over [LWP %ld]? Ignoring, should remain" 4687 debug_printf (
"Need step over [LWP %ld]? Ignoring, suspended\n",
4695 debug_printf (
"Need step over [LWP %ld]? Ignoring, has pending" 4713 debug_printf (
"Need step over [LWP %ld]? Cancelling, PC was changed. " 4714 "Old stop_pc was 0x%s, PC is now 0x%s\n",
4727 debug_printf (
"Need step over [LWP %ld]? Ignoring, has pending" 4748 debug_printf (
"Need step over [LWP %ld]? yes, but found" 4749 " GDB breakpoint at 0x%s; skipping step over\n",
4759 "found breakpoint at 0x%s\n",
4773 debug_printf (
"Need step over [LWP %ld]? No, no breakpoint found" 4799 debug_printf (
"Starting step-over on LWP %ld. Stopping all threads\n",
4807 "LWP %ld suspended=%d\n",
lwpid_of (thread),
4812 debug_printf (
"Done stopping all threads for step-over.\n");
4896 debug_printf (
"detach: step over in progress, finish it first\n");
4993 || leave_all_stopped);
4998 siginfo_t info, *info_p;
5052 bool any_pending =
false;
5065 bool leave_all_stopped = (need_step_over != NULL || any_pending);
5069 if (need_step_over != NULL)
5071 else if (any_pending)
5073 "an LWP with pending status\n");
5075 debug_printf (
"Resuming, no pending status or step over needed\n");
5132 debug_printf (
" client wants LWP to remain %ld stopped\n",
5140 debug_printf (
" LWP %ld has pending status, leaving stopped\n",
5171 "Making sure it has a SIGSTOP pending\n",
5180 debug_printf (
" stepping LWP %ld, client wants it stepping\n",
5237 if (need_step_over != NULL)
5241 "thread %ld needing a step-over\n",
5269 debug_printf (
"unstopping all lwps, except=(LWP %ld)\n",
5294 #ifdef HAVE_LINUX_REGSETS 5296 #define use_linux_regsets 1 5301 regset_disabled (
struct regsets_info *info,
struct regset_info *regset)
5303 return (info->disabled_regsets != NULL
5304 && info->disabled_regsets[regset - info->regsets]);
5310 disable_regset (
struct regsets_info *info,
struct regset_info *regset)
5314 dr_offset = regset - info->regsets;
5315 if (info->disabled_regsets == NULL)
5316 info->disabled_regsets = (
char *)
xcalloc (1, info->num_regsets);
5317 info->disabled_regsets[dr_offset] = 1;
5324 struct regset_info *regset;
5325 int saw_general_regs = 0;
5330 for (regset = regsets_info->regsets; regset->size >= 0; regset++)
5335 if (regset->size == 0 || regset_disabled (regsets_info, regset))
5340 nt_type = regset->nt_type;
5344 iov.iov_len = regset->size;
5345 data = (
void *) &iov;
5351 res =
ptrace (regset->get_request, pid,
5354 res =
ptrace (regset->get_request, pid, data, nt_type);
5362 disable_regset (regsets_info, regset);
5364 else if (
errno == ENODATA)
5370 else if (
errno == ESRCH)
5379 sprintf (s,
"ptrace(regsets_fetch_inferior_registers) PID=%d",
5386 if (regset->type == GENERAL_REGS)
5387 saw_general_regs = 1;
5388 regset->store_function (
regcache, buf);
5392 if (saw_general_regs)
5402 struct regset_info *regset;
5403 int saw_general_regs = 0;
5408 for (regset = regsets_info->regsets; regset->size >= 0; regset++)
5413 if (regset->size == 0 || regset_disabled (regsets_info, regset)
5414 || regset->fill_function == NULL)
5423 nt_type = regset->nt_type;
5427 iov.iov_len = regset->size;
5428 data = (
void *) &iov;
5434 res =
ptrace (regset->get_request, pid,
5437 res =
ptrace (regset->get_request, pid, data, nt_type);
5443 regset->fill_function (
regcache, buf);
5447 res =
ptrace (regset->set_request, pid,
5450 res =
ptrace (regset->set_request, pid, data, nt_type);
5460 disable_regset (regsets_info, regset);
5462 else if (
errno == ESRCH)
5473 perror (
"Warning: ptrace(regsets_store_inferior_registers)");
5476 else if (regset->type == GENERAL_REGS)
5477 saw_general_regs = 1;
5480 if (saw_general_regs)
5488 #define use_linux_regsets 0 5489 #define regsets_fetch_inferior_registers(regsets_info, regcache) 1 5490 #define regsets_store_inferior_registers(regsets_info, regcache) 1 5500 unsigned char mask = 1 << (regno % 8);
5501 size_t index = regno / 8;
5508 #ifdef HAVE_LINUX_USRREGS 5538 regaddr = register_addr (usrregs, regno);
5545 buf = (
char *)
alloca (size);
5552 ptrace (PTRACE_PEEKUSER, pid,
5582 regaddr = register_addr (usrregs, regno);
5589 buf = (
char *)
alloca (size);
5601 ptrace (PTRACE_POKEUSER, pid,
5635 for (regno = 0; regno < usr->
num_regs; regno++)
5637 fetch_register (usr,
regcache, regno);
5640 fetch_register (usr,
regcache, regno);
5656 for (regno = 0; regno < usr->
num_regs; regno++)
5658 store_register (usr,
regcache, regno);
5661 store_register (usr,
regcache, regno);
5666 #define usr_fetch_inferior_registers(regs_info, regcache, regno, all) do {} while (0) 5667 #define usr_store_inferior_registers(regs_info, regcache, regno, all) do {} while (0) 5747 if (len >= 3 *
sizeof (
long))
5753 sprintf (filename,
"/proc/%d/mem", pid);
5763 bytes = pread64 (fd, myaddr, len, memaddr);
5766 if (lseek (fd, memaddr, SEEK_SET) != -1)
5767 bytes = read (fd, myaddr, len);
5848 char str[4 * 2 + 1];
5850 int dump = len < 4 ? len : 4;
5852 for (i = 0; i < dump; i++)
5854 sprintf (p,
"%02x", myaddr[i]);
5860 str, (
long) memaddr, pid);
5878 =
ptrace (PTRACE_PEEKTEXT, pid,
5898 ptrace (PTRACE_POKETEXT, pid,
5913 #ifdef USE_THREAD_DB 5937 char filename[PATH_MAX];
5941 xsnprintf (filename,
sizeof filename,
"/proc/%d/auxv",
pid);
5943 fd = open (filename, O_RDONLY);
5948 && lseek (fd, (off_t)
offset, SEEK_SET) != (off_t)
offset)
5951 n = read (fd, myaddr, len);
6003 return (lwp->
stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT);
6023 return (lwp->
stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT);
6054 return lwp->
stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
6065 #if defined(__UCLIBC__) && defined(HAS_NOMMU) \ 6066 && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \ 6067 && defined(PT_TEXT_END_ADDR) 6080 unsigned long text, text_end, data;
6104 *data_p = data - (text_end - text);
6114 unsigned char *readbuf,
unsigned const char *writebuf,
6136 memcpy (siginfo, inf_siginfo,
sizeof (siginfo_t));
6138 memcpy (inf_siginfo, siginfo,
sizeof (siginfo_t));
6148 gdb_byte inf_siginfo[
sizeof (siginfo_t)];
6157 readbuf != NULL ?
"Reading" :
"Writing",
6160 if (
offset >=
sizeof (siginfo))
6172 if (
offset + len >
sizeof (siginfo))
6173 len =
sizeof (siginfo) -
offset;
6175 if (readbuf != NULL)
6176 memcpy (readbuf, inf_siginfo +
offset, len);
6179 memcpy (inf_siginfo +
offset, writebuf, len);
6198 int old_errno =
errno;
6206 if (write (2,
"sigchld_handler\n",
6207 sizeof (
"sigchld_handler\n") - 1) < 0)
6233 if (previous != enable)
6236 sigemptyset (&mask);
6237 sigaddset (&mask, SIGCHLD);
6239 sigprocmask (SIG_BLOCK, &mask, NULL);
6247 sigprocmask (SIG_UNBLOCK, &mask, NULL);
6249 warning (
"creating event pipe failed.");
6273 sigprocmask (SIG_UNBLOCK, &mask, NULL);
6354 #ifdef HAVE_PERSONALITY 6386 struct dirent *entry;
6388 sprintf (path,
"/proc/%ld/fd", pid);
6389 dir = opendir (path);
6394 while ((entry = readdir (dir)) != NULL)
6400 fd = atoi (entry->d_name);
6404 sprintf (path,
"/proc/%ld/fd/%d", pid, fd);
6405 if (stat (path, &st) != 0)
6410 if (statfs (path, &stfs) != 0)
6417 *(
unsigned int *)(buf + pos -
offset) = fd;
6431 unsigned const char *writebuf,
6439 if (!writebuf && !readbuf)
6450 sprintf (buf,
"/proc/%ld/fd/%s", pid, annex);
6451 fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
6456 && lseek (fd, (off_t)
offset, SEEK_SET) != (off_t)
offset)
6463 ret = write (fd, writebuf, (
size_t) len);
6465 ret = read (fd, readbuf, (
size_t) len);
6471 #if defined PT_GETDSBT || defined PTRACE_GETFDPIC 6472 struct target_loadseg
6482 # if defined PT_GETDSBT 6483 struct target_loadmap
6488 unsigned *dsbt_table;
6489 unsigned dsbt_size, dsbt_index;
6493 struct target_loadseg segs[];
6495 # define LINUX_LOADMAP PT_GETDSBT 6496 # define LINUX_LOADMAP_EXEC PTRACE_GETDSBT_EXEC 6497 # define LINUX_LOADMAP_INTERP PTRACE_GETDSBT_INTERP 6499 struct target_loadmap
6506 struct target_loadseg segs[];
6508 # define LINUX_LOADMAP PTRACE_GETFDPIC 6509 # define LINUX_LOADMAP_EXEC PTRACE_GETFDPIC_EXEC 6510 # define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP 6515 unsigned char *myaddr,
unsigned int len)
6519 struct target_loadmap *data = NULL;
6520 unsigned int actual_length, copy_length;
6522 if (strcmp (annex,
"exec") == 0)
6523 addr = (int) LINUX_LOADMAP_EXEC;
6524 else if (strcmp (annex,
"interp") == 0)
6525 addr = (
int) LINUX_LOADMAP_INTERP;
6529 if (
ptrace (LINUX_LOADMAP, pid, addr, &data) != 0)
6535 actual_length =
sizeof (
struct target_loadmap)
6536 + sizeof (struct target_loadseg) * data->nsegs;
6538 if (offset < 0 || offset > actual_length)
6541 copy_length = actual_length -
offset < len ? actual_length -
offset : len;
6542 memcpy (myaddr, (
char *) data +
offset, copy_length);
6546 # define linux_read_loadmap NULL 6648 unsigned char *jjump_pad_insn,
6655 (tpoint, tpaddr, collector, lockaddr, orig_size,
6656 jump_entry, trampoline, trampoline_size,
6657 jjump_pad_insn, jjump_pad_insn_size,
6658 adjusted_insn_addr, adjusted_insn_addr_end,
6683 char filename[PATH_MAX];
6685 const int auxv_size = is_elf64
6689 xsnprintf (filename,
sizeof filename,
"/proc/%d/auxv", pid);
6691 fd = open (filename, O_RDONLY);
6697 while (read (fd, buf, auxv_size) == auxv_size
6698 && (*phdr_memaddr == 0 || *num_phdr == 0))
6732 if (*phdr_memaddr == 0 || *num_phdr == 0)
6734 warning (
"Unexpected missing AT_PHDR and/or AT_PHNUM: " 6735 "phdr_memaddr = %ld, phdr_num = %d",
6736 (
long) *phdr_memaddr, *num_phdr);
6750 unsigned char *phdr_buf;
6751 const int phdr_size = is_elf64 ?
sizeof (Elf64_Phdr) :
sizeof (Elf32_Phdr);
6757 phdr_buf = (
unsigned char *)
alloca (num_phdr * phdr_size);
6765 for (i = 0; relocation == -1 && i < num_phdr; i++)
6768 Elf64_Phdr *
const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
6770 if (p->p_type == PT_PHDR)
6771 relocation = phdr_memaddr - p->p_vaddr;
6775 Elf32_Phdr *
const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
6777 if (p->p_type == PT_PHDR)
6778 relocation = phdr_memaddr - p->p_vaddr;
6781 if (relocation == -1)
6796 for (i = 0; i < num_phdr; i++)
6800 Elf64_Phdr *
const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
6802 if (p->p_type == PT_DYNAMIC)
6803 return p->p_vaddr + relocation;
6807 Elf32_Phdr *
const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
6809 if (p->p_type == PT_DYNAMIC)
6810 return p->p_vaddr + relocation;
6826 const int dyn_size = is_elf64 ?
sizeof (Elf64_Dyn) :
sizeof (Elf32_Dyn);
6827 unsigned char buf[
sizeof (Elf64_Dyn)];
6831 if (dynamic_memaddr == 0)
6838 Elf64_Dyn *
const dyn = (Elf64_Dyn *) buf;
6839 #if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL 6843 unsigned char buf[
sizeof (Elf64_Xword)];
6847 #ifdef DT_MIPS_RLD_MAP 6848 if (dyn->d_tag == DT_MIPS_RLD_MAP)
6851 rld_map.buf, sizeof (rld_map.buf)) == 0)
6857 #ifdef DT_MIPS_RLD_MAP_REL 6858 if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
6861 rld_map.buf, sizeof (rld_map.buf)) == 0)
6868 if (dyn->d_tag == DT_DEBUG && map == -1)
6869 map = dyn->d_un.d_val;
6871 if (dyn->d_tag == DT_NULL)
6876 Elf32_Dyn *
const dyn = (Elf32_Dyn *) buf;
6877 #if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL 6881 unsigned char buf[
sizeof (Elf32_Word)];
6885 #ifdef DT_MIPS_RLD_MAP 6886 if (dyn->d_tag == DT_MIPS_RLD_MAP)
6889 rld_map.buf, sizeof (rld_map.buf)) == 0)
6895 #ifdef DT_MIPS_RLD_MAP_REL 6896 if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
6899 rld_map.buf, sizeof (rld_map.buf)) == 0)
6906 if (dyn->d_tag == DT_DEBUG && map == -1)
6907 map = dyn->d_un.d_val;
6909 if (dyn->d_tag == DT_NULL)
6913 dynamic_memaddr += dyn_size;
6941 *ptr = addr.core_addr;
6942 else if (ptr_size ==
sizeof (
unsigned int))
6978 unsigned const char *writebuf,
6982 unsigned document_len;
6984 char filename[PATH_MAX];
7009 unsigned int machine;
7012 int allocated = 1024;
7014 CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
7015 int header_done = 0;
7017 if (writebuf != NULL)
7019 if (readbuf == NULL)
7023 xsnprintf (filename,
sizeof filename,
"/proc/%d/exe", pid);
7025 lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets;
7026 ptr_size = is_elf64 ? 8 : 4;
7028 while (annex[0] !=
'\0')
7034 sep = strchr (annex,
'=');
7041 else if (len == 4 &&
startswith (annex,
"prev"))
7045 annex = strchr (sep,
';');
7071 (
unsigned char *) &r_version,
7072 sizeof (r_version)) != 0
7075 warning (
"unexpected r_debug version %d", r_version);
7078 &lm_addr, ptr_size) != 0)
7080 warning (
"unable to read r_map from 0x%lx",
7086 document = (
char *)
xmalloc (allocated);
7087 strcpy (document,
"<library-list-svr4 version=\"1.0\"");
7088 p = document + strlen (document);
7092 &l_name, ptr_size) == 0
7094 &l_addr, ptr_size) == 0
7096 &l_ld, ptr_size) == 0
7098 &l_prev, ptr_size) == 0
7100 &l_next, ptr_size) == 0)
7102 unsigned char libname[PATH_MAX];
7104 if (lm_prev != l_prev)
7106 warning (
"Corrupted shared library list: 0x%lx != 0x%lx",
7107 (
long) lm_prev, (
long) l_prev);
7119 sprintf (p,
" main-lm=\"0x%lx\"", (
unsigned long) lm_addr);
7128 libname[
sizeof (libname) - 1] =
'\0';
7129 if (libname[0] !=
'\0')
7132 size_t len = 6 * strlen ((
char *) libname);
7141 while (allocated < p - document + len + 200)
7144 uintptr_t document_len = p - document;
7146 document = (
char *)
xrealloc (document, 2 * allocated);
7148 p = document + document_len;
7152 p += sprintf (p,
"<library name=\"%s\" lm=\"0x%lx\" " 7153 "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
7154 name.c_str (), (
unsigned long) lm_addr,
7155 (
unsigned long) l_addr, (
unsigned long) l_ld);
7169 strcpy (p,
"</library-list-svr4>");
7171 document_len = strlen (document);
7172 if (
offset < document_len)
7176 if (len > document_len)
7179 memcpy (readbuf, document +
offset, len);
7185 #ifdef HAVE_LINUX_BTRACE 7210 "model=\"%u\" stepping=\"%u\"/>\n",
7238 elem[0] =
tohex ((*data >> 4) & 0xf);
7239 elem[1] =
tohex (*data++ & 0xf);
7271 switch (btrace.format)
7295 linux_low_encode_pt_config (
buffer, &btrace.variant.pt.config);
7297 linux_low_encode_raw (
buffer, btrace.variant.pt.data,
7298 btrace.variant.pt.size);
7402 uint32_t newpc = pc;
7427 uint64_t newpc = pc;
7477 #if defined(__UCLIBC__) && defined(HAS_NOMMU) \ 7478 && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \ 7479 && defined(PT_TEXT_END_ADDR) 7484 #ifdef USE_THREAD_DB 7501 #ifdef USE_THREAD_DB 7523 #ifdef HAVE_LINUX_BTRACE 7526 linux_low_disable_btrace,
7527 linux_low_read_btrace,
7528 linux_low_btrace_conf,
7555 #ifdef HAVE_LINUX_REGSETS 7557 initialize_regsets_info (
struct regsets_info *info)
7559 for (info->num_regsets = 0;
7560 info->regsets[info->num_regsets].size >= 0;
7561 info->num_regsets++)
7569 struct sigaction sigchld_action;
7571 memset (&sigchld_action, 0,
sizeof (sigchld_action));
7577 sigemptyset (&sigchld_action.sa_mask);
7578 sigchld_action.sa_flags = SA_RESTART;
7579 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
CORE_ADDR linux_get_pc_64bit(struct regcache *regcache)
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
static void linux_resume_one_thread(thread_info *thread, bool leave_all_stopped)
#define PTRACE_GETEVENTMSG
int handle_target_event(int err, gdb_client_data client_data)
void collect_register(struct regcache *regcache, int n, void *buf)
int lwp_is_stepping(struct lwp_info *lwp)
constexpr int pid() const
constexpr long lwp() const
struct process_info * add_process(int pid, int attached)
struct thread_info * find_thread_ptid(ptid_t ptid)
static void xfree(T *ptr)
int gdb_condition_true_at_breakpoint(CORE_ADDR where)
int ptid_is_pid(const ptid_t &ptid)
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)
static int linux_supports_hardware_single_step(void)
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)
static int elf_64_file_p(const char *file, unsigned int *machine)
void(* new_fork)(struct process_info *parent, struct process_info *child)
void supply_register_by_name(struct regcache *regcache, const char *name, const void *buf)
static int linux_insert_point(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
static int linux_breakpoint_kind_from_pc(CORE_ADDR *pcptr)
int ptid_get_pid(const ptid_t &ptid)
std::string stringify_argv(const std::vector< char *> &args)
static int linux_attach(unsigned long pid)
int(* cannot_store_register)(int)
#define PTRACE_EVENT_EXEC
int(* supports_z_point_type)(char z_type)
void thread_db_mourn(struct process_info *)
static void enqueue_one_deferred_signal(struct lwp_info *lwp, int *wstat)
void warning(const char *fmt,...)
static long lwpid_of(const thread_info *thread)
int has_single_step_breakpoints(struct thread_info *thread)
int linux_wstatus_maybe_breakpoint(int wstat)
static int save_stop_reason(struct lwp_info *lwp)
static ptid_t ptid_of(const thread_info *thread)
static void linux_resume_one_lwp_throw(struct lwp_info *lwp, int step, int signal, siginfo_t *info)
int default_breakpoint_kind_from_pc(CORE_ADDR *pcptr)
void btrace_data_fini(struct btrace_data *data)
struct lwp_info * find_lwp_pid(ptid_t ptid)
static int linux_supports_disable_randomization(void)
int linux_is_extended_waitstatus(int wstat)
int(* breakpoint_kind_from_current_state)(CORE_ADDR *pcptr)
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)
CORE_ADDR adjusted_insn_addr_end
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
static thread_info * find_thread(Func func)
static void linux_join(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 handle_extended_wait(struct lwp_info **orig_event_lwp, int wstat)
static int linux_supports_range_stepping(void)
#define usr_store_inferior_registers(regs_info, regcache, regno, all)
static ptid_t linux_wait(ptid_t ptid, struct target_waitstatus *ourstatus, int target_options)
static void linux_done_accessing_memory(void)
static int single_step(struct lwp_info *lwp)
static void unsuspend_and_proceed_one_lwp(thread_info *thread, lwp_info *except)
int have_ptrace_getregset
char * paddress(CORE_ADDR addr)
static int elf_64_header_p(const Elf64_Ehdr *header, unsigned int *machine)
void linux_check_ptrace_features(void)
const struct regs_info *(* regs_info)(void)
int(* stopped_by_watchpoint)(void)
constexpr bool matches(const ptid_t &filter) const
static void linux_stabilize_threads(void)
enum btrace_error linux_read_btrace(struct btrace_data *btrace, struct btrace_target_info *tinfo, enum btrace_read_type type)
void uninsert_single_step_breakpoints(struct thread_info *thread)
struct wstep_state * while_stepping
void(* mourn)(struct process_info *proc)
const char * linux_proc_tid_get_name(ptid_t ptid)
void linux_set_pc_64bit(struct regcache *regcache, CORE_ADDR pc)
bool thread_db_thread_handle(ptid_t ptid, gdb_byte **handle, int *handle_len)
struct linux_target_ops the_low_target
static void linux_ptrace_fun()
static void resume_stopped_resumed_lwps(thread_info *thread)
static void for_each_thread(Func func)
static void linux_set_resume_request(thread_info *thread, thread_resume *resume, size_t n)
#define get_thread_lwp(thr)
static int pid_of(const thread_info *thread)
struct target_ops * the_target
int single_step_breakpoint_inserted_here(CORE_ADDR addr)
#define GDB_ARCH_IS_TRAP_HWBKPT(X)
static void install_software_single_step_breakpoints(struct lwp_info *lwp)
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 void wait_for_sigstop(void)
static void unstop_all_lwps(int unsuspend, struct lwp_info *except)
void thread_db_notice_clone(struct thread_info *parent_thr, ptid_t child_ptid)
void perror(const char *)
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)
void set_single_step_breakpoint(CORE_ADDR stop_at, ptid_t ptid)
static bool status_pending_p_callback(thread_info *thread, ptid_t ptid)
enum resume_kind last_resume_kind
#define PTRACE_EVENT_VFORK_DONE
char * xstrdup(const char *s)
static void linux_arch_setup_thread(struct thread_info *thread)
static ptid_t filter_exit_event(struct lwp_info *event_child, struct target_waitstatus *ourstatus)
struct target_desc * allocate_target_description(void)
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 struct lwp_info * linux_low_filter_event(int lwpid, int wstat)
static int linux_supports_catch_syscall(void)
static void linux_detach_lwp_callback(thread_info *thread)
static void async_file_mark(void)
#define PTRACE_EVENT_FORK
fast_tpoint_collect_result fast_tracepoint_collecting(CORE_ADDR thread_area, CORE_ADDR stop_pc, struct fast_tpoint_collect_status *status)
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)
union Elf32_auxv_t::@4 a_un
CORE_ADDR linux_get_pc_32bit(struct regcache *regcache)
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)
unsigned char * regset_bitmap
static void linux_kill_one_lwp(struct lwp_info *lwp)
static int linux_thread_stopped(struct thread_info *thread)
int in_queued_stop_replies(ptid_t ptid)
void collect_register_by_name(struct regcache *regcache, const char *name, void *buf)
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)
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)
fast_tpoint_collect_result collecting_fast_tracepoint
void release_while_stepping_state_list(struct thread_info *tinfo)
void uninsert_fast_tracepoint_jumps_at(CORE_ADDR pc)
static bool resume_status_pending_p(thread_info *thread)
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 lwp_signal_can_be_delivered(struct lwp_info *lwp)
static void linux_detach_one_lwp(struct lwp_info *lwp)
static int start_step_over(struct lwp_info *lwp)
gdb_environ * get_environ()
int disable_randomization
void buffer_xml_printf(struct buffer *buffer, const char *format,...)
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)
process_info * find_process_pid(int pid)
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
fast_tpoint_collect_result
int(* supports_hardware_single_step)(void)
#define regsets_store_inferior_registers(regsets_info, regcache)
int linux_ptrace_get_extended_event(int wstat)
static void linux_arch_setup(void)
#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)
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)
std::vector< int > syscalls_to_catch
static int attach_proc_task_lwp_callback(ptid_t ptid)
static int check_stopped_by_watchpoint(struct lwp_info *child)
static int gdb_catching_syscalls_p(struct lwp_info *event_child)
int linux_supports_traceexec(void)
int gdb_signal_to_host(enum gdb_signal)
#define get_lwp_thread(lwp)
int register_size(const struct target_desc *tdesc, int n)
static int can_software_single_step(void)
int breakpoint_here(CORE_ADDR addr)
CORE_ADDR step_range_start
static int linux_breakpoint_kind_from_current_state(CORE_ADDR *pcptr)
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)
int thread_db_get_tls_address(struct thread_info *thread, CORE_ADDR offset, CORE_ADDR load_module, CORE_ADDR *address)
static void linux_fetch_registers(struct regcache *regcache, int regno)
static int handle_tracepoints(struct lwp_info *lwp)
static void linux_store_registers(struct regcache *regcache, int regno)
void(* collect_ptrace_register)(struct regcache *regcache, int regno, char *buf)
static void suspend_and_send_sigstop(thread_info *thread, lwp_info *except)
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 void kill_one_lwp_callback(thread_info *thread, int pid)
static fast_tpoint_collect_result linux_fast_tracepoint_collecting(struct lwp_info *lwp, struct fast_tpoint_collect_status *status)
static int maybe_hw_step(struct thread_info *thread)
static int startswith(const char *string, const char *pattern)
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 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)
int() iterate_over_lwps_ftype(struct lwp_info *lwp, void *arg)
static int thread_still_has_status_pending_p(struct thread_info *thread)
static int gdb_catch_this_syscall_p(struct lwp_info *event_child)
void(* delete_process)(struct arch_process_info *info)
static void enqueue_pending_signal(struct lwp_info *lwp, int signal, siginfo_t *info)
char * status_to_str(int status)
#define PTRACE_O_TRACEEXEC
struct process_info_private * priv
#define buffer_grow_str(BUFFER, STRING)
static int stabilizing_threads
std::string xml_escape_text(const char *text)
int(* breakpoint_kind_from_pc)(CORE_ADDR *pcptr)
long ptid_get_lwp(const ptid_t &ptid)
const gdb_byte *(* sw_breakpoint_from_kind)(int kind, int *size)
void thread_db_detach(struct process_info *)
static int supports_fast_tracepoints(void)
static bool stuck_in_jump_pad_callback(thread_info *thread)
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)
void(* get_syscall_trapinfo)(struct regcache *regcache, int *sysno)
void post_fork_inferior(int pid, const char *program)
enum target_waitkind syscall_state
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 linux_set_pc_32bit(struct regcache *regcache, CORE_ADDR pc)
void run_breakpoint_commands(CORE_ADDR where)
static void linux_process_qsupported(char **features, int count)
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)
#define PTRACE_GETSIGINFO
#define target_is_async_p()
struct btrace_config_pt pt
#define USE_SIGTRAP_SIGINFO
static void linux_post_create_inferior(void)
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 *)
static bool lwp_running(thread_info *thread)
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_supports_exec_events(void)
static void for_each_process(Func func)
const gdb_byte *(* sw_breakpoint_from_kind)(int kind, int *size)
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
#define GDB_ARCH_IS_TRAP_BRKPT(X)
int linux_proc_pid_is_gone(pid_t pid)
static void linux_handle_new_gdb_connection(void)
void trace_start_error_with_name(const char *string)
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 spu_enumerate_spu_ids(long pid, unsigned char *buf, CORE_ADDR offset, int len)
static void lwp_suspended_inc(struct lwp_info *lwp)
static void move_out_of_jump_pad_callback(thread_info *thread)
void reinsert_breakpoints_at(CORE_ADDR pc)
void delete_single_step_breakpoints(struct thread_info *thread)
int tracepoint_finished_step(struct thread_info *tinfo, CORE_ADDR stop_pc)
pid_t fork_inferior(const char *exec_file_arg, const std::string &allargs, char **env, void(*traceme_fun)(), void(*init_trace_fun)(int), void(*pre_trace_fun)(), const char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
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)
static const gdb_byte * linux_sw_breakpoint_from_kind(int kind, int *size)
#define PTRACE_SETSIGINFO
void linux_enable_event_reporting(pid_t pid, int options)
static void proceed_one_lwp(thread_info *thread, lwp_info *except)
static void lwp_suspended_decr(struct lwp_info *lwp)
#define PTRACE_EVENT_VFORK
static void resume(struct thread_resume *actions, size_t n)
struct cleanup * make_cleanup_restore_current_thread(void)
struct thread_resume * resume
struct lwp_info * fork_relative
void regcache_invalidate_thread(struct thread_info *thread)
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)
void reinsert_single_step_breakpoints(struct thread_info *thread)
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
union Elf64_auxv_t::@5 a_un
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)
static int linux_supports_software_single_step(void)
void remove_thread(struct thread_info *thread)
int insert_memory_breakpoint(struct raw_breakpoint *bp)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
void(* process_qsupported)(char **, int count)
enum target_stop_reason stop_reason
int breakpoint_inserted_here(CORE_ADDR addr)
static CORE_ADDR linux_read_pc(struct regcache *regcache)
static int linux_get_ipa_tdesc_idx(void)
static bool need_step_over_p(thread_info *thread)
static int dequeue_one_deferred_signal(struct lwp_info *lwp, int *wstat)
static int linux_kill(int pid)
static void get_syscall_trapinfo(struct lwp_info *lwp, int *sysno)
static void linux_write_pc(struct regcache *regcache, CORE_ADDR pc)
int(* get_ipa_tdesc_idx)(void)
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))
#define PTRACE_O_TRACESYSGOOD
int linux_mntns_open_cloexec(pid_t pid, const char *filename, int flags, mode_t mode)
int(* breakpoint_kind_from_current_state)(CORE_ADDR *pcptr)
static int linux_prepare_to_access_memory(void)
static void check_zombie_leaders(void)
const char * gdb_signal_to_string(enum gdb_signal)
void(* delete_thread)(struct arch_lwp_info *)
static void siginfo_fixup(siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
static int linux_create_inferior(const char *program, const std::vector< char *> &program_args)
static int linux_xfer_siginfo(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static int linux_supports_z_point_type(char z_type)
static int lwp_resumed(struct lwp_info *lwp)
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]
void initialize_low(void)
void debug_printf(const char *fmt,...)
static thread_info * find_thread_in_random(Func func)
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 int linux_start_non_stop(int nonstop)
static int linux_write_memory(CORE_ADDR memaddr, const unsigned char *myaddr, int len)
static std::vector< char * > program_args
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 kill_lwp(unsigned long lwpid, int signo)
#define PTRACE_O_EXITKILL
int(* siginfo_fixup)(siginfo_t *native, gdb_byte *inf, int direction)
void clone_all_breakpoints(struct thread_info *child_thread, const struct thread_info *parent_thread)
struct arch_lwp_info * lwp_arch_private_info(struct lwp_info *lwp)
void error(const char *fmt,...)
struct process_info * get_thread_process(const struct thread_info *thread)
int delete_breakpoint(struct breakpoint *todel)
int linux_supports_tracesysgood(void)
std::vector< CORE_ADDR >(* get_next_pcs)(struct regcache *regcache)
static bool not_stopped_callback(thread_info *thread, ptid_t filter)
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 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)