login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
October
»
15
Re:
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
[view in full thread]
From: Vivek Goyal
Subject:
Re:
Date: Wednesday, October 15, 2008 - 2:32 pm
On Wed, Oct 15, 2008 at 04:04:47PM +0800, Qinghuang Feng wrote:
quoted text
> This patch is for linus-git, and it do the following: > > 1.updates macros in the file to fix the following errors: > (gdb) btt > There is no member named pid_list. > (gdb) bttnobp > There is no member named pid_list. > > 2.fix bugs in two places when iterateing thread members in a thread group > > original macro: > 16 define bttnobp > .... > 21 while ($next_t != $init_t) > ... > 34 set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) > 35 while ($next_th != $next_t) > 36 set $next_th=(struct task_struct *)$next_th > 37 printf "\npid %d; comm %s:\n", $next_t.pid, $next_t.comm > now, we should print info about the thread member, but it print > info of threadgroup leader repeatly. > ... >
CCing people who contributed these macros. They should be able to have a look at it. Thanks Vivek
quoted text
> 3.introduce two auxiliary macros: psusr and pskern to list info of all tasks > viewed in userspace and kernelspace respectively. > > The following is the testing result, bu it is test in X86 and kgdb remote > debugging environment: > a.out is a muti-thread program, and one of its threads exec the "top". > (gdb) pskern > address state uid pid ppid comm > 0xC03512F4 running 0 0 0 swapper > .... > 0xD9418180 sleeping 0 2379 2371 bash > 0xD94191C0 sleeping 0 2383 2379 a.out > 0xDC52DA20 sleeping 0 2384 2379 a.out > 0xDC52D610 sleeping 0 2385 2379 a.out > 0xDC52D200 sleeping 0 2386 2379 a.out > 0xDC52CDF0 sleeping 0 2387 2386 top > address state uid pid ppid comm > (gdb) btt > .... > pid 2379; addr:0xd9418180; comm bash: > ===================================== > do_wait + 2227 in section .text > sys_wait4 + 121 in section .text > sys_waitpid + 19 in section .text > ia32_sysenter_target + 127 in section .text > > pid 2383; addr:0xd94191c0; comm a.out: > ===================================== > do_nanosleep + 84 in section .text > hrtimer_nanosleep + 74 in section .text > sys_nanosleep + 66 in section .text > ia32_sysenter_target + 127 in section .text > > pid 2384; addr:0xdc52da20; comm a.out: > ===================================== > do_nanosleep + 84 in section .text > hrtimer_nanosleep + 74 in section .text > sys_nanosleep + 66 in section .text > ia32_sysenter_target + 127 in section .text > > pid 2385; addr:0xdc52d610; comm a.out: > ---Type <return> to continue, or q <return> to quit--- > ===================================== > do_nanosleep + 84 in section .text > hrtimer_nanosleep + 74 in section .text > sys_nanosleep + 66 in section .text > ia32_sysenter_target + 127 in section .text > > pid 2386; addr:0xdc52d200; comm a.out: > ===================================== > do_wait + 2227 in section .text > sys_wait4 + 121 in section .text > sys_waitpid + 19 in section .text > ia32_sysenter_target + 127 in section .text > > pid 2387; addr:0xdc52cdf0; comm top: > ===================================== > schedule_timeout + 109 in section .text > do_select + 1081 in section .text > core_sys_select + 440 in section .text > sys_select + 143 in section .text > ia32_sysenter_target + 127 in section .text > > > Signed-off-by: Qinghuang Feng <qhfeng.kernel@gmail.com> > --- > diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt > index 9b9b454..c286da1 100644 > --- a/Documentation/kdump/gdbmacros.txt > +++ b/Documentation/kdump/gdbmacros.txt > @@ -13,39 +13,146 @@ > # Maneesh Soni <maneesh@in.ibm.com> > # > > +define __show_state > + if ($arg0->state == 0) > + printf "running\t\t" > + else > + if ($arg0->state == 1) > + printf "sleeping\t" > + else > + if ($arg0->state == 2) > + printf "disksleep\t" > + else > + if ($arg0->state == 4) > + printf "zombie\t" > + else > + if ($arg0->state == 8) > + printf "stopped\t" > + else > + if ($arg0->state == 16) > + printf "wpaging\t" > + else > + printf "%d\t\t", $arg0->state > + end > + end > + end > + end > + end > + end > +end > +document __show_state > +internel macro, don't call it by hand > +end > + > + > +define psusr > + printf "address\t\tstate\t\tuid\tpid\tppid\tcomm\n" > + set $init_t = &init_task > + set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) > + set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) > + > + while ($next_t != $init_t) > + set $next_t=(struct task_struct *)$next_t > + printf "0x%08X\t", $next_t > + show_state $next_t > + printf "%d\t%d\t%d\t%s\n", \ > + $next_t->uid, $next_t->pid, \ > + $next_t->parent->pid, $next_t->comm > + set $next_t=(char *)($next_t->tasks.next) - $tasks_off > + end > + > + printf "address\t\tstate\t\tuid\tpid\tppid\tcomm\n" > + printf "----end----\n" > + > +end > +document psusr > +print information for all tasks, but not including thread members. > +This command looks like "ps -aux" in userspace. > +end > + > + > +define pskern > + printf "address\t\tstate\t\tuid\tpid\tppid\tcomm\n" > + set $init_t = &init_task > + printf "0x%08X\t", $init_t > + __show_state $init_t > + printf "%d\t%d\t%d\t%s\n", \ > + $init_t->uid, $init_t->pid, \ > + $init_t->parent->pid, $init_t->comm > + > + set $tasks_off=((size_t)&((struct task_struct *)0)->tasks) > + set $thread_off=((size_t)&((struct task_struct *)0)->thread_group.next) > + set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) > + > + while ($next_t != $init_t) > + set $next_t=(struct task_struct *)$next_t > + > + printf "0x%08X\t", $next_t > + show_state $next_t > + printf "%d\t%d\t%d\t%s\n", \ > + $next_t->uid, $next_t->pid, \ > + $next_t->parent->pid, $next_t->comm > + > + set $next_th=(((char *)$next_t->thread_group.next) - $thread_off) > + > + while ($next_th != $next_t) > + set $next_th=(struct task_struct *)$next_th > + > + printf "0x%08X\t", $next_th > + show_state $next_th > + printf "%d\t%d\t%d\t%s\n", \ > + $next_th->uid, $next_th->pid, \ > + $next_th->parent->pid, $next_th->comm > + > + set $next_th=(((char *)$next_th->thread_group.next) - $thread_off) > + end > + > + set $next_t=(char *)($next_t->tasks.next) - $tasks_off > + end > + > + printf "address\t\tstate\t\tuid\tpid\tppid\tcomm\n" > + printf "----end----\n" > + > +end > +document pskern > +print infor for all tasks viewed in kernel, including all thread members > +and swapper(PID==0). > +end > + > + > +define __prinfo_nobp > + printf "\npid %d; addr:0x%08x; comm %s:\n", \ > + $arg0.pid, $arg0, $arg0.comm > + printf "=====================================\n" > + set var $stackp = $arg0.thread.sp > + set var $stack_top = ($stackp & ~4095) + 4096 > + > + while ($stackp < $stack_top) > + if (*($stackp) > _stext && *($stackp) < _sinittext) > + info symbol *($stackp) > + end > + set $stackp += 4 > + end > +end > +document __prinfo_nobp > +internal macro, don't call it by hand. > +end > + > + > 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 $thread_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 > - > - while ($stackp < $stack_top) > - if (*($stackp) > _stext && *($stackp) < _sinittext) > - info symbol *($stackp) > - end > - set $stackp += 4 > - end > - set $next_th=(((char *)$next_t->pids[1].pid_list.next) - $pid_off) > + __prinfo_nobp $next_t > + set $next_th=(((char *)$next_t->thread_group.next) - $thread_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 > - > - while ($stackp < $stack_top) > - if (*($stackp) > _stext && *($stackp) < _sinittext) > - info symbol *($stackp) > - end > - set $stackp += 4 > - end > - set $next_th=(((char *)$next_th->pids[1].pid_list.next) - $pid_off) > + __prinfo_nobp $next_th > + set $next_th=(((char *)$next_th->thread_group.next) - $thread_off) > end > set $next_t=(char *)($next_t->tasks.next) - $tasks_off > end > @@ -54,42 +161,41 @@ document bttnobp > dump all thread stack traces on a kernel compiled with !CONFIG_FRAME_POINTER > end > > + > +define __prinfo > + printf "\npid %d; addr:0x%08x; comm %s:\n", \ > + $arg0.pid, $arg0, $arg0.comm > + printf "=====================================\n" > + set var $stackp = $arg0.thread.sp > + set var $stack_top = ($stackp & ~4095) + 4096 > + set var $stack_bot = ($stackp & ~4095) > + > + set $stackp = *($stackp) > + while (($stackp < $stack_top) && ($stackp > $stack_bot)) > + set var $addr = *($stackp + 4) > + info symbol $addr > + set $stackp = *($stackp) > + end > +end > +document __prinfo > +internal macro, don't call it by hand. > +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 $thread_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) > - > - 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) > + __prinfo $next_t > + set $next_th=(((char *)$next_t->thread_group.next) - $thread_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) > + __prinfo $next_th > + set $next_th=(((char *)$next_th->thread_group.next) - $thread_off) > end > set $next_t=(char *)($next_t->tasks.next) - $tasks_off > end > @@ -101,7 +207,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 $thread_off=((size_t)&((struct task_struct *)0)->thread_group) > set $init_t=&init_task > set $next_t=(((char *)($init_t->tasks).next) - $tasks_off) > set var $pid_task = 0 > @@ -113,29 +219,19 @@ 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) - $thread_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) - $thread_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 > + __prinfo $pid_task > + > end > document btpid > backtrace of pid > @@ -145,7 +241,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 $thread_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 +253,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) - $thread_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) - $thread_off) > end > set $next_t=(char *)($next_t->tasks.next) - $tasks_off > end
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
Messages in current thread:
[PATCH]
, Qinghuang Feng
, (Wed Oct 15, 1:04 am)
Re:
, Vivek Goyal
, (Wed Oct 15, 2:32 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
David Howells
[PATCH] KEYS: Use the variable 'key' in keyctl_describe_key()
Greg Kroah-Hartman
[PATCH 17/36] sysdev: detect multiple driver registrations
Greg Kroah-Hartman
[PATCH 09/36] driver core: register_memory/unregister_memory clean ups and bugfix
Pierre Ossman
Re: sdio: enhance IO_RW_EXTENDED support
Sam Ravnborg
Re: [PATCH] kbuild: fix make V=1
git
:
Mark Junker
git on MacOSX and files with decomposed utf-8 file names
Johannes Schindelin
Re: error: cannot lock ref 'refs/remotes/origin/*'
Pat Thoyts
[PATCH] git-gui: use themed tk widgets with Tk 8.5
Johannes Schindelin
Re: [PATCH 2/2] git-svn: support fetch with autocrlf on
Jonathan Nieder
Re: [PATCH v2] git-send-email.perl: fix In-Reply-To for second and subsequent patc...
linux-netdev
:
David Miller
Re: [PATCH 32/53] netns xfrm: finding policy in netns
Jean-Louis Dupond
Re: tg3 driver not advertising 1000mbit
Jan Engelhardt
[PATCH 1/3] net: tcp: make hybla selectable as default congestion module
Daniel Schaffrath
Re: tcp bw in 2.6
Matt Mackall
Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference
git-commits-head
:
Linux Kernel Mailing List
ipv6: fix an oops when force unload ipv6 module
Linux Kernel Mailing List
tracing: protect reader of cmdline output
Linux Kernel Mailing List
KVM: VMX: Clear CR4.VMXE in hardware_disable
Linux Kernel Mailing List
imxfb: Fix margin settings
Linux Kernel Mailing List
USB: set correct configuration in probe of ti_usb_3410_5052
openbsd-misc
:
Stas Miasnikou
Re: Another question: device naming convention
Darrin Chandler
Re: That whole "Linux stealing our code" thing
Community First Financial
Teacher A+ Loan
Jan Stary
Re: audio recording levels
Andrej Elizarov
Re: Web Browsers
Colocation donated by:
Syndicate