Have gdb step on s immediately - gdb

I am doing a lot of bug-hunting tonight and it's on a remote machine where I have to use terminal gdb, i.e. no GUI.
Is there a way to tell gdb to step on s (no return press required) and next on n (no return press required as well)?
Thank you!

This can be done in the TUI "single key mode". You can enter the TUI with tui enable and enter single-key mode by typing C-x s.

Related

GDB gets messed up after leaving TUI [duplicate]

I am using gdb 7.7.1 on ubuntu, GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1.
My terminal is Konsole 2.13.2.
The problem I am having is, when I go to the TUI mode, after one or two debugger sessions - session, I mean, set breakpoint, run, step over a while and finally kill it by "kill" command - the output starts messed up. Supposedly each output should go to a new line, but now they just all scramble, one immediately after another one.
I attach a screenshot.
I have to quit GDB, open a new terminal tab and start gdb again.
I tried "ctrl-x-a" back and forth, does not help; neither does "ctrl-l".
A while back, I was using another terminal, it also had this problem.
Any help is appreciated.
It appears that your tty settings changed, in much the same way that tty -onlcr might change them (tty onlcr restores the default). Perhaps the code you're debugging changes tty settings, and doesn't get a chance to restore them because of a crash.
As suggested in a comment, using a separate window might provide a workaround.

VSCode C++ debug capture console output

I am running VSCode in Ubuntu to debug a C++ program. Debugging a console app with GDB is working fine except I really want to capture the console log output to a file. I cannot see a way or option to do this. Is there any option to capture this console log output?
Since there does not seem to be a native feature to save the output of a VSCode terminal, maybe you can use in said terminal a command allowing you to save that session.
See for instance "Gdb print to file instead of stdout"
gdb core.3599 -ex bt -ex quit |& tee backtrace.log
As mentioned, the output is written to backtrace.log and also on the screen.
As the OP Andy Tomlin mentions in the comments, this is not compatible with a debugger session.
We solved the problem by just handling it inside the app and redirecting cout internally to a file.

Mac C/C++ Eclipse Debugger hangs

When I try to use the debugger on a simple test project the console dumps out the following:
warning: `/var/folders/s1/dxx9glzn45j6x2ypzk9xkjnc0000gp/T/Test-0061ba.o': can't open to read symbols: No such file or directory.
$1 = 0xff
The target endianness is set automatically (currently little endian)
No symbol table is loaded. Use the "file" command.
Launching the debugger gets 99% complete and gets stuck! It just hangs there for awhile and when I try to terminate the connection nothing happens. Then when I go to shut down eclipse I usually have to force quit it :( Anyone have any ideas?
I fixed this issue by correcting the gdb-cert. Make sure you select code signing "Always trust"

How to do line by line debugging in Code::Blocks IDE?

I am using Code::Blocks IDE which is open source IDE providing multiple languages.
It is using GCC compiler.
I want to do line by line debugging of program.
Have you any about that?
You can use the "Step Into" command in the "Debug" menu which should start debugging and stop at the first line. Then continue through using the "Next Line" command (also in the "Debug" menu).
If that doesn't work as intended, you can set a breakpoint (by clicking in the left 'gutter', or 'margin') at the first line of your app, and start the debugger from the "Debug" menu, and then use the "Next Line" command in the "Debug" menu.
The shortcut keys vary based on your settings but should be listed alongside the menu command, and makes 'step'ping easier.
Since you're using gcc to compile, you can specify the -g parameter to include debugging symbols, and invoke gdb from the a command shell with the compiled binary as an argument: gdb <yourapp>.
(If [n]curses is installed, specify -tui for a more pleasing interface: gdb -tui <yourapp>.
Once in gdb, the command start will start debugging and stop automatically at main(). You can then step thru with the step command, and quit to exit.
You can always man gdb...
GCC's optimization sometimes makes debugging not easy. To improve your debugging experience, make sure you set optimization to off or to a low level via -O0 or -O1.
Additionally, make sure you have all debug information included in the binary: -g3.
Please go through these steps below:
At first click on debug Menu bar : (Debug-> Debugging windows-> Watches). Now your debugging window is on and the window will be shown at the left corner.
Add breakpoint just clicking left portion of the mouse at those lines you want to debug or test.
Again click on (Debug-> start/continue) It will show a console window. Put input on it. Now press Enter button.
Click on (Debug-> Next line) or press F7 for line by line debugging.
Happpy Coding !

Visual Studio .exe files open and immediately close

I have a problem, when I try to open my Hello World.exe file (that I created by following a tutorial). It immediately closes without giving me the chance to read or see if I have done everything correctly.
As you can see, I need help on how to keep it open, without instantly closing.
You can either put a break point before the end of main or try the following:
int main()
{
//...
std::cin.get();
return 0;
}
It is going to wait for you to press some key to exit the console.
EDIT: It is better to add break point which do not change existing code.
In console applications there are a couple of things you can do to stop the window from closing on you such as using system("pause") (not so recommended though), getch(), std::cin >> x etc at the end of the application.
Another option is to start a cmd window, cd to the location of the exe and run it like any other console application is meant to be ran, that way it wont just close on you, it'll simply exit.
In VS2017, you can specify that the executable is a Console app, not a Windows app. This makes your application run in a "Microsoft Visual Studio Debug Console", with "Press Any Key To Close This Window" appearing at the end of the console output:
Right click the project to bring up Properties.
Linker > System > Subsystem > Select "Console".
Press Apply before closing.