From owner-svn-src-head@freebsd.org Wed Jul 25 18:11:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50A1210511B9; Wed, 25 Jul 2018 18:11:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 05ADB884E8; Wed, 25 Jul 2018 18:11:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3C161D9FF; Wed, 25 Jul 2018 18:11:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6PIBbKw028001; Wed, 25 Jul 2018 18:11:37 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PIBbkp028000; Wed, 25 Jul 2018 18:11:37 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201807251811.w6PIBbkp028000@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 25 Jul 2018 18:11:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336722 - head/sys/arm/arm X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/arm/arm X-SVN-Commit-Revision: 336722 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2018 18:11:38 -0000 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 */