I have 2 installations of QtCreator on Windows (with MingW, gcc, g++, make and gdb) and on Ubuntu. On the 2 OS I am able to run some Qt programs (with Qt Windows) or console programs, and debug programs.
But I tried without success the reverse debugging; I checked the option "allow reverse debugging" in the debugger's options and I have a button in the debug view that's called "reverse direction" but when I click on it nothing happens, it does not change other buttons nor transforms the effect of these buttons (from forward to backward).
Related
I am using Qt creator and cdb debugger for my c++ project. I need to set some breakpoints in code and see what happens during runtime. Unfortunately because of some third party library I absolutely can not use Debug mode so I have to stick to the release mode.
In visual studio I always do such thing and use breakpoints in the release mode easily but how could I do that in Qt creator?
(Versions: Qt 5.12 / Qt creator 4.8)
Try using a "Profile" build in Qt Creator. That will include separate debugging line information in a "Release" (optimized) build. You can then launch it using the Debug button in Qt Creator and set breakpoints as you need.
Caveats:
You may not be able to get the exact line you want because of optimizations by the compiler.
You most variables will be optimized into registers, so you can't view them. If you need to view registers, try the good, old fashion method of printing their values out with a qDebug() statement. (When in doubt, print it out.)
I was having an issue with a C++ program where when I ran the .exe the program would run and my window for the program would open, but the console would be open on the desktop in the background. I did a google search and found that compiling with the -mwindows command as an argument, removes the console. Which it did. But I'm unsure of what it actually does and I am curious.
It behaves exactly the same as the /subsystem:windows switch described on MSDN.
Basically, it sets the entry point to WinMain (or wWinMain) instead of main (or wmain), which results in no console window and some Win32 startup code running to create the arguments passed to WinMain. As Neil says, it does not prevent or enable anything you can't do without it.
A similar switch is -municode to switch between main/WinMain and wmain/wWinMain, which is not mirrorred by the Microsoft tools. These seem to automagically select the one you use).
It says that your application is one using the Win32 API that doesn't need a console window. You use this option when you are writing Windows GUI applications, DLLs and the like, although a console window can be useful when debugging these kinds of applications. Even with this option, you can explicitly create a console window, should your application need one dynamically and, contrariwise, you can call Win32 GUI APIs from a console application.
In Code::Blocks 20.03 (uses the MinGW-W64 gcc compiler project) the project target ( bin/Release ) compiles with -mwindows and the project target ( bin/debug ) compiles without -mwindows. The debug target not only has debugging information in the executable, but it runs with the console window exposed in the background. This is 'highly' useful for debugging, since your app can write to the console debugging messages while your gui app is processing... like an active debugging log.
Obviously the console is ugly for release targets. In Code::Blocks the switch -mwindows is set indirectly in the Project properties under the 'build targets' the bin/debug build target is specified as console app, while the bin/release target is specified as gui app.
Back in the day (maybe eight years ago) there was a catch-22; -mwindows was necessary to link the Win32 api (but no console). If you wanted a console AND the Win32 api it didn't work easily; fortunately this is not an issue today... you can mix and match. I generally build my release targets without the console; and I build the debug targets with the console, and I use the console for debugging copiously.
marcus
The dev environment in question consists of:
Windows 7
MinGW (g++)
CMake
Qt Creator
The problem is that Qt Creator, a lovely IDE as far as I can tell, does not display programs' command-line output. It seems to have its own proprietary debug pane, but it doesn't give me, for example, runtime errors. It just tells me that the program has failed and gives me the exit code. I'm using Creator only for its C++ capabilities, and not using Qt in any way, so the proprietary pane is useless to me.
So I ask this: Can something be done? Am I missing something really, stupidly obvious like a built-in command line? Or, if not, can I at least use some filthy and/or repulsive hack to get it to display the Windows command prompt upon running a program?
Last thing; I did do some research, and found a way to edit the Qt project file to display the prompt, but... I'm using CMake, not Qt projects. So that doesn't answer my question. If I can do something similar with CMakeLists.txt, that would be wonderful. But Google has failed me on that front, so I'm not holding out too much hope.
EDIT:
I'm specifically worried about runtime errors. cout and printf are rerouted to Qt Creator's window, so that's fine. I don't get runtime errors unless the debugger catches them, and the frequency of that is less than ideal.
Windows GUI programs don't have standard output.
In Windows there are two possible entry points in the standard runtime. The console one and the windows one. The console one will inherit console window from parent process or create a new one and connect the standard input/output/error streams to it, while the windows one will leave them unconnected unless they were explicitly redirected by the invoking process. A Qt application is (probably; you could have console Qt-Core application) a GUI application and Qt Creator (nor any other Windows IDE) does not redirect the output explicitly. Therefore the standard output is not open at all and the writes are being discarded.
However windows have separate logging facility for debugging purpose. This is what you see in the debug window. You can write to it using the native OutputDebugString API. I am sure you can also direct the Qt debug log there.
Note, that when it tells you the program has exited with status 0, it means the program ran, which in turn means it compiled successfully and thus there were no errors from g++. There may have been warnings, in which case you should see them in the appropriate other window. Compiler and program output are different things; the IDE does read the compiler output.
Recently, Eclipse SDK decided to kill my brain cells.
Out of the blue, it just stopped pausing at breakpoints. I do see it hit the breakpoint, but right then window loses focus and in the thread/callstack window it shows
MyApp [C/C++ Application]
MyApp [18556][cores:1]
Thread [2] (Running : Container)
Thread [1] (Running : User Request)
gdb
I see when i hits my breakpoint and it takes a blink of an eye before it goes into above state. My app stops responding and working and i have to kill it.
My app is a non GUI application which runs in linux as a background task, it reads and writes files, performs communication through COM and TCP/UDP. No user input is ever requested or anything like that.
There are tons of people who have problems with eclipse having problems with breakpoints, however they all are about java projects and or windows version of eclipse and none of the provided solutions work for me.
So far i have:
Rebuilt index.
Cleaned and rebuild project.
Deleted all debug files, makefile, binary and built again.
Cleared all breakpoints.
Made sure it was not set to ignore breakpoints.
and probably more which i already forgot.
Eclipse version is 4.2.1
Linux: Arch linux which was not updated for like 2 years now.
Project is C++.
What other information do i need to provide?
How can i solve this problem. I can't debug my application :(
I resolved this problem in this way: "Run" -> "Debug Configuration" -> select you configuration -> Debugger.
Then check the checkbox which shows "Use external console for inferior (open a new console window for input/output)".
I tried to create a C++ project in Eclipse Helios, it works fine for some simple "Hello World" projects (a single file etc..). However, now I have a little bigger project with several files, the project can still be built without any problems. Actually, when I get into the release folder, the makefile, object files, the actual binary executable are all there. And I could run the binary through the termainl. If I click the "Run/Debug" in Eclipse for this project, it always says "Launch Failed. Binary not found".
How could run the program in Eclipse? I would like to explore its debug features. In addition, I'm running eclipse in CentOS linux and I believe the basic g++, gdb setting etc.. should be all right, otherwise the daemon hello world won't work.
Warning: I have a very old version of eclipse and the CDT so the current procedure could have changed considerably.
In the C/C++ Project view, expand your project then expand the Binaries node. In there you should have a list of the built executables. Right-click on it and select the item Run As.. > Local C/C++ Application. This should automatically create a new run configuration which you can access from the green arrow icon and the little bug icon in your tool bar. Click on these to run normally or to run in debug mode.
If you want to tweak how programs are launched, goto to the Run configuration menu item of the green arrow icon. Select the configuration that you previously created or make a new one. You can then tweak the various launch settings like the executable to run, the arguments you want to pass, the required environment variables, etc.
Note that there's also a separate Debug configuration that can be accessed from the little bug icon in your toolbar. Within that dialog there's a Debugger tab which contains all the controls necessary to set up your debugger. Just randomly screw around with the controls until you find something that works for you.
I just had the same error, and here is what I did - proper binary parser must be selected so Eclipse can recognize the executable:
Select the project, then right click.
Project->Properties->C/C++ Build->Settings->Binary Parsers, PE Windows Parser
(or you can select Cygwin parser if you use Cygwin compiler, on Linux I use Elf parser).
That worked for me at least for Cross compiler (both on Windows 7 and Ubuntu 12.04)