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

查看:27
本文介绍了特定线程上的 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 只读然后释放内存)),工作正常,另一个线程做其他事情,但遗憾的是,有一个错误,它是 segfaulting,我想抓住该段错误,而不是其他线程中发生的其他错误.

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天全站免登陆