1 Medley for the Novice, Release 2.0 1 Medley for the Novice, Release 2.0 10. BREAKPACKAGE 1 10. BREAKPACKAGE 1 "10"10. BREAKPACKAGE 6 The Break Package(BREAK% PACKAGE NIL Break% Package NIL NIL 1) is a part of Interlisp that makes debugging your programs much easier. Break Windows(WINDOWS NIL Windows NIL NIL 1 SUBNAME BREAK SUBTEXT break) 1 A break is a function either called by the programmer or by the system when an error has occurred. A separate window opens for each break. This window works much like the Executive Window, except for extra menus unique to a break window. Inside a break window, you can examine variables, look at the call stack at the time of the break, or call the editor. Each successive break opens a new window, where you can execute functions without disturbing the original system stack. These windows disappear when you resolve the break and return to a higher level. Break Package(BREAK% PACKAGE NIL Break% Package NIL NIL 1 SUBNAME EXAMPLE SUBTEXT example) Example 1 This example illustrates the basic break package functions. A more complete explanation of the breaking functions, and the break package will follow. The correct definition of FACTORIAL is: (defun factorial (x) (if (zerop x) 1 (* x (factorial (1- x))))) To demonstrate the break package, we have edited in an error: DUMMY in the IF statement is an unbound atom, it lacks a value. ((defun factorial (x) (if (zerop x) dummy (* x (factorial (1- x))))) The evaluated function (FACTORIAL 4) should return 24, but the above function has an error. DUMMY is an unbound atom, an atom without an assigned value, so Lisp will "break". A break window appears (Figure 10-1), that has all the functionality of the typing lisp expressions into the Executive Window (The top level), in addition to the break menu functions. Each consecutive break will move to another level "down". `˜‚00џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}ОРј{эіїп|}№;јџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}žпwЛьіїїп}ї}їлћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}ЎпoлэvћћОНїzїлћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}ЖРялэЖћћОНїz№;јџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}ЖпoлэЖћ§}мwwлћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}Кпoлэжћ=|їpwлћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр}МпwЛэцїўћэїoЗлћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрƒОРј|іўћэїoА8џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр````pШ„ ` Š `!`Š `!… `! `! `! `qТ>``````ё$H€ Р`‰fШ€ @`‰fХ8тР–,8‰a Ž,8q`C€`‰ЅED ™2D‰’`2 D@`‰ЅB0ђ ‘"D‰  yGР`‰ЅB ‘"D‰  ‰D`‰ЅBD ‘2D™` ‰DB`№т$B8ђ ‘,8i  y`C‚`````````````````````pG!€ `ˆHЂGтG`0‰$’I` œ‰<’I`‰ ‰ ’Щ`r>‡уG`@ `  ````````````````````````````````````````````````````џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџрџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџр Figure 10-1. Break Window Move the mouse cursor into the break window and hold down the middle mouse button. The Break Menu will appear. Choose BT. Another menu, called the stack menu, will appear beside the break window. Choosing stack items from this menu will display another window. This window displays the function's local variable bindings, or values (see Figure 10-2). This new window, titled FACTORlAL Frame, is an inspector window (see inspector Chapter 17). `бёџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№Рћјp<}їџРџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№пћїОћнї}їџпџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№пѕяўїэїzїџпг3Чџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№СѕяўїэїzїџСЪьЭЛџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№пюяўїьwwџппнƒџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№пряўїэїpwџпоmнПџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№ппwОћнїoЗџпоэнЛџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№ппx~ќ=їoА?ппнЧџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№0000| уу@0@Q„H„@0@Q„H„@0xQ„O@0@‰„J"@0@љ„I>@0@‰„H„"@0@ˆрƒˆŽ"|00000080D0 L0T0T0 d0D08000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџР0пoА>ћ}ƒ§їпп|ўџџџџџџџџџџџџџџџџџџџџџџџР0пgЗнюћ=Н§їп}п}іўџџџџџџџџџџџџџџџџџџџџџџџџФ ’G!(q$0пkЗліћ]ОўяЏ}оНіўџџџџџџџџџџџџџџџџџџџџџџџџФ „’T!(A@$0пmА;іћmОўяЏ}оМўџџџџџџџџџџџџџџџџџџџџџџџУ<„’#!Ш0€t0пmЗліћmОџ_wнніўџџџџџџџџџџџџџџџџџџџџџџџџР0пnЗліћuОЯ_}міўџџџџџџџџџџџџџџџџџџџџџџџџР0пo7нюћyНџОћ}лэіўџџџџџџџџџџџџџџџџџџџџџџџџР€ @0ряА>}ƒџОћ}льџџџџџџџџџџџџџџџџџџџџџџџСроу8 ”c 0џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџТ P”Є –ї0џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџТ ”Є—џ0џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџТ Р!œфИ•j 0Т !Є •j@0Т "”  ”b@!0"DЉP€Dˆ$H‘"DˆDH"DСо“ db@! 0"DЉP€DˆdL‘&D˜„H"d€Р€ @0<8‰€<ˆЄKDhƒШXр€Р0Т"""""""""""""""0ЧˆЯГŽ$0ЬЊЪЬмˆˆˆˆˆˆˆˆˆˆ0ФJDT0Ч7"kІv""""""""""0Ф?J„ќ0ЬЋЊЪЬŒˆˆˆˆˆˆˆˆˆˆ0Ф"Т2N€0Т"""""""""""""""0Р0Р€0СЮ8ˆ@0 #Х"I$’BТ T‰)P„ 0B)"O$’BТ*T )PФ 0"B/ЂH$ВBТT .P„ 0С!Ч8бТТ*ќ *№Ф 0DТ Œ‰)0„ 0ˆС ‹Щ:>ˆ@0Р€@€0Р0Р0У €wˆ0Ф @$0Ф „œу9Ю3€$0Ф „’DЅ)I'0Ф ’G!(q$0Ф „’T!(A@$0У<„’#!Ш0€t0Р0Р0Р€ @0Сроу8 ”c 0Т P”Є –ї0Т ”Є—џ0Т Р!œфИ•j 0Т !Є •j@0Т "”  ”b@!0Со“ db@! 0Р€ @0Р0Р0ЧˆЯГŽ$0Ф"JDT0ФJDT0ЧK„T0Ф?J„ќ0Ф#"JDŒ0Ф"Т2N€0Р0Р0Р€0СЮ8ˆ@0Т T‰)P„ 0Т*T )PФ 0ТT .P„ 0Т*ќ *№Ф 0Т Œ‰)0„ 0Р0Р0џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№ Figure 10-2. Back Trace of the System Stack From the break window, you can call the editor for the function FACTORIAL by middle-buttoning on the word FACTORIAL and selecting DisplayEdit from the menu that pops up. Replace the unbound atom DUMMY with 1. Exit the editor . The function is fixed, and you can restart it from the last call on the stack. (It does not have to be started again from the Top Level.) To begin again from the last call on the stack, choose the last (top) FACTORIAL call in the BT menu. Select REVERT from the middle button break window, or type it into the window. The break window will close, and a new one will appear with the message: Breakpoint at FACTORIAL To start execution with this last call to FACTORIAL, choose OK from the middle button break menu. The break window will disappear, and the correct answer, 24, will be returned to the top level. Ways to Stop Execution from the Keyboard (Breaking Lisp) 1 There are ways you can stop execution from the keyboard. They differ in terms of how much of the current operating state is saved: Control-G(CONTROL-G NIL Control-G NIL NIL 3) Provides you with a menu of processes to interrupt. Your process will usually be "EXEC". Choose it to break your process. A break window will then appear. Control-B(CONTROL-B NIL Control-B NIL NIL 3) Causes your function to break, saves the stack, then displays a break window with all the usual break functions. For information on other interrupt characcers, see Chapter 30 in the IRM. Break Menu(BREAK% MENU NIL Break% Menu NIL NIL 3) 1 Move the mouse cursor into the break window. Hold the middle button down, and a new menu will pop up, like the one in Figure 10-3. `Pzџџџџџџџџ№?A A ‚„?‚„ D Ф $?‚'р?Ÿў „ D?D D D „?Ÿ?Ш'ѓёќ $  D  Ÿ„Gт ?„№  „    ŸСђ *>?уљќј! ˆB„! $‚! $ёј‚>?$‚ $‚ ˆB„ ‡уљќј@ˆ€ I J M H€ˆ@ ?Р ‚ ‚? ‚ ‚ ‚??Ш ‚ ‚? ‚ ‚ ‚?$$?€?€џџџџџџџџ№ Figure 10-3. Middle Button Menu in Break window Five of the selections are particularly important when just starting to use Medley: BT Back Trace displays the stack in a menu beside the break window. Back Trace is a very powerful debugging tool. Each function call is placed on the stack and removed when the execution of that function is complete. Choosing an item on the stack will open another window displaying that item's local variables and their bindings. This is an inspector window that offers all the power of the inspector. (For details, see the section on the Inspector, Chapter 17.) ? = Before you use this menu option, display the stack by choosing BT from this menu, and choose a function from it. Now, choose ?=. It will display the current values of the arguments to the function that has been chosen from the stack. ­ Move back to the previous break window, or if there is no other break window, back to the top level, the Executive Window. REVERT Move the point of execution back to a specified function call before the error. The function to revert back to is, by default, the last function call before the break. If, however, a different function call is chosen on the BT menu, revert will go back to the start of this function and open a new break window. The items on the stack above the new starting place will no longer exist. This is used in the tutorial example (see the Break Package Example section above). OK Continue execution from the point of the break. This is useful if you have a simple error, i.e., an unbound variable or a nonnumeric argument to an arithmetic function. Reset the variable in the break window, then select OK. (see the Break Package Example section above). In addition to being available on the middle button menu of the break window, all of these functions can be typed directly into the window. Only BT behaves differently when typed. It types the stack into the trace window instead of opening a new window.) Returning to Top Level 1 Typing Control-D will immediately take you to the top level from any break window. The functions called before the break will stop, but any side effects of the function that occurred before the break remain. For example, if a function set a global variable before it broke, the variable will still be set after typing Control-D(CONTROL-D NIL Control-D NIL NIL 4).(LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "10-" "") STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "10-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (TEXT NIL NIL (54 54 504 690) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "10-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD LEFT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "10-" "")) (54 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGV) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE VERSOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "10-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "10-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE RECTOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL))))).рTT2Hxрx,llр,llр 2Hр ,HHр,HHр,HHр -рT-рT,HHр,2рр5рЬрFјј PAGEHEADING VERSOHEADFјј PAGEHEADING RECTOHEADEјј PAGEHEADINGFOOTINGVEјј PAGEHEADINGFOOTINGR, ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) CLASSIC TITAN TITAN CLASSIC HELVETICAMODERN HELVETICACLASSIC  HELVETICA MODERN  TIMESROMAN  HRULE.GETFNMODERN  "   HRULE.GETFNCLASSIC  #    HRULE.GETFNCLASSIC      HRULE.GETFNCLASSIC    IM.CHAP.GETFN HELVETICA  HRULE.GETFNMODERN    -IM.INDEX.GETFNG   ;IM.INDEX.GETFN  HRULE.GETFNCLASSIC .  MIM.INDEX.GETFN   HRULE.GETFNCLASSIC –    $ > ;  #    7 @  t BMOBJ.GETFN3CLASSIC    Л  8ˆ BMOBJ.GETFN3CLASSIC  ,  @  [    а  ‹  *  9  HRULE.GETFNCLASSIC  ƒ   #IM.INDEX.GETFNT E  #IM.INDEX.GETFNИ    'IM.INDEX.GETFN  HRULE.GETFNCLASSIC ƒ  а BMOBJ.GETFN3?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))  1 T Я ы ~ и  џ    HRULE.GETFNCLASSIC G #IM.INDEX.GETFN qбzК