Skip to content

Commit

Permalink
Debugger: Send flags information for cpsr register
Browse files Browse the repository at this point in the history
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:
llvm/llvm-project@e07a421

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.
  • Loading branch information
DavidSpickett authored and endrift committed Apr 15, 2023
1 parent fd0f24d commit 225456a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/mgba/internal/debugger/gdb-stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 11 additions & 1 deletion src/debugger/gdb-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>";

Expand Down

0 comments on commit 225456a

Please sign in to comment.