aboutsummaryrefslogtreecommitdiff
path: root/handle_event.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-04-14 02:37:38 +0200
committerPetr Machata <pmachata@redhat.com>2012-04-19 01:38:04 +0200
commit3d0c91c0c7b425e2866f9c65f655d399693328a5 (patch)
tree47abd1a928da93b07310388797cb42f0bd44f483 /handle_event.c
parent70619b0e59cdb5a7cea81c1eaea751cc9daaa7e9 (diff)
downloadltrace-3d0c91c0c7b425e2866f9c65f655d399693328a5.tar.gz
Fixes for tracing across exec
Diffstat (limited to 'handle_event.c')
-rw-r--r--handle_event.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/handle_event.c b/handle_event.c
index 5a49387..bdda4d1 100644
--- a/handle_event.c
+++ b/handle_event.c
@@ -1,18 +1,19 @@
#define _GNU_SOURCE
#include "config.h"
+#include <assert.h>
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <signal.h>
-#include <assert.h>
+#include <string.h>
#include <sys/time.h>
-#include <errno.h>
-#include "common.h"
#include "breakpoint.h"
-#include "proc.h"
+#include "common.h"
#include "library.h"
+#include "proc.h"
static void handle_signal(Event *event);
static void handle_exit(Event *event);
@@ -441,21 +442,26 @@ static void
handle_exec(Event * event) {
Process * proc = event->proc;
+ /* Save the PID so that we can use it after unsuccessful
+ * process_exec. */
+ pid_t pid = proc->pid;
+
debug(DEBUG_FUNCTION, "handle_exec(pid=%d)", proc->pid);
if (proc->state == STATE_IGNORED) {
- untrace_pid(proc->pid);
+ untrace:
+ untrace_pid(pid);
remove_process(proc);
free(proc);
return;
}
output_line(proc, "--- Called exec() ---");
- proc->mask_32bit = 0;
- proc->personality = 0;
- proc->arch_ptr = NULL;
- free(proc->filename);
- proc->filename = pid2name(proc->pid);
- breakpoints_init(proc, 0);
- proc->callstack_depth = 0;
+
+ if (process_exec(proc) < 0) {
+ error(0, errno,
+ "couldn't reinitialize process %d after exec", pid);
+ goto untrace;
+ }
+
continue_process(proc->pid);
/* After the exec, we expect to hit the first executable