mac gdb SIG113

clayluo 2017-12-09

mac自从升级至Sierra系统后,gdb调试程序后出错:

During startup program terminated with signal SIG113, Real-time event 113

网上方案:升级gdb,修改gdb配置:

brew upgrade gdb
cat "set startup-with-shell off" > ~/.gdbinit

 该方案只适合v12.10.2及以下版本,v10.12.6依然无法工作。

上述错误是由于mac的安全保护策略所致,阻止gdb调试程序。网上提出可使用lldb调试,毕竟是苹果自家的产品,亲测可行,命令与gdb基本一致。

lingdeMacBook-Pro:test lingsun$ lldb 1
(lldb) target create "1"
Current executable set to '1' (x86_64).
(lldb) b main
Breakpoint 1: where = 1`main + 42 at 1.cpp:8, address = 0x00000001000013aa
(lldb) r
Process 2551 launched: '/Users/lingsun/test/1' (x86_64)
Process 2551 stopped
* thread #1: tid = 0xd38d, 0x00000001000013aa 1`main(argc=1, argv=0x00007fff5fbff9a0) + 42 at 1.cpp:8, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000013aa 1`main(argc=1, argv=0x00007fff5fbff9a0) + 42 at 1.cpp:8
   5
   6   	int main( int argc, char **argv )
   7   	{
-> 8   	    int a[] = {-1, 1, 1, 1, -1, -1, 0,0,0};
   9   	    vector<int> n(a, a+sizeof(a)/sizeof(int));
   10  	    int pa = 0;
   11  	    cout << n.size() << "---" << pa << endl;
(lldb) n

相关推荐