How to skip assembly code when debugging? - c++

Sometimes when I use the debugger to step through my code, it goes into some assembly code (I guess I've stepped into some system library code).
The question is, how can I skip over it and jump to the nearest c++ code of my project?

Use the "Step-out" button or Shift+F11, this will step back up the call stack.
Alternatively display the call stack (Alt+7), then double click on the function level you want to return to; this will indicate in the source window where the call was made. Then in the source window right-click the statement following the call, and select "Run to cursor". Of course if you already know where the call came from, you could just use "Run to cursor" in any case.

You can close that assembly window by clicking X on right side in the code window. Not the one at top most right(which closes the solution)

Jump Out of the current function? (Shift-F11 in the C++ settings?)

Related

how to use gdb to debug a GUI program

I know how to debug a console program, but what if the program has a GUI?
For example, there is a Calc icon, when I push it down, it will call some methods.
I want to know what methods it will call. I have the source codes but have no idea about which file corresponds to what, and want to back-track what codes it will implement if I click on the icon.
There conceptually isn't any difference between debugging a GUI application and a console application - they both come down procedural programming - some action calls a particular function. There's no difference whether the trigger of the action is you pressing a button on the GUI, or typing in a command in the console. You can use a debugger for both of them (visual or command line).
If you have the source, and know what the triggering mechanism is, it should be easy enough to follow along in the source code to see which functions are called by the trigger (eg. not at runtime). You have the question tagged as Qt, which uses the connect function to connect 'signals' (events) to either other signals or 'slots'. This is essentially associates a callback function, with a particular event, so searching your source for that would be a good starting place.

watch window in the debug is empty

I was trying to understand how to fix my watch window but didn't find any good answer(I'm using visual studio 2013).
I used the debugger and suddenly the watch window didn't show the values or the object i'm have in the block - actually it didn't show anything anymore.
Does anyone know how can it be fixed?
Many thanks!!!
Maby this will help you:
To open the QuickWatch dialog box with a variable added While in break
mode, right-click a variable name in the source window name and choose
QuickWatch. This automatically places the variable into the QuickWatch
dialog box.
Source
The Watch windows don't show anything by default, you need to add things to them to see the values. What might have happened in your case, is that either you deleted what you had by mistake, or you ran into a bug, where something got corrupted in your solution and they were lost.
If you want to see everything that is currently in scope, the Locals window is the way to go.
And if you want a superset of that (which has both current and previous statement), use the Autos window.
The QuickWatch dialog box is similar in concept to the Watch window, but QuickWatch can display only one variable or expression at a time
https://msdn.microsoft.com/en-us/library/bhawk8xd.aspx

How to view contents of an array while debugging in Code Blocks?

This is probably a silly question and i am posting this Post-Googling,
The question is,
How do i view the contents of an array while debugging, Provided the Breakpoint is in function not Main?
I am using code::blocks 13.12 version and i set a break point in my sample simple c++ code,
and i want to observe how the contents of the array change with the code but all i see is the the address of the array under watch window,
It is however displaying the values of other integer variables correctly,
a is an array
I forgot to mention that i am tracking the array in a function and not in main,and i am aware that main passes the address of the array to the function being called(by reference i meant)
I am relatively new to codeblocks, Am i missing some setting or something?
Right click on the cell, then select "Properties", there you can tell it to "watch as array", and tell it the index range to watch.
i am using 12.11. I select the array variable suppose a, choose "watch a" in the right button down menu, and I can see the values in the array a.
Another thing that I use is watching under cursor.
If you go Settings -> Debugger... -> GDB/CDB debugger -> Default and you enable selection "Evaluate expressions under cursor", every time you leave mouse pointer above a variable in the code, it will be watched.
It's not the same with having it in Watches toolbar, but strangely it will show array's fields.
Debug -> Debugging windows -> Watches
you may watch the variables in this way
in convenience, you can find button "Debugging Windows" near to the debug toolbar, choose "watch", hope you can find it!

Visual Studio environment 2010 C++ Debug techniques suggestion required

I am using Visual Studio 2012 for my project in C++. I have a function where I put a break point.
MyFunction(int userid, double totalamount,char *ce_account_ref_num, int payment_type)
My debugger goes to this point and shows some undesirable inputs for userid. Is it possible to go back to the point where this function is called and verify inputs?
In the Call Stack window (usually on the bottom-right of Visual Studio), double-click the line with the name of the method where you want to see values of variables.
You can do many things but maybe the best choice is to comment all the lines in your MyFunction method and step over to the next line outside MyFunction to check the variables. You can also check the Call Stack and Call Hierarchy to see where your function is called from, in the case you have more than one call to the same method.
Unfortunately it is not possible to role back(undo executions) to the point where this function is called. However you can try put break point right after you give input and verify it. Call stack is also helpful to track how your program flow sequence get there.
I do this by pressing ctrl and - . This can be done recursively (press the combination again). This takes me back to the point where my cursor was last. By doing this I can go back to where the function is called and check the values etc. And by the way you can execute the same function again (in debug mode) by going to the point where the function is called by selecting "set next statement" from the right click menu, while you are debugging - a very powerful feature.

Tracing recursive function using XCode debugger

How do I trace recursive functions like these that calls itself recursively two times? I wanted to create a tree of the calls. When I stumbled into this, how do I know which of the methods that currently are being executed? CountWays(numStairs-1) or CountWays(numStairs-2)
GDB answer?
If you see near the bottom-right of your screenshot there are 3 buttons in a group and the left-most button has been selected. Press either the center or the far-right button to open the debug console. In there you may type 'bt' and it will print your back-trace.
GUI answer?
You need to trigger a backtrace upon your breakpoint (or exception breakpoint), instructions for this can be found here:
http://www.oramind.com/index.php/articles/182-ios-5-xcode-backtrace