How do I set a software breakpoint on an ARM processor?

前端 未结 8 922
北恋
北恋 2021-02-12 14:40

How do I do the equivalent of an x86 software interrupt:

asm( \"int $3\" )

on an ARM processor (specifically a Cortex A8) to generate an event

相关标签:
8条回答
  • 2021-02-12 15:08

    I have a simple library (scottt/debugbreak) just for this:

    #include <debugbreak.h>
    ...
    debug_break();
    

    Just copy the single debugbreak.h header into your code and it'll correctly handle ARM, AArch64, i386, x86-64 and even MSVC.

    0 讨论(0)
  • 2021-02-12 15:09

    Using arm-none-eabi-gdb.exe cross compiler, this works great for me (thanks to Igor's answer):

    __asm__("BKPT");
    
    0 讨论(0)
提交回复
热议问题