]>
Commit | Line | Data |
---|---|---|
997358a6 MW |
1 | <PRE> |
2 | To: Michael Richardson <mcr@sandelman.ottawa.on.ca> | |
3 | Cc: user-mode-linux-devel@lists.sourceforge.net | |
4 | From: Jeff Dike <jdike@karaya.com> | |
5 | Subject: [uml-devel] Re: stack trace | |
6 | Date: Mon, 16 Sep 2002 22:36:06 -0500 | |
7 | ||
8 | mcr@sandelman.ottawa.on.ca said: | |
9 | > Can you post (on list or web site) a "script" output of you trying to | |
10 | > get the right stack out of a stuck uml (tracing myself)...? | |
11 | ||
12 | Yup. Here we go... | |
13 | ||
14 | Here, I attach to the tracing thread and get the stack of the current thread, | |
15 | which happens to be the idle thread. | |
16 | ||
17 | um 1013: gdb linux 14936 | |
18 | GNU gdb 5.0rh-5 Red Hat Linux 7.1 | |
19 | Copyright 2001 Free Software Foundation, Inc. | |
20 | GDB is free software, covered by the GNU General Public License, and you are | |
21 | welcome to change it and/or distribute copies of it under certain conditions. | |
22 | Type "show copying" to see the conditions. | |
23 | There is absolutely no warranty for GDB. Type "show warranty" for details. | |
24 | This GDB was configured as "i386-redhat-linux"... | |
25 | /home/jdike/linux/2.4/um/14936: No such file or directory. | |
26 | Attaching to program: /home/jdike/linux/2.4/um/linux, process 14936 | |
27 | 0xa014efe9 in __wait4 () | |
28 | ||
29 | # This is how you get the current task in the tracing thread - get_current() | |
30 | # only works in a kernel thread. | |
31 | (gdb) p (struct task_struct *)cpu_tasks[0].task | |
32 | $2 = (struct task_struct *) 0xa01c0000 | |
33 | ||
34 | # Get the host pid of that task. | |
35 | (gdb) p $2.thread.extern_pid | |
36 | $3 = 14939 | |
37 | ||
38 | # Get the current ip and sp. | |
39 | (gdb) shell cat /proc/14939/stat | |
40 | 14939 (linux) T 14936 14936 883 34816 14936 64 5 3 806 7 62 12 0 0 9 0 0 2 | |
41 | 588043 142770176 5008 4294967295 2684358656 2686348640 3221223520 2686205764 | |
42 | sp ^^^^^^^^^^ | |
43 | 2685727185 73728 201392128 167776768 268444672 3222308129 0 0 17 0 | |
44 | ip ^^^^^^^^^^ | |
45 | ||
46 | # the sp and ip are items 4 and 5 after the 4294967295 (on 2.2 hosts, that's | |
47 | 2^31 - 1 rather than 2^32 - 1). | |
48 | ||
49 | (gdb) p/x 2686205764 | |
50 | $4 = 0xa01c3f44 | |
51 | (gdb) p/x 2685727185 | |
52 | $5 = 0xa014f1d1 | |
53 | ||
54 | # Where's the ip? | |
55 | (gdb) i sym 0xa014f1d1 | |
56 | nanosleep + 17 in section .text | |
57 | ||
58 | # look at the stack around the sp | |
59 | (gdb) x/32x 0xa01c3f30 | |
60 | 0xa01c3f30 : 0x00000000 0x00000000 0xa01c3f60 0xa00020a8 | |
61 | 0xa01c3f40 : 0x00000004 0xa012e891 0xa01c3f58 0xa01c3f58 | |
62 | 0xa01c3f50 : 0xa01c3f70 0xa0023667 0x00000009 0x3b023380 | |
63 | 0xa01c3f60 : 0xa01c3fa0 0xa012a21d 0x0000000a 0xa01c0000 | |
64 | 0xa01c3f70 : 0xa01c3fa0 0xa012a213 0x00000003 0x00000024 | |
65 | 0xa01c3f80 : 0xa01c3fa0 0xa0011bc4 0xa012b25c 0x00000000 | |
66 | 0xa01c3f90 : 0xa01c3fb0 0x00000000 0xa01c3ffc 0x0000000d | |
67 | 0xa01c3fa0 : 0xa01c3fb0 0xa000c50e 0xa01812e0 0xa01c3ffc | |
68 | ||
69 | # The trick here is to locate a frame near the current sp. You're looking | |
70 | # for a consecutive pair of longwords (fp, ip) having the properties that: | |
71 | # fp is on the current kernel stack and points further up it | |
72 | # ip is a text address (if you can't recognize a UML text address by | |
73 | # sight, print out &_stext and &_etext) | |
74 | # | |
75 | # Starting at 0xa01c3f44, the first pair of works satisfying these requirements | |
76 | # is at 0xa01c3f50. | |
77 | # So, print that pair out as hex. | |
78 | (gdb) p/x *((int (*)[2])0xa01c3f50) | |
79 | $9 = {0xa01c3f70, 0xa0023667} | |
80 | ||
81 | # Now, we start climbing the stack. | |
82 | (gdb) p/x *((int (*)[2])$[0]) | |
83 | $10 = {0xa01c3fa0, 0xa012a213} | |
84 | (gdb) | |
85 | $11 = {0xa01c3fb0, 0xa000c50e} | |
86 | (gdb) | |
87 | $12 = {0xa01c3fc0, 0xa000356d} | |
88 | (gdb) | |
89 | $13 = {0xa01c3fd0, 0xa013082f} | |
90 | (gdb) | |
91 | $14 = {0xa01c3ff0, 0xa012fbdd} | |
92 | # Stop when you see a NULL frame pointer or gdb bitches at you. | |
93 | (gdb) | |
94 | $15 = {0x0, 0xa01513aa} | |
95 | ||
96 | # Now we get the symbolic version of the stack with 'i sym' of the second item | |
97 | # in each pair. | |
98 | (gdb) i sym 0xa0023667 | |
99 | check_pgt_cache + 23 in section .text | |
100 | (gdb) i sym 0xa012a213 | |
101 | cpu_idle + 123 in section .text | |
102 | (gdb) i sym 0xa000c50e | |
103 | rest_init + 46 in section .text | |
104 | (gdb) i sym 0xa000356d | |
105 | start_kernel + 361 in section .text.init | |
106 | (gdb) i sym 0xa013082f | |
107 | start_kernel_proc + 63 in section .text | |
108 | (gdb) i sym 0xa012fbdd | |
109 | signal_tramp + 209 in section .text | |
110 | (gdb) i sym 0xa01513aa | |
111 | thread_start + 4 in section .text | |
112 | ||
113 | # You can also get line number information with 'i line'. | |
114 | (gdb) i line *0xa012a213 | |
115 | Line 488 of "process_kern.c" starts at address 0xa012a213 <cpu_idle+123> | |
116 | and ends at 0xa012a21d <cpu_idle+133>. | |
117 | (gdb) | |
118 | ||
119 | ||
120 | ------------------------------------------------------- | |
121 | Sponsored by: AMD - Your access to the experts on Hammer Technology! | |
122 | Open Source & Linux Developers, register now for the AMD Developer | |
123 | Symposium. Code: EX8664 http://www.developwithamd.com/developerlab | |
124 | _______________________________________________ | |
125 | User-mode-linux-devel mailing list | |
126 | User-mode-linux-devel@lists.sourceforge.net | |
127 | https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel | |
128 | ||
129 | </PRE> |