How Do I Debug My Application Using the Debugger? (Magic xpa 4.x)
Magic xpa has a powerful debugging tool built in. You can use it to view exactly what the engine is doing as it executes, and to view the call stacks, database access, see what is going on as the program executes, view all the contexts, set watches on variables, view all the variables in memory, and even change the variables as the program is running.
Here we will review how to use the debugger.
The first thing you need to do is to make sure you have Debug Mode switched on. Do this by selecting Debug->Debug Mode, or clicking on the icon on the Toolbar. It will show as depressed when it is selected.
When the debugger runs, it will show data in a series of windows. These windows can be merged together or viewed separately, just like the other panes in the Studio. You can choose to have all of them open, or none of them.
Open up the monitors you want by clicking on the desired item in the View pulldown menu. You can open up the monitors after you have started the debugging process also.
Now, you need to tell the debugger where to pause. There are two ways to do this:
Each of these are useful in different ways. For a full discussion of how to use these, see How Do I Set Breakpoints in the Application?.
It is important to set the breakpoint or use Break Now, because the variables, call stack, and contexts become visible only during a breakpoint. However, you can also set them as the program is running.
Now, you need to start running your program or project. If you are just debugging one program, position the cursor on that program and press F7 (Debug->Run). You don’t need to exit the task you are working on to run it; Magic xpa will save your changes before running the program.
If you want to test the entire project, press Ctrl+F7 (Debug->Run Project).
Once you have your breakpoints established, you can step through your program, operation by operation, while watching the execution in the runtime window. You have several step options, as shown in the table below.
|
|
|
Continue
|
F7
|
Once the program has started running, Continue will cause the program to execute until it hits the next breakpoint.
|
Step
|
F10
|
Proceeds to the next operation in the current program, then pauses again. However, if the operation is a call to another program, it doesn’t pause within the called program.
|
Step Into
|
F11
|
Works like Step, except that if the operation is a call to a Magic xpa task or program, or a Raise Event, you will remain in Step mode inside the called task or program.
|
Step Out
|
Shift+F11
|
Stops step-by-step operations within the current handler, but resumes them again in the calling handler.
|
Toggle Breakpoint
|
F9
|
If, while you are paused on a breakpoint, you decide you don’t need to use this breakpoint any more, you can turn off that breakpoint by pressing F9.
Or, if you are stepping through a program with F10, you can set new breakpoints with F9.
|
When you are finished debugging, you can stop the program quickly by pressing Debug->Stop, or selecting the on the toolbar. If there is a major problem with your program, you can restart the Magic xpa engine by pressing Ctrl+Shift+F9 (Debug->Reset Runtime Engine).