3.3.6. Using GDB to intercept handling of signals by applications


To stop the execution of a program under specific circumstances, you can use the GNU Debugger (GDB). To stop the execution when the program receives a signal from the operating system, use a GDB catchpoint.

Procedure

  1. Set the catchpoint:

    (gdb) catch signal signal-type

    The command catch signal sets a special type of a breakpoint that halts execution when a signal is received by the program. The signal-type option specifies the type of the signal. Use the special value 'all' to catch all signals.

  2. Let the program run.

    • If the program has not started execution, start it:

      (gdb) r
    • If the program execution is halted, resume it:

      (gdb) c
  3. GDB halts execution after the program receives any specified signal.
  4. Continue by debugging the program code handling the signal, or resume execution with the knowledge of the signal being received.
  5. Later, to exit the GDB debugging session:

    (gdb) q
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部