Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.org
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Haren Myneni <hbabu@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Corey Minyard and committed by
Linus Torvalds
a0c20dea 7a0058ec

+44 -52
+44 -52
Documentation/kdump/gdbmacros.txt
··· 15 15 16 16 define bttnobp 17 17 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) 19 19 set $init_t=&init_task 20 20 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) 21 + set var $stacksize = sizeof(union thread_union) 21 22 while ($next_t != $init_t) 22 23 set $next_t=(struct task_struct *)$next_t 23 24 printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm 24 25 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 27 28 28 29 while ($stackp < $stack_top) 29 30 if (*($stackp) > _stext && *($stackp) < _sinittext) ··· 32 31 end 33 32 set $stackp += 4 34 33 end 35 - set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) 34 + set $next_th=(((char *)$next_t->thread_group.next) - $pid_off) 36 35 while ($next_th != $next_t) 37 36 set $next_th=(struct task_struct *)$next_th 38 37 printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm 39 38 printf "===================\n" 40 - set var $stackp = $next_t.thread.esp 41 - set var $stack_top = ($stackp & ~4095) + 4096 39 + set var $stackp = $next_t.thread.sp 40 + set var $stack_top = ($stackp & ~($stacksize - 1)) + stacksize 42 41 43 42 while ($stackp < $stack_top) 44 43 if (*($stackp) > _stext && *($stackp) < _sinittext) ··· 46 45 end 47 46 set $stackp += 4 48 47 end 49 - set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) 48 + set $next_th=(((char *)$next_th->thread_group.next) - $pid_off) 50 49 end 51 50 set $next_t=(char *)($next_t->tasks.next) - $tasks_off 52 51 end ··· 55 54 dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER 56 55 end 57 56 57 + define btthreadstack 58 + set var $pid_task = $arg0 59 + 60 + printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm 61 + printf "task struct: " 62 + print $pid_task 63 + printf "===================\n" 64 + set var $stackp = $pid_task.thread.sp 65 + set var $stacksize = sizeof(union thread_union) 66 + set var $stack_top = ($stackp & ~($stacksize - 1)) + $stacksize 67 + set var $stack_bot = ($stackp & ~($stacksize - 1)) 68 + 69 + set $stackp = *((unsigned long *) $stackp) 70 + while (($stackp < $stack_top) && ($stackp > $stack_bot)) 71 + set var $addr = *(((unsigned long *) $stackp) + 1) 72 + info symbol $addr 73 + set $stackp = *((unsigned long *) $stackp) 74 + end 75 + end 76 + document btthreadstack 77 + dump a thread stack using the given task structure pointer 78 + end 79 + 80 + 58 81 define btt 59 82 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) 60 - set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) 83 + set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next) 61 84 set $init_t=&init_task 62 85 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) 63 86 while ($next_t != $init_t) 64 87 set $next_t=(struct task_struct *)$next_t 65 - printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm 66 - printf "===================\n" 67 - set var $stackp = $next_t.thread.esp 68 - set var $stack_top = ($stackp & ~4095) + 4096 69 - set var $stack_bot = ($stackp & ~4095) 88 + btthreadstack $next_t 70 89 71 - set $stackp = *($stackp) 72 - while (($stackp < $stack_top) && ($stackp > $stack_bot)) 73 - set var $addr = *($stackp + 4) 74 - info symbol $addr 75 - set $stackp = *($stackp) 76 - end 77 - 78 - set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) 90 + set $next_th=(((char *)$next_t->thread_group.next) - $pid_off) 79 91 while ($next_th != $next_t) 80 92 set $next_th=(struct task_struct *)$next_th 81 - printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm 82 - printf "===================\n" 83 - set var $stackp = $next_t.thread.esp 84 - set var $stack_top = ($stackp & ~4095) + 4096 85 - set var $stack_bot = ($stackp & ~4095) 86 - 87 - set $stackp = *($stackp) 88 - while (($stackp < $stack_top) && ($stackp > $stack_bot)) 89 - set var $addr = *($stackp + 4) 90 - info symbol $addr 91 - set $stackp = *($stackp) 92 - end 93 - set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) 93 + btthreadstack $next_th 94 + set $next_th=(((char *)$next_th->thread_group.next) - $pid_off) 94 95 end 95 96 set $next_t=(char *)($next_t->tasks.next) - $tasks_off 96 97 end ··· 104 101 define btpid 105 102 set var $pid = $arg0 106 103 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) 107 - set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) 104 + set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next) 108 105 set $init_t=&init_task 109 106 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) 110 107 set var $pid_task = 0 ··· 116 113 set $pid_task = $next_t 117 114 end 118 115 119 - set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) 116 + set $next_th=(((char *)$next_t->thread_group.next) - $pid_off) 120 117 while ($next_th != $next_t) 121 118 set $next_th=(struct task_struct *)$next_th 122 119 if ($next_th.pid == $pid) 123 120 set $pid_task = $next_th 124 121 end 125 - set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) 122 + set $next_th=(((char *)$next_th->thread_group.next) - $pid_off) 126 123 end 127 124 set $next_t=(char *)($next_t->tasks.next) - $tasks_off 128 125 end 129 126 130 - printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm 131 - printf "===================\n" 132 - set var $stackp = $pid_task.thread.esp 133 - set var $stack_top = ($stackp & ~4095) + 4096 134 - set var $stack_bot = ($stackp & ~4095) 135 - 136 - set $stackp = *($stackp) 137 - while (($stackp < $stack_top) && ($stackp > $stack_bot)) 138 - set var $addr = *($stackp + 4) 139 - info symbol $addr 140 - set $stackp = *($stackp) 141 - end 127 + btthreadstack $pid_task 142 128 end 143 129 document btpid 144 130 backtrace of pid ··· 137 145 define trapinfo 138 146 set var $pid = $arg0 139 147 set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) 140 - set $pid_off=((size_t)&((struct task_struct *)0)->pids[1].pid_list.next) 148 + set $pid_off=((size_t)&((struct task_struct *)0)->thread_group.next) 141 149 set $init_t=&init_task 142 150 set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) 143 151 set var $pid_task = 0 ··· 149 157 set $pid_task = $next_t 150 158 end 151 159 152 - set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) 160 + set $next_th=(((char *)$next_t->thread_group.next) - $pid_off) 153 161 while ($next_th != $next_t) 154 162 set $next_th=(struct task_struct *)$next_th 155 163 if ($next_th.pid == $pid) 156 164 set $pid_task = $next_th 157 165 end 158 - set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) 166 + set $next_th=(((char *)$next_th->thread_group.next) - $pid_off) 159 167 end 160 168 set $next_t=(char *)($next_t->tasks.next) - $tasks_off 161 169 end