1 |
|
(in-package 'si) |
2 |
|
|
3 |
|
;; (load "gprof.o") |
4 |
|
;; You must have a kcl image with profiling information and monstartup |
5 |
|
;; typically saved_kcp. NOTE: if monstartup calls sbrk (true in |
6 |
|
;; most 4.3bsd's except sun >= OS 4.0) you must be very careful to |
7 |
|
;; allocate all the space you will use prior to calling monstartup. |
8 |
|
;; If subsequent storage allocation causes the hole to move you will |
9 |
|
;; most certainly lose. See below for instructions |
10 |
|
;; on how to construct saved_kcp. |
11 |
|
|
12 |
|
;; If you want function invocation counts to be kept do |
13 |
|
;; (setq compiler::*cc* (concatentate 'string compiler::*cc* " -pg ")) |
14 |
|
;; before compiling the relevant files. (This is done when you load |
15 |
|
;; lsp/gprof.o) |
16 |
|
|
17 |
|
;; In the image saved_kcp Load in your files. Load in gprof.o: (load |
18 |
|
;; "lsp/gprof.o") Invoke monstartup once to setup buffers: (monstartup |
19 |
|
;; lowpc highpc) eg. (monstartup #x800 3000000) [highpc should be a bit |
20 |
|
;; bigger than the highest address you have seen when loading your files] |
21 |
|
;; Use moncontrol to toggle profiling on and off: (moncontrol 0) to turn |
22 |
|
;; profiling off, and (moncontrol 1) to turn it on. Use |
23 |
|
;; (wrtie-gmons+syms) to terminate with writing a gmon.out and syms.out |
24 |
|
;; in the current directory. I know of no way of clearing the buffers, |
25 |
|
;; since secret routines set up the buffers, and we don't know where they |
26 |
|
;; are or how large. Thus all information is cumulative. |
27 |
|
|
28 |
|
;; % gprof syms.out |
29 |
|
;; will display the output (add -b) to make it briefer. |
30 |
|
|
31 |
|
;; A sample session on rascal: |
32 |
|
#| |
33 |
|
/usr2/skcl/unixport/saved_kcp |
34 |
|
GCL (Austin Kyoto Common Lisp) Version(1.147) Sun May 14 15:26:07 CDT 1989 |
35 |
|
Contains Enhancements by W. Schelter |
36 |
|
|
37 |
|
>(load "/tmp/fo") |
38 |
|
Loading /tmp/fo.o |
39 |
|
start address -T 1d04e0 Finished loading /tmp/fo.o |
40 |
|
528 |
41 |
|
|
42 |
|
>(load "/usr2/skcl/lsp/gprof") |
43 |
|
Loading gprof.o |
44 |
|
|
45 |
|
Adding -pg to the *cc* commandstart address -T 1d0800 |
46 |
|
Finished loading gprof.o |
47 |
|
2112 |
48 |
|
|
49 |
|
;; NOTE: If the following calls sbrk [eg 4.3bsd or sun OS3 ] but not Sun OS4, |
50 |
|
;; then you MUST make sure to allocate sufficient memory before doing |
51 |
|
;; monstartup, so that the hole will not have to be moved. |
52 |
|
>(si::monstartup #x800 2000000) |
53 |
|
2584576 |
54 |
|
|
55 |
|
>(si::goo)(si::goo) ;;defined in /tmp/foo.lisp |
56 |
|
NIL |
57 |
|
|
58 |
|
>NIL |
59 |
|
|
60 |
|
>(si::write-gmon+syms) |
61 |
|
writing syms.. |
62 |
|
0 |
63 |
|
[NOTE: The safest way to exit the lisp is to stop it with Ctrl-Z |
64 |
|
and then kill it. We do NOT want to run the exit code which |
65 |
|
normally writes out a monitoring file]. |
66 |
|
|
67 |
|
rascal% gprof -b syms.out |
68 |
|
... |
69 |
|
called/total parents |
70 |
|
index %time self descendents called+self name index |
71 |
|
called/total children |
72 |
|
|
73 |
|
0.00 0.00 1/200 _call_or_link [8] |
74 |
|
0.02 0.02 199/200 GOO [2] |
75 |
|
[1] 49.6 0.02 0.02 200 FOO [1] |
76 |
|
0.02 0.00 200/203 _make_cons [4] |
77 |
|
|
78 |
|
... Interpretation: Foo is called 199 times by (parent) goo and once |
79 |
|
by (parent) call_or_link (the setting up of the fast link). Foo |
80 |
|
itself calls (child) make_cons 200 of the 203 times that make_cons is |
81 |
|
called... Lower down we would see that goo is called twice. |
82 |
|
|
83 |
|
-- /tmp/fo.lisp -- |
84 |
|
(defun foo () (cons nil nil)) |
85 |
|
(defun goo () (sloop::sloop for i below 100 do (foo))) |
86 |
|
-- end of file -- |
87 |
|
|
88 |
|
|# |
89 |
|
|
90 |
|
;; Creating saved_gcp |
91 |
|
;; |
92 |
|
;; cd gcl |
93 |
|
;; make go |
94 |
|
;; (cd unixport ; make gcp-sun) |
95 |
|
;; (cd go ; ln -s ../o/makefile ../o/*.o ../o/*.c ../o/*.d ../o/*.ini .) |
96 |
|
;; remove a few .o files and do |
97 |
|
;; (cd go ; make "CFLAGS = -I../h -I../gcl-tk -pg -g -c") |
98 |
|
|
99 |
|
;; then (cd unixport ; make kcp) |
100 |
|
|
101 |
|
(clines |
102 |
|
#-aix3 "#include \"gprof.hc\"" |
103 |
|
#+aix3 "#include \"aix_gprof.hc\"" |
104 |
|
) |
105 |
|
|
106 |
|
(eval-when (load) |
107 |
|
(progn (setq compiler::*cc* (CONCATENATE 'string compiler::*cc* " -pg ")) |
108 |
|
(format t "~% Adding -pg to the *cc* command")) |
109 |
|
) |
110 |
|
(defun write-gmon+syms() |
111 |
|
(monitor2 0 0 0 0) |
112 |
|
(princ "writing syms..") |
113 |
|
(set-up-combined) |
114 |
|
(write_outsyms) |
115 |
|
) |
116 |
|
|
117 |
|
|
118 |
|
(defentry monstartup (int int) (int "mymonstartup")) |
119 |
|
|
120 |
|
(defentry monitor2 (int int int int) (int "mymonitor")) |
121 |
|
|
122 |
|
(defentry moncontrol (int) (int "moncontrol")) |
123 |
|
|
124 |
|
(defentry write_outsyms () (int "write_outsyms")) |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|