0

I'm developing a program for the raspberry pi pico in C++, I'm using Visual Studio Code for my IDE and GCC to compile the source code.

Normally when using breakpoints, execution stops at source code and I can debug as usual. But sometimes when running the program, breakpoints stop the execution in assembly code. This happens randomly without changing any settings or properties and randomly changes back as well.

Sorry if I haven't explained this very well but I couldn't find the issue posted anywhere else.

Just ask if you need any more information, any help is appreciated, thanks.

Ben Sharpe
  • 21
  • 3
  • Does it stop at inline assembly code? You see the actual assembly source? – Sep Roland Nov 21 '21 at 22:04
  • Yes, I place the breakpoint in the source code but it stops at the corresponding assembly code. – Ben Sharpe Nov 21 '21 at 22:08
  • I assume it has an option to flip between source vs. disassembly in the debugger, like GDB's `layout asm` (or `layout reg`) vs. `layout src`. Does that work, or is it stuck on disassembly until you single step? – Peter Cordes Nov 22 '21 at 01:22
  • @PeterCordes That doesn't seem to work, also its stuck on disassembly. I'm not very experienced in this area but it seems like it can't find the source file to link back to. But when making the files and building the project there are no errors or warning being given. – Ben Sharpe Nov 22 '21 at 21:18
  • Did you maybe stop execution inside library code? In that case, usually only disassembly will be available until execution comes back into your own code. – Peter Cordes Nov 22 '21 at 21:25
  • @PeterCordes Nope, I've tried removing all breakpoints. I'm using Cortex Debug and in its description it says 'disassembly will automatically be shown if it cannot locate the corresponding source code.' But I've defined the source code in the CMakeLists.txt and launch.json so I'm out of ideas. How familiar are you with CMake and Cortex Debug? – Ben Sharpe Nov 22 '21 at 21:44
  • Not at all, and not with VSCode either, and haven't heard of Cortex Debug. I'm here for the [assembly] tag. Could well be something like missing a `-g` in your build options to include debug info, but I thought you said you could sometimes get source code. Maybe only some of your files got built with `-g`; having `-g` at link time only is too late, it's needed for compilation as well, if that helps. – Peter Cordes Nov 22 '21 at 21:51
  • @PeterCordes It was happening yesterday, it switched to disassembly, then to source code, and now I'm stuck on assembly again, it's really strange. I define the build options in a json file so I don't I'll need to use -g, but I'm not too sure. I'll open an issue on the cortex debug github page. Thanks for your help anyway – Ben Sharpe Nov 22 '21 at 22:04
  • 1
    @PeterCordes My bad, you was right. I was missing a '-g' when defining the debug optimization level. Thanks! – Ben Sharpe Nov 23 '21 at 17:53

0 Answers0