| 1 |
# Annotated debugging commands for the demo debugging session. |
| 2 |
# |
| 3 |
# After seeing the 'automatic' debugging session you may want to repeat |
| 4 |
# some of the commands manually in a new interactive session. |
| 5 |
|
| 6 |
# |
| 7 |
# The following commands use a liberal amount of 'fprint' to make the output |
| 8 |
# more readable. |
| 9 |
# The first few commands are spelled out fully. Then we start using |
| 10 |
# abbreviations. |
| 11 |
# |
| 12 |
|
| 13 |
# When you get the first prompt you are somewhere in anonymous initialization |
| 14 |
# code. Enter 'next' to step into a real source file. This is not necessary, |
| 15 |
# but may allow you to omit the file name in 'breakpoint' commands. |
| 16 |
next |
| 17 |
|
| 18 |
# What source files do we have? |
| 19 |
info files |
| 20 |
|
| 21 |
# Let's find out what globals the program contains... |
| 22 |
fprint "--- Globals:\n" |
| 23 |
info global |
| 24 |
|
| 25 |
# ...and the locals of the current procedure: |
| 26 |
fprint "--- Locals in %1:\n"; &proc |
| 27 |
info locals |
| 28 |
|
| 29 |
# Set a breakpoint in the main loop. |
| 30 |
break 88 |
| 31 |
goon |
| 32 |
|
| 33 |
# Got the first break. |
| 34 |
print word |
| 35 |
goon |
| 36 |
|
| 37 |
# Next break. |
| 38 |
pr word |
| 39 |
|
| 40 |
# Boring to 'print word' every time. Add this command to the |
| 41 |
# breakpoint. Note that when a breakpoint has commands the usual |
| 42 |
# prelude is not printed when a breakpoint is reached. Thus add some |
| 43 |
# extra printing. Note that 'fprint' does not automatically output a |
| 44 |
# newline. |
| 45 |
do . |
| 46 |
fprint "--- Break in %1 line %2: "; &proc; &line |
| 47 |
print word |
| 48 |
end |
| 49 |
|
| 50 |
go |
| 51 |
go |
| 52 |
go |
| 53 |
|
| 54 |
# Attach a condition to the breakpoint. This time we use the explicit |
| 55 |
# breakpoint id (1). |
| 56 |
cond 1 word == "buffer" |
| 57 |
go |
| 58 |
|
| 59 |
# Let's examine a compound variable. |
| 60 |
fprint "--- Examining 'resword'.\n" |
| 61 |
pr resword |
| 62 |
# It's a list. Try 'eprint' to see all elements. |
| 63 |
eprint !resword |
| 64 |
# 'eprint' prints 'every' value generated by an expression. |
| 65 |
|
| 66 |
# Try another one. |
| 67 |
pr prec |
| 68 |
# A list again. Prints its elements, |
| 69 |
epr !prec |
| 70 |
# Only one element which is a record. |
| 71 |
pr prec[1].pname |
| 72 |
epr !prec[1] |
| 73 |
|
| 74 |
# We may even invoke one of the target program's procedures. |
| 75 |
# Here we invoke 'addword' to add a bogus entry in the cross reference. |
| 76 |
# We use global 'linenum' to provide the line number. |
| 77 |
pr addword("ZORRO", "nowhere", linenum) |
| 78 |
|
| 79 |
# Examine globals again. |
| 80 |
fprint "--- Globals one more time:\n" |
| 81 |
inf gl |
| 82 |
fprint "--- WHAT??!!! The program has modified 'proc' -- bad manners!\n" |
| 83 |
# It's good to have a robust debugger. Let's examine the new value. |
| 84 |
pr proc; type(proc) |
| 85 |
|
| 86 |
# Examine the current breakpoint. |
| 87 |
fprint "--- The current breakpoint:\n" |
| 88 |
info br . |
| 89 |
|
| 90 |
# Let's set a breakpoint i procedure 'addword'... |
| 91 |
br 150 |
| 92 |
# ...and delete the first breakpoint. |
| 93 |
clear br 1 |
| 94 |
go |
| 95 |
|
| 96 |
# This is the way to find out where we are (the procedure call chain): |
| 97 |
where |
| 98 |
# It is possible to examine any of the frames in the call chain. |
| 99 |
frame 1 |
| 100 |
|
| 101 |
# Let the program work along for a while. |
| 102 |
# Ignore the 280 next breaks. |
| 103 |
fprint "--- Ignoring the next 280 breaks...\n" |
| 104 |
ign . 280 |
| 105 |
go |
| 106 |
# Find out about the word "word": |
| 107 |
pr var["word"] |
| 108 |
# It's a table. Examine its keys and entries. |
| 109 |
epr key(var["word"]) |
| 110 |
epr !var["word"] |
| 111 |
# The entries are lists. Let's look at the "addword" entry. |
| 112 |
epr !var["word"]["addword"] |
| 113 |
# That's a lot of typing. Let's try a macro. |
| 114 |
mac var |
| 115 |
eprint !var["word"]["addword"] |
| 116 |
fprint "That was %1 items.\n"; *var["word"]["addword"] |
| 117 |
end |
| 118 |
|
| 119 |
# Try the macro (which has now become a new command): |
| 120 |
var |
| 121 |
|
| 122 |
# Now we've tried the most common commands. |
| 123 |
# Let the program run to completion undisturbed. The following is an |
| 124 |
# abbreviation of 'goon nobreak'. |
| 125 |
fpr "--- Now let the program produce its normal output...\n\n" |
| 126 |
go no |
| 127 |
|
| 128 |
# We will se the normal output of the program: a cross reference listing |
| 129 |
# (in this case applied to its own source code). |
| 130 |
# Note the bogus 'ZORRO' variable we entered by calling 'addword'. |