"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Does GDB Cry "Missing raise.c" When Catching Exceptions?

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

Posted on 2025-02-06
Browse:875

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.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3