Invisible and locked Breakpoint in Sphere SDK for vs code

126 Views Asked by At

I'm trying to get started with microsoft's azure sphere development.

When I try to debug any of the starter projects within vs code, it tells me that I have a breakpoint set on the first line of the app. However, vs code doesn't show any breakpoints in the "Breakpoints" tab.

I am running the latest VS code version (1.44) with the Azure Sphere Extension 20.1 on windows 10. The same problem appears on Linux.

To reproduce the bug:

  1. Download the starter projects from github
  2. Install the Azure sphere extension for visual studio code.
  3. open HelloWorld_HighLevelApp folder in azure-sphere-samples\Samples\HelloWorld\HelloWorld_HighLevelApp in visual studio code.
  4. Go to the Debug tab and hit the green play button on top left corner. Next to the button it should say Launch for Azure Sphere High-Level Applications (gdb)

For me it doesn't an error but the output console shows:

Deploying image...
Starting debugger....

Process /mnt/apps/1689d8b2-c835-2e27-27ad-e894d6d15fa9/bin/app created; pid = 2233
Listening on port 2345

Remote debugging from host 192.168.35.1, port 54911

Starting CMake Hello World application...

The Debug Console shows:

...
Breakpoint 1, main () at ../../main.c:45
45  {
Loaded 'target:/usr/lib/libapplibs.so.0'. Symbols loaded.
Loaded 'target:/lib/libgcc_s.so.1'. Symbols loaded.
Loaded 'target:/usr/lib/libc++runtime.so.1'. Symbols loaded.

Is there a work around / a plan to fix the issue?

Addition 1: To provide extra clarification here is a screenshot, showing the miss match of console output (breakpoint set) and ui (no breakpoint set) enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

Solution:

Finally I found the root cause of the issue. Visual studio code acts just slightly different when debugging the sphere device compared to just plain c code.

When you start the debugging mode and you haven't set a breakpoint initially, it won't start running your program till you have set a breakpoint. In plain c debugging the program just runs through and printed values are shown in the debug console.

0
On

Azure Sphere uses gdbserver to provide a debug channel to the device. A default behavior of gdb is to break on entering main. This can be confusing to people on Windows who expect a run to breakpoint behavior as is common in Visual Studio. For our interface with GDB we intentionally silently skip the breakpoint on entering main in Visual Studio to be consistent. You can actually see that breakpoint skipped in the debug log output window.

For VS Code we also skip the breakpoint on main when you are on Windows. It looks like you are on Linux from the output above. I haven't used it on Linux for a few weeks so can't recall if the behavior is intentionally different there or not. It would make sense to me to break on entering to main when on Linux as that is the common expectation when using GDB which is more common there than on Windows. I'll check if this is by design or not and reply back, but I suspect it is.