This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

setting DEBUG flag in eclipse

I am trying to track down a fatal error and want to use the Error module as documented below, to get the line number and file name.

Using eclipse, where should DEBUG be set. So far I have tried sdk_config.h file with the following addition:

#ifndef DEBUG 

#define DEBUG 1

#endif

However this is only giving me the PC and I am not getting through to app_error_save_and_stop where the line number and filename should be determined. Is this the correct way to set the DEBUG flag?

If the DEBUG flag is set:

When app_error_fault_handler is invoked, the error info (for example the function parameters: error code, line number, and file name) are copied to global memory, interrupts are disabled, and the application enters an infinite loop.

Parents
  • Hi,

    You should define DEBUG in the makefile. I.e. CFLAGS += -DDEBUG

    You should also add the -g3 flag and remove compiler optimization (to get expected debug results). I.e. CFLAGS += -Wall -Werror -O0 -g3.

  • Unfortunately I am not seeing the expected behaviour. Despite implementing all of the above with the addition of adding app_error_weak.c to the makefile to ensure it is recompiled. I can see -DDEBUG applied to the compilation of app_error_weak.c in the build log.

    However I am not hitting the expected line:

    It has just occurred to me that I am using segger RTT which could be effecting the behaviour of NRF_LOG_FINAL_FLUSH()

    Also Eclipse isn't alway honest when comes to highlighting.

    So I have access to the PC, I guess I need to manually go through the map file to determine where things are failing?

Reply
  • Unfortunately I am not seeing the expected behaviour. Despite implementing all of the above with the addition of adding app_error_weak.c to the makefile to ensure it is recompiled. I can see -DDEBUG applied to the compilation of app_error_weak.c in the build log.

    However I am not hitting the expected line:

    It has just occurred to me that I am using segger RTT which could be effecting the behaviour of NRF_LOG_FINAL_FLUSH()

    Also Eclipse isn't alway honest when comes to highlighting.

    So I have access to the PC, I guess I need to manually go through the map file to determine where things are failing?

Children
Related