Using the Debugger: The Basics

 There are several options for controlling the program execution of the program you would like to debug:

·      Same level (F4). This means that the debugger will run the program until it reaches the next source line. If the current line contains a function call, it will be skipped. You remain on the same level. If you reach the end of the function, the line where the function call was implemented will be displayed. This is not possible in all cases — specifically if your function is a Windows callback, it was called up by the operating system. You cannot step through system code, so the debugger will stop when control reaches one of the source lines of your program again.

·      Step in (F8). This means that the debugger will run the program until it reaches the next source line. If there is a function call in the current line, the debugger will try to see if it has debug information for the function in question. If yes, execution will stop at the first line of that function. If that function does not have any debug information, the debugger will arrange to skip that call. In cases where the function calls one of the procedures of your program indirectly, the debugger will stop when control reaches the next source line of your program. A SendMessage call is one example of this. This function will call the callback procedure for the window that can be in your program. In this case, the debugger will stop at the beginning of the callback procedure.

·      Step out (F9). This means that the debugger will run the program until it exits the current function and place a stop at the calling function. The same rules apply as in the return from a procedure explained in Same level above.

·      Run to cursor (F7). The debugger will put a temporary stop at the indicated line and pass control to the program being debugged. If control reaches the indicated line, the debugger will stop. If not, the program will continue normal execution. Be careful to ensure that control MUST reach the line you indicate with F7.

·      Set a breakpoint (F2). This will set a breakpoint at the indicated line.

·      Unset a breakpoint (F2). If the line that is under the cursor contained a breakpoint, that breakpoint will be deleted.

·      Break. This makes the debugger stops the program under debug, no matter where it is.

·      Stop debugging. This stops the execution of the program under debug, and closes the debugger.

·      Set next statement. This can be reached through the right mouse button menu. Using this feature, you can skip several lines of code in the current function, or return backwards to retrace the execution. Note that you can make the program fail if you set the next statement where it would use variables that were initialized in a piece of code that you just skipped. The debugger cannot undo what the program has done, when you reset the current line to some line before the current one. If the program opened, closed, or deleted files, for instance, the debugger does not undo those actions.

·      Set next instruction. When the ‘Machine instructions’ window is open, you can move the program counter explicitly to a new location by pressing the right mouse button anywhere on that window. A contextual menu will appear, prompting you to change the program counter to the selected line in the ‘Machine instructions’ window. To do this, choose this menu item and the program counter will be set to that location.

Debugger menu

Description

Accelerator key

Execute

Continues the execution of the program.

F5

Step in

If the line contains a function call, the debugger steps into the called function if debug information for that function is available.

F8

Same level

Stops ignoring function calls.

F4

Step out

Stops when the current function is finished.

F9

Run to cursor

Stops when execution arrives at the line where the text cursor is placed. If this line is never reached, this is equivalent to Execute.

F7

Stop debugging

Stops the debugger and returns to the editor.

 

CPU

Activates the register display.

 

Stack

Shows the call stack.

 

Memory

Allows you to inspect memory contents.

 

Machine instructions

Activates the assembly display.

 

Watchs

Activates the watch window.

 

Evaluate symbol

Lets you evaluate a symbol or a simple expression.

 

Info

Shows several information displays about the program being debugged. 

 

Restart

Stops the program being debugged, and restarts it from the beginning.

 

Break

Interrupts the execution of the program immediately.

 

Breakpoint

Sets or unsets a breakpoint at the line where the text cursor is.

F2

Edit breakpoints

Shows the breakpoints dialog box.

 

Data breakpoints

Shows the data breakpoints dialog box.