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.
  • Hi,

    elektron314 said:
    I'm using exactly this. nRF Debug as a Backend

    Thank you for this information.

    Could you please summarize which applications you can debug and which not? 

    Best regards,
    Dejan

  • With Enable debug options I can debug only samples and can't debug my own firmware.

    Without Enable debug options I can debug my own firmware with the button Debug

  • Hi,

    Did debugging issue start recently? Were you able to debug your firmware at some point?

    Do you have any other application to try debugging on?

    Best regards,
    Dejan

  • I'm the second firmware engingeer in our company and I continued to work with the already prepaired project by other programmer. He doesn't use VSCode but CLion.

    I have never had a possibility do do debug with debug enabled in VSCode. I work with this FW for 1.5 month.

    Other applications e.g. samples are ok. They are being debugged normally in debug mode with debug enabled.

  • Hi,

    You could try to debug without debug options enabled.

    You could also try disabling config optimizations which you have in your code. Additionally, you could try setting the breakpoint close to beginning of main and see if it can be reached.

    Best regards,
    Dejan

Reply Children
No Data
Related