All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-02-25 13:51 ` minyard
  0 siblings, 0 replies; 19+ messages in thread
From: minyard @ 2016-02-25 13:51 UTC (permalink / raw)
  To: kexec, linux-kernel, Vivek Goyal, Haren Myneni; +Cc: minyard, Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

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.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 50 deletions(-)

I sent this earlier, but I didn't get a response.  These are clearly
wrong.  I'd be happy to take over maintenance of these macros.  It
might be better to move them someplace else, too, since they are also
useful for kgdb.

diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
index 9b9b454..e5bbd8d 100644
--- a/Documentation/kdump/gdbmacros.txt
+++ b/Documentation/kdump/gdbmacros.txt
@@ -15,14 +15,14 @@
 
 define bttnobp
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
 		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
+		set var $stackp = $next_t.thread.sp
 		set var $stack_top = ($stackp & ~4095) + 4096
 
 		while ($stackp < $stack_top)
@@ -31,12 +31,12 @@ define bttnobp
 			end
 			set $stackp += 4
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 			printf "===================\n"
-			set var $stackp = $next_t.thread.esp
+			set var $stackp = $next_t.thread.sp
 			set var $stack_top = ($stackp & ~4095) + 4096
 
 			while ($stackp < $stack_top)
@@ -45,7 +45,7 @@ define bttnobp
 				end
 				set $stackp += 4
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -54,42 +54,43 @@ document bttnobp
 	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
 end
 
+define btthreadstruct
+	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 $stack_top = ($stackp & ~4095) + 4096
+	set var $stack_bot = ($stackp & ~4095)
+
+	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 btthreadstruct
+	 dump a thread stack using the given task structure pointer
+end
+
+
 define btt
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
-		set var $stack_top = ($stackp & ~4095) + 4096
-		set var $stack_bot = ($stackp & ~4095)
+		btthreadstruct $next_t
 
-		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)
 			set $next_th=(struct task_struct *)$next_th
-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-			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_th->pids[1].pid_list.next) - $pid_off)
+			btthreadstruct $next_th
+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
 		end
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -101,7 +102,7 @@ end
 define btpid
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -113,29 +114,18 @@ define btpid
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
 
-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
-	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
+	btthreadstruct $pid_task
 end
 document btpid
 	backtrace of pid
@@ -145,7 +135,7 @@ end
 define trapinfo
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -157,13 +147,13 @@ define trapinfo
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-02-25 13:51 ` minyard
  0 siblings, 0 replies; 19+ messages in thread
From: minyard @ 2016-02-25 13:51 UTC (permalink / raw)
  To: kexec, linux-kernel, Vivek Goyal, Haren Myneni; +Cc: Corey Minyard, minyard

From: Corey Minyard <cminyard@mvista.com>

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.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 50 deletions(-)

I sent this earlier, but I didn't get a response.  These are clearly
wrong.  I'd be happy to take over maintenance of these macros.  It
might be better to move them someplace else, too, since they are also
useful for kgdb.

diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
index 9b9b454..e5bbd8d 100644
--- a/Documentation/kdump/gdbmacros.txt
+++ b/Documentation/kdump/gdbmacros.txt
@@ -15,14 +15,14 @@
 
 define bttnobp
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
 		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
+		set var $stackp = $next_t.thread.sp
 		set var $stack_top = ($stackp & ~4095) + 4096
 
 		while ($stackp < $stack_top)
@@ -31,12 +31,12 @@ define bttnobp
 			end
 			set $stackp += 4
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 			printf "===================\n"
-			set var $stackp = $next_t.thread.esp
+			set var $stackp = $next_t.thread.sp
 			set var $stack_top = ($stackp & ~4095) + 4096
 
 			while ($stackp < $stack_top)
@@ -45,7 +45,7 @@ define bttnobp
 				end
 				set $stackp += 4
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -54,42 +54,43 @@ document bttnobp
 	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
 end
 
+define btthreadstruct
+	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 $stack_top = ($stackp & ~4095) + 4096
+	set var $stack_bot = ($stackp & ~4095)
+
+	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 btthreadstruct
+	 dump a thread stack using the given task structure pointer
+end
+
+
 define btt
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
-		set var $stack_top = ($stackp & ~4095) + 4096
-		set var $stack_bot = ($stackp & ~4095)
+		btthreadstruct $next_t
 
-		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)
 			set $next_th=(struct task_struct *)$next_th
-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-			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_th->pids[1].pid_list.next) - $pid_off)
+			btthreadstruct $next_th
+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
 		end
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -101,7 +102,7 @@ end
 define btpid
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -113,29 +114,18 @@ define btpid
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
 
-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
-	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
+	btthreadstruct $pid_task
 end
 document btpid
 	backtrace of pid
@@ -145,7 +135,7 @@ end
 define trapinfo
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -157,13 +147,13 @@ define trapinfo
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
-- 
2.5.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-02-25 13:51 ` minyard
@ 2016-04-27 12:21   ` Corey Minyard
  -1 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-04-27 12:21 UTC (permalink / raw)
  To: kexec, linux-kernel, Vivek Goyal, Haren Myneni; +Cc: Corey Minyard

Any comments on this?  If no one else cares I'd be willing to take over
maintenance of this.

-corey

On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
>
> 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.
>
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>   Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
>   1 file changed, 40 insertions(+), 50 deletions(-)
>
> I sent this earlier, but I didn't get a response.  These are clearly
> wrong.  I'd be happy to take over maintenance of these macros.  It
> might be better to move them someplace else, too, since they are also
> useful for kgdb.
>
> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> index 9b9b454..e5bbd8d 100644
> --- a/Documentation/kdump/gdbmacros.txt
> +++ b/Documentation/kdump/gdbmacros.txt
> @@ -15,14 +15,14 @@
>   
>   define bttnobp
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	while ($next_t != $init_t)
>   		set $next_t=(struct task_struct *)$next_t
>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>   		printf "===================\n"
> -		set var $stackp = $next_t.thread.esp
> +		set var $stackp = $next_t.thread.sp
>   		set var $stack_top = ($stackp & ~4095) + 4096
>   
>   		while ($stackp < $stack_top)
> @@ -31,12 +31,12 @@ define bttnobp
>   			end
>   			set $stackp += 4
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>   			printf "===================\n"
> -			set var $stackp = $next_t.thread.esp
> +			set var $stackp = $next_t.thread.sp
>   			set var $stack_top = ($stackp & ~4095) + 4096
>   
>   			while ($stackp < $stack_top)
> @@ -45,7 +45,7 @@ define bttnobp
>   				end
>   				set $stackp += 4
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
> @@ -54,42 +54,43 @@ document bttnobp
>   	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
>   end
>   
> +define btthreadstruct
> +	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 $stack_top = ($stackp & ~4095) + 4096
> +	set var $stack_bot = ($stackp & ~4095)
> +
> +	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 btthreadstruct
> +	 dump a thread stack using the given task structure pointer
> +end
> +
> +
>   define btt
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	while ($next_t != $init_t)
>   		set $next_t=(struct task_struct *)$next_t
> -		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> -		printf "===================\n"
> -		set var $stackp = $next_t.thread.esp
> -		set var $stack_top = ($stackp & ~4095) + 4096
> -		set var $stack_bot = ($stackp & ~4095)
> +		btthreadstruct $next_t
>   
> -		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)
>   			set $next_th=(struct task_struct *)$next_th
> -			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> -			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_th->pids[1].pid_list.next) - $pid_off)
> +			btthreadstruct $next_th
> +			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
>   		end
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
> @@ -101,7 +102,7 @@ end
>   define btpid
>   	set var $pid = $arg0
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	set var $pid_task = 0
> @@ -113,29 +114,18 @@ define btpid
>   			set $pid_task = $next_t
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			if ($next_th.pid == $pid)
>   				set $pid_task = $next_th
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
>   
> -	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> -	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
> +	btthreadstruct $pid_task
>   end
>   document btpid
>   	backtrace of pid
> @@ -145,7 +135,7 @@ end
>   define trapinfo
>   	set var $pid = $arg0
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	set var $pid_task = 0
> @@ -157,13 +147,13 @@ define trapinfo
>   			set $pid_task = $next_t
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			if ($next_th.pid == $pid)
>   				set $pid_task = $next_th
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-04-27 12:21   ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-04-27 12:21 UTC (permalink / raw)
  To: kexec, linux-kernel, Vivek Goyal, Haren Myneni; +Cc: Corey Minyard

Any comments on this?  If no one else cares I'd be willing to take over
maintenance of this.

-corey

On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
>
> 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.
>
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>   Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
>   1 file changed, 40 insertions(+), 50 deletions(-)
>
> I sent this earlier, but I didn't get a response.  These are clearly
> wrong.  I'd be happy to take over maintenance of these macros.  It
> might be better to move them someplace else, too, since they are also
> useful for kgdb.
>
> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> index 9b9b454..e5bbd8d 100644
> --- a/Documentation/kdump/gdbmacros.txt
> +++ b/Documentation/kdump/gdbmacros.txt
> @@ -15,14 +15,14 @@
>   
>   define bttnobp
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	while ($next_t != $init_t)
>   		set $next_t=(struct task_struct *)$next_t
>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>   		printf "===================\n"
> -		set var $stackp = $next_t.thread.esp
> +		set var $stackp = $next_t.thread.sp
>   		set var $stack_top = ($stackp & ~4095) + 4096
>   
>   		while ($stackp < $stack_top)
> @@ -31,12 +31,12 @@ define bttnobp
>   			end
>   			set $stackp += 4
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>   			printf "===================\n"
> -			set var $stackp = $next_t.thread.esp
> +			set var $stackp = $next_t.thread.sp
>   			set var $stack_top = ($stackp & ~4095) + 4096
>   
>   			while ($stackp < $stack_top)
> @@ -45,7 +45,7 @@ define bttnobp
>   				end
>   				set $stackp += 4
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
> @@ -54,42 +54,43 @@ document bttnobp
>   	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
>   end
>   
> +define btthreadstruct
> +	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 $stack_top = ($stackp & ~4095) + 4096
> +	set var $stack_bot = ($stackp & ~4095)
> +
> +	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 btthreadstruct
> +	 dump a thread stack using the given task structure pointer
> +end
> +
> +
>   define btt
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	while ($next_t != $init_t)
>   		set $next_t=(struct task_struct *)$next_t
> -		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> -		printf "===================\n"
> -		set var $stackp = $next_t.thread.esp
> -		set var $stack_top = ($stackp & ~4095) + 4096
> -		set var $stack_bot = ($stackp & ~4095)
> +		btthreadstruct $next_t
>   
> -		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)
>   			set $next_th=(struct task_struct *)$next_th
> -			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> -			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_th->pids[1].pid_list.next) - $pid_off)
> +			btthreadstruct $next_th
> +			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
>   		end
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
> @@ -101,7 +102,7 @@ end
>   define btpid
>   	set var $pid = $arg0
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	set var $pid_task = 0
> @@ -113,29 +114,18 @@ define btpid
>   			set $pid_task = $next_t
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			if ($next_th.pid == $pid)
>   				set $pid_task = $next_th
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end
>   
> -	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> -	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
> +	btthreadstruct $pid_task
>   end
>   document btpid
>   	backtrace of pid
> @@ -145,7 +135,7 @@ end
>   define trapinfo
>   	set var $pid = $arg0
>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>   	set var $pid_task = 0
> @@ -157,13 +147,13 @@ define trapinfo
>   			set $pid_task = $next_t
>   		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)
>   			set $next_th=(struct task_struct *)$next_th
>   			if ($next_th.pid == $pid)
>   				set $pid_task = $next_th
>   			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
>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>   	end


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-04-27 12:21   ` Corey Minyard
@ 2016-05-05  2:37     ` Baoquan He
  -1 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-05  2:37 UTC (permalink / raw)
  To: Corey Minyard
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, Corey Minyard, dyoung

On 04/27/16 at 07:21am, Corey Minyard wrote:
> Any comments on this?  If no one else cares I'd be willing to take over
> maintenance of this.

Vivek is busy with some other issues. He asked Dave and me to test and
review this patch. Will check this recently.

Thanks
Baoquan

> 
> -corey
> 
> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> >From: Corey Minyard <cminyard@mvista.com>
> >
> >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.
> >
> >Signed-off-by: Corey Minyard <cminyard@mvista.com>
> >---
> >  Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
> >  1 file changed, 40 insertions(+), 50 deletions(-)
> >
> >I sent this earlier, but I didn't get a response.  These are clearly
> >wrong.  I'd be happy to take over maintenance of these macros.  It
> >might be better to move them someplace else, too, since they are also
> >useful for kgdb.
> >
> >diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >index 9b9b454..e5bbd8d 100644
> >--- a/Documentation/kdump/gdbmacros.txt
> >+++ b/Documentation/kdump/gdbmacros.txt
> >@@ -15,14 +15,14 @@
> >  define bttnobp
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >+		set var $stackp = $next_t.thread.sp
> >  		set var $stack_top = ($stackp & ~4095) + 4096
> >  		while ($stackp < $stack_top)
> >@@ -31,12 +31,12 @@ define bttnobp
> >  			end
> >  			set $stackp += 4
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  			printf "===================\n"
> >-			set var $stackp = $next_t.thread.esp
> >+			set var $stackp = $next_t.thread.sp
> >  			set var $stack_top = ($stackp & ~4095) + 4096
> >  			while ($stackp < $stack_top)
> >@@ -45,7 +45,7 @@ define bttnobp
> >  				end
> >  				set $stackp += 4
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -54,42 +54,43 @@ document bttnobp
> >  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >  end
> >+define btthreadstruct
> >+	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 $stack_top = ($stackp & ~4095) + 4096
> >+	set var $stack_bot = ($stackp & ~4095)
> >+
> >+	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 btthreadstruct
> >+	 dump a thread stack using the given task structure pointer
> >+end
> >+
> >+
> >  define btt
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >-		set var $stack_top = ($stackp & ~4095) + 4096
> >-		set var $stack_bot = ($stackp & ~4095)
> >+		btthreadstruct $next_t
> >-		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-			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_th->pids[1].pid_list.next) - $pid_off)
> >+			btthreadstruct $next_th
> >+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
> >  		end
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -101,7 +102,7 @@ end
> >  define btpid
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -113,29 +114,18 @@ define btpid
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> >-	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
> >+	btthreadstruct $pid_task
> >  end
> >  document btpid
> >  	backtrace of pid
> >@@ -145,7 +135,7 @@ end
> >  define trapinfo
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -157,13 +147,13 @@ define trapinfo
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-05  2:37     ` Baoquan He
  0 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-05  2:37 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

On 04/27/16 at 07:21am, Corey Minyard wrote:
> Any comments on this?  If no one else cares I'd be willing to take over
> maintenance of this.

Vivek is busy with some other issues. He asked Dave and me to test and
review this patch. Will check this recently.

Thanks
Baoquan

> 
> -corey
> 
> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> >From: Corey Minyard <cminyard@mvista.com>
> >
> >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.
> >
> >Signed-off-by: Corey Minyard <cminyard@mvista.com>
> >---
> >  Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
> >  1 file changed, 40 insertions(+), 50 deletions(-)
> >
> >I sent this earlier, but I didn't get a response.  These are clearly
> >wrong.  I'd be happy to take over maintenance of these macros.  It
> >might be better to move them someplace else, too, since they are also
> >useful for kgdb.
> >
> >diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >index 9b9b454..e5bbd8d 100644
> >--- a/Documentation/kdump/gdbmacros.txt
> >+++ b/Documentation/kdump/gdbmacros.txt
> >@@ -15,14 +15,14 @@
> >  define bttnobp
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >+		set var $stackp = $next_t.thread.sp
> >  		set var $stack_top = ($stackp & ~4095) + 4096
> >  		while ($stackp < $stack_top)
> >@@ -31,12 +31,12 @@ define bttnobp
> >  			end
> >  			set $stackp += 4
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  			printf "===================\n"
> >-			set var $stackp = $next_t.thread.esp
> >+			set var $stackp = $next_t.thread.sp
> >  			set var $stack_top = ($stackp & ~4095) + 4096
> >  			while ($stackp < $stack_top)
> >@@ -45,7 +45,7 @@ define bttnobp
> >  				end
> >  				set $stackp += 4
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -54,42 +54,43 @@ document bttnobp
> >  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >  end
> >+define btthreadstruct
> >+	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 $stack_top = ($stackp & ~4095) + 4096
> >+	set var $stack_bot = ($stackp & ~4095)
> >+
> >+	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 btthreadstruct
> >+	 dump a thread stack using the given task structure pointer
> >+end
> >+
> >+
> >  define btt
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >-		set var $stack_top = ($stackp & ~4095) + 4096
> >-		set var $stack_bot = ($stackp & ~4095)
> >+		btthreadstruct $next_t
> >-		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-			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_th->pids[1].pid_list.next) - $pid_off)
> >+			btthreadstruct $next_th
> >+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
> >  		end
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -101,7 +102,7 @@ end
> >  define btpid
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -113,29 +114,18 @@ define btpid
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> >-	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
> >+	btthreadstruct $pid_task
> >  end
> >  document btpid
> >  	backtrace of pid
> >@@ -145,7 +135,7 @@ end
> >  define trapinfo
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -157,13 +147,13 @@ define trapinfo
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-04-27 12:21   ` Corey Minyard
@ 2016-05-09  5:18     ` Baoquan He
  -1 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-09  5:18 UTC (permalink / raw)
  To: Corey Minyard
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, Corey Minyard, dyoung

Hi Corey,

I am trying to review this patch now, and these fixes contained are very
great. Just several concerns are added in inline comment.

By the way, did you run this in your side?

Hi Vivek,

Member variable was added into task_struct in below commit replacing
pids[PIDTYPE_TGID], and from then on nobody complained about it. Seems
people rarely use this utility.

commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3
Author: Oleg Nesterov <oleg@tv-sign.ru>
Date:   Tue Mar 28 16:11:25 2006 -0800

    [PATCH] pids: kill PIDTYPE_TGID



On 04/27/16 at 07:21am, Corey Minyard wrote:
> Any comments on this?  If no one else cares I'd be willing to take over
> maintenance of this.
> 
> -corey
> 
> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> >From: Corey Minyard <cminyard@mvista.com>
> >
> >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.
> >
> >Signed-off-by: Corey Minyard <cminyard@mvista.com>
> >---
> >  Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
> >  1 file changed, 40 insertions(+), 50 deletions(-)
> >
> >I sent this earlier, but I didn't get a response.  These are clearly
> >wrong.  I'd be happy to take over maintenance of these macros.  It
> >might be better to move them someplace else, too, since they are also
> >useful for kgdb.
> >
> >diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >index 9b9b454..e5bbd8d 100644
> >--- a/Documentation/kdump/gdbmacros.txt
> >+++ b/Documentation/kdump/gdbmacros.txt
> >@@ -15,14 +15,14 @@
> >  define bttnobp
> >  	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)

This is a quite nice fix.

> >  	set $init_t=&init_task
> >  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >+		set var $stackp = $next_t.thread.sp
> >  		set var $stack_top = ($stackp & ~4095) + 4096
> >  		while ($stackp < $stack_top)
> >@@ -31,12 +31,12 @@ define bttnobp
> >  			end
> >  			set $stackp += 4
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  			printf "===================\n"
> >-			set var $stackp = $next_t.thread.esp
> >+			set var $stackp = $next_t.thread.sp
> >  			set var $stack_top = ($stackp & ~4095) + 4096
> >  			while ($stackp < $stack_top)
> >@@ -45,7 +45,7 @@ define bttnobp
> >  				end
> >  				set $stackp += 4
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -54,42 +54,43 @@ document bttnobp
> >  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >  end
> >+define btthreadstruct

This is a nice wrapping, but I guess you want to name it as
btthreadstack, right? Since I didn't get at all why it's related to
thread_struct except of getting 'sp'.

> >+	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 $stack_top = ($stackp & ~4095) + 4096
> >+	set var $stack_bot = ($stackp & ~4095)
> >+
> >+	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 btthreadstruct
> >+	 dump a thread stack using the given task structure pointer
> >+end
> >+
> >+
> >  define btt
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >-		set var $stack_top = ($stackp & ~4095) + 4096
> >-		set var $stack_bot = ($stackp & ~4095)
> >+		btthreadstruct $next_t
> >-		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-			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_th->pids[1].pid_list.next) - $pid_off)
> >+			btthreadstruct $next_th
> >+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
> >  		end
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -101,7 +102,7 @@ end
> >  define btpid
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -113,29 +114,18 @@ define btpid
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> >-	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
> >+	btthreadstruct $pid_task
> >  end
> >  document btpid
> >  	backtrace of pid
> >@@ -145,7 +135,7 @@ end
> >  define trapinfo
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -157,13 +147,13 @@ define trapinfo
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-09  5:18     ` Baoquan He
  0 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-09  5:18 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

Hi Corey,

I am trying to review this patch now, and these fixes contained are very
great. Just several concerns are added in inline comment.

By the way, did you run this in your side?

Hi Vivek,

Member variable was added into task_struct in below commit replacing
pids[PIDTYPE_TGID], and from then on nobody complained about it. Seems
people rarely use this utility.

commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3
Author: Oleg Nesterov <oleg@tv-sign.ru>
Date:   Tue Mar 28 16:11:25 2006 -0800

    [PATCH] pids: kill PIDTYPE_TGID



On 04/27/16 at 07:21am, Corey Minyard wrote:
> Any comments on this?  If no one else cares I'd be willing to take over
> maintenance of this.
> 
> -corey
> 
> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
> >From: Corey Minyard <cminyard@mvista.com>
> >
> >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.
> >
> >Signed-off-by: Corey Minyard <cminyard@mvista.com>
> >---
> >  Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
> >  1 file changed, 40 insertions(+), 50 deletions(-)
> >
> >I sent this earlier, but I didn't get a response.  These are clearly
> >wrong.  I'd be happy to take over maintenance of these macros.  It
> >might be better to move them someplace else, too, since they are also
> >useful for kgdb.
> >
> >diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >index 9b9b454..e5bbd8d 100644
> >--- a/Documentation/kdump/gdbmacros.txt
> >+++ b/Documentation/kdump/gdbmacros.txt
> >@@ -15,14 +15,14 @@
> >  define bttnobp
> >  	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)

This is a quite nice fix.

> >  	set $init_t=&init_task
> >  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >+		set var $stackp = $next_t.thread.sp
> >  		set var $stack_top = ($stackp & ~4095) + 4096
> >  		while ($stackp < $stack_top)
> >@@ -31,12 +31,12 @@ define bttnobp
> >  			end
> >  			set $stackp += 4
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >  			printf "===================\n"
> >-			set var $stackp = $next_t.thread.esp
> >+			set var $stackp = $next_t.thread.sp
> >  			set var $stack_top = ($stackp & ~4095) + 4096
> >  			while ($stackp < $stack_top)
> >@@ -45,7 +45,7 @@ define bttnobp
> >  				end
> >  				set $stackp += 4
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -54,42 +54,43 @@ document bttnobp
> >  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >  end
> >+define btthreadstruct

This is a nice wrapping, but I guess you want to name it as
btthreadstack, right? Since I didn't get at all why it's related to
thread_struct except of getting 'sp'.

> >+	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 $stack_top = ($stackp & ~4095) + 4096
> >+	set var $stack_bot = ($stackp & ~4095)
> >+
> >+	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 btthreadstruct
> >+	 dump a thread stack using the given task structure pointer
> >+end
> >+
> >+
> >  define btt
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	while ($next_t != $init_t)
> >  		set $next_t=(struct task_struct *)$next_t
> >-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-		printf "===================\n"
> >-		set var $stackp = $next_t.thread.esp
> >-		set var $stack_top = ($stackp & ~4095) + 4096
> >-		set var $stack_bot = ($stackp & ~4095)
> >+		btthreadstruct $next_t
> >-		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >-			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_th->pids[1].pid_list.next) - $pid_off)
> >+			btthreadstruct $next_th
> >+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
> >  		end
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >@@ -101,7 +102,7 @@ end
> >  define btpid
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -113,29 +114,18 @@ define btpid
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end
> >-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
> >-	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
> >+	btthreadstruct $pid_task
> >  end
> >  document btpid
> >  	backtrace of pid
> >@@ -145,7 +135,7 @@ end
> >  define trapinfo
> >  	set var $pid = $arg0
> >  	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >  	set var $pid_task = 0
> >@@ -157,13 +147,13 @@ define trapinfo
> >  			set $pid_task = $next_t
> >  		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)
> >  			set $next_th=(struct task_struct *)$next_th
> >  			if ($next_th.pid == $pid)
> >  				set $pid_task = $next_th
> >  			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
> >  		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
> >  	end

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-05-09  5:18     ` Baoquan He
@ 2016-05-09 12:10       ` Corey Minyard
  -1 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-05-09 12:10 UTC (permalink / raw)
  To: Baoquan He
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, Corey Minyard, dyoung

On 05/09/2016 12:18 AM, Baoquan He wrote:
> Hi Corey,
>
> I am trying to review this patch now, and these fixes contained are very
> great. Just several concerns are added in inline comment.
>
> By the way, did you run this in your side?

Yes, I tested on x86, x86_64, ARM and MIPS.

Comments inline...


> Hi Vivek,
>
> Member variable was added into task_struct in below commit replacing
> pids[PIDTYPE_TGID], and from then on nobody complained about it. Seems
> people rarely use this utility.
>
> commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3
> Author: Oleg Nesterov <oleg@tv-sign.ru>
> Date:   Tue Mar 28 16:11:25 2006 -0800
>
>      [PATCH] pids: kill PIDTYPE_TGID
>
>
>
> On 04/27/16 at 07:21am, Corey Minyard wrote:
>> Any comments on this?  If no one else cares I'd be willing to take over
>> maintenance of this.
>>
>> -corey
>>
>> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
>>> From: Corey Minyard <cminyard@mvista.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>>> ---
>>>   Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
>>>   1 file changed, 40 insertions(+), 50 deletions(-)
>>>
>>> I sent this earlier, but I didn't get a response.  These are clearly
>>> wrong.  I'd be happy to take over maintenance of these macros.  It
>>> might be better to move them someplace else, too, since they are also
>>> useful for kgdb.
>>>
>>> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
>>> index 9b9b454..e5bbd8d 100644
>>> --- a/Documentation/kdump/gdbmacros.txt
>>> +++ b/Documentation/kdump/gdbmacros.txt
>>> @@ -15,14 +15,14 @@
>>>   define bttnobp
>>>   	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)
> This is a quite nice fix.
>
>>>   	set $init_t=&init_task
>>>   	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	while ($next_t != $init_t)
>>>   		set $next_t=(struct task_struct *)$next_t
>>>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>   		printf "===================\n"
>>> -		set var $stackp = $next_t.thread.esp
>>> +		set var $stackp = $next_t.thread.sp
>>>   		set var $stack_top = ($stackp & ~4095) + 4096
>>>   		while ($stackp < $stack_top)
>>> @@ -31,12 +31,12 @@ define bttnobp
>>>   			end
>>>   			set $stackp += 4
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>   			printf "===================\n"
>>> -			set var $stackp = $next_t.thread.esp
>>> +			set var $stackp = $next_t.thread.sp
>>>   			set var $stack_top = ($stackp & ~4095) + 4096
>>>   			while ($stackp < $stack_top)
>>> @@ -45,7 +45,7 @@ define bttnobp
>>>   				end
>>>   				set $stackp += 4
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> @@ -54,42 +54,43 @@ document bttnobp
>>>   	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
>>>   end
>>> +define btthreadstruct
> This is a nice wrapping, but I guess you want to name it as
> btthreadstack, right? Since I didn't get at all why it's related to
> thread_struct except of getting 'sp'.
>

The name is based on what is passed into the function.  You do a 
backtrace when given a thread structure.  In my experience it is best to 
name functions based upon how the function's user sees it. Though I'm 
not stuck on the name, if you would prefer 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 $stack_top = ($stackp & ~4095) + 4096
>>> +	set var $stack_bot = ($stackp & ~4095)
>>> +
>>> +	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 btthreadstruct
>>> +	 dump a thread stack using the given task structure pointer
>>> +end
>>> +
>>> +
>>>   define btt
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	while ($next_t != $init_t)
>>>   		set $next_t=(struct task_struct *)$next_t
>>> -		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>> -		printf "===================\n"
>>> -		set var $stackp = $next_t.thread.esp
>>> -		set var $stack_top = ($stackp & ~4095) + 4096
>>> -		set var $stack_bot = ($stackp & ~4095)
>>> +		btthreadstruct $next_t
>>> -		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>> -			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>> -			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_th->pids[1].pid_list.next) - $pid_off)
>>> +			btthreadstruct $next_th
>>> +			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
>>>   		end
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> @@ -101,7 +102,7 @@ end
>>>   define btpid
>>>   	set var $pid = $arg0
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	set var $pid_task = 0
>>> @@ -113,29 +114,18 @@ define btpid
>>>   			set $pid_task = $next_t
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			if ($next_th.pid == $pid)
>>>   				set $pid_task = $next_th
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> -	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
>>> -	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
>>> +	btthreadstruct $pid_task
>>>   end
>>>   document btpid
>>>   	backtrace of pid
>>> @@ -145,7 +135,7 @@ end
>>>   define trapinfo
>>>   	set var $pid = $arg0
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	set var $pid_task = 0
>>> @@ -157,13 +147,13 @@ define trapinfo
>>>   			set $pid_task = $next_t
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			if ($next_th.pid == $pid)
>>>   				set $pid_task = $next_th
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-09 12:10       ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-05-09 12:10 UTC (permalink / raw)
  To: Baoquan He
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

On 05/09/2016 12:18 AM, Baoquan He wrote:
> Hi Corey,
>
> I am trying to review this patch now, and these fixes contained are very
> great. Just several concerns are added in inline comment.
>
> By the way, did you run this in your side?

Yes, I tested on x86, x86_64, ARM and MIPS.

Comments inline...


> Hi Vivek,
>
> Member variable was added into task_struct in below commit replacing
> pids[PIDTYPE_TGID], and from then on nobody complained about it. Seems
> people rarely use this utility.
>
> commit 47e65328a7b1cdfc4e3102e50d60faf94ebba7d3
> Author: Oleg Nesterov <oleg@tv-sign.ru>
> Date:   Tue Mar 28 16:11:25 2006 -0800
>
>      [PATCH] pids: kill PIDTYPE_TGID
>
>
>
> On 04/27/16 at 07:21am, Corey Minyard wrote:
>> Any comments on this?  If no one else cares I'd be willing to take over
>> maintenance of this.
>>
>> -corey
>>
>> On 02/25/2016 07:51 AM, minyard@acm.org wrote:
>>> From: Corey Minyard <cminyard@mvista.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>>> ---
>>>   Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
>>>   1 file changed, 40 insertions(+), 50 deletions(-)
>>>
>>> I sent this earlier, but I didn't get a response.  These are clearly
>>> wrong.  I'd be happy to take over maintenance of these macros.  It
>>> might be better to move them someplace else, too, since they are also
>>> useful for kgdb.
>>>
>>> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
>>> index 9b9b454..e5bbd8d 100644
>>> --- a/Documentation/kdump/gdbmacros.txt
>>> +++ b/Documentation/kdump/gdbmacros.txt
>>> @@ -15,14 +15,14 @@
>>>   define bttnobp
>>>   	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)
> This is a quite nice fix.
>
>>>   	set $init_t=&init_task
>>>   	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	while ($next_t != $init_t)
>>>   		set $next_t=(struct task_struct *)$next_t
>>>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>   		printf "===================\n"
>>> -		set var $stackp = $next_t.thread.esp
>>> +		set var $stackp = $next_t.thread.sp
>>>   		set var $stack_top = ($stackp & ~4095) + 4096
>>>   		while ($stackp < $stack_top)
>>> @@ -31,12 +31,12 @@ define bttnobp
>>>   			end
>>>   			set $stackp += 4
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>   			printf "===================\n"
>>> -			set var $stackp = $next_t.thread.esp
>>> +			set var $stackp = $next_t.thread.sp
>>>   			set var $stack_top = ($stackp & ~4095) + 4096
>>>   			while ($stackp < $stack_top)
>>> @@ -45,7 +45,7 @@ define bttnobp
>>>   				end
>>>   				set $stackp += 4
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> @@ -54,42 +54,43 @@ document bttnobp
>>>   	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
>>>   end
>>> +define btthreadstruct
> This is a nice wrapping, but I guess you want to name it as
> btthreadstack, right? Since I didn't get at all why it's related to
> thread_struct except of getting 'sp'.
>

The name is based on what is passed into the function.  You do a 
backtrace when given a thread structure.  In my experience it is best to 
name functions based upon how the function's user sees it. Though I'm 
not stuck on the name, if you would prefer 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 $stack_top = ($stackp & ~4095) + 4096
>>> +	set var $stack_bot = ($stackp & ~4095)
>>> +
>>> +	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 btthreadstruct
>>> +	 dump a thread stack using the given task structure pointer
>>> +end
>>> +
>>> +
>>>   define btt
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	while ($next_t != $init_t)
>>>   		set $next_t=(struct task_struct *)$next_t
>>> -		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>> -		printf "===================\n"
>>> -		set var $stackp = $next_t.thread.esp
>>> -		set var $stack_top = ($stackp & ~4095) + 4096
>>> -		set var $stack_bot = ($stackp & ~4095)
>>> +		btthreadstruct $next_t
>>> -		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>> -			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>> -			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_th->pids[1].pid_list.next) - $pid_off)
>>> +			btthreadstruct $next_th
>>> +			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
>>>   		end
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> @@ -101,7 +102,7 @@ end
>>>   define btpid
>>>   	set var $pid = $arg0
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	set var $pid_task = 0
>>> @@ -113,29 +114,18 @@ define btpid
>>>   			set $pid_task = $next_t
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			if ($next_th.pid == $pid)
>>>   				set $pid_task = $next_th
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end
>>> -	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
>>> -	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
>>> +	btthreadstruct $pid_task
>>>   end
>>>   document btpid
>>>   	backtrace of pid
>>> @@ -145,7 +135,7 @@ end
>>>   define trapinfo
>>>   	set var $pid = $arg0
>>>   	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>   	set var $pid_task = 0
>>> @@ -157,13 +147,13 @@ define trapinfo
>>>   			set $pid_task = $next_t
>>>   		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)
>>>   			set $next_th=(struct task_struct *)$next_th
>>>   			if ($next_th.pid == $pid)
>>>   				set $pid_task = $next_th
>>>   			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
>>>   		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
>>>   	end


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-05-09 12:10       ` Corey Minyard
@ 2016-05-09 14:29         ` Baoquan He
  -1 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-09 14:29 UTC (permalink / raw)
  To: Corey Minyard
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, Corey Minyard, dyoung

On 05/09/16 at 07:10am, Corey Minyard wrote:
> On 05/09/2016 12:18 AM, Baoquan He wrote:
> >Hi Corey,
> >
> >I am trying to review this patch now, and these fixes contained are very
> >great. Just several concerns are added in inline comment.
> >
> >By the way, did you run this in your side?
> 
> Yes, I tested on x86, x86_64, ARM and MIPS.
> 
> Comments inline...

That's awesome. I will have a try too.

> >>>diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >>>index 9b9b454..e5bbd8d 100644
> >>>--- a/Documentation/kdump/gdbmacros.txt
> >>>+++ b/Documentation/kdump/gdbmacros.txt
> >>>@@ -15,14 +15,14 @@
> >>>  define bttnobp
> >>>  	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)
> >This is a quite nice fix.
> >
> >>>  	set $init_t=&init_task
> >>>  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >>>  	while ($next_t != $init_t)
> >>>  		set $next_t=(struct task_struct *)$next_t
> >>>  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >>>  		printf "===================\n"
> >>>-		set var $stackp = $next_t.thread.esp
> >>>+		set var $stackp = $next_t.thread.sp
> >>>  		set var $stack_top = ($stackp & ~4095) + 4096

Missed one place here. Currently the kernel stack is decided by
THREAD_SIZE since the definition:

union thread_union {
        struct thread_info thread_info;
        unsigned long stack[THREAD_SIZE/sizeof(long)];
};

Should we get the top and bottom of stack according to this now?

Correct me if I was wrong.

Thanks
Baoquan

> >>>  		while ($stackp < $stack_top)
> >>>@@ -31,12 +31,12 @@ define bttnobp
> >>>  			end
> >>>  			set $stackp += 4
> >>>  		end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-09 14:29         ` Baoquan He
  0 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-09 14:29 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

On 05/09/16 at 07:10am, Corey Minyard wrote:
> On 05/09/2016 12:18 AM, Baoquan He wrote:
> >Hi Corey,
> >
> >I am trying to review this patch now, and these fixes contained are very
> >great. Just several concerns are added in inline comment.
> >
> >By the way, did you run this in your side?
> 
> Yes, I tested on x86, x86_64, ARM and MIPS.
> 
> Comments inline...

That's awesome. I will have a try too.

> >>>diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >>>index 9b9b454..e5bbd8d 100644
> >>>--- a/Documentation/kdump/gdbmacros.txt
> >>>+++ b/Documentation/kdump/gdbmacros.txt
> >>>@@ -15,14 +15,14 @@
> >>>  define bttnobp
> >>>  	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)
> >This is a quite nice fix.
> >
> >>>  	set $init_t=&init_task
> >>>  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >>>  	while ($next_t != $init_t)
> >>>  		set $next_t=(struct task_struct *)$next_t
> >>>  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >>>  		printf "===================\n"
> >>>-		set var $stackp = $next_t.thread.esp
> >>>+		set var $stackp = $next_t.thread.sp
> >>>  		set var $stack_top = ($stackp & ~4095) + 4096

Missed one place here. Currently the kernel stack is decided by
THREAD_SIZE since the definition:

union thread_union {
        struct thread_info thread_info;
        unsigned long stack[THREAD_SIZE/sizeof(long)];
};

Should we get the top and bottom of stack according to this now?

Correct me if I was wrong.

Thanks
Baoquan

> >>>  		while ($stackp < $stack_top)
> >>>@@ -31,12 +31,12 @@ define bttnobp
> >>>  			end
> >>>  			set $stackp += 4
> >>>  		end

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-05-09 14:29         ` Baoquan He
@ 2016-05-09 15:40           ` Corey Minyard
  -1 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-05-09 15:40 UTC (permalink / raw)
  To: Baoquan He, Corey Minyard
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, dyoung

On 05/09/2016 09:29 AM, Baoquan He wrote:
> On 05/09/16 at 07:10am, Corey Minyard wrote:
>> On 05/09/2016 12:18 AM, Baoquan He wrote:
>>> Hi Corey,
>>>
>>> I am trying to review this patch now, and these fixes contained are very
>>> great. Just several concerns are added in inline comment.
>>>
>>> By the way, did you run this in your side?
>> Yes, I tested on x86, x86_64, ARM and MIPS.
>>
>> Comments inline...
> That's awesome. I will have a try too.
>
>>>>> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
>>>>> index 9b9b454..e5bbd8d 100644
>>>>> --- a/Documentation/kdump/gdbmacros.txt
>>>>> +++ b/Documentation/kdump/gdbmacros.txt
>>>>> @@ -15,14 +15,14 @@
>>>>>   define bttnobp
>>>>>   	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)
>>> This is a quite nice fix.
>>>
>>>>>   	set $init_t=&init_task
>>>>>   	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>>>   	while ($next_t != $init_t)
>>>>>   		set $next_t=(struct task_struct *)$next_t
>>>>>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>>>   		printf "===================\n"
>>>>> -		set var $stackp = $next_t.thread.esp
>>>>> +		set var $stackp = $next_t.thread.sp
>>>>>   		set var $stack_top = ($stackp & ~4095) + 4096
> Missed one place here. Currently the kernel stack is decided by
> THREAD_SIZE since the definition:
>
> union thread_union {
>          struct thread_info thread_info;
>          unsigned long stack[THREAD_SIZE/sizeof(long)];
> };
>
> Should we get the top and bottom of stack according to this now?
>
> Correct me if I was wrong.

I think you are correct.  We should use something like:

    set var $stack_top = ($stackp & ~(sizeof(thread_union) - 1)) +
    sizeof(thread_union)

Is this what you are suggesting?

-corey

>
> Thanks
> Baoquan
>
>>>>>   		while ($stackp < $stack_top)
>>>>> @@ -31,12 +31,12 @@ define bttnobp
>>>>>   			end
>>>>>   			set $stackp += 4
>>>>>   		end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-09 15:40           ` Corey Minyard
  0 siblings, 0 replies; 19+ messages in thread
From: Corey Minyard @ 2016-05-09 15:40 UTC (permalink / raw)
  To: Baoquan He, Corey Minyard
  Cc: Haren Myneni, dyoung, kexec, linux-kernel, Vivek Goyal

On 05/09/2016 09:29 AM, Baoquan He wrote:
> On 05/09/16 at 07:10am, Corey Minyard wrote:
>> On 05/09/2016 12:18 AM, Baoquan He wrote:
>>> Hi Corey,
>>>
>>> I am trying to review this patch now, and these fixes contained are very
>>> great. Just several concerns are added in inline comment.
>>>
>>> By the way, did you run this in your side?
>> Yes, I tested on x86, x86_64, ARM and MIPS.
>>
>> Comments inline...
> That's awesome. I will have a try too.
>
>>>>> diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
>>>>> index 9b9b454..e5bbd8d 100644
>>>>> --- a/Documentation/kdump/gdbmacros.txt
>>>>> +++ b/Documentation/kdump/gdbmacros.txt
>>>>> @@ -15,14 +15,14 @@
>>>>>   define bttnobp
>>>>>   	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)
>>> This is a quite nice fix.
>>>
>>>>>   	set $init_t=&init_task
>>>>>   	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
>>>>>   	while ($next_t != $init_t)
>>>>>   		set $next_t=(struct task_struct *)$next_t
>>>>>   		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
>>>>>   		printf "===================\n"
>>>>> -		set var $stackp = $next_t.thread.esp
>>>>> +		set var $stackp = $next_t.thread.sp
>>>>>   		set var $stack_top = ($stackp & ~4095) + 4096
> Missed one place here. Currently the kernel stack is decided by
> THREAD_SIZE since the definition:
>
> union thread_union {
>          struct thread_info thread_info;
>          unsigned long stack[THREAD_SIZE/sizeof(long)];
> };
>
> Should we get the top and bottom of stack according to this now?
>
> Correct me if I was wrong.

I think you are correct.  We should use something like:

    set var $stack_top = ($stackp & ~(sizeof(thread_union) - 1)) +
    sizeof(thread_union)

Is this what you are suggesting?

-corey

>
> Thanks
> Baoquan
>
>>>>>   		while ($stackp < $stack_top)
>>>>> @@ -31,12 +31,12 @@ define bttnobp
>>>>>   			end
>>>>>   			set $stackp += 4
>>>>>   		end


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-05-09 15:40           ` Corey Minyard
@ 2016-05-10  1:37             ` Baoquan He
  -1 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-10  1:37 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Vivek Goyal, Haren Myneni, dyoung

On 05/09/16 at 10:40am, Corey Minyard wrote:
> >>>>>  define bttnobp
> >>>>>  	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)
> >>>This is a quite nice fix.
> >>>
> >>>>>  	set $init_t=&init_task
> >>>>>  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >>>>>  	while ($next_t != $init_t)
> >>>>>  		set $next_t=(struct task_struct *)$next_t
> >>>>>  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >>>>>  		printf "===================\n"
> >>>>>-		set var $stackp = $next_t.thread.esp
> >>>>>+		set var $stackp = $next_t.thread.sp
> >>>>>  		set var $stack_top = ($stackp & ~4095) + 4096
> >Missed one place here. Currently the kernel stack is decided by
> >THREAD_SIZE since the definition:
> >
> >union thread_union {
> >         struct thread_info thread_info;
> >         unsigned long stack[THREAD_SIZE/sizeof(long)];
> >};
> >
> >Should we get the top and bottom of stack according to this now?
> >
> >Correct me if I was wrong.
> 
> I think you are correct.  We should use something like:
> 
>    set var $stack_top = ($stackp & ~(sizeof(thread_union) - 1)) +
>    sizeof(thread_union)
> 
> Is this what you are suggesting?

Exactly, it's cool. Thanks!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-10  1:37             ` Baoquan He
  0 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-10  1:37 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

On 05/09/16 at 10:40am, Corey Minyard wrote:
> >>>>>  define bttnobp
> >>>>>  	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)
> >>>This is a quite nice fix.
> >>>
> >>>>>  	set $init_t=&init_task
> >>>>>  	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
> >>>>>  	while ($next_t != $init_t)
> >>>>>  		set $next_t=(struct task_struct *)$next_t
> >>>>>  		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
> >>>>>  		printf "===================\n"
> >>>>>-		set var $stackp = $next_t.thread.esp
> >>>>>+		set var $stackp = $next_t.thread.sp
> >>>>>  		set var $stack_top = ($stackp & ~4095) + 4096
> >Missed one place here. Currently the kernel stack is decided by
> >THREAD_SIZE since the definition:
> >
> >union thread_union {
> >         struct thread_info thread_info;
> >         unsigned long stack[THREAD_SIZE/sizeof(long)];
> >};
> >
> >Should we get the top and bottom of stack according to this now?
> >
> >Correct me if I was wrong.
> 
> I think you are correct.  We should use something like:
> 
>    set var $stack_top = ($stackp & ~(sizeof(thread_union) - 1)) +
>    sizeof(thread_union)
> 
> Is this what you are suggesting?

Exactly, it's cool. Thanks!



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
  2016-05-09 12:10       ` Corey Minyard
@ 2016-05-10  1:48         ` Baoquan He
  -1 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-10  1:48 UTC (permalink / raw)
  To: Corey Minyard
  Cc: kexec, linux-kernel, Vivek Goyal, Haren Myneni, Corey Minyard, dyoung

Hi Corey,

On 05/09/16 at 07:10am, Corey Minyard wrote:
> >>>diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >>>index 9b9b454..e5bbd8d 100644
> >>>--- a/Documentation/kdump/gdbmacros.txt
> >>>+++ b/Documentation/kdump/gdbmacros.txt
> >>>@@ -54,42 +54,43 @@ document bttnobp
> >>>  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >>>  end
> >>>+define btthreadstruct
> >This is a nice wrapping, but I guess you want to name it as
> >btthreadstack, right? Since I didn't get at all why it's related to
> >thread_struct except of getting 'sp'.
> >
> 
> The name is based on what is passed into the function.  You do a
> backtrace when given a thread structure.  In my experience it is
> best to name functions based upon how the function's user sees it.
> Though I'm not stuck on the name, if you would prefer btthreadstack.

About the name, in fact a task struct is passed in. Mainly there's a
thread_struct defined in x86 ARCH, I thought you are handling
thread_struct related things when I look at the first glance.
btthreadstack is far better name that that, I like it.

******************************
arch/x86/include/asm/processor.h
struct thread_struct {         
        /* Cached TLS descriptors: */   
        struct desc_struct      tls_array[GDT_ENTRY_TLS_ENTRIES];
        unsigned long           sp0;    
        unsigned long           sp;     
#ifdef CONFIG_X86_32           
        unsigned long           sysenter_cs;
#else
......
}

Thanks
Baoquan

> 
> >>>+	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 $stack_top = ($stackp & ~4095) + 4096
> >>>+	set var $stack_bot = ($stackp & ~4095)
> >>>+
> >>>+	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 btthreadstruct
> >>>+	 dump a thread stack using the given task structure pointer
> >>>+end

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-05-10  1:48         ` Baoquan He
  0 siblings, 0 replies; 19+ messages in thread
From: Baoquan He @ 2016-05-10  1:48 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Corey Minyard, kexec, linux-kernel, Haren Myneni, dyoung, Vivek Goyal

Hi Corey,

On 05/09/16 at 07:10am, Corey Minyard wrote:
> >>>diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
> >>>index 9b9b454..e5bbd8d 100644
> >>>--- a/Documentation/kdump/gdbmacros.txt
> >>>+++ b/Documentation/kdump/gdbmacros.txt
> >>>@@ -54,42 +54,43 @@ document bttnobp
> >>>  	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
> >>>  end
> >>>+define btthreadstruct
> >This is a nice wrapping, but I guess you want to name it as
> >btthreadstack, right? Since I didn't get at all why it's related to
> >thread_struct except of getting 'sp'.
> >
> 
> The name is based on what is passed into the function.  You do a
> backtrace when given a thread structure.  In my experience it is
> best to name functions based upon how the function's user sees it.
> Though I'm not stuck on the name, if you would prefer btthreadstack.

About the name, in fact a task struct is passed in. Mainly there's a
thread_struct defined in x86 ARCH, I thought you are handling
thread_struct related things when I look at the first glance.
btthreadstack is far better name that that, I like it.

******************************
arch/x86/include/asm/processor.h
struct thread_struct {         
        /* Cached TLS descriptors: */   
        struct desc_struct      tls_array[GDT_ENTRY_TLS_ENTRIES];
        unsigned long           sp0;    
        unsigned long           sp;     
#ifdef CONFIG_X86_32           
        unsigned long           sysenter_cs;
#else
......
}

Thanks
Baoquan

> 
> >>>+	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 $stack_top = ($stackp & ~4095) + 4096
> >>>+	set var $stack_bot = ($stackp & ~4095)
> >>>+
> >>>+	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 btthreadstruct
> >>>+	 dump a thread stack using the given task structure pointer
> >>>+end

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels
@ 2016-01-19 16:57 minyard
  0 siblings, 0 replies; 19+ messages in thread
From: minyard @ 2016-01-19 16:57 UTC (permalink / raw)
  To: Vivek Goyal, Haren Myneni, kexec; +Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

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.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 Documentation/kdump/gdbmacros.txt | 90 +++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 50 deletions(-)

diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
index 9b9b454..e5bbd8d 100644
--- a/Documentation/kdump/gdbmacros.txt
+++ b/Documentation/kdump/gdbmacros.txt
@@ -15,14 +15,14 @@
 
 define bttnobp
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
 		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
+		set var $stackp = $next_t.thread.sp
 		set var $stack_top = ($stackp & ~4095) + 4096
 
 		while ($stackp < $stack_top)
@@ -31,12 +31,12 @@ define bttnobp
 			end
 			set $stackp += 4
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
 			printf "===================\n"
-			set var $stackp = $next_t.thread.esp
+			set var $stackp = $next_t.thread.sp
 			set var $stack_top = ($stackp & ~4095) + 4096
 
 			while ($stackp < $stack_top)
@@ -45,7 +45,7 @@ define bttnobp
 				end
 				set $stackp += 4
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -54,42 +54,43 @@ document bttnobp
 	dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER
 end
 
+define btthreadstruct
+	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 $stack_top = ($stackp & ~4095) + 4096
+	set var $stack_bot = ($stackp & ~4095)
+
+	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 btthreadstruct
+	 dump a thread stack using the given task structure pointer
+end
+
+
 define btt
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	while ($next_t != $init_t)
 		set $next_t=(struct task_struct *)$next_t
-		printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-		printf "===================\n"
-		set var $stackp = $next_t.thread.esp
-		set var $stack_top = ($stackp & ~4095) + 4096
-		set var $stack_bot = ($stackp & ~4095)
+		btthreadstruct $next_t
 
-		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)
 			set $next_th=(struct task_struct *)$next_th
-			printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm
-			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_th->pids[1].pid_list.next) - $pid_off)
+			btthreadstruct $next_th
+			set $next_th=(((char *)$next_th->thread_group.next) - $pid_off)
 		end
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
@@ -101,7 +102,7 @@ end
 define btpid
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -113,29 +114,18 @@ define btpid
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
 
-	printf "\npid %d; comm %s:\n", $pid_task.pid, $pid_task.comm
-	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
+	btthreadstruct $pid_task
 end
 document btpid
 	backtrace of pid
@@ -145,7 +135,7 @@ end
 define trapinfo
 	set var $pid = $arg0
 	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 $next_t=(((char *)($init_t->tasks).next) - $tasks_off)
 	set var $pid_task = 0
@@ -157,13 +147,13 @@ define trapinfo
 			set $pid_task = $next_t
 		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)
 			set $next_th=(struct task_struct *)$next_th
 			if ($next_th.pid == $pid)
 				set $pid_task = $next_th
 			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
 		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
 	end
-- 
2.5.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-05-10  1:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 13:51 [PATCH] kdump: Fix gdb macros work work with newer and 64-bit kernels minyard
2016-02-25 13:51 ` minyard
2016-04-27 12:21 ` Corey Minyard
2016-04-27 12:21   ` Corey Minyard
2016-05-05  2:37   ` Baoquan He
2016-05-05  2:37     ` Baoquan He
2016-05-09  5:18   ` Baoquan He
2016-05-09  5:18     ` Baoquan He
2016-05-09 12:10     ` Corey Minyard
2016-05-09 12:10       ` Corey Minyard
2016-05-09 14:29       ` Baoquan He
2016-05-09 14:29         ` Baoquan He
2016-05-09 15:40         ` Corey Minyard
2016-05-09 15:40           ` Corey Minyard
2016-05-10  1:37           ` Baoquan He
2016-05-10  1:37             ` Baoquan He
2016-05-10  1:48       ` Baoquan He
2016-05-10  1:48         ` Baoquan He
  -- strict thread matches above, loose matches on Subject: below --
2016-01-19 16:57 minyard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.