Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2016-10-19 18:39:09 -0400
committerEugene Tarassov2016-10-19 18:39:09 -0400
commit1fcf7ebda310f3866cb8916e6b2b4dedcbc50b62 (patch)
treecda6db42b924ee088a0eb07ea371387d9defc9d4
parent3f5205436bcebca963e2d6bfbf0d2f16be2ba5bd (diff)
downloadorg.eclipse.tcf.agent-1fcf7ebda310f3866cb8916e6b2b4dedcbc50b62.tar.gz
org.eclipse.tcf.agent-1fcf7ebda310f3866cb8916e6b2b4dedcbc50b62.tar.xz
org.eclipse.tcf.agent-1fcf7ebda310f3866cb8916e6b2b4dedcbc50b62.zip
TCF Agent: when debugging over exec() call on Linux, and address of main() does not change, breakpoints are not properly replanted
-rw-r--r--agent/system/GNU/Linux/tcf/context-linux.c1
-rw-r--r--agent/tcf/services/breakpoints.c14
-rw-r--r--agent/tcf/services/breakpoints.h3
3 files changed, 18 insertions, 0 deletions
diff --git a/agent/system/GNU/Linux/tcf/context-linux.c b/agent/system/GNU/Linux/tcf/context-linux.c
index fbe0f45d..9fa76cca 100644
--- a/agent/system/GNU/Linux/tcf/context-linux.c
+++ b/agent/system/GNU/Linux/tcf/context-linux.c
@@ -1495,6 +1495,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
}
break;
case PTRACE_EVENT_EXEC:
+ invalidate_breakpoints_on_process_exec(ctx);
send_context_changed_event(ctx);
memory_map_event_mapping_changed(ctx->mem);
break;
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 2a0a4524..2efe57af 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -815,6 +815,20 @@ void clone_breakpoints_on_process_fork(Context * parent, Context * child) {
}
}
+void invalidate_breakpoints_on_process_exec(Context * ctx) {
+ Context * mem = context_get_group(ctx, CONTEXT_GROUP_PROCESS);
+ LINK * l = instructions.next;
+ while (l != &instructions) {
+ BreakInstruction * bi = link_all2bi(l);
+ l = l->next;
+ if (!bi->planted) continue;
+ if (!bi->saved_size) continue;
+ if (bi->cb.ctx != mem) continue;
+ if (!bi->virtual_addr) planted_sw_bp_cnt--;
+ bi->planted = 0;
+ }
+}
+
int unplant_breakpoints(Context * ctx) {
int error = 0;
LINK * l = instructions.next;
diff --git a/agent/tcf/services/breakpoints.h b/agent/tcf/services/breakpoints.h
index e03afcb8..da878031 100644
--- a/agent/tcf/services/breakpoints.h
+++ b/agent/tcf/services/breakpoints.h
@@ -172,6 +172,9 @@ extern int is_breakpoint_address(Context * ctx, ContextAddress address);
/* Clone all planted breakpoints when a process forks */
extern void clone_breakpoints_on_process_fork(Context * parent, Context * child);
+/* Invalidate all planted breakpoints when a process calls exec() */
+extern void invalidate_breakpoints_on_process_exec(Context * prs);
+
/*
* Unplant all breakpoints in a process (e.g. before detaching).
* Return -1 and set errno if cannot remove some of the breakpoints.

Back to the top