1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)wheredump.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 /*
13  * Print a list of currently active blocks starting with most recent.
14  */
15 
16 #include "defs.h"
17 #include "runtime.h"
18 #include "frame.rep"
19 #include "sym.h"
20 #include "machine.h"
21 #include "object.h"
22 #include "mappings.h"
23 
24 where()
25 {
26     FRAME *frp;
27     ADDRESS prevpc;
28     LINENO line;
29     SYM *f;
30 
31     if (pc == 0) {
32 	error("program is not active");
33     }
34     prevpc = pc;
35     for (frp = curframe(); frp != NIL; frp = nextframe(frp)) {
36 	f = whatblock(entry(frp));
37 	line = srcline(prevpc);
38 	printf("%s", name(f));
39 	printparams(f, frp);
40 	printf(", ");
41 	printwhere(line, srcfilename(prevpc));
42 	printf("\n");
43 	prevpc = frp->save_pc;
44     }
45     line = srcline(prevpc);
46     printf("%s, ", name(program));
47     printwhere(line, srcfilename(prevpc));
48     printf("\n");
49 }
50 
51 /*
52  * Dump the world to the given file.
53  * Like "where", but variables are dumped also.
54  */
55 
56 dump()
57 {
58     FRAME *frp;
59     ADDRESS prevpc;
60     LINENO line;
61     SYM *f;
62 
63     if (pc == 0) {
64 	error("program is not active");
65     }
66     prevpc = pc;
67     for (frp = curframe(); frp != NIL; frp = nextframe(frp)) {
68 	f = whatblock(entry(frp));
69 	line = srcline(prevpc);
70 	printf("%s", name(f));
71 	printparams(f, frp);
72 	printf(", ");
73 	printwhere(line, srcfilename(prevpc));
74 	printf("\n");
75 	dumpvars(f, frp);
76 	putchar('\n');
77 	prevpc = frp->save_pc;
78     }
79     line = srcline(prevpc);
80     printf("%s, ", name(program));
81     printwhere(line, srcfilename(prevpc));
82     printf("\n");
83     dumpvars(program, NIL);
84 }
85