FS#47220 - [gcc][gdb] gdb outputs: "No such file or directory." while debugging

Attached to Project: Arch Linux
Opened by Ortomala Lokni (ortomala) - Monday, 30 November 2015, 08:39 GMT
Last edited by Allan McRae (Allan) - Saturday, 14 January 2017, 07:33 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

When debugging hello world, gdb outputs an error:

std::operator<< <std::char_traits<char> > (__out=..., __s=0x400864 "Hello") at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream:556
556 /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream: No such file or directory.

Additional info:
* package versions: gcc 5.2.0 and gdb 7.10

Steps to reproduce:
1)Create a tst.cc file:

#include <iostream>
int main(){
std::cout << "Hello";
}

2)Compile it, with debug symbols:

g++ -g -otst tst.cc

3)Run gdb:

gdb tst
(gdb) break main
(gdb) run
(gdb) step
std::operator<< <std::char_traits<char> > (__out=..., __s=0x400864 "Hello") at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream:556
556 /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream: No such file or directory.



This doesn't happen with Debian Jessie and gcc 4.9.2
This task depends upon

Closed by  Allan McRae (Allan)
Saturday, 14 January 2017, 07:33 GMT
Reason for closing:  Deferred
Additional comments about closing:  Waiting on debug symbol packages.
Comment by Evangelos Foutras (foutrelis) - Tuesday, 01 December 2015, 09:03 GMT
It happens on Debian Jessie too, if you install the libstdc++6-4.9-dbg package. Stripping /usr/lib/libstdc++.so.6.0.21 on Arch will get rid of the message as well.

Fedora is being extra fancy and include source files in their debuginfo packages (I believe they also process them a bit and/or change paths slightly) and there the step command will find the "ostream" source file and print the relevant line(s) from it.

In conclusion, I don't think there's anything to be done here (unless maybe Allan wants to look into stripping libstdc++?). This is not an error per se; ostream is considered a source file and it cannot be found since it's not part of the package, but GDB tries to open it since libstdc++ contains debug symbols.
Comment by Allan McRae (Allan) - Tuesday, 01 December 2015, 10:27 GMT
Bah - damned if I do, damned if I don't! I left the debug symbols there to improve backtraces, but it breaks this.
Comment by Dave Reisner (falconindy) - Tuesday, 01 December 2015, 14:12 GMT
I don't think this is about debug symbols, it's just finding the wrong path to the headers. You can avoid the error in gdb by calling this at startup:

set substitute-path /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include /usr/include/c++/5.2.0

I'm not sure where gdb gets this path from, though.
Comment by Allan McRae (Allan) - Saturday, 14 January 2017, 07:33 GMT
The path to the source files are embedded in the debug symbols during build time. This case it is just lucky that the source files match the installed headers...

Absolutely nothing will happen here until Arch gets debug symbol packages. Closing.

Loading...