better debugging support (-d option)
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index cbda70b..65d561f 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -161,6 +161,7 @@
void
trace_me(void) {
+ debug(DEBUG_PROCESS, "trace_me: pid=%d\n", getpid());
if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0) {
perror("PTRACE_TRACEME");
exit(1);
@@ -169,6 +170,7 @@
int
trace_pid(pid_t pid) {
+ debug(DEBUG_PROCESS, "trace_pid: pid=%d\n", pid);
if (ptrace(PTRACE_ATTACH, pid, 1, 0) < 0) {
return -1;
}
@@ -190,6 +192,8 @@
if (proc->tracesysgood & 0x80)
return;
+ debug(DEBUG_PROCESS, "trace_set_options: pid=%d\n", pid);
+
long options = PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEFORK |
PTRACE_O_TRACEVFORK | PTRACE_O_TRACECLONE |
PTRACE_O_TRACEEXEC;
@@ -203,6 +207,7 @@
void
untrace_pid(pid_t pid) {
+ debug(DEBUG_PROCESS, "untrace_pid: pid=%d\n", pid);
ptrace(PTRACE_DETACH, pid, 1, 0);
}
@@ -210,6 +215,8 @@
continue_after_signal(pid_t pid, int signum) {
Process *proc;
+ debug(DEBUG_PROCESS, "continue_after_signal: pid=%d, signum=%d", pid, signum);
+
proc = pid2proc(pid);
if (proc && proc->breakpoint_being_enabled) {
#if defined __sparc__ || defined __ia64___
@@ -226,6 +233,8 @@
continue_process(pid_t pid) {
/* We always trace syscalls to control fork(), clone(), execve()... */
+ debug(DEBUG_PROCESS, "continue_process: pid=%d", pid);
+
ptrace(PTRACE_SYSCALL, pid, 0, 0);
}
@@ -237,6 +246,7 @@
void
continue_after_breakpoint(Process *proc, Breakpoint *sbp) {
+ debug(DEBUG_PROCESS, "continue_after_breakpoint: pid=%d, addr=%p", proc->pid, sbp->addr);
if (sbp->enabled)
disable_breakpoint(proc->pid, sbp);
set_instruction_pointer(proc, sbp->addr);