-
Notifications
You must be signed in to change notification settings - Fork 994
fix: expand RTT debugger compatibility #5025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Man, having a debugger to give you stack traces and live readouts of memory and registers is so nice, not having stack traces felt like living in the stone age. This is the minimal launch.json I'm working with right now (goes in {
"version": "0.2.0",
"configurations": [
{
"name": "TinyGo Debug",
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"executable": "./tinygo-build.elf",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/rp2350.cfg"
],
"svdFile": "RaspberryPi::RP2xxx_DFP@0.9.5",
"preLaunchTask": "${defaultBuildTask}",
"openOCDLaunchCommands": [
"adapter speed 10000"
],
"rttConfig": {
"enabled": true,
"clearSearch": false,
"polling_interval": 10,
"decoders": [
{
"label": "RTT channel 0",
"port": 0,
"timestamp": true,
"type": "console"
}
]
}
}
]
}And tasks.json I'm using to automatically build it before running the debugger: {
"version": "2.0.0",
"tasks": [
{
"label": "TinyGo Build",
"type": "shell",
"command": "${userHome}/git/tinygo/build/tinygo build -target=metro-rp2350 -serial=rtt -opt=1 -o ${workspaceFolder}/tinygo-build.elf",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new",
"close": true
}
}
]
} |
|
Personally I don't care about backwards compatibility in this case. You'd only really use this while debugging, and would rebuild the binary anyway. What about just renaming the global? That seems like a simpler solution to me than adding an alias. (If going this route, please also add a comment to machine.rttSerialInstance explaining that it is renamed in the compiler). --- a/compiler/symbol.go
+++ b/compiler/symbol.go
@@ -712,6 +712,9 @@ func (c *compilerContext) getGlobalInfo(g *ssa.Global) globalInfo {
// Pick the default linkName.
linkName: g.RelString(nil),
}
+ if info.linkName == "machine.rttSerialInstance" {
+ info.linkName = "_SEGGER_RTT"
+ }
// Check for //go: pragmas, which may change the link name (among others).
doc := c.astComments[info.linkName]
if doc != nil {(Ideally this would be done using |
|
Oh, sure, that works for me too. I'll look into the globals issue while I'm at it |
|
I ended up chasing my tail for a bit thinking the debug info wasn't getting properly attached since it wasn't showing in the |
|
@mikesmitty I switched this PR to |
|
Oh whoops, yeah one sec |
13b51af to
626bb62
Compare
|
@mikesmitty you might also want to squash this PR into 2 commits, one for the RTT debugger, additions, the other for the |
626bb62 to
6324e3d
Compare
|
Yep, done |
|
Thank you @mikesmitty and to @aykevl for review. Now merging. |
I recently saw/fell in love with the idea of the https://github.com/piersfinlayson/airfrog debugger tool (wireless SWD+RTT) and got a bit jealous of the probe-rs debugger features/tight integration with VSCode. Turns out it is largely powered by the https://github.com/Marus/cortex-debug extension, which was not originally written with rust in mind so I've been working on some things to make it easier to use (like an example launch.json for VSCode, etc.).
This PR in particular expands RTT debugger compatibility by adding a
_SEGGER_RTTsymbol alias tomachine.rttSerialInstancefor RTT debuggers (such as Marus/cortex-debug) that are hard-coded to look for the_SEGGER_RTTsymbol specifically and struggle with memory scanning. probe-rs does something similar-ish, but since monitor.go specifically looks formachine.rttSerialInstancewe need both to exist to avoid breaking compatibility.Example output from an nm dump: