diff options
author | markj <markj@FreeBSD.org> | 2013-10-27 20:39:10 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2013-10-27 20:39:10 +0000 |
commit | 7799e7909514ade5a6bed2c5c96437f480fb66ff (patch) | |
tree | c3e5d57b0ede806e1bbdfd6008e59072bea60245 /lib/libproc/proc_bkpt.c | |
parent | 977e19e0686a42b91c6eeb80be9a14338f1b7f2e (diff) | |
download | FreeBSD-src-7799e7909514ade5a6bed2c5c96437f480fb66ff.zip FreeBSD-src-7799e7909514ade5a6bed2c5c96437f480fb66ff.tar.gz |
Clean up the debug printing in libproc a bit. In particular:
* Don't print any error messages to stderr unless DEBUG is defined.
* Add a DPRINTFX macro for use when errno isn't set.
* Print the error string from libelf when appropriate.
Diffstat (limited to 'lib/libproc/proc_bkpt.c')
-rw-r--r-- | lib/libproc/proc_bkpt.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c index c15e53c..1878c7f 100644 --- a/lib/libproc/proc_bkpt.c +++ b/lib/libproc/proc_bkpt.c @@ -78,8 +78,8 @@ proc_bkptset(struct proc_handle *phdl, uintptr_t address, piod.piod_addr = &paddr; piod.piod_len = BREAKPOINT_INSTR_SZ; if (ptrace(PT_IO, proc_getpid(phdl), (caddr_t)&piod, 0) < 0) { - DPRINTF("ERROR: couldn't read instruction at address 0x%" PRIuPTR, - address); + DPRINTF("ERROR: couldn't read instruction at address 0x%" + PRIuPTR, address); return (-1); } *saved = paddr; @@ -93,8 +93,8 @@ proc_bkptset(struct proc_handle *phdl, uintptr_t address, piod.piod_addr = &paddr; piod.piod_len = BREAKPOINT_INSTR_SZ; if (ptrace(PT_IO, proc_getpid(phdl), (caddr_t)&piod, 0) < 0) { - warn("ERROR: couldn't write instruction at address 0x%" PRIuPTR, - address); + DPRINTF("ERROR: couldn't write instruction at address 0x%" + PRIuPTR, address); return (-1); } @@ -113,7 +113,7 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address, errno = ENOENT; return (-1); } - DPRINTF("removing breakpoint at 0x%lx\n", address); + DPRINTFX("removing breakpoint at 0x%lx\n", address); /* * Overwrite the breakpoint instruction that we setup previously. */ @@ -124,8 +124,8 @@ proc_bkptdel(struct proc_handle *phdl, uintptr_t address, piod.piod_addr = &paddr; piod.piod_len = BREAKPOINT_INSTR_SZ; if (ptrace(PT_IO, proc_getpid(phdl), (caddr_t)&piod, 0) < 0) { - DPRINTF("ERROR: couldn't write instruction at address 0x%" PRIuPTR, - address); + DPRINTF("ERROR: couldn't write instruction at address 0x%" + PRIuPTR, address); return (-1); } @@ -153,12 +153,12 @@ proc_bkptexec(struct proc_handle *phdl, unsigned long saved) int status; if (proc_regget(phdl, REG_PC, &pc) < 0) { - warn("ERROR: couldn't get PC register"); + DPRINTFX("ERROR: couldn't get PC register"); return (-1); } proc_bkptregadj(&pc); if (proc_bkptdel(phdl, pc, saved) < 0) { - warn("ERROR: couldn't delete breakpoint"); + DPRINTFX("ERROR: couldn't delete breakpoint"); return (-1); } /* @@ -167,13 +167,13 @@ proc_bkptexec(struct proc_handle *phdl, unsigned long saved) */ proc_regset(phdl, REG_PC, pc); if (ptrace(PT_STEP, proc_getpid(phdl), (caddr_t)1, 0) < 0) { - warn("ERROR: ptrace step failed"); + DPRINTFX("ERROR: ptrace step failed"); return (-1); } proc_wstatus(phdl); status = proc_getwstat(phdl); if (!WIFSTOPPED(status)) { - warn("ERROR: don't know why process stopped"); + DPRINTFX("ERROR: don't know why process stopped"); return (-1); } /* @@ -181,7 +181,7 @@ proc_bkptexec(struct proc_handle *phdl, unsigned long saved) * the same as the one that we were passed in. */ if (proc_bkptset(phdl, pc, &samesaved) < 0) { - warn("ERROR: couldn't restore breakpoint"); + DPRINTFX("ERROR: couldn't restore breakpoint"); return (-1); } assert(samesaved == saved); |