vadimcn / codelldb

A native debugger extension for VSCode based on LLDB
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
MIT License
2.54k stars 245 forks source link

Peripheral register view for debugging of embedded devices #643

Open micwurm opened 2 years ago

micwurm commented 2 years ago

It would be very useful for embedded debugging to view/edit registers of peripherals. This feature is available in the CDT plugin for Eclipse and also the Cortex-Debug plugin for vscode.

You would load a SVD file from the chip vendor that contains the description of the registers. The file format is described here: https://www.keil.com/pack/doc/CMSIS/SVD/html/index.html

Here is how it looks like in Eclipse: register-view

vadimcn commented 2 years ago

I don't do any embedded development at the moment, so I've only a very vague notion of what SVD files are and what one might want to do with them. Before the possibility of new features like this can be entertained, there needs to be some sort of an agreed design for it. Would you care to write something up?

mcrajah commented 2 years ago

I can take a stab at the design, but I am not familiar with the code base. I only know C and asm. However, SVD files are just a database of all the valid registers and the bit fields. So its a mapping from memory location to a human readable register/bitfield name. Most microcontroller vendors provide the SVD file with all the meta info required. I think the plug in would have to read the value at a memory location when user selects it. I image the design would be similar to the view of general purpose CPU registers that is already supported by the plugin today. If you have a sample design document to go on, I can make the updates to support SVD. This would be a great feature to have for embedded development.

This plugin already supports something similar, https://github.com/Marus/cortex-debug/wiki/Specifying-SVD-Files

vadimcn commented 2 years ago

Most, if not all, of the work needs to happen on VSCode side. I think there would need to be a custom view that interacts with the debug adapter via readMemory messages to retrieve data. The existing Modules View could be used as a starting point.

What I would like to see in the design proposal is stuff like: