gdb suddenly starts ignoring breakpoints - gdb

This just happened randomly while debugging. I've restarted the terminal (i'm using ubuntu on windows specifically) and even my pc, yet the problem still persists.
I set a breakpoint at line 43, but when i run the code, it jumps right to line 55 for no apparent reason.
edit: I actually figured out that gdb is working as it should. I just overlooked that i set a breakpoint in a for loop body that my code couldn't reach.

Related

GDB Debugger in QtCreator

I'm having problems debugging my C++ code. I'm using GDB with QtCreator and when the code stops at a breakpoint and I step over (either using keyboard shortcut, or from the menu) most of the times it goes to an irrelevant file (like memory or algorithm from STL, or some other Qt file)
At the beginning I thought I pressed step into or had some other breakpoint and it stopped there, but I tried it with only setting one breakpoint
Any ideas?
It was suggested it's a duplicate question (Setup GDB with QtCreator) but it's not, because as I said in my case all breakpoints work, the program stops at the correct line, but step over doesn't work, even when I step into and then step out the code doesn't return to the previous line of code

clion debugger stops working after one step

I have a weird problem with the CLion debugger.
When I put a breakpoint or two and then hit the debug button, the debugger would initialize and stop at the first breakpoint. But then when I hit any of the step buttons in the console (Step Over, Step Into), it executes the line and then it won't allow me to step any more. The debugging process is still on, but I can't in fact do anything.
It's worth mentioning that this problem occurs only with projects that I create in CLion in my computer. When a friend creates a new CLion project and shares it with me, the CLion debugger works just fine when I use it with this project in the same computer (mine).
Any clue would be appreciated!
I ran into the same problem, and it turned out single-stepping worked only for the first few lines of code - until I called gethostname() followed by WSACleanup(). When one of them was commented out, the single stepping worked fine (F7/F8).
This is on a Windows 10 machine, and the functions are part of Microsoft's WinSock implementation.

Netbeans v7 C++ debugger bug

I have a program that I have written in C++ under linux (Ubuntu 10.10).
The programming and debugging worked perfectly until the moment I added the following lines to the code:
mapfile = fopen(map_filename,"wb");
fwrite(map_header,1,20,mapfile); // <-- this is the problem line
fclose(mapfile);
After I added those, the program compiles ok, but the debugger now won't start. It immediately fails with this message:
Program completed, Exit code 0x177
error while loading shared libraries: unexpected PLT reloc type 0xcc
And if I remove the line with the "fwrite", the debugger will start normally.
This problem only happends inside Netbeans.
When I debug it using the command-line "gdb" it also works ok without any problems.
Anyone have idea why its happening and how to fix it?
P.S: Those problems started recently so I assume maybe it has to do something with system updates, I'm not sure.
Found the problem:
Not long ago, I removed some old C++ projects from netbeans. It figures out that netbeans (at least v7.0) remembers all the breakpoints that I put on old projects that don't even exist in the IDE anymore.
I found this by looking at the Debugger Console (Window->Debugging->Debugging Console) and seeing that when "gdb" starts, it tries to setup all these breakpoints from other projects or from projects that do not exists (this is a bug in netbeans, btw)
The solution: I simply cleaned all the breakpoints (inside Window->Debugging->Breakpoints) and now the program can be debugged properly.
Hope this will help to anyone out there who has the similar problem.

strange Debugging Error: possible memory corruption?

I've got a strange problem:
I use eclipse and have written a program which is quite long. Now if I compile "Debug" (so no compiler optimization) and click "Run" then everything is finde and my Program produces the expected output.
Now If I compile "Release" the program does not terminate but instead "stops" at one point...
So I've started Debugging with the dgb Debugger build into eclipse and clicked through the program. And if I let it just run through everything is fine, but If I click through every single line of code then the program "stops" at some other point.
Now I've gone one step further and clicked not only through every line but stepped into each function.
What I found very strange is that in depence on HOW I step through my program with the debugger I get the error at different positions. So I think the stopping of the debugger is related to eclipse which cannot show something in the debugger-window or so.
Additionally the error critically depends on other lines of code.
So my best guess is that the error is related to some memory problem.
Thank you very much!

Breakpoints are deleted in Eclipse CDT and MinGW using Windows

In a simple Hello World Project in Eclipse CDT (version: Kepler) on Windows 7, I tried to set breakpoints to debug the program.
However, when the program is launched, the debugger stops at the first line of main(), and when the Resume button is pressed, all the breakpoints are skipped and the program terminates with: expect signal SIGINT when the program is resumed.
A strange thing happened too: the same installation on a second computer in which the username does not include spaces works fine.
The console for gdb traces does not report anything strange. The breakpoints are set and the execution does not report other errors (but I don't assure this is the problem).
The same settings are used on MacOS X too, but here it works fine.
Any hints? Thank you.