Commit a0c20dea authored by Corey Minyard's avatar Corey Minyard Committed by Linus Torvalds

kdump: fix gdb macros work work with newer and 64-bit kernels

Lots of little changes needed to be made to clean these up, remove the
four byte pointer assumption and traverse the pid queue properly.  Also
consolidate the traceback code into a single function instead of having
three copies of it.

Link: http://lkml.kernel.org/r/1462926655-9390-1-git-send-email-minyard@acm.orgSigned-off-by: default avatarCorey Minyard <cminyard@mvista.com>
Acked-by: default avatarBaoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Haren Myneni <hbabu@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7a0058ec
...@@ -15,15 +15,16 @@ ...@@ -15,15 +15,16 @@
define bttnobp define bttnobp
set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next)
set $init_t=&init_task set $init_t=&init_task
set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
set var $stacksize = sizeof(union thread_union)
while ($next_t != $init_t) while ($next_t != $init_t)
set $next_t=(struct task_struct *)$next_t set $next_t=(struct task_struct *)$next_t
printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
printf "===================\n" printf "===================\n"
set var $stackp = $next_t.thread.esp set var $stackp = $next_t.thread.sp
set var $stack_top = ($stackp & ~4095) + 4096 set var $stack_top = ($stackp & ~($stacksize - 1)) + $stacksize
while ($stackp < $stack_top) while ($stackp < $stack_top)
if (*($stackp) > _stext && *($stackp) < _sinittext) if (*($stackp) > _stext && *($stackp) < _sinittext)
...@@ -31,13 +32,13 @@ define bttnobp ...@@ -31,13 +32,13 @@ define bttnobp
end end
set $stackp += 4 set $stackp += 4
end end
set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_t->thread_group.next) - $pid_off)
while ($next_th != $next_t) while ($next_th != $next_t)
set $next_th=(struct task_struct *)$next_th set $next_th=(struct task_struct *)$next_th
printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
printf "===================\n" printf "===================\n"
set var $stackp = $next_t.thread.esp set var $stackp = $next_t.thread.sp
set var $stack_top = ($stackp & ~4095) + 4096 set var $stack_top = ($stackp & ~($stacksize - 1)) + stacksize
while ($stackp < $stack_top) while ($stackp < $stack_top)
if (*($stackp) > _stext && *($stackp) < _sinittext) if (*($stackp) > _stext && *($stackp) < _sinittext)
...@@ -45,7 +46,7 @@ define bttnobp ...@@ -45,7 +46,7 @@ define bttnobp
end end
set $stackp += 4 set $stackp += 4
end end
set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
end end
set $next_t=(char *)($next_t->tasks.next) - $tasks_off set $next_t=(char *)($next_t->tasks.next) - $tasks_off
end end
...@@ -54,42 +55,44 @@ document bttnobp ...@@ -54,42 +55,44 @@ document bttnobp
dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
end end
define btthreadstack
set var $pid_task = $arg0
printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
printf "task struct: "
print $pid_task
printf "===================\n"
set var $stackp = $pid_task.thread.sp
set var $stacksize = sizeof(union thread_union)
set var $stack_top = ($stackp & ~($stacksize - 1)) + $stacksize
set var $stack_bot = ($stackp & ~($stacksize - 1))
set $stackp = *((unsigned long *) $stackp)
while (($stackp < $stack_top) && ($stackp > $stack_bot))
set var $addr = *(((unsigned long *) $stackp) + 1)
info symbol $addr
set $stackp = *((unsigned long *) $stackp)
end
end
document btthreadstack
dump a thread stack using the given task structure pointer
end
define btt define btt
set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next)
set $init_t=&init_task set $init_t=&init_task
set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
while ($next_t != $init_t) while ($next_t != $init_t)
set $next_t=(struct task_struct *)$next_t set $next_t=(struct task_struct *)$next_t
printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm btthreadstack $next_t
printf "===================\n"
set var $stackp = $next_t.thread.esp
set var $stack_top = ($stackp & ~4095) + 4096
set var $stack_bot = ($stackp & ~4095)
set $stackp = *($stackp)
while (($stackp < $stack_top) && ($stackp > $stack_bot))
set var $addr = *($stackp + 4)
info symbol $addr
set $stackp = *($stackp)
end
set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_t->thread_group.next) - $pid_off)
while ($next_th != $next_t) while ($next_th != $next_t)
set $next_th=(struct task_struct *)$next_th set $next_th=(struct task_struct *)$next_th
printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm btthreadstack $next_th
printf "===================\n" set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
set var $stackp = $next_t.thread.esp
set var $stack_top = ($stackp & ~4095) + 4096
set var $stack_bot = ($stackp & ~4095)
set $stackp = *($stackp)
while (($stackp < $stack_top) && ($stackp > $stack_bot))
set var $addr = *($stackp + 4)
info symbol $addr
set $stackp = *($stackp)
end
set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off)
end end
set $next_t=(char *)($next_t->tasks.next) - $tasks_off set $next_t=(char *)($next_t->tasks.next) - $tasks_off
end end
...@@ -101,7 +104,7 @@ end ...@@ -101,7 +104,7 @@ end
define btpid define btpid
set var $pid = $arg0 set var $pid = $arg0
set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next)
set $init_t=&init_task set $init_t=&init_task
set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
set var $pid_task = 0 set var $pid_task = 0
...@@ -113,29 +116,18 @@ define btpid ...@@ -113,29 +116,18 @@ define btpid
set $pid_task = $next_t set $pid_task = $next_t
end end
set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_t->thread_group.next) - $pid_off)
while ($next_th != $next_t) while ($next_th != $next_t)
set $next_th=(struct task_struct *)$next_th set $next_th=(struct task_struct *)$next_th
if ($next_th.pid == $pid) if ($next_th.pid == $pid)
set $pid_task = $next_th set $pid_task = $next_th
end end
set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
end end
set $next_t=(char *)($next_t->tasks.next) - $tasks_off set $next_t=(char *)($next_t->tasks.next) - $tasks_off
end end
printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm btthreadstack $pid_task
printf "===================\n"
set var $stackp = $pid_task.thread.esp
set var $stack_top = ($stackp & ~4095) + 4096
set var $stack_bot = ($stackp & ~4095)
set $stackp = *($stackp)
while (($stackp < $stack_top) && ($stackp > $stack_bot))
set var $addr = *($stackp + 4)
info symbol $addr
set $stackp = *($stackp)
end
end end
document btpid document btpid
backtrace of pid backtrace of pid
...@@ -145,7 +137,7 @@ end ...@@ -145,7 +137,7 @@ end
define trapinfo define trapinfo
set var $pid = $arg0 set var $pid = $arg0
set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next)
set $init_t=&init_task set $init_t=&init_task
set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
set var $pid_task = 0 set var $pid_task = 0
...@@ -157,13 +149,13 @@ define trapinfo ...@@ -157,13 +149,13 @@ define trapinfo
set $pid_task = $next_t set $pid_task = $next_t
end end
set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_t->thread_group.next) - $pid_off)
while ($next_th != $next_t) while ($next_th != $next_t)
set $next_th=(struct task_struct *)$next_th set $next_th=(struct task_struct *)$next_th
if ($next_th.pid == $pid) if ($next_th.pid == $pid)
set $pid_task = $next_th set $pid_task = $next_th
end end
set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
end end
set $next_t=(char *)($next_t->tasks.next) - $tasks_off set $next_t=(char *)($next_t->tasks.next) - $tasks_off
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment