[Pdbg] [PATCH v2 35/38] gdbserver: send regs with stop reason
Nicholas Piggin
npiggin at gmail.com
Wed Mar 30 02:49:28 AEDT 2022
This reduces round-trip time getting registers after stopping.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
src/pdbgproxy.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 7dc0555..b34dec5 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -202,7 +202,11 @@ static void send_stop_for_thread(struct pdbg_target *target)
uint64_t pir = gdb_thread->pir;
char data[MAX_RESP_LEN];
size_t s = 0;
+ struct thread_regs regs;
+ uint64_t value;
+ uint32_t value32;
int sig;
+ int i;
if (gdb_thread->stop_attn)
sig = 5; /* TRAP */
@@ -213,6 +217,39 @@ static void send_stop_for_thread(struct pdbg_target *target)
s += snprintf(data + s, sizeof(data) - s, "T%02uthread:%04" PRIx64 ";%s", sig, pir, sig == 5 ? "swbreak:;" : "");
+ if (thread_getregs(target, ®s))
+ PR_ERROR("Error reading gprs\n");
+
+ for (i = 0; i < 32; i++)
+ s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", i, be64toh(regs.gprs[i]));
+
+ thread_getnia(target, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x40, be64toh(value));
+
+ thread_getmsr(target, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x41, be64toh(value));
+
+ thread_getcr(target, &value32);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x42, be32toh(value32));
+
+ thread_getspr(target, SPR_LR, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x43, be64toh(value));
+
+ thread_getspr(target, SPR_CTR, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%016" PRIx64 ";", 0x44, be64toh(value));
+
+ thread_getspr(target, SPR_XER, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x45, be32toh(value));
+
+ thread_getspr(target, SPR_FPSCR, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x46, be32toh(value));
+
+ thread_getspr(target, SPR_VSCR, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x67, be32toh(value));
+
+ thread_getspr(target, SPR_VRSAVE, &value);
+ s += snprintf(data + s, sizeof(data) - s, "%x:%08" PRIx32 ";", 0x68, be32toh(value));
+
send_response(fd, data);
}
--
2.23.0
More information about the Pdbg
mailing list