我们有一个使用最新版本的 gcc (g++-7.2) 编译的应用程序 不幸的是,生产服务器很旧并且有一个非常旧的 gdb 版本 (6.5.25-el5rh)
现场调试软件很困难,因为gdb
没有显示带有核心文件的回溯。使用 gdb 打开核心文件会导致此消息:
GNU gdb Red Hat Linux (6.5-25.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
warning: Can't read pathname for load map: Erreur d'entrée/sortie.
[...]
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Core was generated by `[binary_filename]'.
Program terminated with signal 11, Segmentation fault.
Die: DW_TAG_unspecified_type (abbrev = 218, offset = 2719370)
has children: FALSE
attributes:
DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module [path_to_binary]]
我在http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Null_pointer上找到了nullptr
可以翻译成DW_TAG_unspecified_type
.
nullptr
这个旧版本的 gdb 有问题吗?是否可以要求 gcc 避免为 nullptr 生成侏儒信息?
精度:
- 我们无法实际更新 gdb 版本,也无法部署我们自己的 gdb 版本
- 我们依赖于最新版本的 gcc (>= C++11),因此不希望降级 gcc
[local_installation]/generated/bin/g++ -v
:
COLLECT_GCC=./g++
COLLECT_LTO_WRAPPER=[local_installation]/generated/libexec/gcc/i686-pc-linux-gnu/7.2.0/lto-wrapper
Cible : i686-pc-linux-gnu
Configuré avec: [local_installation]/gcc-7.2.0/configure --prefix=[local_installation]/generated --disable-multilib --disable-libstdcxx-dual-abi --with-dwarf2 --enable-cxx-flags=-gdwarf-2
Modèle de thread: posix
gcc version 7.2.0 (GCC)
CXXFLAGS
:
-pipe -fpermissive -Wshadow -Wextra -Wundef -Wno-deprecated-declarations -std=gnu++17 -D_GLIBCXX_USE_CXX11_ABI=0 -gdwarf-2 -gstrict-dwarf $(INCLUDES) -O2 -Wall -W -D_REENTRANT $(DEFINES)
问候