My program is using too much CPU power when I select text. And I don't know why. Normally I'd just press "Break all" to see what the program is currently doing. But in this case I'm busy selecting text with the mouse.
Is there any trick to delay the "Break all" command for a few seconds?
you can start a separate thread with Sleep(5000); DebugBreak();
Press CTRL-Break while selecting. This should bring the debugger up immediately.
You can sprinkle all your suspicious code with special kind of breakpoints that do not stop execution, but print a message in Output window.
Add a breakpoint, go to Breakpoints window, find the breakpoint that was just added, right-click, select "When Hit...", in new window select "Print a message". Make sure check box "Continue execution" is checked (it should be by default). Breakpoint icon will change from circle to diamond. Repeat this for several breakpoints.
You can adjust the text that breakpoint will display to whatever you need.
Related
When I run C++ program under qt creator in debug mode, Qt creator shows me debug window with "local and expressions", "breakpoints" and so on.
Sometimes I close these windows to watch the code by pressing Esc. How to return this views back? I really need to loot at stack trace right now, but I can't find a button to show me the stack.
I looked at this question but it didn't help. My debugging window working well, but when I close it, I cannot open it again. The only way - restart whole program, than debugging view appear again and I can operate with it.
You need to go back to the "Debug" mode by clicking on the debug (bug) icon on the left hand side.
You can do so by pressing CTRL + 4.
"Debug" mode and CTRL + 4 didn't help me, so here is another solution:
Click "Views" which should be on the dark grey bar in the lower right area of your user interface, in small print. There you can check or uncheck any of the Debug windows you want to see.
I find it easier to just click "Reset to Default Layout" under this menu because I'm not hard to please and it brings all the debug windows I want to see back instantly.
I have a simple problem that I am struggling to find an answer to. In my situation, I am attempting to wait for user input into the console to activate the main loop of the program, but the program can not be allowed to enter the main loop until the window behind it is in focus. If you do not understand what I mean, here is an example. I have two windows, the one in focus(on top) is the console running the program which is at a pause state while waiting for the window behind it to become the window on top and in focus. I think that either enabling the console to read keyboard input while not in focus or having the program recognize that it is no longer in focus would work. Is it possible to pull off either of those situations in Windows?
Thank you in advance.
I think "focus" doesn't mean what you think it means. "Pause state" on the other hand has no special meaning. If your program has a "pause state", then you defined that state, and you define when the state is entered. So just enter the pause state when you feel like it.
That said, the strict answer to your question is the WM_KILLFOCUS message, but that arrives in the message loop for a window and you don't own the message loop of a console window.
Is there a way how to set up more complex condition for breakpoints in QtCreator? (dbg) At least comparing the QStrings, but other complex type would be nice too. Integer comparing like in tutorials works fine.
Right click the breakpoint (red ball in the left hand side of the text editor) and select something like "Edit breakpoint". A dialog then let you put conditions on the breakpoint.
ctrl+click or right click a breakpoint and choose Edit Breakpoint.
A window comes up where you can set "Condition" and how many times it should be ignored before the debugger stops the execution.
The condition can be whatever you would write in a conditional c++ clause.
There are other options as well such as which thread are you targeting.
When I am debugging my program, I often want to make it run from where it is paused to a specific line.
In Xcode 3, I was able to do that by clicking on the button appearing next to the line number when hovering it.
In Xcode 4, it seems to be possible to do that either by right clicking on the line number and select Continue to here, either by using the Debug menu and choose Continue To Current Line item.
However these options are always grayed out when I want to use them.
Note, I don't know if this is relevant but I am using c++
Is there something I am doing wrong?
Thanks in advance,
Kevin
It seems that this is because you are using the LLDB debugger. As the same thing happens to me, whilst using the LLDB debugger and debugging C++ code, as you can see here:
I tested this with Objective-C code, and this feature works perfectly fine whilst debugging Objective-C.
The green button you mentioned, for Xcode 3, also pops-up with Objective-C code (using Xcode 4). As you can see here:
Perhaps it's a bug in Xcode, or Apple just wants you to program in Objective-C. It seems to be only an issue whilst using LLDB, and debugging C++ code (I am unsure of C code). On the other hand, debugging with GDB works fine with both: C++ and Obj-C code.
The only real options you have at the current time is:
Option 1:
Use the GDB debugger instead, as the GDB debugger with Xcode supports this.
To change the debugger:
Step 1:
Click your project name under the Scheme Menu, in the top left.
Step 2:
Click "Edit Scheme..."
Step 3:
Once the Edit Scheme menu comes up, click the pop-up menu next to the "Debugger" option.
Step 4:
Click the option "GDB" to use the GDB debugger.
NOTE:
Once you click GDB, the "Debug Process As" option will be greyed out.
Step 5:
Click OK.
NOTE:
I'm not sure about the limitations whilst using the GDB debugger, over LLDB (I think Xcode does not support any recent versions of GDB, as they have switched to LLDB and clang).
Option 2:
Create a breakpoint to where you wish to continue, and then continue to it. It really isn't that hard compared to right clicking and pressing "Continue Here" or the green button. This also provides the same functionality. With the use of keyboard shortcuts it could be just as fast (see below).
For example:
Say you want to continue until you hit line 39.
Set a breakpoint at line 39.
Click "Continue program execution" button, which is the button that likes some-what like a media-play button. Alternatively you can continue using the keyboard shortcut: Command + Ctrl + Y, or use the Menu (Product->Debug->Continue)
NOTE:
You need the Debug area shown (Shift-Command-Y), in order to see the "Continue program execution" button.
I am in desperate need of help.... :). I am running a script from cmd line console. It does a sequence of operations. whats the best way to pause the script in between to check the results and resume it back using mouse????? or any key
I would appreciate for your reply back,
-Abishek
If I understand your question correctly, and if your program is writing to the standard output (the console window) and you are running on Windows:
You can turn on 'quick edit' in the console window by editing the cmd.exe window properties.
Open a command prompt (start | run | cmd.exe)
Click the upper left corner of the window and choose 'Defaults'.
Click the Options tab and then in Edit Options section make sure the QuickEdit Mode box is checked.
Click OK and you should be set.
If you click with the mouse inside the console window when quick edit is enabled, it will block the program from continuing while it is waiting to be able to write the next message to the output. If you then hit 'esc', the program will continue.
It's a useful shortcut for pausing a running console program that I use all of the time.
try cin.get()
There isn't any easy way to do that. You'd need to create a wrapper to run the program (for example, a debugger is a wrapper to a program), and this wrapper would have to have mouse functions programmed into it.
Without use of the mouse, use cin.get();. It will take an input from the keyboard before continuing.
I'm not sure about using the mouse to pause, but you can pause the execution of command line process by pressing the Pause / Break key or Ctrl + NumLock .
You can then resume the execution with Ctrl + Z