In riscv-011 target, the handle_halt() function, and thus also
riscv_semihosting(), can get called from within examine() before
the examination is actually complete!
The chain of the function calls is:
- examine() -> riscv011_poll() -> poll_target()
-> handle_halt() -> riscv_semihosting()
If the target is already halted due to a breakpoint (dcsr.cause = SWBP)
at the time OpenOCD connects to it, semihosting will be attempted before
completing the examination, and the examination will fail.
This issue was observed on HiFive1 Rev A01.
The fix is to handle semihosting only after the target got successfully
examined.
Change-Id: Iccfa0da35d47a430d8674131ebd2eb8e5e2922c0
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>