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
Related
Within QtCreator, in an Ubuntu machine, I want to debug a C++ application.
I make a debug build by adding -DCMAKE_BUILD_TYPE=Debug argument to the CMAKE part of the build settings. I set a breakpoint and I start debugging. The breakpoint is hit, but instead of stepping through the code linearly, the program counter (PC) keeps jumping around like it I was trying to debug optimized code, yet it's a debug build. The program is multi-threaded but I've verified that while debugging I am in the same thread, and yet the PC keep jumping to lines unrelated to the code.
Why could this happen? how to avoid it?
I suspect if this behavior may be related to another question I made a while ago debugging with gdb. Unfortunately, the question went unanswered and I'm not sure why this happens.
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.
I use Eclipse with CDT plugin for my C/C++ development. And I use MinGW compiler. Environment Path set properly. All the setting done properly in Eclipse. While editing the source code its working fine but after compilation when I try to execute the source code sometimes it says it cannot open the .exe file or sometimes doesn't show anything when there is some input to take. When I stop the execution pressing the red button program gets executed completely with default values.
But everything is fine if I compile and run the same source code using notepad and the command prompt. Please help.
A common problem is that if the program is currently executing, the program file is opened by the system and cannot be reopened for writing by the compiler (or more exactly by the linker). This problem can be easily reproduced by starting the program in debug mode and stop it at a breakpoint. Then, while the process is active, change a line in source and ask for a new build: you will get the error saying that the exe file cannot be opened.
How to fix: ensure to close any possible execution of the program when the error happens and rebuild
I'm using a 3rd party dll with no source code available. It runs perfectly fine, but every time I run my program, an annoying pop-up says "MyProgram.exe has triggered a breakpoint".
If I press continue, my program runs 100% correctly.
If I press break, I can see that the breakpoint is occurring in the 3rd party file alp41basic.dll
I have no clue why they put breakpoints in their dll. How can I disable them?
My question is identical to one that went unanswered:
https://stackoverflow.com/questions/17514072/is-there-a-way-to-make-visual-studio-continue-when-an-exception-occurs-on-a-line
I eventually checked in with the company that distributed the dll, and indeed there are breakpoints in there for reasons that I won't get into. However, if I run the program outside the debugger (even simply open the binary from windows), these popup windows do not occur.
Thank you all for your help!
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.