我的代码中遇到了一个非常奇怪的错误。
我在我的程序中使用了一个变量m_requestedStructures
,而调试器在检查它时访问了错误的地址。例如,我在代码中有:
qDebug() << "requested: " << m_requestedStructures << " " << &m_requestedStructures
我在这里设置了一个断点。到达断点时,我将打印的值和地址m_requestedStructures
与 gdb 正在访问的值和地址进行比较:
requested: 0 0xfce640
Breakpoint 1
157 qDebug() << "requested: " << m_requestedStructures << " " << &m_requestedStructures;
(gdb) p m_requestedStructures
$5 = -1167616
(gdb) p &m_requestedStructures
$6 = (int *) 0xfce644
(gdb)
可以看出,值和地址都不同。
我看到的另一个症状是我有一个函数,QueueManager::checkPopulation_()
我很久以前就删除了它,但是 gdb 仍然尝试制表符完成它,如果我在它上面设置一个断点,它会在函数使用的点中断成为。
在我看来,符号读取不正确。我试过从一个干净的目录重建,但问题仍然存在。有谁知道可能导致此问题的原因或如何解决?
提前致谢!
编辑:我刚刚尝试在我添加的新函数上设置断点。该函数QueueManager::run()
出现在 gdb 的选项卡中完成,但是当我尝试设置断点时,我得到
the class GlobalSearch::QueueManager does not have any method named run
此外,检查其他变量,包括本地范围和 QueueManager 的成员,似乎工作正常。
这是编译器/链接器的输出。包含该类的文件是queuemanager.cpp
,它是静态库的一部分,libglobalsearch.a
在动态库中使用xtalopt.so
:
$ make VERBOSE=1 xtalopt
/usr/bin/cmake -H/git/xtalopt-public -B/git/xtalopt-public/build --check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 xtalopt
make[1]: Entering directory `/git/xtalopt-public/build'
/usr/bin/cmake -H/git/xtalopt-public -B/git/xtalopt-public/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /git/xtalopt-public/build/CMakeFiles 63
make -f CMakeFiles/Makefile2 src/xtalopt/CMakeFiles/xtalopt.dir/all
make[2]: Entering directory `/git/xtalopt-public/build'
make -f src/spglib/CMakeFiles/spglib.dir/build.make src/spglib/CMakeFiles/spglib.dir/depend
make[3]: Entering directory `/git/xtalopt-public/build'
cd /git/xtalopt-public/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /git/xtalopt-public /git/xtalopt-public/src/spglib /git/xtalopt-public/build /git/xtalopt-public/build/src/spglib /git/xtalopt-public/build/src/spglib/CMakeFiles/spglib.dir/DependInfo.cmake --color=
make[3]: Leaving directory `/git/xtalopt-public/build'
make -f src/spglib/CMakeFiles/spglib.dir/build.make src/spglib/CMakeFiles/spglib.dir/build
make[3]: Entering directory `/git/xtalopt-public/build'
make[3]: Nothing to be done for `src/spglib/CMakeFiles/spglib.dir/build'.
make[3]: Leaving directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_report /git/xtalopt-public/build/CMakeFiles 18 19 20 21 22 23
[ 9%] Built target spglib
make -f src/libssh/CMakeFiles/ssh_static.dir/build.make src/libssh/CMakeFiles/ssh_static.dir/depend
make[3]: Entering directory `/git/xtalopt-public/build'
cd /git/xtalopt-public/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /git/xtalopt-public /git/xtalopt-public/src/libssh /git/xtalopt-public/build /git/xtalopt-public/build/src/libssh /git/xtalopt-public/build/src/libssh/CMakeFiles/ssh_static.dir/DependInfo.cmake --color=
make[3]: Leaving directory `/git/xtalopt-public/build'
make -f src/libssh/CMakeFiles/ssh_static.dir/build.make src/libssh/CMakeFiles/ssh_static.dir/build
make[3]: Entering directory `/git/xtalopt-public/build'
make[3]: Nothing to be done for `src/libssh/CMakeFiles/ssh_static.dir/build'.
make[3]: Leaving directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_report /git/xtalopt-public/build/CMakeFiles 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
[ 33%] Built target ssh_static
make -f src/globalsearch/CMakeFiles/globalsearch.dir/build.make src/globalsearch/CMakeFiles/globalsearch.dir/depend
make[3]: Entering directory `/git/xtalopt-public/build'
cd /git/xtalopt-public/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /git/xtalopt-public /git/xtalopt-public/src/globalsearch /git/xtalopt-public/build /git/xtalopt-public/build/src/globalsearch /git/xtalopt-public/build/src/globalsearch/CMakeFiles/globalsearch.dir/DependInfo.cmake --color=
make[3]: Leaving directory `/git/xtalopt-public/build'
make -f src/globalsearch/CMakeFiles/globalsearch.dir/build.make src/globalsearch/CMakeFiles/globalsearch.dir/build
make[3]: Entering directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_report /git/xtalopt-public/build/CMakeFiles
[ 33%] Building CXX object src/globalsearch/CMakeFiles/globalsearch.dir/queuemanager.cpp.o
cd /git/xtalopt-public/build/src/globalsearch && /usr/bin/c++ -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_PLUGIN -DQT_SHARED -D_HAVE_EXECINFO_H_ -DQT_DEBUG -fPIC -g -I/usr/include/QtOpenGL -I/usr/include/QtGui -I/usr/include/QtCore -I/usr/include/eigen2 -I/git/xtalopt-public/build -I/usr/include/openbabel-2.0 -I/git/xtalopt-public/src -o CMakeFiles/globalsearch.dir/queuemanager.cpp.o -c /git/xtalopt-public/src/globalsearch/queuemanager.cpp
Linking CXX static library libglobalsearch.a
cd /git/xtalopt-public/build/src/globalsearch && /usr/bin/cmake -P CMakeFiles/globalsearch.dir/cmake_clean_target.cmake
cd /git/xtalopt-public/build/src/globalsearch && /usr/bin/cmake -E cmake_link_script CMakeFiles/globalsearch.dir/link.txt --verbose=1
/usr/bin/ar cr libglobalsearch.a CMakeFiles/globalsearch.dir/optbase.cpp.o CMakeFiles/globalsearch.dir/queuemanager.cpp.o CMakeFiles/globalsearch.dir/structure.cpp.o CMakeFiles/globalsearch.dir/tracker.cpp.o CMakeFiles/globalsearch.dir/optimizer.cpp.o CMakeFiles/globalsearch.dir/bt.cpp.o CMakeFiles/globalsearch.dir/sshconnection.cpp.o CMakeFiles/globalsearch.dir/sshmanager.cpp.o CMakeFiles/globalsearch.dir/random.cpp.o CMakeFiles/globalsearch.dir/ui/abstractdialog.cpp.o CMakeFiles/globalsearch.dir/ui/abstracttab.cpp.o CMakeFiles/globalsearch.dir/moc_optbase.cxx.o CMakeFiles/globalsearch.dir/moc_queuemanager.cxx.o CMakeFiles/globalsearch.dir/moc_structure.cxx.o CMakeFiles/globalsearch.dir/moc_tracker.cxx.o CMakeFiles/globalsearch.dir/moc_optimizer.cxx.o CMakeFiles/globalsearch.dir/moc_bt.cxx.o CMakeFiles/globalsearch.dir/moc_sshconnection.cxx.o CMakeFiles/globalsearch.dir/moc_sshmanager.cxx.o CMakeFiles/globalsearch.dir/moc_random.cxx.o CMakeFiles/globalsearch.dir/ui/moc_abstractdialog.cxx.o CMakeFiles/globalsearch.dir/ui/moc_abstracttab.cxx.o
/usr/bin/ranlib libglobalsearch.a
make[3]: Leaving directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_report /git/xtalopt-public/build/CMakeFiles 1 2 3 4 5 6 7 8 9 10 11 12 13 14
[ 55%] Built target globalsearch
make -f src/xtalopt/CMakeFiles/xtalopt.dir/build.make src/xtalopt/CMakeFiles/xtalopt.dir/depend
make[3]: Entering directory `/git/xtalopt-public/build'
cd /git/xtalopt-public/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /git/xtalopt-public /git/xtalopt-public/src/xtalopt /git/xtalopt-public/build /git/xtalopt-public/build/src/xtalopt /git/xtalopt-public/build/src/xtalopt/CMakeFiles/xtalopt.dir/DependInfo.cmake --color=
make[3]: Leaving directory `/git/xtalopt-public/build'
make -f src/xtalopt/CMakeFiles/xtalopt.dir/build.make src/xtalopt/CMakeFiles/xtalopt.dir/build
make[3]: Entering directory `/git/xtalopt-public/build'
Linking CXX shared library xtalopt.so
cd /git/xtalopt-public/build/src/xtalopt && /usr/bin/cmake -E cmake_link_script CMakeFiles/xtalopt.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -fPIC -g -shared -Wl,-soname,xtalopt.so -o xtalopt.so CMakeFiles/xtalopt.dir/extension.cpp.o CMakeFiles/xtalopt.dir/xtalopt.cpp.o CMakeFiles/xtalopt.dir/genetic.cpp.o CMakeFiles/xtalopt.dir/structures/xtal.cpp.o CMakeFiles/xtalopt.dir/optimizers/xtaloptoptimizer.cpp.o CMakeFiles/xtalopt.dir/optimizers/vasp.cpp.o CMakeFiles/xtalopt.dir/optimizers/gulp.cpp.o CMakeFiles/xtalopt.dir/optimizers/pwscf.cpp.o CMakeFiles/xtalopt.dir/optimizers/castep.cpp.o CMakeFiles/xtalopt.dir/testing/xtalopttest.cpp.o CMakeFiles/xtalopt.dir/ui/dialog.cpp.o CMakeFiles/xtalopt.dir/ui/tab_init.cpp.o CMakeFiles/xtalopt.dir/ui/tab_edit.cpp.o CMakeFiles/xtalopt.dir/ui/tab_opt.cpp.o CMakeFiles/xtalopt.dir/ui/tab_sys.cpp.o CMakeFiles/xtalopt.dir/ui/tab_progress.cpp.o CMakeFiles/xtalopt.dir/ui/tab_plot.cpp.o CMakeFiles/xtalopt.dir/ui/tab_log.cpp.o CMakeFiles/xtalopt.dir/moc_extension.cxx.o CMakeFiles/xtalopt.dir/moc_xtalopt.cxx.o CMakeFiles/xtalopt.dir/moc_genetic.cxx.o CMakeFiles/xtalopt.dir/structures/moc_xtal.cxx.o CMakeFiles/xtalopt.dir/optimizers/moc_xtaloptoptimizer.cxx.o CMakeFiles/xtalopt.dir/optimizers/moc_vasp.cxx.o CMakeFiles/xtalopt.dir/optimizers/moc_gulp.cxx.o CMakeFiles/xtalopt.dir/optimizers/moc_pwscf.cxx.o CMakeFiles/xtalopt.dir/optimizers/moc_castep.cxx.o CMakeFiles/xtalopt.dir/testing/moc_xtalopttest.cxx.o CMakeFiles/xtalopt.dir/ui/moc_dialog.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_init.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_edit.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_opt.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_sys.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_progress.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_plot.cxx.o CMakeFiles/xtalopt.dir/ui/moc_tab_log.cxx.o -lavogadro ../globalsearch/libglobalsearch.a ../spglib/libspglib.a -lQtOpenGL -lGLU -lGL -lSM -lICE -lX11 -lXext -lopenbabel -lQtGui -lQtCore ../libssh/libssh_static.a -lnsl -lresolv -lrt -lz -lssl -lcrypto
make[3]: Leaving directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_report /git/xtalopt-public/build/CMakeFiles 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
[100%] Built target xtalopt
make[2]: Leaving directory `/git/xtalopt-public/build'
/usr/bin/cmake -E cmake_progress_start /git/xtalopt-public/build/CMakeFiles 0
make[1]: Leaving directory `/git/xtalopt-public/build'