Error handling
diff --git a/sysdeps/linux-gnu/breakpoint.c b/sysdeps/linux-gnu/breakpoint.c
index 2e0af18..4658df8 100644
--- a/sysdeps/linux-gnu/breakpoint.c
+++ b/sysdeps/linux-gnu/breakpoint.c
@@ -2,6 +2,8 @@
#include <sys/ptrace.h>
#include <string.h>
+#include <errno.h>
+#include <error.h>
#include "common.h"
#include "sysdep.h"
@@ -27,6 +29,10 @@
for (i = 0; i < 1 + ((BREAKPOINT_LENGTH - 1) / sizeof(long)); i++) {
long a = ptrace(PTRACE_PEEKTEXT, pid,
sbp->addr + i * sizeof(long), 0);
+ if (a == -1 && errno) {
+ error(0, errno, "enable_breakpoint pid=%d, addr=%p", pid, sbp->addr);
+ return;
+ }
for (j = 0;
j < sizeof(long)
&& i * sizeof(long) + j < BREAKPOINT_LENGTH; j++) {
@@ -35,7 +41,11 @@
sbp->orig_value[i * sizeof(long) + j] = bytes[j];
bytes[j] = break_insn[i * sizeof(long) + j];
}
- ptrace(PTRACE_POKETEXT, pid, sbp->addr + i * sizeof(long), a);
+ a = ptrace(PTRACE_POKETEXT, pid, sbp->addr + i * sizeof(long), a);
+ if (a == -1) {
+ error(0, errno, "enable_breakpoint pid=%d, addr=%p", pid, sbp->addr);
+ return;
+ }
}
}
#endif /* ARCH_HAVE_ENABLE_BREAKPOINT */