Post navigation
Sometimes, all what I have is a ELF/Dwarf binary, and I need to debug it. I don’t want to build it, only debug it. The NXP VS Code extension makes that possible. I simply import the binary and start debugging.
Debugging Executable
Outline
This article describes how to import an embedded ELF/Dwarf (.elf or .axf) file without project for debugging. ELF/Dwarf files are the standard binaries for targets and cross development. They include the code. They also contain debug information if it has not been stripped.
For this, I use the ‘Import’ on an executable in VS Code. After that, I can debug it right away.
Prerequisites
Install the NXP extension i…
Post navigation
Sometimes, all what I have is a ELF/Dwarf binary, and I need to debug it. I don’t want to build it, only debug it. The NXP VS Code extension makes that possible. I simply import the binary and start debugging.
Debugging Executable
Outline
This article describes how to import an embedded ELF/Dwarf (.elf or .axf) file without project for debugging. ELF/Dwarf files are the standard binaries for targets and cross development. They include the code. They also contain debug information if it has not been stripped.
For this, I use the ‘Import’ on an executable in VS Code. After that, I can debug it right away.
Prerequisites
Install the NXP extension into VS Code (extension identifier nxpsemiconductors.mcuxpresso or https://marketplace.visualstudio.com/items?itemName=NXPSemiconductors.mcuxpresso)
Import
Click on the NXP extension icon in the side bar and use ‘Import Project‘:
Import Project
Executable
Then select ‘Executable‘:
Import Executable
Then browse to the ELF/Dwarf file you want to debug: In my case it is
c:\tmp\LPC55S16_blinky.elf
and it is detected as ‘executable’:
Executable file path
Next, I can specify a folder where VS Code can store the settings. I’m using the
c:\tmp\binary
location:
location to store the settings
Toolchain
Next I specify the toolchain which includes the GDB for debugging:
Toolchain selection
Finally, press ‘Import’:
Import
Debug
This creates an entry for the executable in the side view with a ‘debug/run’ icon I can use:
Debug Icon
MCU Selection
Using the executable the first time, I get asked about what MCU I want to use:
MCU Selection
After this: I’m debugging that executable:
Debugging Executable
Assembly Level Debugging
Based on the debug information, VS code is using the source file information present in the ELF/Dwarf file. Ideally, I have the source files available. If not, I still can debug it on assembly level instruction level:
Assembly Level Debugging
Summary
Using VS Code with the NXP MCUXpresso Extension, it is surprisingly easy to debug the binary. There’s no need to import or build project. All I need to do is point to the executable. Then, I select the toolchain for the GDB and device I want to use. This is very useful for a quick check of a binary on an embedded target board. All I need is the binary with VS Code. Then, I can start debugging it. If I have the sources available, I even can do source-level-debugging. Or I can debug on assembly instruction level.
Happy debugging 🙂
Links
- NXP VS Code MCUXpresso Extension: https://marketplace.visualstudio.com/items?itemName=NXPSemiconductors.mcuxpresso
- Dwarf files: https://en.wikipedia.org/wiki/DWARF
- Elf files: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format