Qt Creator调试器未显示返回值

时间:2019-01-29 12:32:46

标签: c++ qt debugging qt-creator

我的环境:

  • Windows 10(64位)
  • Microsoft Visual Studio 2015更新3
  • Qt 5.6.2
  • Qt Creator 4.8.1

根据Qt Creator文档,退出该函数时,应该可能让Qt Creator的调试器显示该函数返回的值。摘自http://doc.qt.io/qtcreator/creator-debug-mode.html#local-variables-and-function-parameters

“本地”视图由“本地”窗格和“返回值”窗格(为空时隐藏)组成。

只要程序在调试器的控制下停止,它就会检索有关最顶层堆栈帧的信息,并将其显示在“本地”视图中。 Locals窗格显示有关该框架中的函数参数以及局部变量的信息。如果在按Shift + F11后调试器中的最后一个操作是从函数返回,则“返回值”窗格将显示该函数返回的值。

问题是,我看不到返回窗格(因此看不到最后一个函数返回的值)。

这是一个最小的示例:

编译最小的项目后,在main()即将被调用时,在foo()中设置一个断点,然后启动调试器(F5)。调试器正确地在断点处停止:

enter image description here

我将命令 Step Into (F11)交给调试器。在调试器中,我可以看到控件已到达调用的函数foo()

enter image description here

现在是关键步骤。我将命令 Step (Shift + F11)交给调试器。如预期的那样,控制权返回给调用方(main()),但是未显示foo()返回的值:

enter image description here

那么,如何查看返回值?

这是我的 Compile Output 窗格的内容:

15:45:44: Running steps for project debugger_return_pane...
15:45:44: Starting: "C:\Qt\5.6.2\msvc2015_64\bin\qmake.exe" C:\experiments\debugger_return_pane\debugger_return_pane.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug"
15:45:44: The process "C:\Qt\5.6.2\msvc2015_64\bin\qmake.exe" exited normally.
15:45:44: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" -f C:/experiments/build-debugger_return_pane-Desktop_Qt_5_6_3_MSVC2015_64bit2-Debug/Makefile qmake_all

jom 1.1.2 - empower your cores

15:45:45: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited normally.
15:45:45: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" 
    C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
    cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\DebuggerReturnPane.vc.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\debugger_return_pane -I. -I..\..\Qt\5.6.2\msvc2015_64\include -I..\..\Qt\5.6.2\msvc2015_64\include\QtWidgets -I..\..\Qt\5.6.2\msvc2015_64\include\QtGui -I..\..\Qt\5.6.2\msvc2015_64\include\QtANGLE -I..\..\Qt\5.6.2\msvc2015_64\include\QtCore -Idebug -I..\..\Qt\5.6.2\msvc2015_64\mkspecs\win32-msvc2015 -Fodebug\ @C:\Users\dave\AppData\Local\Temp\main.obj.8348.0.jom
main.cpp
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\DebuggerReturnPane.exe @C:\Users\dave\AppData\Local\Temp\DebuggerReturnPane.exe.8348.78.jom
15:45:45: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited normally.
15:45:45: Elapsed time: 00:01.

3 个答案:

答案 0 :(得分:0)

现在已将其视为Qt Creator中的错误:https://bugreports.qt.io/browse/QTCREATORBUG-21913

答案 1 :(得分:-1)

您需要通过以下方式在文件顶部包含QDebug:

包括

,因此在返回之前,您需要以这种方式打印foo函数返回的值:

qDebug()<<值;

答案 2 :(得分:-1)

对我有用,在调试器停止到第8行F10(跳过)之后,您会看到返回值显示在右侧面板enter image description here