home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pop / 87 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  2.6 KB

  1. Path: sparky!uunet!know!cass.ma02.bull.com!think.com!ames!agate!doc.ic.ac.uk!uknet!news.cs.bham.ac.uk!lpb
  2. From: lpb@cs.bham.ac.uk (Luc Beaudoin)
  3. Newsgroups: comp.lang.pop
  4. Subject: A tip: using exitto while debugging
  5. Keywords: help * control
  6. Message-ID: <By4ppB.BDu@cs.bham.ac.uk>
  7. Date: 22 Nov 92 17:53:34 GMT
  8. Sender: news@cs.bham.ac.uk
  9. Organization: School of Computer Science, University of Birmingham, UK
  10. Lines: 66
  11. Nntp-Posting-Host: emotsun
  12.  
  13. The following probably occurred to most of you, but in case it's useful
  14. to someone, I'm mentioning it.
  15.  
  16. It is sometimes very convenient within the context of a procedure held
  17. in the variable * INTERRUPT , such as debugger_interrupt (cf HELP *
  18. DEBUGGER) to (eventually) EXITTO a calling procedure rather than let
  19. the call to SETPOP take place. This is especially convenient when
  20. debugging a program which takes time to get into a particular state
  21. which you're studying. If the call to the interrupt procedure follows a
  22. MISHAP, it's sometimes useful to fix the cause of the mishap, then to
  23. exitto a calling procedure.
  24.  
  25. It's easy to do this kind of thing in the debbuger, which permits you to
  26. examine the call stack by using the BACKTRACE command. In the following
  27. example, during the execution of debugger_interrupt, I examined the call
  28. frame and decided to exitto run.
  29.  
  30. debug(1): backtrace
  31. > [ 1] debugger_interrupt
  32.   [ 2] mishap
  33.   [ 3] nmMonitorSched(sched:NmSchedule)  (line 625)
  34.   [ 4] nmRun(nm:NmNursemaid)  (line 1043)
  35.   [ 5] nursemaid_interface  (line 2454)
  36.   [ 6] run  (line 278)
  37.   [14] compile
  38.   [19] runproc
  39.   [27] runproc
  40.   [37] compile
  41.   [39] setpop
  42. debug(1): :exitto(run);
  43.  
  44. (The  debugger as it stands only allows you to return from the current
  45. procedure, not an arbitrary procedure.)
  46.  
  47. If you're not using the debugger, you could assign a procedure like the
  48. following to interrupt.
  49.  
  50. define myinterrupt();
  51. /*  exitto a procedure in syscallers, or just exit */
  52.     lvars callers = syscallers();
  53.     define valid_index(i);
  54.         i.isinteger and i>0 and i <= callers.length
  55.     enddefine;
  56.  
  57.     vars i;
  58.     for i from 1 to
  59.         callers.length do
  60.         [[^i]% callers(i)%]=>
  61.     endfor;
  62.     getline('Input index to exitto')-> i;
  63.     if i matches [?i:valid_index] then
  64.         exitto(callers(i))
  65.     else
  66.         [Wrong input!]=>
  67.     endif;
  68. enddefine;
  69.  
  70. Of course, this kind of thing doesn't always make sense, e.g., if
  71. results are expected on the stack.
  72.  
  73. Luc
  74. -- 
  75. -------------------------------------- -----------------------------------
  76. Luc Beaudoin                          |  School of Computer Science
  77. E-mail: lpb@cs.bham.ac.uk             |  University of Birmingham
  78. voice:  +44 (21) 414-4766 or 3743     |  Birmingham B15 2TT, UK
  79.