Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: ctrace9.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)ctrace9.fth 1.5 04/04/15 19:10:03 | |
43 | purpose: | |
44 | copyright: Copyright 1990-2004 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | \ Copyright 1985-1990 Bradley Forthware | |
47 | ||
48 | \ After a crash, displays a backtrace of C stack frames. | |
49 | \ This assumes the stack format used by the Sun SPARC C compiler. | |
50 | ||
51 | only forth also hidden also forth definitions | |
52 | ||
53 | headers | |
54 | defer .subname ( adr -- ) | |
55 | headerless | |
56 | ' .x is .subname | |
57 | ||
58 | : >reg ( reg# -- addr ) | |
59 | dup 3 >> case | |
60 | 0 of addr %g0 size-of %g0 endof | |
61 | 1 of addr %o0 size-of %o0 endof | |
62 | 2 of addr %l0 size-of %l0 endof | |
63 | 3 of addr %i0 size-of %i0 endof | |
64 | endcase ( reg# base size ) | |
65 | rot h# 7 and ( base size reg# ) | |
66 | over * ( base size offset ) | |
67 | swap /l = if | |
68 | + l@ | |
69 | else | |
70 | + dup 1 and if V9_SP_BIAS + then x@ | |
71 | then | |
72 | ; | |
73 | : >ea ( instruction -- address ) | |
74 | dup h# 1000 and if ( instruction ) \ Immediate | |
75 | dup d# 20 << d# 12 >>a ( instruction immediate ) | |
76 | else | |
77 | dup h# 1f and >reg ( instruction regval ) | |
78 | then | |
79 | swap d# 14 >> h# 1f and >reg + ( target-address ) | |
80 | ; | |
81 | : decode-jmpl ( instruction -- false | target true ) | |
82 | dup h# 81f80000 and h# 81c00000 = if >ea true else drop false then | |
83 | ; | |
84 | headers | |
85 | : .subroutine ( return-adr -- ) \ Show subroutine address | |
86 | dup pointer-bad? over 0= or if drop ." XXXXXXX " exit then ( return-adr ) | |
87 | dup l@ h# c000.0000 and h# 4000.0000 = if \ call instruction ? | |
88 | ." call " dup l@ h# 3fff.ffff and 2 << l->n + .subname | |
89 | else | |
90 | \ XXX decode the address specification from the jmpl | |
91 | \ if that address spec references OUT's or GLOBAL's, we can't | |
92 | \ be sure that it is correct. The next window context contains | |
93 | \ the relevant registers. | |
94 | l@ decode-jmpl if | |
95 | ." jmpl " .subname \ indirect call (jmpl) | |
96 | else | |
97 | ." ???? " | |
98 | then | |
99 | then | |
100 | ; | |
101 | headerless | |
102 | : .2x ( n -- ) push-hex 2 u.r pop-base ; | |
103 | : .c-call ( -- exit? ) | |
104 | %o7 .subroutine ." from " %o7 .subname cr | |
105 | ." " window# .2x ." w %o0-%o7: (" | |
106 | %o0 .x %o1 .x %o2 .x %o3 .x %o4 .x %o5 .x %o6 .x %o7 .x | |
107 | ." )" cr | |
108 | cr exit? | |
109 | ; | |
110 | ||
111 | headers | |
112 | : ctrace ( -- ) \ C stack backtrace | |
113 | state-valid @ 0= if ." No saved state" exit then | |
114 | ." PC: " %pc .subname cr | |
115 | ." Last leaf: " | |
116 | ||
117 | window# ( previous-window# ) | |
118 | 0w begin .c-call (+w) or until ( previous-window# ) | |
119 | set-window | |
120 | ; |