Merge pull request #201 from gsmcmullin/stub_check_halt_status
cortexm: Check halt reason on stub exit.
This commit is contained in:
commit
97afffed8b
|
@ -633,10 +633,17 @@ int cortexm_run_stub(target *t, uint32_t loadaddr,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Execute the stub */
|
/* Execute the stub */
|
||||||
|
enum target_halt_reason reason;
|
||||||
cortexm_halt_resume(t, 0);
|
cortexm_halt_resume(t, 0);
|
||||||
while (!cortexm_halt_poll(t, NULL))
|
while ((reason = cortexm_halt_poll(t, NULL)) == TARGET_HALT_RUNNING)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (reason == TARGET_HALT_ERROR)
|
||||||
|
raise_exception(EXCEPTION_ERROR, "Target lost in stub");
|
||||||
|
|
||||||
|
if (reason != TARGET_HALT_BREAKPOINT)
|
||||||
|
return -2;
|
||||||
|
|
||||||
uint32_t pc = cortexm_pc_read(t);
|
uint32_t pc = cortexm_pc_read(t);
|
||||||
uint16_t bkpt_instr = target_mem_read16(t, pc);
|
uint16_t bkpt_instr = target_mem_read16(t, pc);
|
||||||
if (bkpt_instr >> 8 != 0xbe)
|
if (bkpt_instr >> 8 != 0xbe)
|
||||||
|
|
Loading…
Reference in New Issue