Debug in VSCode problem

My setup:

Our own PCB with nRF5340

Debugger = nRF5340 DK

macOS 13.2.1 (22D68)

Project with T2: Star topology, application is the manifest repository. The only external files used by project is Toolchain aka zephyr-sdk-0.15.2.

I have such a problem. Debug in VSCode doesn't work as it is supposed to.

(!) If I don't tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build I can debug but with stipulations. A part of my code is not accessible, probably it optiized, breakpoints are ignored and this code is never touched by the processor/compiler/system.

- How to workaround this? How not to optimize my code?

- + I have played with some config like DEBUG_OPTIMIZATION and NO_OPTIMIZATION, my code just can't be built.

- Why I even have a possibility to run Debug if  I didn't tick Enable debug options in Edit Build Configuratioin?

(!) If I tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build my program just runs as it would be run after Flashing (w/o Debug). But I have that DEBUG CONSOLE OUTPUT with some information so the last lines are:

Thread 4 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 3939856308]
There are even debug flow buttons. But they doesn' work, only Pause, Restart and Stop are available and Pause doesn't do nothing, Restart breaks everything so that even nRF5340 DK is not available anymore.
What's going on there?
Parents
  • Hi,

    Could you provide more information about your application?

    A part of my code is not accessible, probably it optiized, breakpoints are ignored and this code is never touched by the processor/compiler/system.

    Which part of your code is not accessible and from where?

    If I don't tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build I can debug but with stipulations.

    Which button do you refer to as Debug Launch? What are the stipulations?

    I have played with some config like DEBUG_OPTIMIZATION and NO_OPTIMIZATION, my code just can't be built.

    I assume you used CONFIG_DEBUG_OPTIMIZATIONS. Is this correct? Could you show the log of failed build?

    Why I even have a possibility to run Debug if  I didn't tick Enable debug options in Edit Build Configuratioin?

    You are able to use Debug because normal debugging can be used even if enable debug options are not included. Selecting Enable Debug Options enables advanced debugging options, such as thread aware debugging.

     If I tick Enable debug options in Edit Build Configuratioin then by pressing Debug Launch build my program just runs as it would be run after Flashing (w/o Debug). But I have that DEBUG CONSOLE OUTPUT with some information so the last lines are:

    Thread 4 received signal SIGTRAP, Trace/breakpoint trap.
    [Switching to Thread 3939856308]
    There are even debug flow buttons. But they doesn' work, only Pause, Restart and Stop are available and Pause doesn't do nothing, Restart breaks everything so that even nRF5340 DK is not available anymore.

    Could you please rephrase the following part "by pressing Debug Launch build my program just runs as it would be run after Flashing (w/o Debug)"?

    Best regards,
    Dejan

  • 1. For example this part:

    *1* const struct device* nct218_dev = DEVICE_DT_GET_ONE(onnn_nct218);

    *2* if (!device_is_ready(nct218_dev)) {
    LOG_ERR("NCT218: device not ready");
    return -ENODEV;
    }
    *1* is the first breakpoint. It's not available, just disappear in debug.
    *2* is the second breakpoint. Debug moves it to the next line but I want to dive into exactly that statement. What's wrong?
    2. Debug button in the nRF Connet extension for VSC
    3. Stipulations are: A part of my code is not accessible, probably it optiized, breakpoints are ignored and this code is never touched by the processor/compiler/system.
    4. File attached12453.log.log
    5. Could you please explain what does it change and where? I mean that Tick in GUI in VSC.
    6. Rephrasing: If I tick Enable debug options in Edit Build Configuratioin then it doesn't matter if I press Debug or Flash, my program runs ignoring all the breakpoints there is not Debug related menu, register's values on the left side of the screen. See the screenshot. The only attribute I see is Debug flow control in ther right upper corner.
  • I set breakpoints like that:

    But in debug it looks like this

    I use nRF5340 DK as a debugger HW and VSC with nRF extension

  • Hi,

    dejans said:
    Could you please explain your use case regarding breakpoints? 

    Could you provide more information about your project? Why do you need to set breakpoint to the place that is affected by debug optimizations?

    dejans said:
    dejans said:
    Which debugger do you use?

    Do you use nRF Debug? You could check this in the Settings of nRF Connect for VS Code extension.

    Best regards,
    Dejan

  • I want to dive into the code as I'm learning programming now.

    Check this, what this?

    But the question is why during Debug with the tick on Enable debug options leads to no debug at all?

  • Hi,

    elektron314 said:
    Check this, what this?

    I referred to the debugger that you use, and which is currently selected in your nRF Connect for VS Code extension settings.

    elektron314 said:
    But the question is why during Debug with the tick on Enable debug options leads to no debug at all?

    This is what we try to find out. Are you able to use Debug option with any of our provided samples

    Best regards,
    Dejan

  • Yes, It works perfectly. I have uploaded Blinky with Debug option enabled and then I could easily debug step by step.

Reply Children
Related