简体   繁体   English

为什么 gdb 向我抱怨没有可用的源(使用 g++ -ggdb3)

[英]Why gdb complain to me that No Source Available (with g++ -ggdb3)

For some reason I reinstalled my OS(manjaro linux) yesterday, and installed gcc and gdb by pacman , then I write a very small example program to make sure my environment is correct, because I am a beginner in linux and gdb.由于某种原因,我昨天重新安装了我的操作系统(manjaro linux),并通过pacman安装了gccgdb ,然后我编写了一个非常小的示例程序来确保我的环境正确,因为我是 linux 和 gdb 的初学者。 After compile,it went according to my expectations.编译后,它按照我的预期进行。 Then I wanted to take a look at the STL source code through gdb, so I opened my gdb with tui mode .然后想通过gdb看看STL源码,所以用tui mode打开了我的gdb Everything seemed normal at first, but my gdb can't step into ss.insert() that I want to see, with [ No Source Available ] on the top side of the screen.一开始一切似乎都很正常,但我的 gdb 无法进入我想看到的ss.insert() ,屏幕顶部有[ No Source Available ] And I've found the directory of the source file of operator<< is different to the version that before reinstall OS, and /usr/shared/c++/ doesn't exist anymore!而且我发现operator<<的源文件目录和重装系统前的版本不一样, /usr/shared/c++/已经不存在了!

This is the version information of GCC(g++) and gdb这是GCC(g++)gdb的版本信息

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

捕获gdb

Why gdb complain to me that No Source Available (with g++ -ggdb3)为什么 gdb 向我抱怨没有可用的源(使用 g++ -ggdb3)

Because you are stopped inside libstdc++ , which was built in a temporary directory (here /build/gcc/src/gcc-build/... ) and that directory is not present on your machine.因为您已在libstdc++中停止,该目录构建在临时目录(此处为/build/gcc/src/gcc-build/... )中,并且您的计算机上不存在该目录。

It is exceedingly unlikely that you actually need to look at the source of operator<<() , but if you really do want to do that, install GCC sources, and use (gdb) directory to point GDB to the relevant sources.这是不可能,你实际上需要看源operator<<()但如果你真的想这样做,安装GCC的来源和使用(gdb) directory指向GDB相关人士透露。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM