GDB 디버깅 시 sigwait 장애에 대한 해결 방법
사실, 프로그램에 신호를 보내서 그가 신호를 받아들이게 하면 된다. 예를 들어:kill-2[프로세스 번호](-2는SIGINT 신호)
외국어 참조:
gdb puts the debugged process in its own pgrp and sets the terminal to that pgrp. (Try e.g. ps j on the PIDs of gdb and your program being debugged.)
When you hit C-c, the signal goes to the current pgrp, i.e. to the debugged process and not to gdb. When a signal is delivered, ptrace will intercept it and let gdb decide what to do before it actually reaches the debugged process. Unless you are using "handle SIGINT nostop", then gdb will stop and give you a prompt here.
However, your program uses sigwait and so the signal is never actually delivered. Instead, you dequeue it via sigwait without going through actual signal delivery. ptrace only reports a signal that is about to be delivered. When you use sigwait, technically the signal is blocked the whole time and never delivered as such. The fact that ptrace does not report this signal is the expected behavior.
It could indeed be useful to let debuggers intercept signals being dequeued by sigwait. But, it would be wrong to change the existing ptrace interface to report these the same way it reports signals being dequeued for delivery. The existing ptrace indication of a signal says that the reporting thread will run the handler or default action, and that is what debuggers now expect that it means. Using the same report for a signal that was swallowed by sigwait could confuse existing debuggers. A report may be desireable, but it will have to be requested differently from the existing vanilla ptrace signal case.
For your situation, you are not really interested in the sigwait reporting per se. What you have asked for is to get a terminal signal to wake up gdb. That is entirely doable within gdb's domain already. You might be able to get it to happen by using gdb's "attach" and/or "tty" commands. If not, that is an issue with gdb that you can try to get fixed. If it provides some way to interrupt gdb that does not involve any signals generated for the debugged process, you are fine. It could do that by not changing the pgrp of gdb's controlling tty so that a C-c sends SIGINT to gdb and not to the debugged process, or by giving some other means to wake up gdb. (To avoid changing gdb's ctty's pgrp, you'd have to use a different tty for the debugged process if it does any terminal i/o of its own.)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.