Home > Backend Development > C++ > Why Does GDB Report a Missing File Error When Debugging C Exceptions in Ubuntu?

Why Does GDB Report a Missing File Error When Debugging C Exceptions in Ubuntu?

DDD
Release: 2024-11-11 00:29:02
Original
607 people have browsed it

Why Does GDB Report a Missing File Error When Debugging C   Exceptions in Ubuntu?

GDB Displays Missing File Error for Library Source Code

When using GDB to debug C exceptions, users may encounter an error message indicating a missing file, such as "No such file or directory" for "raise.c." This error can occur even if the exception is handled correctly.

Solution: Obtain Library Source Code and Debug Information

To address this issue, it is necessary to obtain the source code and debug information for the relevant library, in this case, libc6. Ubuntu provides the debuginfo package for this purpose.

Steps to Debugging C Library Source Code:

  1. Install the debuginfo version of libc6: sudo apt install libc6-dbg.
  2. Configure the package system to download source code packages:

    • Install dpkg-dev: sudo apt install dpkg-dev.
    • Uncomment "deb-src" lines in /etc/apt/sources.list if necessary.
  3. Download source code:

    • Create a directory: /opt/src.
    • Download source code: apt source libc6.
    • Note the source code directory (e.g., /opt/src/glibc-2.23).
  4. Adjust GDB's source code directory:

    • Identify the expected source code directory using (gdb) info source.
    • Move or symlink the source code to the expected location, or set a substitute path: (gdb) set substitute-path /expected-location /actual-location.

Once these steps are completed, GDB will be able to access the correct source code and provide accurate debugging information for the exception.

The above is the detailed content of Why Does GDB Report a Missing File Error When Debugging C Exceptions in Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template