Date: Wed, 25 Jul 2018 18:11:37 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336722 - head/sys/arm/arm Message-ID: <201807251811.w6PIBbkp028000@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Jul 25 18:11:37 2018 New Revision: 336722 URL: https://svnweb.freebsd.org/changeset/base/336722 Log: Raise a proper SIGTRAP / TRAP_TRACE signal for a PT_STEP step on arm. Previously, a step by PT_STEP resulted in no signal being raised to the debugger so that a step was silently completed with the program continuing to execute after the step. Fix by raising a SIGTRAP signal with TRAP_TRACE as the signal code. To simplify the error handling cases (if ptrace_clear_single_step() fails, etc.) move the handling of PTRACE_BREAKPOINT into the gdb_trapper() function. If ptrace_clear_single_step() fails, gdb_trapper() won't claim the fault, and the default case of SIGILL / ILL_OPC will be used. Differential Revision: https://reviews.freebsd.org/D16100 Modified: head/sys/arm/arm/undefined.c Modified: head/sys/arm/arm/undefined.c ============================================================================== --- head/sys/arm/arm/undefined.c Wed Jul 25 17:45:56 2018 (r336721) +++ head/sys/arm/arm/undefined.c Wed Jul 25 18:11:37 2018 (r336722) @@ -144,6 +144,7 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe * { struct thread *td; ksiginfo_t ksi; + int error; td = (curthread == NULL) ? &thread0 : curthread; @@ -162,6 +163,27 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe * #endif #endif } + + if (code == FAULT_USER) { + /* TODO: No support for ptrace from Thumb-2 */ + if ((frame->tf_spsr & PSR_T) == 0 && + insn == PTRACE_BREAKPOINT) { + PROC_LOCK(td->td_proc); + _PHOLD(td->td_proc); + error = ptrace_clear_single_step(td); + _PRELE(td->td_proc); + PROC_UNLOCK(td->td_proc); + if (error == 0) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGTRAP; + ksi.ksi_code = TRAP_TRACE; + ksi.ksi_addr = (u_int32_t *)addr; + trapsignal(td, &ksi); + return (0); + } + } + } + return 1; } @@ -191,7 +213,6 @@ undefinedinstruction(struct trapframe *frame) int fault_code; int coprocessor; struct undefined_handler *uh; - int error; #ifdef VERBOSE_ARM32 int s; #endif @@ -304,26 +325,6 @@ undefinedinstruction(struct trapframe *frame) if (uh->uh_handler(fault_pc, fault_instruction, frame, fault_code) == 0) break; - - if (fault_code & FAULT_USER) { - /* TODO: No support for ptrace from Thumb-2 */ - if ((frame->tf_spsr & PSR_T) == 0 && - fault_instruction == PTRACE_BREAKPOINT) { - PROC_LOCK(td->td_proc); - _PHOLD(td->td_proc); - error = ptrace_clear_single_step(td); - _PRELE(td->td_proc); - PROC_UNLOCK(td->td_proc); - if (error != 0) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGILL; - ksi.ksi_code = ILL_ILLOPC; - ksi.ksi_addr = (u_int32_t *)(intptr_t) fault_pc; - trapsignal(td, &ksi); - } - return; - } - } if (uh == NULL && (fault_code & FAULT_USER)) { /* Fault has not been handled */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807251811.w6PIBbkp028000>