Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

XENIX Programming adb: Program Debugger Breakpoints are typically set to stop program execution at a specific place in the program, such as the beginning of a function, so that the contents of registers and memory can be examined. For example, the command main:br sets a breakpoint at the start of the function main. The breakpoint is taken just as control enters the function and before the function's stack frame is created. A breakpoint with a count is typically used within a function that is called several times during execution of a program, or within the instructions that correspond to a for or while statement. Such a breakpoint allows the program to cont inue to execute until the given function or instructions have been executed the specified number of times. For example, the command light,S:br sets a breakpoint at the fifth invocation of the function light. The breakpoint does not stop the program until function light has been called five times. Note that no more than 16 breakpoints at a time are allowed. Displaying Breakpoints The command $b displays the location and count of each currently defined breakpoint. Breakpoints are listed by address, along with any count and/or command associated with them. Continuing Execution You can continue the execution of a program after it has been stopped by a breakpoint by using the :co command. The command has the form [ address 1 [,count] :co [signal] where address is the address of the instruction at which you wish to continue execution, count is the number of breakpoints you wish to ignore, and signal is the number of the signal to send to the program (see signal in "System Functions" in the XENIX 286 C Library Guide). If no address is given, the program starts at the next instruction after the breakpoint. If count is given, adb ignores the first count breakpoints. 6-15

adb: Program Debugger XENIX Programming Stopping a Program with Interrupt and Quit You can stop execution of a program at any time by pressing the INTERRUPT or QUIT keys. These keys stop the current program and return control to adb. These keys are especially useful for programs with infinite loops or other program errors. Note that whenever you press the INTERRUPT or QUIT key to stop a program, adb automatically saves the signal and passes it to the program if you start it again by using the :co command. This is very useful if you wish to test a program that uses these signals as part of its processing. If you wish to continue execution of the program but do not wish to send the signals, type :co 0 The command argument 0 prevents a pending signal from being sent to the program. Single-Stepping a Program You can single-step a program, i.e., execute it one instruction at a time, by using the :s command. The command executes an instruction and returns control to adb. The command has the form [ address ] [, count ] :s where address is the address of the instruction you wish to execute, and count is the number of times you wish to repeat the command. If no address is given, adb uses the current address. If count is given, adb continues to execute each successive instruction until count instructions have been executed. For example, the com mand main,S:s executes the first five instructions in the function main. Killing a Program You can kill the program you are debugging by using the :k command. The com mand kills the process created for the program and returns control to adb. The command is typically used to clear the current contents of the CPU registers and stack and begin the program again. 6-16

<strong>XENIX</strong> Programming adb: Program Debugger<br />

Breakpoints are typically set to stop program execution at a specific place in the<br />

program, such as the beginning of a function, so that the contents of registers and<br />

memory can be examined. For example, the command<br />

main:br<br />

sets a breakpoint at the start of the function main. The breakpoint is taken just as<br />

control enters the function and before the function's stack frame is created.<br />

A breakpoint with a count is typically used within a function that is called several times<br />

during execution of a program, or within the instructions that correspond to a for or<br />

while statement. Such a breakpoint allows the program to cont inue to execute until the<br />

given function or instructions have been executed the specified number of times. For<br />

example, the command<br />

light,S:br<br />

sets a breakpoint at the fifth invocation of the function light. The breakpoint does not<br />

stop the program until function light has been called five times.<br />

Note that no more than 16 breakpoints at a time are allowed.<br />

Displaying Breakpoints<br />

The command $b displays the location and count of each currently defined breakpoint.<br />

Breakpoints are listed by address, along with any count and/or command associated with<br />

them.<br />

Continuing Execution<br />

You can continue the execution of a program after it has been stopped by a breakpoint<br />

by using the :co command. The command has the form<br />

[ address 1 [,count] :co [signal]<br />

where address is the address of the instruction at which you wish to continue execution,<br />

count is the number of breakpoints you wish to ignore, and signal is the number of the<br />

signal to send to the program (see signal in "System Functions" in the <strong>XENIX</strong> <strong>2<strong>86</strong></strong> C<br />

Library <strong>Guide</strong>).<br />

If no address is given, the program starts at the next instruction after the breakpoint. If<br />

count is given, adb ignores the first count breakpoints.<br />

6-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!