|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
2 "http://www.w3.org/TR/html4/loose.dtd"> |
|
3 <html><head> |
|
4 <title>Finding the Stack</title> |
|
5 <link href="sysdoc-eclipse.css" type="text/css" rel="stylesheet" > |
|
6 <link href="sysdoc-eclipse.css" type="text/css" rel="stylesheet" > |
|
7 <link href="../../book.css" type="text/css" rel="stylesheet" > |
|
8 <div class="Head2"> |
|
9 <h2>Finding the Stack</h2> |
|
10 </div><div> |
|
11 <p>To trace back through a thread’s kernel or user stack, you first |
|
12 need to find the stack pointer value. On the ARM, R13 always |
|
13 points to the stack, but there are different R13 registers for |
|
14 each processor mode:</p> |
|
15 <ul> |
|
16 <li><p>In thread context:</p> |
|
17 <ul> |
|
18 <li> |
|
19 <p>R13usr points to the thread’s user |
|
20 stack,</p> |
|
21 </li> |
|
22 <li> |
|
23 <p>R13svc points to the thread’s kernel |
|
24 stack.</p> |
|
25 </li> |
|
26 </ul> |
|
27 </li> |
|
28 <li> |
|
29 <p>When handling interrupts, dedicated stacks are used:</p> |
|
30 <ul> |
|
31 <li> |
|
32 <p>R13Fiq points to the stack used when |
|
33 processing fast interrupts (FIQ).</p> |
|
34 </li> |
|
35 <li> |
|
36 <p>R13Irq points to the stack used when |
|
37 processing general purpose interrupts (IRQ)</p> |
|
38 </li> |
|
39 </ul> |
|
40 </li> |
|
41 </ul> |
|
42 <p>To find out which stack to inspect, you need to know what mode the |
|
43 CPU was in when the fault occurred. The |
|
44 <a href="CrashDebuggerARMexceptionsProcessorModes.guide.html" title="ARM Exception types, fault status register values, processor modes / ARM processor modes (CPSR register)">processor mode</a> is identified by the five least-significant bits of the CPSR |
|
45 register. To get the value of the CPSR register:</p> |
|
46 <ul> |
|
47 <li> |
|
48 <p>use the <a href="CrashDebugger_cmd_f.guide.html" title="The debug monitor and command syntax / f - display kernel fault information">f</a> command when the |
|
49 debug monitor is triggered by a hardware exception.</p> |
|
50 </li> |
|
51 <li> |
|
52 <p>use the <a href="CrashDebugger_cmd_r.guide.html" title="The debug monitor and command syntax / r - dump register contents">r</a> command when the |
|
53 debug monitor is triggered by a panic.</p> |
|
54 </li> |
|
55 </ul> |
|
56 <p>The following examples show how to find the stack(s):</p> |
|
57 <ul> |
|
58 <li> |
|
59 <p><b><a href="CrashDebuggerCallStack.guide03.html#call01" title="Examining the call stack / Finding the stack / Kernel & user stacks of the current thread after a hardware exception">Kernel & user stacks of the current thread after a hardware exception</a></b></p> |
|
60 </li> |
|
61 <li class="style6"> |
|
62 <p><a href="CrashDebuggerCallStack.guide03.html#call02" title="Examining the call stack / Finding the stack / Kernel & user stacks of the current thread after a panic">Kernel & user stacks of the current thread after a panic</a></p> |
|
63 </li> |
|
64 <li class="style6"> |
|
65 <p><a href="CrashDebuggerCallStack.guide03.html#call03" title="Examining the call stack / Finding the stack / Interrupt stacks">Interrupt stacks</a></p> |
|
66 </li> |
|
67 <li> |
|
68 <p><b><a href="CrashDebuggerCallStack.guide03.html#call04" title="Examining the call stack / Finding the stack / Kernel & user stacks of a non-current thread">Kernel & user stacks of a non-current thread</a></b></p> |
|
69 </li> |
|
70 </ul> |
|
71 </div> |
|
72 <div class="Head3"> |
|
73 <h3><a name="call01"></a>Kernel & user stacks of the current thread after a |
|
74 hardware exception</h3> |
|
75 </div><div> |
|
76 <p>Use the <a href="CrashDebugger_cmd_f.guide.html" title="The debug monitor and command syntax / f - display kernel fault information">f</a> command.</p> |
|
77 <p class="CodeBlock">Fault Category: Exception Fault Reason: 10000000<br>ExcId 00000001 CodeAddr f816c908 DataAddr 80000001 Extra c0007003<br>Exc 1 Cpsr=60000010 FAR=80000001 FSR=c0007003<br> R0=00000000 R1=00000000 R2=30000000 R3=80000001<br> R4=00000001 R5=00403d88 R6=00002000 R7=f816c768<br> R8=00000012 R9=00000040 R10=00000000 R11=00403fa4<br>R12=00403d5c R13=00403d70 R14=f80906f8 R15=f816c908<br>R13Svc=6571e000 R14Svc=f80074bc SpsrSvc=80000010</p> |
|
78 <p>In this example:</p> |
|
79 <ul> |
|
80 <li> |
|
81 <p>the kernel stack is the value of R13Svc, i.e. |
|
82 0x6571e00.</p> |
|
83 </li> |
|
84 <li> |
|
85 <p>the user stack is the value of R13, i.e. |
|
86 0x00403d70.</p> |
|
87 </li> |
|
88 </ul> |
|
89 </div> |
|
90 <div class="Head3"> |
|
91 <h3><a name="call02" id="call02"></a>Kernel & user stacks of the current thread after a |
|
92 panic</h3> |
|
93 </div><div> |
|
94 <p>Use the <a href="CrashDebugger_cmd_r.guide.html" title="The debug monitor and command syntax / r - dump register contents">r</a> command.</p> |
|
95 <p class="CodeBlock">MODE_USR:<br> R0=6571de54 R1=0000002a R2=00000002 R3=ffffffff<br> R4=0000002a R5=f8170414 R6=6571df14 R7=6403cc50<br> R8=00000001 R9=6403c44c R10=640002f8 R11=6571de70<br>R12=00000020 R13=00404e00 R14=f80818c0 R15=f800bfa8<br>CPSR=60000013<br>MODE_FIQ:<br> R8=00000000 R9=ffffffff R10=ffffffff R11=00000000<br>R12=00000000 R13=64000d0c R14=c080079c SPSR=e00000dc<br>MODE_IRQ:<br>R13=6400110c R14=00000013 SPSR=20000013<br>MODE_SVC:<br>R13=6571de54 R14=f80328bc SPSR=60000010<br>MODE_ABT:<br>R13=6400090c R14=ccbfd0e0 SPSR=b00000d9<br>MODE_UND:<br>R13=6400090c R14=b5a39950 SPSR=f000009d</p> |
|
96 <p>In this example:</p> |
|
97 <ul> |
|
98 <li> |
|
99 <p>the kernel stack is the value of R13 under |
|
100 MODE_SVC:, i.e. 0x6571de54.</p> |
|
101 </li> |
|
102 <li> |
|
103 <p>the user stack is the value of R13 under |
|
104 MODE_USR:, i.e. 0x00404e00.</p> |
|
105 </li> |
|
106 </ul> |
|
107 </div> |
|
108 <div class="Head3"> |
|
109 <h3><a name="call03" id="call03"></a>Interrupt stacks</h3> |
|
110 </div><div> |
|
111 <p>Use the <a href="CrashDebugger_cmd_r.guide.html" title="The debug monitor and command syntax / r - dump register contents">r</a> command.</p> |
|
112 <p class="CodeBlock">MODE_USR:<br> R0=6571de54 R1=0000002a R2=00000002 R3=ffffffff<br> R4=0000002a R5=f8170414 R6=6571df14 R7=6403cc50<br> R8=00000001 R9=6403c44c R10=640002f8 R11=6571de70<br>R12=00000020 R13=00404e00 R14=f80818c0 R15=f800bfa8<br>CPSR=60000013<br>MODE_FIQ:<br> R8=00000000 R9=ffffffff R10=ffffffff R11=00000000<br>R12=00000000 R13=64000d0c R14=c080079c SPSR=e00000dc<br>MODE_IRQ:<br>R13=6400110c R14=00000013 SPSR=20000013<br>MODE_SVC:<br>R13=6571de54 R14=f80328bc SPSR=60000010<br>MODE_ABT:<br>R13=6400090c R14=ccbfd0e0 SPSR=b00000d9<br>MODE_UND:<br>R13=6400090c R14=b5a39950 SPSR=f000009d</p> |
|
113 <p>In this example:</p> |
|
114 <ul> |
|
115 <li> |
|
116 <p>the IRQ stack is the value of R13 under |
|
117 MODE_IRQ:, i.e. 0x6400110c.</p> |
|
118 </li> |
|
119 <li> |
|
120 <p>the FRQ stack is the value of R13 under |
|
121 MODE_FIQ:, i.e. 0x64000d0c.</p> |
|
122 </li> |
|
123 </ul> |
|
124 </div> |
|
125 <div class="Head3"> |
|
126 <h3><a name="call04" id="call04"></a>Kernel & user stacks of a non-current |
|
127 thread</h3> |
|
128 </div><div> |
|
129 <p>Use the output of the |
|
130 <a href="CrashDebugger_cmd_i.guide.html" title="The debug monitor and command syntax / i - display information for the current process and thread">i</a>, |
|
131 <a href="CrashDebugger_cmd_q.guide.html" title="The debug monitor and command syntax / q - display full DObject information">q</a> and |
|
132 <a href="CrashDebugger_cmd_c.guide.html" title="The debug monitor and command syntax / c - display contents of object container">c</a> |
|
133 commands.</p> |
|
134 <p class="CodeBlock">THREAD at 6403c194 VPTR=f8046c18 AccessCount=5 Owner=6403bb4c<br>Full name t_dmasim::Main<br>Thread MState READY<br>Default priority 12 WaitLink Priority 12<br>ExitInfo 3,0,<br>Flags 00000002, Handles 6403b418<br>Supervisor stack base 6571d000 size 1000<br>User stack base 00403000 size 2000<br>Id=25, Alctr=00700000, Created alctr=00700000, Frame=00000000<br>Trap handler=00000000, ActiveScheduler=007000c8, Exception handler=00000000<br>TempObj=00000000 TempAlloc=00000000<br>NThread @ 6403c44c Pri 12 NState READY<br>Next=6403c44c Prev=6403c44c Att=03 iUserContextType=02<br>HeldFM=00000000 WaitFM=00000000 AddrSp=6403bb4c<br>Time=0 Timeslice=20 ReqCount=0<br>SuspendCount=0 CsCount=1 CsFunction=00000000<br>SavedSP=6571df98<br>DACR f800bd2c<br>R13_USR 0d404c38 R14_USR 00000001 SPSR_SVC 00000000<br> R4 f8022d84 R5 6571dfd4 R6 6571dfbc R7 f8022db8<br> R8 f800bddc R9 f800a454 R10 00000000 R11 f801daac<br> PC 60000010</p> |
|
135 <p>In this example:</p> |
|
136 <ul> |
|
137 <li> |
|
138 <p>the kernel stack is the value of SavedSP, i.e. |
|
139 0x6571df98.</p> |
|
140 </li> |
|
141 <li> |
|
142 <p>the user stack is the value of R13_USR, i.e. |
|
143 0x0d404c38.</p> |
|
144 </li> |
|
145 </ul> |
|
146 <h5>Related tasks</h5> |
|
147 <ul> |
|
148 <li><a href="CrashDebuggerCallStack.guide02.html">General Points</a></li> |
|
149 <li><a href="CrashDebuggerCallStack.guide04.html">Tracing through the Call Stack Heuristically</a></li> |
|
150 <li><a href="CrashDebuggerCallStack.guide05.html">Walking through the Call Stack</a></li> |
|
151 </ul> |
|
152 <div id="footer">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div> |
|
153 |