1 # $NetBSD: stack,v 1.2 2000/06/08 14:42:11 jhawk Exp $
3 # Copyright (c) 2000 The NetBSD Foundation, Inc.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by John A. Hawkinson.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
31 # Follow an i386 kernel stack trace.
32 # This code makes presumptions about the way frames look, consistent
33 # with arch/i386/i386/db_trace.c. It also steals algorithms from there.
37 # 0xc03049cb <cpu_reboot+99>(0x100,0x0,0xc04fd728,0x0,0x6)
38 # at 0xc01bc97d <panic+197> (frame at 0xc5633bd0)
40 # In this case, the initial hex number and offset should be disregarded,
41 # and it should be interprted as if it were:
43 # cpu_reboot(0x100,0x0,0xc04fd728,0x0,0x6)
44 # at 0xc01bc97d <panic+197> (frame at 0xc5633bd0)
46 # due to limitations of gdb scripting.
53 set $callpc = $retaddr
54 set $retaddr = *(long*)($frame+sizeof(long*))
56 set $inst=*(long*)$retaddr
57 if (($inst & 0xff) == 0x59)
60 else if (($inst & 0xffff) == 0xc483)
62 set $narg = (($inst >> 16) & 0xff) / 4
67 set $argp = $frame+sizeof(long*)+sizeof(int)
72 printf "0x%lx", *(long*)$argp
73 set $argp = $argp+sizeof(long*)
81 printf " (frame at %#x)\n", $frame
83 set $frame=*(long*)$frame
88 ==> (gdb) stacktrace FP IP
89 print a backtrace of all stack frames, starting at frame pointer FP,
90 and instruction pointer IP.
99 Print a backtrace of all strack frames, starting at the current $ebp