为什么GDB不加载dll?

时间:2015-07-02 13:22:53

标签: c++ qt dll gdb mingw32

帮助我理解为什么简单的动态加载库的qt应用程序在gdb下运行,但更复杂的不是。 Qt Toolkit我使用了两者。

这是我的测试应用程序的构建方式(之后是lib和exe):

C:/devtools/mingw-i686-4.8.2-release-posix-dwarf-rt_v3-rev3/mingw32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/juriy/testlib'
g++ -c -pipe -Wall -Wextra -Werror -g -fprofile-arcs -ftest-coverage -O0 -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DTESTLIB_LIBRARY -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I'../../../Qt/4.8.6/include/QtCore' -I'../../../Qt/4.8.6/include/QtGui' -I'../../../Qt/4.8.6/include' -I'../../../Qt/4.8.6/include/ActiveQt' -I'debug' -I'../../../Qt/4.8.6/mkspecs/win32-g++' -o debug/testlib.o testlib.cpp
g++ -export-dynamic -lgcov -coverage -mthreads -shared -Wl,--out-implib,debug/libtestlib.a -o debug/testlib.dll debug/testlib.o  -L'c:/Qt/4.8.6/lib' -lQtGuid4 -lQtCored4 
C:/devtools/mingw-i686-4.8.2-release-posix-dwarf-rt_v3-rev3/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: warning: --export-dynamic is not supported for PE targets, did you mean --export-all-symbols?
mingw32-make[1]: Leaving directory 'C:/Users/juriy/testlib'

g++ -c -pipe -Wall -Wextra -Werror -g -fprofile-arcs -ftest-coverage -O0 -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../Qt/4.8.6/include/QtCore' -I'../../../Qt/4.8.6/include/QtGui' -I'../../../Qt/4.8.6/include' -I'../testlib' -I'../../../Qt/4.8.6/include/ActiveQt' -I'debug' -I'.' -I'../../../Qt/4.8.6/mkspecs/win32-g++' -o debug/widget.o widget.cpp
g++ -c -pipe -Wall -Wextra -Werror -g -fprofile-arcs -ftest-coverage -O0 -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../Qt/4.8.6/include/QtCore' -I'../../../Qt/4.8.6/include/QtGui' -I'../../../Qt/4.8.6/include' -I'../testlib' -I'../../../Qt/4.8.6/include/ActiveQt' -I'debug' -I'.' -I'../../../Qt/4.8.6/mkspecs/win32-g++' -o debug/moc_widget.o debug/moc_widget.cpp
g++ -export-dynamic -lgcov -coverage -mthreads -Wl,-subsystem,windows -o debug/test.exe debug/main.o debug/widget.o debug/moc_widget.o  -L'c:/Qt/4.8.6/lib' -lmingw32 -lqtmaind -ltestlib -L../testlib/debug -lQtGuid4 -lQtCored4 
C:/devtools/mingw-i686-4.8.2-release-posix-dwarf-rt_v3-rev3/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: warning: --export-dynamic is not supported for PE targets, did you mean --export-all-symbols?
mingw32-make[1]: Leaving directory 'C:/Users/juriy/test'

我的复杂应用程序构建:

g++ -c -pipe -Wall -Wextra -Werror -g -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DSIP_LIB -DQWT_DLL -DQT_DLL -DQT_WEBKIT_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I'../../../../Qt/4.8.6/include/QtCore' -I'../../../../Qt/4.8.6/include/QtNetwork' -I'../../../../Qt/4.8.6/include/QtGui' -I'../../../../Qt/4.8.6/include/QtXml' -I'../../../../Qt/4.8.6/include/QtXmlPatterns' -I'../../../../Qt/4.8.6/include/QtSql' -I'../../../../Qt/4.8.6/include/QtSvg' -I'../../../../Qt/4.8.6/include/QtWebKit' -I'../../../../Qt/4.8.6/include' -I'.' -I'../SIP_Common' -I'../SIP_Qwt' -I'../SIP_Qwt/src' -I'../../../../Qt/4.8.6/include/ActiveQt' -I'debug/mocs' -I'debug/uics' -I'../../../../Qt/4.8.6/mkspecs/win32-g++' -o debug/objs/moc_sbmrscwidget.o debug/mocs/moc_sbmrscwidget.cpp
g++ -export-dynamic -mthreads -shared -Wl,--out-implib,./debug/libWidgets.a -o debug/Widgets.dll object_script.Widgets.Debug  -L'c:/Qt/4.8.6/lib' -lCommon -L../SIP_Common/debug -lQwt_4 -L../SIP_Qwt/debug -lQtWebKitd4 -lQtSvgd4 -lQtSqld4 -lQtXmlPatternsd4 -lQtXmld4 -lQtGuid4 -lQtNetworkd4 -lQtCored4 
C:/devtools/mingw-i686-4.8.2-release-posix-dwarf-rt_v3-rev3/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: warning: --export-dynamic is not supported for PE targets, did you mean --export-all-symbols?

Tha最后说明了库和exe构建标志,标记相同。

当gdb启动时,我在QtCreator中看到gdb输出的具体差异。对于简单的应用程序,gdb开始像这样加载库:

>=library-loaded,id="C:\\Windows\\system32\\ntdll.dll",target-name="C:\\Windows\\system32\\ntdll.dll",host-name="C:\\Windows\\system32\\ntdll.dll",symbols-loaded="0",thread-group="i1"
sLibrary C:\Windows\system32\ntdll.dll loaded
>=library-loaded,id="C:\\Windows\\syswow64\\kernel32.dll",target-name="C:\\Windows\\syswow64\\kernel32.dll",host-name="C:\\Windows\\syswow64\\kernel32.dll",symbols-loaded="0",thread-group="i1"
sLibrary C:\Windows\syswow64\kernel32.dll loaded
>=library-loaded,id="C:\\Windows\\syswow64\\KernelBase.dll",target-name="C:\\Windows\\syswow64\\KernelBase.dll",host-name="C:\\Windows\\syswow64\\KernelBase.dll",symbols-loaded="0",thread-group="i1"
sLibrary C:\Windows\syswow64\KernelBase.dll loaded
>=library-loaded,id="C:\\Users\\juriy\\testlib\\debug\\testlib.dll",target-name="C:\\Users\\juriy\\testlib\\debug\\testlib.dll",host-name="C:\\Users\\juriy\\testlib\\debug\\testlib.dll",symbols-loaded="0",thread-group="i1"
sLibrary C:\Users\juriy\testlib\debug\testlib.dll loaded

但是当更复杂的启动时,gdb会忽略加载和输出:

>=thread-exited,id="1",group-id="i1"
sThread 1 in group i1 exited
>=thread-group-exited,id="i1"
sThread group i1 exited
>19^error,msg="During startup program exited with code 0xc0000022."
dCOOKIE FOR TOKEN 19 ALREADY EATEN (InferiorRunOk). TWO RESPONSES FOR ONE COMMAND?
dNOTE: INFERIOR EXITED
dState changed from InferiorRunOk(11) to InferiorExitOk(16) [master]
dState changed from InferiorExitOk(16) to InferiorShutdownOk(19) [master]
dState changed from InferiorShutdownOk(19) to EngineShutdownRequested(20) [master]
dQUEUE: SHUTDOWN ENGINE
sExecutable failed: During startup program exited with code 0xc0000022.

PS。关于CROSS_COMPILE有一些警告,我应该忽略这个吗? Here同样的问题,但由于我无法看到决定,因此有点无用。

0 个答案:

没有答案