Merge pull request #201 from gsmcmullin/stub_check_halt_status

cortexm: Check halt reason on stub exit.
This commit is contained in:
Gareth McMullin 2017-04-13 08:35:20 +12:00 committed by GitHub
commit 97afffed8b
1 changed files with 8 additions and 1 deletions

View File

@ -633,10 +633,17 @@ int cortexm_run_stub(target *t, uint32_t loadaddr,
return -1;
/* Execute the stub */
enum target_halt_reason reason;
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);
uint16_t bkpt_instr = target_mem_read16(t, pc);
if (bkpt_instr >> 8 != 0xbe)