MbedOS Fault Handler filename + line number

Hi guys,
is it possible to get filename and line number when crash occurs. I am having hard time finding where my crash happens.

What i tried.

  1. Compile the code with --profile=develop
  2. Started GDB server using JLinkGDBServer -if SWD -select usb=683367368 -device nRF52840_xxAA -speed 4000
  3. start the GDB client using arm-none-eabi-gdb -x gdb.conf.

The content of my gdb.conf are:

set sysroot ./BUILD/NRF52840_DK/GCC_ARM
file ./BUILD/NRF52840_DK/GCC_ARM/firmware_nrf52_mbed_app_ble.elf
target remote 127.0.0.1:2331
set pagination off
break mbed_error
commands
printf “JAIKS\n”
end
mon reset 0
c

When the crash happens i get:

ticker_read_us (ticker=ticker@entry=0x50dfc <us_data>) at ./mbed-os/hal/mbed_ticker_api.c:445
445 core_util_critical_section_enter();
Breakpoint 1 at 0x3b61c: file ./mbed-os/platform/internal/mbed_atomic_impl.h, line 949.
Resets core & peripherals via SYSRESETREQ & VECTRESET bit.

Breakpoint 1, mbed_error (error_status=error_status@entry=-2130771651, error_msg=error_msg@entry=0x50f10 “Fault exception”, error_value=error_value@entry=536871168, filename=filename@entry=0x0 , line_number=line_number@entry=0) at ./mbed-os/platform/internal/mbed_atomic_impl.h:949
949 return (bool)core_util_atomic_exchange_u8((volatile uint8_t *)valuePtr, desiredValue);
JAIKS
(gdb) info symbol 0x00042E70
_free_r + 160 in section .text
(gdb) bt
#0 mbed_error (error_status=error_status@entry=-2130771651, error_msg=error_msg@entry=0x50f10 “Fault exception”, error_value=error_value@entry=536871168, filename=filename@entry=0x0 , line_number=line_number@entry=0) at ./mbed-os/platform/internal/mbed_atomic_impl.h:949
#1 0x0003b00e in mbed_fault_handler (fault_type=, mbed_fault_context_in=0x20000100) at ./mbed-os/platform/source/TARGET_CORTEX_M/mbed_fault_handler.c:88
#2 0x0003aecc in Fault_Handler () at except.S:188
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Here is mbed report:

[13:03:20] ++ MbedOS Fault Handler ++

[13:03:20] FaultType: HardFault

[13:03:20] Context:
[13:03:20] R0 : 20012028
[13:03:20] R1 : 370E273C
[13:03:20] R2 : 20012038
[13:03:20] R3 : 00000010
[13:03:20] R4 : 170D0704
[13:03:20] R5 : 200008F0
[13:03:20] R6 : 200004C8
[13:03:20] R7 : 20012030
[13:03:20] R8 : 20010AFC
[13:03:20] R9 : 20012622
[13:03:20] R10 : 20001084
[13:03:20] R11 : 20012704
[13:03:20] R12 : 00000011
[13:03:20] SP : 20010AC0
[13:03:20] LR : 0003D803
[13:03:20] PC : 00042E70
[13:03:20] xPSR : 21000000
[13:03:20] PSP : 20010A58
[13:03:20] MSP : 2003FFC0
[13:03:20] CPUID: 410FC241
[13:03:20] HFSR : 40000000
[13:03:20] MMFSR: 00000000
[13:03:20] BFSR : 00000082
[13:03:20] UFSR : 00000000
[13:03:20] DFSR : 00000000
[13:03:20] AFSR : 00000000
[13:03:20] BFAR : 370E2740
[13:03:20] Mode : Thread
[13:03:20] Priv : Privileged
[13:03:20] Stack: PSP

[13:03:20] – MbedOS Fault Handler –

How can i get to the name of my function call?

Thanks.

GitHub - ARMmbed/mbed-os-example-fault-handler: Example application to demonstrate Mbed-OS fault exception handler Has a python script that can look up the filename and location using the crash report and the elf file.

I hoped that i would have more info like some kind of stack history, function history.
But thanks anyway. I will try to use a method like -finstrument-functions or break point on all functions call but that would drastically slow down the code. I hoped there was i nicer way.

I believe you can set a breakpoint on the mbed-os crash handler and see the stack backtrace in gdb with the “where” command.