gdb: set a breakpoint for a SIGBUS handler

前端 未结 4 2024
孤独总比滥情好
孤独总比滥情好 2021-02-08 20:14

I\'m trying to debug a simple stop-and-copy garbage collector (written in C) using GDB. The GC works by handling SIGBUS. I\'ve set a breakpoint at the top of my SIGBUS signal ha

4条回答
  •  天命终不由人
    2021-02-08 20:35

    Internally, bad memory accesses result in the Mach exception EXC_BAD_ACCESS being sent to the program. Normally, this is translated into a SIGBUS UNIX signal. However, gdb intercepts Mach exceptions directly, before the signal translation. The solution is to give gdb the command set dont-handle-bad-access 1 before running your program. Then the normal mechanism is used, and breakpoints inside your signal handler are honored.

提交回复
热议问题