Skip to content

Commit 74d912e

Browse files
authored
Merge pull request riscv-collab#1228 from JanMatCodasip/jm-codasip/riscv-011-dont-trigger-semihosting-before-examine
riscv-011: Don't trigger semihosting before the target is examined
2 parents 41a2254 + c01427d commit 74d912e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/target/riscv/riscv-011.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,8 +1889,16 @@ static int handle_halt(struct target *target, bool announce)
18891889

18901890
if (target->debug_reason == DBG_REASON_BREAKPOINT) {
18911891
int retval;
1892-
if (riscv_semihosting(target, &retval) != 0)
1893-
return retval;
1892+
/* Hotfix: Don't try to handle semihosting before the target is marked as examined. */
1893+
/* TODO: The code should be rearranged so that:
1894+
* - Semihosting is not attempted before the target is examined.
1895+
* - When the target is already halted on a semihosting magic sequence
1896+
* at the time when OpenOCD connects to it, this semihosting attempt
1897+
* gets handled right after the examination.
1898+
*/
1899+
if (target_was_examined(target))
1900+
if (riscv_semihosting(target, &retval) != SEMIHOSTING_NONE)
1901+
return retval;
18941902
}
18951903

18961904
if (announce)

0 commit comments

Comments
 (0)