I'm compiling a custom application using the CMake scripts in the nRF mesh SDK. When I debug the application, even though the debugger is working – I can pause execution – breakpoints are not being hit. I wondered if it is perhaps because the breakpoints are not being set for the correct memory location, but I'm not sure how I could check that.
In addition, when I place a breakpoint, execution is immediately paused (SIGTRAP, but not where I placed the breakpoint), it would be good to know how to prevent this.
Here is the output from JLinkGDBServer when a breakpoint is set on the first line of main():
/usr/local/bin/JLinkGDBServer -device nrf52 -strict -timeout 0 -nogui -if swd -speed 1000 -endian little
SEGGER J-Link GDB Server V6.44h Command Line Version
JLinkARM.dll V6.44h (DLL compiled May 3 2019 17:40:32)
Command line: -device nrf52 -strict -timeout 0 -nogui -if swd -speed 1000 -endian little
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: nrf52
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Error during pretty printers setup: Undefined info command: "pretty-printer". Try "help info".
Some features and performance optimizations will not be available.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jan 7 2019 14:07:15
Hardware: V1.00
S/N: 682644303
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Reading 64 bytes @ address 0x00027A80
Read 4 bytes @ address 0x00027BA8 (Data = 0x20004998)
Read 2 bytes @ address 0x00027B8A (Data = 0x4669)
Reading 64 bytes @ address 0x000262C0
Read 4 bytes @ address 0x000262F0 (Data = 0x00045E5C)
Read 2 bytes @ address 0x000262DA (Data = 0x4B05)
Read 4 bytes @ address 0x00029AC2 (Data = 0x3007F89D)
Read 4 bytes @ address 0x00029EA8 (Data = 0xE8BDB004)
Debugger connected to tcp:localhost:2331
Setting breakpoint @ address 0x000262DA, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x00027B8A, Size = 2, BPHandle = 0x0002
Starting target CPU...
Also related, the breakpoint in main is hit when another problem occurs: devzone.nordicsemi.com/.../sigtrap-on-sd_softdevice_enable
I'm wondering if breakpoints are not being hit because they are not being offset by the softdevice length? In the output above a breakpoint is set at 0x000262DA, but the flash start is 0x00026000 and the soft device hex is >400kb.