gerrit
2017-05-09 13:31:16 UTC
This is an automated email from Gerrit.
Salvador Arroyo (***@yahoo.es) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4129
-- gerrit
commit 1934e3eb194704b6961f1143c2e301ebdaeb02d5
Author: Salvador Arroyo <***@yahoo.es>
Date: Tue May 9 15:24:22 2017 +0200
mips32: bug in mips_m4k_unset_breakpoint()
In software breakpoints if the isa bit is set,
fails to restore original instruction.
Use address with the isa bit cleared
Change-Id: Ic4e44fec9eae1db45e1d78849b407db6b9eb8cd6
Signed-off-by: Salvador Arroyo <***@yahoo.es>
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 7d1c06c..01d6caf 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -768,6 +768,7 @@ static int mips_m4k_unset_breakpoint(struct target *target,
/* restore original instruction (kept in target endianness) */
uint32_t isa_req = breakpoint->length & 1;
uint32_t bplength = breakpoint->length & ~1;
+ uint32_t bpaddr = breakpoint->address & ~1;
uint8_t current_instr[4];
LOG_DEBUG("bpid: %" PRIu32, breakpoint->unique_id);
if (bplength == 4) {
@@ -775,9 +776,9 @@ static int mips_m4k_unset_breakpoint(struct target *target,
if (ejtag_info->endianness && isa_req)
sdbbp32_instr = SWAP16(sdbbp32_instr);
- if ((breakpoint->address & 3) == 0) { /* 32bit aligned */
+ if ((bpaddr & 3) == 0) { /* 32bit aligned */
/* check that user program has not modified breakpoint instruction */
- retval = target_read_memory(target, breakpoint->address, 4, 1, current_instr);
+ retval = target_read_memory(target, bpaddr, 4, 1, current_instr);
if (retval != ERROR_OK)
return retval;
/**
@@ -786,32 +787,29 @@ static int mips_m4k_unset_breakpoint(struct target *target,
* we must first transform it to _host_ endianess using target_buffer_get_u16().
*/
if (sdbbp32_instr == target_buffer_get_u32(target, current_instr)) {
- retval = target_write_memory(target, breakpoint->address, 4, 1,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 4, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
} else { /* 16bit alligned */
- retval = target_read_memory(target, breakpoint->address, 2, 2, current_instr);
+ retval = target_read_memory(target, bpaddr, 2, 2, current_instr);
if (retval != ERROR_OK)
return retval;
if (sdbbp32_instr == target_buffer_get_u32(target, current_instr)) {
- retval = target_write_memory(target, breakpoint->address, 2, 2,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 2, 2, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
}
} else {
/* check that user program has not modified breakpoint instruction */
- retval = target_read_memory(target, breakpoint->address, 2, 1, current_instr);
+ retval = target_read_memory(target, bpaddr, 2, 1, current_instr);
if (retval != ERROR_OK)
return retval;
if (target_buffer_get_u16(target, current_instr) == MIPS16_SDBBP(isa_req)) {
- retval = target_write_memory(target, breakpoint->address, 2, 1,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 2, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
--
Salvador Arroyo (***@yahoo.es) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4129
-- gerrit
commit 1934e3eb194704b6961f1143c2e301ebdaeb02d5
Author: Salvador Arroyo <***@yahoo.es>
Date: Tue May 9 15:24:22 2017 +0200
mips32: bug in mips_m4k_unset_breakpoint()
In software breakpoints if the isa bit is set,
fails to restore original instruction.
Use address with the isa bit cleared
Change-Id: Ic4e44fec9eae1db45e1d78849b407db6b9eb8cd6
Signed-off-by: Salvador Arroyo <***@yahoo.es>
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 7d1c06c..01d6caf 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -768,6 +768,7 @@ static int mips_m4k_unset_breakpoint(struct target *target,
/* restore original instruction (kept in target endianness) */
uint32_t isa_req = breakpoint->length & 1;
uint32_t bplength = breakpoint->length & ~1;
+ uint32_t bpaddr = breakpoint->address & ~1;
uint8_t current_instr[4];
LOG_DEBUG("bpid: %" PRIu32, breakpoint->unique_id);
if (bplength == 4) {
@@ -775,9 +776,9 @@ static int mips_m4k_unset_breakpoint(struct target *target,
if (ejtag_info->endianness && isa_req)
sdbbp32_instr = SWAP16(sdbbp32_instr);
- if ((breakpoint->address & 3) == 0) { /* 32bit aligned */
+ if ((bpaddr & 3) == 0) { /* 32bit aligned */
/* check that user program has not modified breakpoint instruction */
- retval = target_read_memory(target, breakpoint->address, 4, 1, current_instr);
+ retval = target_read_memory(target, bpaddr, 4, 1, current_instr);
if (retval != ERROR_OK)
return retval;
/**
@@ -786,32 +787,29 @@ static int mips_m4k_unset_breakpoint(struct target *target,
* we must first transform it to _host_ endianess using target_buffer_get_u16().
*/
if (sdbbp32_instr == target_buffer_get_u32(target, current_instr)) {
- retval = target_write_memory(target, breakpoint->address, 4, 1,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 4, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
} else { /* 16bit alligned */
- retval = target_read_memory(target, breakpoint->address, 2, 2, current_instr);
+ retval = target_read_memory(target, bpaddr, 2, 2, current_instr);
if (retval != ERROR_OK)
return retval;
if (sdbbp32_instr == target_buffer_get_u32(target, current_instr)) {
- retval = target_write_memory(target, breakpoint->address, 2, 2,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 2, 2, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
}
} else {
/* check that user program has not modified breakpoint instruction */
- retval = target_read_memory(target, breakpoint->address, 2, 1, current_instr);
+ retval = target_read_memory(target, bpaddr, 2, 1, current_instr);
if (retval != ERROR_OK)
return retval;
if (target_buffer_get_u16(target, current_instr) == MIPS16_SDBBP(isa_req)) {
- retval = target_write_memory(target, breakpoint->address, 2, 1,
- breakpoint->orig_instr);
+ retval = target_write_memory(target, bpaddr, 2, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
}
--