首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SIGSEGV上的11分贝断裂

SIGSEGV上的11分贝断裂
EN

Stack Overflow用户
提问于 2014-10-23 13:46:49
回答 2查看 6.2K关注 0票数 7

gdb来自Linux/gdb世界,默认情况下,在检测到SEGV之前,gdb会在默认处理程序清理进程之前中断程序的执行。

11分局怎么能做类似的把戏呢?目前,该进程只是退出,使得无法查询回溯等。

编辑proccess handle -p true -n true -s true尝试-没有结果:(

代码语言:javascript
复制
(lldb) process handle -p true -n true -s true SIGSEGV
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGSEGV     true   true   true 
(lldb) run
Process 97630 launched: '/Volumes/My Finder Extensions 1/My_Daemon.app/Contents/PlugIns/My_ShellExt.appex/Contents/MacOS/My_ShellExt' (x86_64)
Process 97630 exited with status = 0 (0x00000000) Terminated due to signal 9

编辑:更多信息:

代码语言:javascript
复制
(lldb) bt all
error: invalid thread

我怀疑lldb不会很好地处理损坏的堆栈--我正试图找到一个涉及_NSExtensionMain入口点的问题,或者从那里开始的问题。

EN

回答 2

Stack Overflow用户

发布于 2014-10-23 13:52:31

您应该根据process handle SIGSEGV --notify true --pass true --stop true在lldb上键入this

(Lldb)进程句柄SIGSEGV --通知真--传递真--停止真

票数 5
EN

Stack Overflow用户

发布于 2014-10-23 18:11:04

我做了一个快速测试程序,

代码语言:javascript
复制
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

void handler (int in)
{
    puts ("signal received");
}

int main ()
{
    signal (SIGSEGV, handler);    
    kill (getpid (), SIGSEGV);
    return 0;
}

然后,我尝试调试它,让lldb停止在SIGSEGV上。

代码语言:javascript
复制
(lldb) br s -n main
(lldb) r
(lldb) pr h -p true -n true -s true SIGSEGV
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGSEGV     true   true   true 
(lldb) c
Process 5024 resuming
Process 5024 stopped

(lldb) bt
* thread #1: tid = 0x19d6ae, 0x00007fff8f27fc7e libsystem_kernel.dylib`__kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSEGV
  * #0: 0x00007fff8f27fc7e libsystem_kernel.dylib`__kill + 10
    #1: 0x0000000100000f25 a.out`main + 53 at a.c:13
    #2: 0x00007fff8c0e65c9 libdyld.dylib`start + 1
(lldb) c
Process 5024 resuming
signal received
Process 5024 exited with status = 0 (0x00000000) 
(lldb) 

好的,这看起来和我们预期的一样。我还可以要求lldb不间断地转发信号:

代码语言:javascript
复制
(lldb) br s -n main
(lldb) r
(lldb) pr h -p true -n true -s false SIGSEGV
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGSEGV     true   false  true 
(lldb) c
Process 5055 resuming
Process 5055 stopped and restarted: thread 1 received signal: SIGSEGV
signal received
Process 5055 exited with status = 0 (0x00000000) 
(lldb) 

看起来它做了我们想做的事情: lldb通知我们信号已经接收,然后发送给程序。

这是在Mac上安装了Xcode 6。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26529581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档