Home >Backend Development >C++ >Why Does GDB Cry 'Missing raise.c' When Catching Exceptions?

Why Does GDB Cry 'Missing raise.c' When Catching Exceptions?

Susan Sarandon
Susan SarandonOriginal
2024-11-08 21:11:02407browse

Why Does GDB Cry

GDB's Lament: Resolving the Missing raise.c Conundrum

An annoying error can arise in GDB when catching exceptions, with the debugger lamenting the absence of "raise.c." To resolve this issue, let's delve into the depths of the problem and its solution.

The Underlying Cause

The missing "raise.c" file is crucial for GDB to provide accurate source line information during debugging. Without it, GDB defaults to uncertain locations, leading to confusing error messages.

Step-by-Step Solution

To address this issue effectively, follow these comprehensive steps:

  1. Install Debuginfo Packages: Ensure that the debuginfo version of the C library ("libc6-dbg") is installed.
  2. Enable Source Code Packages: Prepare the Ubuntu package system to process source code packages by installing the "dpkg-dev" package and checking that deb-src lines in "/etc/apt/sources.list" are uncommented.
  3. Download Source Code: Obtain the source code for the installed C library version by creating a directory (e.g., "/opt/src"), running "apt source libc6", and identifying the directory where the source code resides (e.g., "/opt/src/glibc-2.23").
  4. Specify Source Code Location: GDB expects the source code in specific locations. Determine the expected directory using "gdb" commands like "info source." If the actual and expected directories differ, update GDB's path using "set substitute-path /build/glibc-KM3i_a/glibc-2.23 /opt/src/glibc-2.23."

Conclusion

By adhering to these steps, GDB's complaints about missing source files will be silenced, allowing seamless debugging of exceptions. You can now navigate the depths of the C library code with confidence, ensuring accurate diagnosis and resolution of runtime issues.

The above is the detailed content of Why Does GDB Cry 'Missing raise.c' When Catching Exceptions?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn