Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see return value in Qt Creator (gdb)

Tags:

gdb

qt

qt-creator

Is there a way to see the return value of a function in Qt Creator (in my case using GDB as the debugger)?

I found answer 3505002 (how to use gdb command list), but I was looking for something within the GUI if possible.

Here is the link to the closest answer found:

How to use gdb command list to print a function's parameter and return value without pausing?

like image 752
user3761340 Avatar asked Jul 15 '14 21:07

user3761340


People also ask

How to use breakpoint in Qt?

Adding BreakpointsIn the code editor, click the left margin or press F9 (F8 on macOS) on a particular line you want the program to stop. In the Breakpoint Preset view or the Breakpoints view: Double-click the empty part of the view. Right-click the view, and select Add Breakpoint in the context menu.


2 Answers

One can see the return value by stepping out of the function (using the "Step Out" button or the F11 key in the Windows version of Creator) in the GUI.

Note that exiting the function by single stepping (using the Step Over button or F10 in the Windows version of Creator) does not provide the result.

When stepping out, the return value is shown in the Locals and Expressions View in a window that pops up between the stack variables and the expression evaluators.

It would be nice to always be able to see the return value of the most recently exited function, but it appears that gdb does not readily support it, so it may be unlikely that Creator will support it anytime soon. Anyway, using the Step Out feature anytime the return value is needed is a sufficient workaround.

like image 103
user3761340 Avatar answered Oct 05 '22 21:10

user3761340


@Felix Dombek:

  • At least on Linux step out is Shift-F11.
  • The return value will appear in an extra section of the variable explorer (available if you choose debug mode. Switch to debug mode by pressing the bug icon on the very left bar of Qt Creator or press Ctrl+4)
  • Screenshot:

enter image description here

like image 35
Semjon Mössinger Avatar answered Oct 05 '22 23:10

Semjon Mössinger