breakpoint: enable breakpoints by default on amd64 and arm64

Signed-off-by: fu.lin <fulin10@huawei.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
fu.lin 2022-08-09 12:18:00 -07:00 committed by Andrei Vagin
parent bb73e1cf5a
commit dfe9d006ad
3 changed files with 23 additions and 8 deletions

View file

@ -207,6 +207,7 @@ static struct hwbp_cap *ptrace_get_hwbp_cap(pid_t pid)
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
k_rtsigset_t block;
struct hwbp_cap *info = ptrace_get_hwbp_cap(pid);
struct user_hwdebug_state regs = {};
unsigned int ctrl = 0;
@ -242,6 +243,17 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
if (ptrace(PTRACE_SETREGSET, pid, NT_ARM_HW_BREAK, &iovec))
return -1;
/*
* FIXME(issues/1429): SIGTRAP can't be blocked, otherwise its handler
* will be reset to the default one.
*/
ksigfillset(&block);
ksigdelset(&block, SIGTRAP);
if (ptrace(PTRACE_SETSIGMASK, pid, sizeof(k_rtsigset_t), &block)) {
pr_perror("Can't block signals for %d", pid);
return -1;
}
if (ptrace(PTRACE_CONT, pid, NULL, NULL) != 0) {
pr_perror("Unable to restart the stopped tracee process %d", pid);
return -1;

View file

@ -588,6 +588,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
k_rtsigset_t block;
int ret;
/* Set a breakpoint */
@ -603,6 +604,16 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
return -1;
}
/*
* FIXME(issues/1429): SIGTRAP can't be blocked, otherwise its handler
* will be reset to the default one.
*/
ksigfillset(&block);
ksigdelset(&block, SIGTRAP);
if (ptrace(PTRACE_SETSIGMASK, pid, sizeof(k_rtsigset_t), &block)) {
pr_perror("Can't block signals for %d", pid);
return -1;
}
ret = ptrace(PTRACE_CONT, pid, NULL, NULL);
if (ret) {
pr_perror("Unable to restart the stopped tracee process %d", pid);

View file

@ -24,14 +24,6 @@ enum faults {
static inline bool __fault_injected(enum faults f, enum faults fi_strategy)
{
/*
* Temporary workaround for Xen guests. Breakpoints degrade
* performance linearly, so until we find out the reason,
* let's disable them.
*/
if (f == FI_NO_BREAKPOINTS)
return true;
return fi_strategy == f;
}