Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-04-03 11:54:46 -0400
committerEugene Tarassov2013-04-03 11:54:46 -0400
commit365a449f409e3da4221ae04dcadb693396c64906 (patch)
tree1b89368e106daa2f86834ccce2382769a68b6921
parent15d6464dccbd7c835018ea93ee8976f4d27d18e4 (diff)
downloadorg.eclipse.tcf.agent-365a449f409e3da4221ae04dcadb693396c64906.tar.gz
org.eclipse.tcf.agent-365a449f409e3da4221ae04dcadb693396c64906.tar.xz
org.eclipse.tcf.agent-365a449f409e3da4221ae04dcadb693396c64906.zip
TCF Agent: fixed: when removing a software breakpoint, Breakpoints service should check if the code at the breakpoint location has not changed
-rw-r--r--agent/tcf/services/breakpoints.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 589082ba..640ab8b5 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -113,11 +113,14 @@ struct InstructionRef {
int cnt;
};
+#define MAX_BI_SIZE 16
+
struct BreakInstruction {
LINK link_all;
LINK link_adr;
ContextBreakpoint cb; /* cb.ctx is "canonical" context, see context_get_canonical_addr() */
- char saved_code[16];
+ char saved_code[MAX_BI_SIZE];
+ char planted_code[MAX_BI_SIZE];
size_t saved_size;
ErrorReport * planting_error;
ErrorReport * address_error;
@@ -298,6 +301,7 @@ static void plant_instruction(BreakInstruction * bi) {
assert(!bi->virtual_addr);
error = 0;
planting_instruction = 1;
+ memcpy(bi->planted_code, break_inst, bi->saved_size);
if (context_read_mem(bi->cb.ctx, bi->cb.address, bi->saved_code, bi->saved_size) < 0) {
error = errno;
}
@@ -334,8 +338,12 @@ static int remove_instruction(BreakInstruction * bi) {
if (bi->saved_size) {
if (!bi->cb.ctx->exited) {
int r = 0;
+ char buf[MAX_BI_SIZE];
planting_instruction = 1;
- r = context_write_mem(bi->cb.ctx, bi->cb.address, bi->saved_code, bi->saved_size);
+ r = context_read_mem(bi->cb.ctx, bi->cb.address, buf, bi->saved_size);
+ if (r >= 0 && memcmp(buf, bi->planted_code, bi->saved_size) == 0) {
+ r = context_write_mem(bi->cb.ctx, bi->cb.address, bi->saved_code, bi->saved_size);
+ }
planting_instruction = 0;
if (r < 0) return -1;
}

Back to the top