特定线程上的gdb nostop SIGSEGV [英] gdb nostop SIGSEGV on a specific thread

查看:79
本文介绍了特定线程上的gdb nostop SIGSEGV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序专门在一个线程上进行段错误处理,但是我遇到另一个线程在进行段错误处理的问题,我想用GDB来捕获它,我发现我可以做到这一点:

I have a program that purposely segfaults on one threads, but I have a problem that the other thread is segfaulting, I'd like to catch it with GDB, I saw that I can:

handle SIGSEGV nostop noprint

但是我只想在故意这样做的线程上这样做.是否可能?

but I'd like to do that only on the thread that purposely does that.. is it possible?

我将解释: 我有2个线程,一个线程是segfaulting(然后恢复(mprotect只读,然后释放内存)),它工作正常,另一个线程做了其他事情,但是可悲的是,有一个bug且它是segfaulting,我想抓住segfault,而不是发生在另一个线程中的其他段.

I'll explain: I have 2 threads, one thread is segfaulting(and recovers(mprotect read only and then releasing memory)), that works fine, the other thread does something else, but sadly, there is a bug and it is segfaulting, I want to catch that segfault, and not the other ones that occur in the other thread.

推荐答案

据我所知,具体取决于操作系统,我假定答案是linux,答案是否"!

As I know, depending on the OS, and I assume linux for my answer and the answer is 'NO'!

Posix异常每个线程可以有一个sigmask,但每个任务只能有一个处理程序.因此,不可能为每个线程设置不同的处理. sigaction将处理整个过程.因此,我看不到gdb更改此方法的方法.

Posix exceptions can have a sigmask per thread but only one handler per task. So it is not possible to set different handling for each thread. sigaction will handle it for the complete process. So I see no way for gdb to change this.

这篇关于特定线程上的gdb nostop SIGSEGV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆