1515
1616define bttnobp
1717 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
18- set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list .next)
18+ set $pid_off=((size_t)&((struct task_struct *)0)->thread_group .next)
1919 set $init_t=&init_task
2020 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
21+ set var $stacksize = sizeof(union thread_union)
2122 while ($next_t != $init_t)
2223 set $next_t=(struct task_struct *)$next_t
2324 printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
2425 printf "===================\n"
25- set var $stackp = $next_t.thread.esp
26- set var $stack_top = ($stackp & ~4095) + 4096
26+ set var $stackp = $next_t.thread.sp
27+ set var $stack_top = ($stackp & ~($stacksize - 1)) + $stacksize
2728
2829 while ($stackp < $stack_top)
2930 if (*($stackp) > _stext && *($stackp) < _sinittext)
3031 info symbol *($stackp)
3132 end
3233 set $stackp += 4
3334 end
34- set $next_th=(((char *)$next_t->pids[1].pid_list .next) - $pid_off)
35+ set $next_th=(((char *)$next_t->thread_group .next) - $pid_off)
3536 while ($next_th != $next_t)
3637 set $next_th=(struct task_struct *)$next_th
3738 printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
3839 printf "===================\n"
39- set var $stackp = $next_t.thread.esp
40- set var $stack_top = ($stackp & ~4095) + 4096
40+ set var $stackp = $next_t.thread.sp
41+ set var $stack_top = ($stackp & ~($stacksize - 1)) + stacksize
4142
4243 while ($stackp < $stack_top)
4344 if (*($stackp) > _stext && *($stackp) < _sinittext)
4445 info symbol *($stackp)
4546 end
4647 set $stackp += 4
4748 end
48- set $next_th=(((char *)$next_th->pids[1].pid_list .next) - $pid_off)
49+ set $next_th=(((char *)$next_th->thread_group .next) - $pid_off)
4950 end
5051 set $next_t=(char *)($next_t->tasks.next) - $tasks_off
5152 end
@@ -54,42 +55,44 @@ document bttnobp
5455 dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
5556end
5657
58+ define btthreadstack
59+ set var $pid_task = $arg0
60+
61+ printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
62+ printf "task struct: "
63+ print $pid_task
64+ printf "===================\n"
65+ set var $stackp = $pid_task.thread.sp
66+ set var $stacksize = sizeof(union thread_union)
67+ set var $stack_top = ($stackp & ~($stacksize - 1)) + $stacksize
68+ set var $stack_bot = ($stackp & ~($stacksize - 1))
69+
70+ set $stackp = *((unsigned long *) $stackp)
71+ while (($stackp < $stack_top) && ($stackp > $stack_bot))
72+ set var $addr = *(((unsigned long *) $stackp) + 1)
73+ info symbol $addr
74+ set $stackp = *((unsigned long *) $stackp)
75+ end
76+ end
77+ document btthreadstack
78+ dump a thread stack using the given task structure pointer
79+ end
80+
81+
5782define btt
5883 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
59- set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list .next)
84+ set $pid_off=((size_t)&((struct task_struct *)0)->thread_group .next)
6085 set $init_t=&init_task
6186 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
6287 while ($next_t != $init_t)
6388 set $next_t=(struct task_struct *)$next_t
64- printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
65- printf "===================\n"
66- set var $stackp = $next_t.thread.esp
67- set var $stack_top = ($stackp & ~4095) + 4096
68- set var $stack_bot = ($stackp & ~4095)
69-
70- set $stackp = *($stackp)
71- while (($stackp < $stack_top) && ($stackp > $stack_bot))
72- set var $addr = *($stackp + 4)
73- info symbol $addr
74- set $stackp = *($stackp)
75- end
89+ btthreadstack $next_t
7690
77- set $next_th=(((char *)$next_t->pids[1].pid_list .next) - $pid_off)
91+ set $next_th=(((char *)$next_t->thread_group .next) - $pid_off)
7892 while ($next_th != $next_t)
7993 set $next_th=(struct task_struct *)$next_th
80- printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
81- printf "===================\n"
82- set var $stackp = $next_t.thread.esp
83- set var $stack_top = ($stackp & ~4095) + 4096
84- set var $stack_bot = ($stackp & ~4095)
85-
86- set $stackp = *($stackp)
87- while (($stackp < $stack_top) && ($stackp > $stack_bot))
88- set var $addr = *($stackp + 4)
89- info symbol $addr
90- set $stackp = *($stackp)
91- end
92- set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off)
94+ btthreadstack $next_th
95+ set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
9396 end
9497 set $next_t=(char *)($next_t->tasks.next) - $tasks_off
9598 end
101104define btpid
102105 set var $pid = $arg0
103106 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
104- set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list .next)
107+ set $pid_off=((size_t)&((struct task_struct *)0)->thread_group .next)
105108 set $init_t=&init_task
106109 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
107110 set var $pid_task = 0
@@ -113,29 +116,18 @@ define btpid
113116 set $pid_task = $next_t
114117 end
115118
116- set $next_th=(((char *)$next_t->pids[1].pid_list .next) - $pid_off)
119+ set $next_th=(((char *)$next_t->thread_group .next) - $pid_off)
117120 while ($next_th != $next_t)
118121 set $next_th=(struct task_struct *)$next_th
119122 if ($next_th.pid == $pid)
120123 set $pid_task = $next_th
121124 end
122- set $next_th=(((char *)$next_th->pids[1].pid_list .next) - $pid_off)
125+ set $next_th=(((char *)$next_th->thread_group .next) - $pid_off)
123126 end
124127 set $next_t=(char *)($next_t->tasks.next) - $tasks_off
125128 end
126129
127- printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
128- printf "===================\n"
129- set var $stackp = $pid_task.thread.esp
130- set var $stack_top = ($stackp & ~4095) + 4096
131- set var $stack_bot = ($stackp & ~4095)
132-
133- set $stackp = *($stackp)
134- while (($stackp < $stack_top) && ($stackp > $stack_bot))
135- set var $addr = *($stackp + 4)
136- info symbol $addr
137- set $stackp = *($stackp)
138- end
130+ btthreadstack $pid_task
139131end
140132document btpid
141133 backtrace of pid
145137define trapinfo
146138 set var $pid = $arg0
147139 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
148- set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list .next)
140+ set $pid_off=((size_t)&((struct task_struct *)0)->thread_group .next)
149141 set $init_t=&init_task
150142 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
151143 set var $pid_task = 0
@@ -157,13 +149,13 @@ define trapinfo
157149 set $pid_task = $next_t
158150 end
159151
160- set $next_th=(((char *)$next_t->pids[1].pid_list .next) - $pid_off)
152+ set $next_th=(((char *)$next_t->thread_group .next) - $pid_off)
161153 while ($next_th != $next_t)
162154 set $next_th=(struct task_struct *)$next_th
163155 if ($next_th.pid == $pid)
164156 set $pid_task = $next_th
165157 end
166- set $next_th=(((char *)$next_th->pids[1].pid_list .next) - $pid_off)
158+ set $next_th=(((char *)$next_th->thread_group .next) - $pid_off)
167159 end
168160 set $next_t=(char *)($next_t->tasks.next) - $tasks_off
169161 end
0 commit comments