Home > Backend Development > C++ > body text

Why is GDB Missing Source Code When Debugging C Programs?

Linda Hamilton
Release: 2024-11-13 01:33:01
Original
282 people have browsed it

Why is GDB Missing Source Code When Debugging C Programs?

Missing Source Code Error in GDB

Problem:

When using GDB to debug C programs that throw exceptions, users encounter an error message indicating that raise.c is missing. This error prevents full source code debugging.

Fix:

To fix this issue and enable full source code debugging in GDB, follow these steps:

1. Install Debuginfo Version of Libc6:

Ensure that the libc6-dbg package is installed on your system. This package contains the debugging information for the C library.

2. Configure Package System for Source Code Handling:

If not already configured, enable your package system to download and process source code packages by:

  • Installing dpkg-dev
  • Enabling deb-src lines in /etc/apt/sources.list and running sudo apt update

3. Download Source Code for C Library:

  • Create a directory for source code storage (e.g., /opt/src)
  • Download the source code corresponding to the installed C library version using apt source libc6

4. Locate Source Code Directory and Set GDB Path:

  • Determine the expected source code location using (gdb) info source command
  • Move or symlink source code to the expected location or use (gdb) set substitute-path to redirect GDB to the correct path

With these steps complete, GDB should now correctly display source code when debugging C programs.

The above is the detailed content of Why is GDB Missing Source Code When Debugging C Programs?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template