We all know that we can enter debug mode by using the command line switches /h and /hs (debug and system debug mode).
However, do you know that you can enter debug mode at any time, even when there is no command line to enter the commands into when for example you are displaying a pop up message ??
Create a text file on your desktop using notepad that contains the lines:
- Code: Select all
Then, when you want to enter debug mode just drag and drop the file onto the active window.
Whilst in debug mode, did you know you can set breakpoints at a:
- Specific statement (such as Select or Message)
At the start of a procedure
At the start of a Function Module
At a system exception
Have a look under Break-points->Breakpoint at while in the debugger.[/list]
Whilst in Debug mode, there are various other useful tools including the Watch Points mentioned in 0002 - Structures - What Are They and How To Use/Find Them.
Accessing the menu path Goto->Display Condition displays the following menu:
One of the main functions I use on this menu is 'Active Call Stack'. The other selections I use on a less than frequent basis.
What is the Active Call Stack?
The Active Call Stack is a list of all procedures that have been executed to get to the current position of the program.
Having said that, what's the concept of a 'stack' ?
Have you ever stayed in a hotel, where at breakfast time you collected your plate from a pile of plates that weigh down a spring, the removal of the top plate causing the spring to expand moving the next plate up slightly so that it is ready to be picked up ?? That's a stack. To be precise it's a First In Last Out or Pushdown Stack. Items are pushed onto the stack and popped off the stack in the reverse order that they were put on it - 1 2 3 4 5 5 4 3 2 1. This is exactly the same type of stack that you are looking at when you look at the Active Call Stack (Although in a processors case it is a variable called a 'Stack Pointer' that is incremented on a push and decremented on a pop rather than a spring that is is moved...)
There are other types of stack such as a FIFO (First in First Out) stack, normally called a Queue, and the HEAP stack (just called heaps these days) first used in the Pascal programming language.
The Stack concept has played a major part in programming from the very first microprocessors right up to now. The 6502 processor had a stack starting at $0100 in memory which could be used to store the contents of the accumulator temporarily and was also used to store the return address from a subroutine call. The Z80 had the concept of a mobile stack, with the start of the stack being specified by a register rather than by processor model.
Higher level languages also use the FILO stack by using it as a transport mechanism to pass parameters to procedures. Prior to calling the procedure the program pushes onto the stack the parameters required and then calls the subroutine. The subroutine pops the return address off of the stack and saves it, then pops the various parameters off the stack, does it's stuff and pushes the results on the stack followed by the return address. The RET instruction pops the return address off of the stack into the program counter and the program jumps back to the point in the program just after the procedure call.
What Does The Active Call Stack Enable Us To Do ?
The Active Call Stack shown below is a simple report showing the events, functions or procedures that the program has passed through to reach the current breakpoint.
By clicking on one of the lines, the program displays the location where the procedure was called from. Not only that, it also re-instates the environment as it was just prior to the procedure call. This means you can then examine variables and so on. What it doesn't do is reset the program counter (ie the current place in the program) to that position.
The Active Programs view displays a list of all the programs that are currently loaded. This is basically a display only list.
Memory usage displays the amount of memory in use. It also allows you to change such things as the debugging mode and so forth.
As you can probably tell, I find the last two options of not much value!
A batch job can be restarted in debug mode by entering the command 'JDBG' in the Okcode field. The program acts as though it has been called in the back ground even though it is actually running in the foreground. This is not a simulation - everything happens including any updates!