Cannot debug in a static library

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot debug in a static library

1,449 Views
ruslan1
Contributor II

I try to debug my application that runs on LPC11C24 chip using MCUxpresso 11.5. The application uses a static library that encapsulates some functions. Both application and the library are in Debug mode The debug level is Maximum (-g3) for both of them.

The very simplified code looks like the following:

 

 

int main(void) {
    while(1) {
        lib_func();
    }
}

// my_lib.a

int lib_func(void) {
    some_func(); // here the debug fails
}

int some_func(void) {
}

 

 

I can debug the application but for some reason what I enter the function and try to step it with F6 the debugging failed with error: 

Failed to execute MI command: 
-exec-next 1
Error message from debugger back end:
Cannot find bounds of current function

That what I see in the debug tab:

Untitled.png

As for me it looks that the library has no debug symbols. 

 

The application MCU compiler options:

 

 

-DDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC11xx -D__REDLIB__ -I"F:\source\my_lib\inc" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fmerge-constants -fmacro-prefix-map="$(<D)/"= -mcpu=cortex-m0 -mthumb -D__REDLIB__ -fstack-usage -specs=redlib.specs

 

 

The application MCU Linker options:

 

 

-nostdlib -L"F:\source\my_lib\Debug" -Xlinker -Map="my_app.map" -Xlinker --gc-sections -mcpu=cortex-m0 -mthumb -T "my_app.ld" -L ../linker

 

 

 

The library MCU compiler options:

 

-DDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC11xx -D__REDLIB__ -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fmerge-constants -fmacro-prefix-map="$(<D)/"= -mcpu=cortex-m0 -mthumb -D__REDLIB__ -fstack-usage -specs=redlib.specs

 

0 Kudos
Reply
5 Replies

1,386 Views
lpcxpresso_supp
NXP Employee
NXP Employee

0x1FFF_0042 is somewhere in the memory area reserved for boot ROM. If you're trying to Step Over (F6) when core is stopped there, failure of "-exec-next 1" is somehow expected... GDB does not have the appropriate debug information to cover the boot ROM code area, so it cannot step over anything.

Without having any kind of knowledge about your app, I cannot say what could be wrong... I recommend inspecting the Disassembly view to understand what makes the debugger end-up in the boot ROM area. Also, you could activate Instruction Stepping in Debug view and single step (F5) instructions. Is the expected function/point reached eventually?

Also, is there any chance there's some kind of watchdog resetting the MCU when stepping? Or maybe there's something else causing a reset.

Regards,
MCUXpresso IDE Support

0 Kudos
Reply

1,387 Views
ErichStyger
Specialist I

it would be certainly helpful if you could provide a minimal reproducible example.

0 Kudos
Reply

1,395 Views
ruslan1
Contributor II

Ok, it looks that debugger just steps to some space out of the application. I don't understand why. It stops on any breakpoint (in the application or in the library) but when I press F6 it just jumps out (see the red arrow on the screenshot).

0 Kudos
Reply

1,437 Views
ErichStyger
Specialist I

I don't see anything wrong, but maybe you could share your .a file?

 

The debugger message looks like a problem in gdb with that 'empty' library function. Have you maybe tried the same with IDE 11.6.1 as it comes with a newer GNU toolchain and debugger?

0 Kudos
Reply

1,393 Views
ruslan1
Contributor II

I've upgraded the IDE to the last version but that didn't help.

0 Kudos
Reply