CONFIG_DEBUG_OPTIMIZATIONS does not allow setting breakpoints anywhere

When debugging the exercise 1 application from `Lesson 2 – Reading buttons and controlling LEDs` of `nRF Connect SDK Fundamentals`, I cannot set a breakpoint wherever I want.

Somehow it is either not picked up or it gets picked the line below.

However, if I debug step by step from the beginning, it can stop on all lines.

In this code:

The 2 lines below get ignored, I cannot break on them:

I am setting CONFIG_DEBUG_OPTIMIZATIONS by selecting:

However, it seems not sufficient as there are probably some optimisations that are made on the code.

I remember when debugging on nRF52, I had to set:

so `-O0 -g3` flags in order to propely debug and I think I need to also enable `CONFIG_NO_OPTIMIZATIONS` but I can't override its value together with `CONFIG_DEBUG_OPTIMIZATIONS`.

Another issue I see is if I put a breakpoint here just before starting to debug:

I get the debugger to stop here:

Any hints?

Parents
  • Hi,

    Did you enable the following on your prj.conf ?

    CONFIG_DEBUG=y

    CONFIG_DEBUG_OPTIMIZATIONS=y

    CONFIG_NO_OPTIMIZATIONS=y

    Regards,

    Priyanka

  • I've modified the prj.conf file as follows:

    However it seems that CONFIG_NO_OPTIMIZATIONS is overridden to `n` instead of 'y'.

    By the way, I'm using a Mac but it shouldn't make a difference.

  • No worries Slight smile

    So here I select any since CONFIG_NO_OPTIMIZATIONS is not possible in the drop down list:

    Then in prj.conf I do force CONFIG_NO_OPTIMIZATIONS=y and CONFIG_DEBUG_OPTIMIZATIONS=n:

    Then in "Output files" folder I have .config file with:

    Somehow I still can't add a breakpoint anywhere I want.

    Is .config file the final state or is it overridden by prj.conf?

  • Hi,

    Could you tr building with project default ? Does this help?

    -Priyanka

  • Hello

    Still not able to put breakpoints where I want and also I get the notification "The selected build configuration does not have debugging options enabled" even though I enable either  CONFIG_NO_OPTIMIZATIONS or CONFIG_DEBUG_OPTIMIZATIONS in the prj.conf file.

  • Hi,

    The breakpoint issue you are facing is because of the optimizations that take place. This changes the machine code so that it does not exactly map the C code, so it makes debugging harder. So the only way is to disable all optimizations when debugging. Please take a look at this ticket.

    Regards,

    Priyanka

  • I'm sorry but something is wrong with debugging using the dev kit nRF9160 DK.

    This should be straightforward.

    Below a video, please try to reproduce the issue, I'm not doing anything fancy, just using "fund_less2_exer1_solution" sample code and trying to put a breakpoint in the while loop.

    CONFIG_NO_OPTIMIZATIONS=y
    CONFIG_DEBUG_OPTIMIZATIONS=y

    Please check the following video and let me know:

Reply
  • I'm sorry but something is wrong with debugging using the dev kit nRF9160 DK.

    This should be straightforward.

    Below a video, please try to reproduce the issue, I'm not doing anything fancy, just using "fund_less2_exer1_solution" sample code and trying to put a breakpoint in the while loop.

    CONFIG_NO_OPTIMIZATIONS=y
    CONFIG_DEBUG_OPTIMIZATIONS=y

    Please check the following video and let me know:

Children
Related