diff options
author | markj <markj@FreeBSD.org> | 2014-05-04 03:34:32 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2014-05-04 03:34:32 +0000 |
commit | bddfd9feb6bf0e57bbc5d9c020e96bd4168448ad (patch) | |
tree | f1394d4a73972700719026b1b857a9c0577ae0e3 /lib/libproc/proc_bkpt.c | |
parent | baf69d5639fe2290e61dec8cdb426f24b4bef1e5 (diff) | |
download | FreeBSD-src-bddfd9feb6bf0e57bbc5d9c020e96bd4168448ad.zip FreeBSD-src-bddfd9feb6bf0e57bbc5d9c020e96bd4168448ad.tar.gz |
If the traced process stops because it received a signal, libproc needs
to ensure that the signal is forwarded when proc_continue() is called.
MFC after: 3 weeks
Diffstat (limited to 'lib/libproc/proc_bkpt.c')
-rw-r--r-- | lib/libproc/proc_bkpt.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c index 2c2761a..fe6ed4a 100644 --- a/lib/libproc/proc_bkpt.c +++ b/lib/libproc/proc_bkpt.c @@ -55,13 +55,6 @@ __FBSDID("$FreeBSD$"); #error "Add support for your architecture" #endif -static void -proc_cont(struct proc_handle *phdl) -{ - - ptrace(PT_CONTINUE, proc_getpid(phdl), (caddr_t)1, 0); -} - static int proc_stop(struct proc_handle *phdl) { @@ -87,7 +80,7 @@ proc_bkptset(struct proc_handle *phdl, uintptr_t address, { struct ptrace_io_desc piod; unsigned long paddr, caddr; - int ret = 0; + int ret = 0, stopped; *saved = 0; if (phdl->status == PS_DEAD || phdl->status == PS_UNDEAD || @@ -98,9 +91,12 @@ proc_bkptset(struct proc_handle *phdl, uintptr_t address, DPRINTFX("adding breakpoint at 0x%lx", address); - if (phdl->status != PS_STOP) + stopped = 0; + if (phdl->status != PS_STOP) { if (proc_stop(phdl) != 0) return (-1); + stopped = 1; + } /* * Read the original instruction. @@ -135,9 +131,9 @@ proc_bkptset(struct proc_handle *phdl, uintptr_t address, } done: - if (phdl->status != PS_STOP) + if (stopped) /* Restart the process if we had to stop it. */ - proc_cont(phdl); + proc_continue(phdl); return (ret); } @@ -148,7 +144,7 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address, { struct ptrace_io_desc piod; unsigned long paddr, caddr; - int ret = 0; + int ret = 0, stopped; if (phdl->status == PS_DEAD || phdl->status == PS_UNDEAD || phdl->status == PS_IDLE) { @@ -158,9 +154,12 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address, DPRINTFX("removing breakpoint at 0x%lx", address); - if (phdl->status != PS_STOP) + stopped = 0; + if (phdl->status != PS_STOP) { if (proc_stop(phdl) != 0) return (-1); + stopped = 1; + } /* * Overwrite the breakpoint instruction that we setup previously. @@ -177,9 +176,9 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address, ret = -1; } - if (phdl->status != PS_STOP) + if (stopped) /* Restart the process if we had to stop it. */ - proc_cont(phdl); + proc_continue(phdl); return (ret); } |