I'm debugging some C++ code in Eclipse configured with a MinGW gdb configuration.
When running gdb directly in a shell, I can return from a function immediately, and tell it what value the function should return, with for example return 3.
How do I do that while debugging in Eclipse rather than running gdb outside of Eclipse in a shell window?
Eclipse CDT does not provide that feature in the UI with a button or similar. Feel free to enter a feature request, or even better a patch.
However, you can of type return 3 in the GDB input console in CDT without having to leave the Eclipse environment. Here are some instructions I wrote for a related (but not duplicate) question that shows you how to use the console.
The console view allows you to enter GDB commands in standard GDB syntax.
To use the Console:


print i + j or p i - j (p is short for print):
Other Hints when using the Console
You can "pin" the console so that it stays the selected console top with this button on the toolbar: 
You can switch console with this drop-down:


If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With