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
Bugfix/debugging docs #1131
base: master
Are you sure you want to change the base?
Bugfix/debugging docs #1131
Conversation
Download the artifacts for this pull request: |
09e2ef7
to
af61719
Compare
56c6cf4
to
110b256
Compare
110b256
to
2ecf21b
Compare
Hi there!
Any suggestion on what I might be doing wrong, or perhaps a bug that occurs? Regards, |
@TheHexaCube Hi Daniel thank you for your feedback. You are still using the old debug adapter. Please update your {
"configurations": [
{
"type": "gdbtarget",
"request": "attach",
"name": "Eclipse CDT Remote",
"program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
"initCommands": [
"set remote hardware-watchpoint-limit 2",
"mon reset halt",
"maintenance flush register-cache",
"thb app_main",
],
"gdb": "${command:espIdf.getXtensaGdb}",
"target": {
"port": "3333"
},
}
]
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some commented lines of code which I've notice.
Other than that LGTM! Tested it on Linux (Fedora 39)
Hi Brian, The debugger seems to work fine now, however I noticed that the peripheral values don't update "automatically" whenever the debugger stops at a breakpoint (or is manually stopped), instead I have to "close and open" the registers for them to update. Thanks for your help, I really appreciate it and the update itself! Best regards |
Thanks for the feedback. The peripheral tree view values open/close trigger a read memory request to GDB, I think having too many read request on each breakpoint stop will provide a slower debugger experience and since it is just a memory address we don't know which specific peripheral value has changed for a given step. I'm not sure if it would be a good approach to read all on each stop event or allow the user to enable such as a feature. What do you think @TheHexaCube ? |
Hey Brian! Alternatively I think at least allowing a user to configure a "update all on breakpoint" would be a fair decision, especially if the performance impact would be mentioned in the docs, and also would be turned off by default. I personally feel like having to open/close the view on every breakpoint, when trying to debug a peripheral, is sort of cumbersome aswell, so at least an option would be nice in my eyes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for the console.log I've commented about
Actually I tested again with updating values on debug stop event (which I added to this PR) and doesn't seems to trigger many readMemory requests. If you don't mind please try the updated VSIX installer @TheHexaCube |
I've tried a multi_config example with this vsix version following the steps outlined here using selecting any config, build and flash work so far as outlined in multi_config - I uploaded a snapshot . my open questions:
thanks in advance, Michael |
I kind of got this working with dual targets by using explicitly customized debug launch configs - not sure this is the way how it is supposed to be done switching between targets of different archs requires vscode restart, seems some openocd config values are cached and not reread? maybe we can mutate this example into a reference for how it should be done - learning curve and amount of custom incantations is still staggering the new debug adapter is much better, and the Native Debug extension is a working alternative as reference opening a terminal before debugging sends things haywire once debugging starts, but that looks more like the fickle USB hardware - the only variant working is start debugging, start terminal without touching DTR I am still at loss regarding question 3 and 4 |
So the project configuration settings override some of the settings from extension settings as described in the project configuration. This allow to have multiple build flash configuration as the multi_config ESP-IDF example. It doesn't override IDF_PATH and tools settings because it is intended to generate multiple builds for same ESP-IDF version.
The project configuration editor modifies some of the existing parameters like build arguments. If you take a look at these profiles they are basically build arguments About how to debug with these multiple project configuration: I think the missing part is to update Let me know how it goes. |
fix doctor cmd test test node 16 try node 18 remove out delete try rm set output modify github output another try at test result test again rm comment code
08c3f76
to
5671403
Compare
@brianignacio5 hi ! Tested under: Followed debug doc from https://github.com/espressif/vscode-esp-idf-extension/blob/bugfix/debugging-docs/docs/tutorial/debugging.md Was able to run debug and repeat all steps from docs. Only thing I think we should add to make it easier for user to navigate is just to modify illustrations a bit like this What do you think ? Also it would be nice if you could fix this comma typos. Caz users probably gonna copy all the setting from the our docs and they hope that this will work :) |
"flushregs", | ||
"thb app_main" | ||
"maintenance flush register-cache", | ||
"thb app_main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
"set remote hardware-watchpoint-limit 2", | ||
"mon reset halt", | ||
"maintenance flush register-cache", | ||
"thb app_main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
"gdb": "${command:espIdf.getXtensaGdb}", | ||
"target": { | ||
"port": "3333" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
{ "text": "target remote :3333" }, | ||
{ "text": "set remote hardware-watchpoint-limit 2"}, | ||
{ "text": "mon reset halt" }, | ||
{ "text": "maintenance flush register-cache" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing comma
{ "text": "set remote hardware-watchpoint-limit 2"}, | ||
{ "text": "mon reset halt" }, | ||
{ "text": "maintenance flush register-cache" } | ||
{ "text": "thb app_main" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
|
||
> **NOTE:** Please take a look at [Configuring of OpenOCD for specific target](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/jtag-debugging/tips-and-quirks.html#configuration-of-openocd-for-specific-target) for more information about these configuration files. | ||
|
||
3. With the blink example folder open in your visual studio code window, press F5. | ||
|
||
Several steps will be automatically done for you but explained for clarity. You can skip to step 6 to continue the debug tutorial part. | ||
|
||
4. OpenOCD server is launched in the background and the output is shown in menu `View` -> Output -> OpenOCD. By default it will be launched using localhost, port 4444 for Telnet communication, port 6666 for TCL communication and port 3333 for gdb. | ||
4. OpenOCD server is launched in the background and the output is shown in menu `View` -> Output -> ESP-IDF. By default it will be launched using localhost, port `4444` for Telnet communication, port `6666` for TCL communication and port `3333` for gdb. | ||
|
||
> **NOTE:** The user can start or stop the openOCD from Visual Studio Code using the **ESP-IDF: OpenOCD Manager** command or from the `OpenOCD Server (Running | Stopped)` button in the visual studio code status bar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'OpenOCD'
"set remote hardware-watchpoint-limit 2", | ||
"mon reset halt", | ||
"maintenance flush register-cache", | ||
"thb app_main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
], | ||
"target": { | ||
"port": "3333" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
], | ||
"target": { | ||
"port": "3333" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
"set remote hardware-watchpoint-limit 2", | ||
"mon reset halt", | ||
"maintenance flush register-cache", | ||
"thb app_main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brianignacio5 Thanks for working on the new debug adapter. Lastly, I had time to play with existing debug adapters. For me, the most crucial part is to see what is going on in the background. When users come up with an issue, we ask OpenOCD for verbose logs in a file. So IMO, it should be easy to have it, and needs to be mentioned somewhere in the debugging.md
Maybe it is related to the espidf
debug adapter but I couldn't manage to get it to work when I increased the adapter log level. It gets too slow and the debug session never starts.
I wanted to share my experience so I left some comments. If I can find a time, I would also like to test and see how it works.
|
||
```JSON | ||
{ | ||
"configurations": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an example for the RiscV chips as well?
"name": "Eclipse CDT Remote", | ||
"program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf", | ||
"initCommands": [ | ||
"set remote hardware-watchpoint-limit 2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider to add set remotetimeout 10
to the beginning of GDB commands. RiscV chips (usb_serial_jtag) are slower than ESP-PROG debugging. Without sufficient timeout users will have a timeout error on the GDB side.
And preferably this can be configurable from the json file.
}, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }], | ||
"setupCommands": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested setup command flow does not work well. Lastly, I did something like;
"setupCommands": [
{ "text": "set remotetimeout 10" },
],
"postRemoteConnectCommands": [
{ "text": "mon reset halt" },
{ "text": "maintenance flush register-cache"},
],
"name": "NativeDebug", | ||
"target": "extended-remote :3333", | ||
"executable": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf", | ||
"gdbpath": "${command:espIdf.getXtensaGdb}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have getRiscvGdb
function? Again RiscV example would be good to have.
|
||
> **NOTE:** The user can start or stop the openOCD from Visual Studio Code using the **ESP-IDF: OpenOCD Manager** command or from the `OpenOCD Server (Running | Stopped)` button in the visual studio code status bar. | ||
|
||
> **NOTE:** The user can modify `openocd.tcl.host` and `openocd.tcl.port` configuration settings to modify these values. You can also set `idf.openOcdDebugLevel` to lower or increase (0-4) the messages from OpenOCD in the OpenOCD output. Please review [ESP-IDF Settings](../SETTINGS.md) to see how to modify these configuration settings. | ||
|
||
5. The [ESP-IDF Debug Adapter](https://github.com/espressif/esp-debug-adapter) server is launched in the background and the output is shown in menu View -> Output -> `ESP-IDF Debug Adapter`. This server is a proxy between Visual Studio Code, configured toolchain GDB and OpenOCD server. It will be launched at port `43474` by default. Please review [Debugging](../DEBUGGING.md) for more information how to customize the debugging behavior like application offset, logging level and set your own gdb startup commands. | ||
5. The [Eclipse CDT GDB Adapter](https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter) is launched in the background and the output is shown in the Debug Console. This adapter is a proxy between Visual Studio Code, configured toolchain GDB and OpenOCD server. Please review [Debugging](../DEBUGGING.md) for more information how to customize the debugging behavior by modifying launch.json arguments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the commands to set the OpenOCD debug level and debug destination? These are the same for cdt-gdb?
"idf.openOcdDebugLevel" : 2,
"idf.openOcdLaunchArgs" : ["-l log.txt"],
Description
Update documentation regarding debugging using other extensions and now using Eclipse CDT GDB
Fixes #918
Fixes #1164
Fixes #1138
Fixes #1168
Fixes #1177
Type of change
Steps to test this pull request
New debugging should work faster and better than previous debug adapter.
Debugging experience should be the same as debugging tutorial.
How has this been tested?
Test running the debugging tutorial.
Test Configuration:
Dependent components impacted by this PR:
Checklist