home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / packs / itweak / demo.cmd < prev    next >
OS/2 REXX Batch file  |  2000-07-29  |  4KB  |  132 lines

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