From 1bfda7293ac0f06681097a8cd6964d86af0b24ba Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 10 Oct 2018 15:54:10 -0700 Subject: libpayload: gdb: Factor out gdb_handle_reentrant_exception() from arm32 The arm32 GDB architecture code contains a little hack that allows it to (sort of) correctly deal with a reentrant exception triggered from within the GDB stub. The main logic for this isn't really arm32 specific and could be useful for other architectures as well, so factor it out into a separate function. Change-Id: I3c6db8cecf1e86bba23de6fd2ac9fdf0cf69d3c6 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/29019 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- payloads/libpayload/arch/arm/gdb.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'payloads/libpayload/arch') diff --git a/payloads/libpayload/arch/arm/gdb.c b/payloads/libpayload/arch/arm/gdb.c index 830382e8fa..2a8eb310b2 100644 --- a/payloads/libpayload/arch/arm/gdb.c +++ b/payloads/libpayload/arch/arm/gdb.c @@ -39,23 +39,7 @@ static struct exception_state sentinel_exception_state; static int gdb_exception_hook(u32 type) { - /* - * If we were not resumed we are in deep trouble here. GDB probably told - * us to do something stupid and caused a reentrant exception. All we - * can do is just blindly send an error code and keep going. Eventually - * GDB will tell us to resume and we return right back to the original - * exception state ("jumping over" all the nested ones). - */ - if (gdb_state.connected && !gdb_state.resumed) { - static const char error_code[] = "E22"; /* EINVAL? */ - static const struct gdb_message tmp_reply = { - .buf = (u8 *)error_code, - .used = sizeof(error_code), - .size = sizeof(error_code), - }; - gdb_send_reply(&tmp_reply); - gdb_command_loop(gdb_state.signal); /* preserve old signal */ - } else { + if (!gdb_handle_reentrant_exception()) { if (type >= ARRAY_SIZE(type_to_signal) || !type_to_signal[type]) return 0; exception_state_ptr = &sentinel_exception_state; -- cgit v1.2.3