[Pdbg] [PATCH v2 30/39] gdbserver: tidy poll()
Nicholas Piggin
npiggin at gmail.com
Wed Apr 20 16:50:04 AEST 2022
Remove the pointless case statement and reduce indentation.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
src/pdbgproxy.c | 46 +++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 01419108..c5870091 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -708,40 +708,36 @@ static void poll(void)
{
struct thread_state status;
+ if (state != SIGNAL_WAIT)
+ return;
+
thread_target->probe(thread_target);
status = thread_status(thread_target);
- switch (state) {
- case IDLE:
- break;
-
- case SIGNAL_WAIT:
- if (!(status.quiesced))
- break;
-
- set_attn(false);
+ if (!(status.quiesced))
+ return;
- state = IDLE;
- poll_interval = VCONT_POLL_DELAY;
+ set_attn(false);
- if (thread_check_attn(thread_target)) {
- uint64_t nia;
+ state = IDLE;
+ poll_interval = VCONT_POLL_DELAY;
- if (!(status.active)) {
- PR_ERROR("Thread inactive after trap\n");
- send_response(fd, ERROR(EPERM));
- return;
- }
+ if (thread_check_attn(thread_target)) {
+ uint64_t nia;
- /* Restore NIA */
- if (thread_getnia(thread_target, &nia))
- PR_ERROR("Error during getnia\n");
- if (thread_putnia(thread_target, nia - 4))
- PR_ERROR("Error during putnia\n");
+ if (!(status.active)) {
+ PR_ERROR("Thread inactive after trap\n");
+ send_response(fd, ERROR(EPERM));
+ return;
}
- send_response(fd, TRAP);
- break;
+
+ /* Restore NIA */
+ if (thread_getnia(thread_target, &nia))
+ PR_ERROR("Error during getnia\n");
+ if (thread_putnia(thread_target, nia - 4))
+ PR_ERROR("Error during putnia\n");
}
+ send_response(fd, TRAP);
}
static void cmd_default(uint64_t *stack, void *priv)
--
2.35.1
More information about the Pdbg
mailing list