home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!know!cass.ma02.bull.com!think.com!ames!agate!doc.ic.ac.uk!uknet!news.cs.bham.ac.uk!lpb
- From: lpb@cs.bham.ac.uk (Luc Beaudoin)
- Newsgroups: comp.lang.pop
- Subject: A tip: using exitto while debugging
- Keywords: help * control
- Message-ID: <By4ppB.BDu@cs.bham.ac.uk>
- Date: 22 Nov 92 17:53:34 GMT
- Sender: news@cs.bham.ac.uk
- Organization: School of Computer Science, University of Birmingham, UK
- Lines: 66
- Nntp-Posting-Host: emotsun
-
- The following probably occurred to most of you, but in case it's useful
- to someone, I'm mentioning it.
-
- It is sometimes very convenient within the context of a procedure held
- in the variable * INTERRUPT , such as debugger_interrupt (cf HELP *
- DEBUGGER) to (eventually) EXITTO a calling procedure rather than let
- the call to SETPOP take place. This is especially convenient when
- debugging a program which takes time to get into a particular state
- which you're studying. If the call to the interrupt procedure follows a
- MISHAP, it's sometimes useful to fix the cause of the mishap, then to
- exitto a calling procedure.
-
- It's easy to do this kind of thing in the debbuger, which permits you to
- examine the call stack by using the BACKTRACE command. In the following
- example, during the execution of debugger_interrupt, I examined the call
- frame and decided to exitto run.
-
- debug(1): backtrace
- > [ 1] debugger_interrupt
- [ 2] mishap
- [ 3] nmMonitorSched(sched:NmSchedule) (line 625)
- [ 4] nmRun(nm:NmNursemaid) (line 1043)
- [ 5] nursemaid_interface (line 2454)
- [ 6] run (line 278)
- [14] compile
- [19] runproc
- [27] runproc
- [37] compile
- [39] setpop
- debug(1): :exitto(run);
-
- (The debugger as it stands only allows you to return from the current
- procedure, not an arbitrary procedure.)
-
- If you're not using the debugger, you could assign a procedure like the
- following to interrupt.
-
- define myinterrupt();
- /* exitto a procedure in syscallers, or just exit */
- lvars callers = syscallers();
- define valid_index(i);
- i.isinteger and i>0 and i <= callers.length
- enddefine;
-
- vars i;
- for i from 1 to
- callers.length do
- [[^i]% callers(i)%]=>
- endfor;
- getline('Input index to exitto')-> i;
- if i matches [?i:valid_index] then
- exitto(callers(i))
- else
- [Wrong input!]=>
- endif;
- enddefine;
-
- Of course, this kind of thing doesn't always make sense, e.g., if
- results are expected on the stack.
-
- Luc
- --
- -------------------------------------- -----------------------------------
- Luc Beaudoin | School of Computer Science
- E-mail: lpb@cs.bham.ac.uk | University of Birmingham
- voice: +44 (21) 414-4766 or 3743 | Birmingham B15 2TT, UK
-