Debugger: Send flags information for cpsr register

There is a feature of target XML called flags. It allows
you to describe what a register contains.

https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html

GDB has supported this for a long time and I recently added support
in LLDB:
e07a421dd5

This change adds this flags information for the cpsr register of the ARM7TDMI.
Based on the information in https://developer.arm.com/documentation/ddi0210/c/.

This is what it looks like when using GDB:
```
(gdb) info registers
r0             0x0                 0
<...>
cpsr           0x6000001f          [ Z C M=31 ]
```
And LLDB:
```
(lldb) register read cpsr
    cpsr = 0x6000001f
         = (N = 0, Z = 1, C = 1, V = 0, I = 0, F = 0, T = 0, M=31)
```

(the format is up to the debugger, lldb is a lot more verbose at the moment)

To enable this I have increased the GDB stub's outgoing buffer to 1400 bytes.
The target XML is just above 130 bytes with the flags added.
This commit is contained in:
David Spickett 2023-04-14 11:59:50 +01:00 committed by Vicki Pfau
parent fd0f24d01e
commit 225456a39c
2 changed files with 12 additions and 2 deletions

View File

@ -14,7 +14,7 @@ CXX_GUARD_START
#include <mgba-util/socket.h>
#define GDB_STUB_MAX_LINE 1200
#define GDB_STUB_MAX_LINE 1400
#define GDB_STUB_INTERVAL 32
enum GDBStubAckState {

View File

@ -50,7 +50,17 @@ static const char* TARGET_XML = "<target version=\"1.0\">"
"<reg name=\"sp\" bitsize=\"32\" type=\"data_ptr\"/>"
"<reg name=\"lr\" bitsize=\"32\"/>"
"<reg name=\"pc\" bitsize=\"32\" type=\"code_ptr\"/>"
"<reg name=\"cpsr\" bitsize=\"32\" regnum=\"25\"/>"
"<flags id=\"cpsr_flags\" size=\"4\">"
"<field name=\"N\" start=\"31\" end=\"31\"/>"
"<field name=\"Z\" start=\"30\" end=\"30\"/>"
"<field name=\"C\" start=\"29\" end=\"29\"/>"
"<field name=\"V\" start=\"28\" end=\"28\"/>"
"<field name=\"I\" start=\"7\" end=\"7\"/>"
"<field name=\"F\" start=\"6\" end=\"6\"/>"
"<field name=\"T\" start=\"5\" end=\"5\"/>"
"<field name=\"M\" start=\"0\" end=\"4\"/>"
"</flags>"
"<reg name=\"cpsr\" bitsize=\"32\" regnum=\"25\" type=\"cpsr_flags\"/>"
"</feature>"
"</target>";