-
Notifications
You must be signed in to change notification settings - Fork 79
Description
I tried to use debugbreak.h in a "SEGGER Embedded Studio for ARM (Nordic Edition)" project, built using the NRF Connect SDK (NCS), which ultimately uses the arm-none-eabi gcc toolchain. I happen to be targeting an nRF9160.
It built, but the resulting code was considered an "invalid opcode" and would cause a hard-fault if executed. So while the debugger would be triggered, there was no useful program counter, stack frame or other debuggable information.
I believe the path that gets built in that environment is this one:
/* 'eabi_linux_thumb_le_breakpoint' */
__asm__ volatile(".inst 0xde01");
In the end, this alternate did work. I derived it from some other mysterious Nordic library, where it is referred to as NRF_BREAKPOINT:
#if defined(__GNUC__)
__asm__("BKPT 0");
#else
__BKPT(0)
#endif
It looks like this may be useful on other platforms too. I don't know why the environment detection in debugbreak didn't work in the first place, so I'm not sure how you'd merge it. But if you're interested, I can do some experimentation to help you figure it out.