All of lore.kernel.org
 help / color / mirror / Atom feed
* Linux Kernel GDB tracepoint module 2010-8-30 release
@ 2010-08-30  7:00 Hui Zhu
  2010-09-03  9:06 ` Steven
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-08-30  7:00 UTC (permalink / raw)
  To: gdb, linux-kernel
  Cc: Michael Snyder, Marc Khouzam, Thiago Jung Bauermann, mqyoung

http://kgtp.googlecode.com/files/kgtp_20100830.tar.bz2
or
svn co https://kgtp.googlecode.com/svn/tags/20100830
to get it.

Fix bug in ref16, ref32, ref64 in issue
https://code.google.com/p/kgtp/issues/detail?id=2
Fix bug that disable some tracepoint will make "tstart" get error.

Support qtstatus. Then KGTP support GDB command "tstatus".
Add support for "make install" and "make uninstall".
Add support for qtro. Fix a bug about GTP_GDBRSP_REG_SIZE.

Change gtp_list make it more efficient.

Please goto http://code.google.com/p/kgtp/wiki/HOWTO to get more info
about how to use KGTP.

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-08-30  7:00 Linux Kernel GDB tracepoint module 2010-8-30 release Hui Zhu
@ 2010-09-03  9:06 ` Steven
  2010-09-03 14:05   ` Frank Ch. Eigler
  2010-09-04  3:41   ` Hui Zhu
  0 siblings, 2 replies; 22+ messages in thread
From: Steven @ 2010-09-03  9:06 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam, Thiago Jung Bauermann

Dear Hui,

I encountered two issue when I use your GTP.

1) Following your HOWTO, I collect the two variables jiffies_64(global),
*file(argument), the result are as following, where you may see
jiffies_64 = 4298520928, that's OK, but the members of *file are all 0.
What's the problem? Thank you very much!
        -------------------------------------------------------------------
        (gdb) trace vfs_readdir 
        Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
        (gdb) actions
        Enter actions for tracepoint 3, one per line.
        End with a line saying just "end".
        > collect jiffies_64
        > collect *file
        > end
        (gdb) tstart
        (gdb) tstop
        (gdb) tfind
        #0  0xc1175691 i (file=0x0, filler=0, buf=0x0) at
        fs/readdir.c:23
        23      {
        (gdb) p jiffies_64
        $7 = 4298520928
        (gdb) p *file
        $8 = {f_u = {fu_list = {next = 0x0, prev = 0x0}, fu_rcuhead =
        {next = 0x0, func = 0}}, f_path = {mnt = 0x0, dentry = 0x0},
        f_op = 0x0, f_lock = {{ rlock = {raw_lock = {slock = 0}}}},
        f_count = {counter = 0}, f_flags = 0, f_mode = 0, f_pos = 0,
        f_owner = {lock = {raw_lock = { lock = 0}}, pid = 0x0, pid_type
        = PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred = 0x0,
        f_ra = {stra_pages = 00, f_security = 0x0, private_data = 0x0,
        f_ep_links = {next = 0x0, prev = 0x0}, f_mapping = 0x0}
        -------------------------------------------------------------------


2) I can not collect local variable, despite I rebuild the kernel with
-O0 optimization option. what is the problem? Many thanks
        -------------------------------------------------------------------
        (gdb) trace fs/readdir.c:29
        Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
        (gdb) actions 
        Enter actions for tracepoint 2, one per line.
        End with a line saying just "end".
        > collect res
        > end
        (gdb) tstart
        res: don't know symbol class 20
        -------------------------------------------------------------------
        
        Code fragment of readdir.c
        -------------------------------------------------------------------
         22 int vfs_readdir(struct file *file, filldir_t filler, void
        *buf)
         23 {
         24         struct inode *inode = file->f_path.dentry->d_inode;
         25         int res = -ENOTDIR;
         26         if (!file->f_op || !file->f_op->readdir)
         27                 goto out;
         28 
         29         res = security_file_permission(file, MAY_READ);
         30         if (res)
         31                 goto out;
        -------------------------------------------------------------------

Best Regards,
Steven


On Mon, 2010-08-30 at 15:00 +0800, Hui Zhu wrote:
> http://kgtp.googlecode.com/files/kgtp_20100830.tar.bz2
> or
> svn co https://kgtp.googlecode.com/svn/tags/20100830
> to get it.
> 
> Fix bug in ref16, ref32, ref64 in issue
> https://code.google.com/p/kgtp/issues/detail?id=2
> Fix bug that disable some tracepoint will make "tstart" get error.
> 
> Support qtstatus. Then KGTP support GDB command "tstatus".
> Add support for "make install" and "make uninstall".
> Add support for qtro. Fix a bug about GTP_GDBRSP_REG_SIZE.
> 
> Change gtp_list make it more efficient.
> 
> Please goto http://code.google.com/p/kgtp/wiki/HOWTO to get more info
> about how to use KGTP.



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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-03  9:06 ` Steven
@ 2010-09-03 14:05   ` Frank Ch. Eigler
  2010-09-04  4:29     ` Hui Zhu
  2010-09-04 16:34     ` Hui Zhu
  2010-09-04  3:41   ` Hui Zhu
  1 sibling, 2 replies; 22+ messages in thread
From: Frank Ch. Eigler @ 2010-09-03 14:05 UTC (permalink / raw)
  To: Steven
  Cc: Hui Zhu, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann


Steven <mqyoung@gmail.com> writes:

> [...]
>         (gdb) trace vfs_readdir 
>         Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
>         (gdb) actions
>         Enter actions for tracepoint 3, one per line.
>         End with a line saying just "end".
>         > collect jiffies_64
>         > collect *file
>         > end

By the way, the systemtap equivalent would be:

#! /usr/bin/stap -g
probe kernel.function("vfs_readdir") {
      println(%{ jiffies_64 %})
      println($file$)
}


> 2) I can not collect local variable, despite I rebuild the kernel with
> -O0 optimization option. what is the problem? Many thanks
>         -------------------------------------------------------------------
>         (gdb) trace fs/readdir.c:29
>         Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
>         (gdb) actions 
>         Enter actions for tracepoint 2, one per line.
>         End with a line saying just "end".
>         > collect res
>         > end


#! /usr/bin/stap
probe kernel.statement("*@fs/readdir.c:29") {
      println($res)
}


- FChE

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-03  9:06 ` Steven
  2010-09-03 14:05   ` Frank Ch. Eigler
@ 2010-09-04  3:41   ` Hui Zhu
  2010-09-04  7:47     ` Hui Zhu
                       ` (2 more replies)
  1 sibling, 3 replies; 22+ messages in thread
From: Hui Zhu @ 2010-09-04  3:41 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Hi Steven,

On Fri, Sep 3, 2010 at 17:06, Steven <mqyoung@gmail.com> wrote:
> Dear Hui,
>
> I encountered two issue when I use your GTP.
>
> 1) Following your HOWTO, I collect the two variables jiffies_64(global),
> *file(argument), the result are as following, where you may see
> jiffies_64 = 4298520928, that's OK, but the members of *file are all 0.
> What's the problem? Thank you very much!
>        -------------------------------------------------------------------
>        (gdb) trace vfs_readdir
>        Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
>        (gdb) actions
>        Enter actions for tracepoint 3, one per line.
>        End with a line saying just "end".
>        > collect jiffies_64
>        > collect *file
>        > end
>        (gdb) tstart
>        (gdb) tstop
>        (gdb) tfind
>        #0  0xc1175691 i (file=0x0, filler=0, buf=0x0) at
>        fs/readdir.c:23
>        23      {
>        (gdb) p jiffies_64
>        $7 = 4298520928
>        (gdb) p *file
>        $8 = {f_u = {fu_list = {next = 0x0, prev = 0x0}, fu_rcuhead =
>        {next = 0x0, func = 0}}, f_path = {mnt = 0x0, dentry = 0x0},
>        f_op = 0x0, f_lock = {{ rlock = {raw_lock = {slock = 0}}}},
>        f_count = {counter = 0}, f_flags = 0, f_mode = 0, f_pos = 0,
>        f_owner = {lock = {raw_lock = { lock = 0}}, pid = 0x0, pid_type
>        = PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred = 0x0,
>        f_ra = {stra_pages = 00, f_security = 0x0, private_data = 0x0,
>        f_ep_links = {next = 0x0, prev = 0x0}, f_mapping = 0x0}
>        -------------------------------------------------------------------
>

It looks like a old bug that I have fixed in new version.
I try it in 20100830 version cannot reproduce this issue:
(gdb) target remote /proc/gtp
Remote debugging using /proc/gtp
0x0000000000000000 in ?? ()
(gdb) trace vfs_readdir
Tracepoint 1 at 0xffffffff81147d3c: file
/home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect jiffies_64
>collect *file
>end
(gdb) tstart
(gdb) sh
sharedlibrary  shell          show
(gdb) shell ls
2      block	firmware  i	   ipc	   Makefile	    modules.order
scripts   source	  t~	vmlinux
a.out  crypto	fs	  include  kernel  mm		    Module.symvers  security
System.map  usr	vmlinux.o
arch   drivers	gdb.txt   init	   lib	   modules.builtin  net		
sound     t		  virt
(gdb) tstop
(gdb) tfind
Found trace frame 0, tracepoint 1
#0  0xffffffff81147d3d in vfs_readdir (file=0xffff88007b22bcc0,
filler=0xffffffff81147ba0 <filldir>, buf=0xffff88006cc31f38)
    at /home/teawater/kernel/linux-2.6/fs/readdir.c:24
24	{
(gdb) p jiffies_64
$1 = 4295113995
(gdb) p *file
$2 = {f_u = {fu_list = {next = 0xffff88007b22b480, prev =
0xffffe8ffffc86960}, fu_rcuhead = {next = 0xffff88007b22b480,
      func = 0xffffe8ffffc86960}}, f_path = {mnt = 0xffff880037bd6b00,
dentry = 0xffff88007e15b6c0}, f_op = 0xffffffff81622b00, f_lock = {{
      rlock = {raw_lock = {slock = 0}}}}, f_sb_list_cpu = 1, f_count =
{counter = 2}, f_flags = 624640, f_mode = 29, f_pos = 0, f_owner = {
    lock = {raw_lock = {lock = 16777216}}, pid = 0x0, pid_type =
PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred =
0xffff88007ae6f780,
  f_ra = {start = 0, size = 0, async_size = 0, ra_pages = 32,
mmap_miss = 0, prev_pos = -1}, f_version = 0, f_security = 0x0,
  private_data = 0x0, f_ep_links = {next = 0xffff88007b22bd68, prev =
0xffff88007b22bd68}, f_mapping = 0xffff880036662590}


Could you try the new version?  I think it will work OK.

If you still meet this issue, maybe you can try with the new GDB from
http://www.gnu.org/software/gdb/download/ANNOUNCEMENT


>
> 2) I can not collect local variable, despite I rebuild the kernel with
> -O0 optimization option. what is the problem? Many thanks
>        -------------------------------------------------------------------
>        (gdb) trace fs/readdir.c:29
>        Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
>        (gdb) actions
>        Enter actions for tracepoint 2, one per line.
>        End with a line saying just "end".
>        > collect res
>        > end
>        (gdb) tstart
>        res: don't know symbol class 20

This error is from GDB, I think it's a GDB bug, I will try to find out
the root cause.

BTW, looks GCC and GDB don't want handle the optimization debug
trouble (all they want is rewrite the GCC in C++ :P).
So I think make linux kernel can close optimization is better idea, do
you know some way or some patch to do it?


The MIPS support that you interest is check in to the KGTP truck.  I
just try it with a mips32el board.
To cross-compile it, you need set the CROSS_COMPILE ,KERNELDIR and
ARCH in Makefile.

Thanks,
Hui





>        -------------------------------------------------------------------
>
>        Code fragment of readdir.c
>        -------------------------------------------------------------------
>         22 int vfs_readdir(struct file *file, filldir_t filler, void
>        *buf)
>         23 {
>         24         struct inode *inode = file->f_path.dentry->d_inode;
>         25         int res = -ENOTDIR;
>         26         if (!file->f_op || !file->f_op->readdir)
>         27                 goto out;
>         28
>         29         res = security_file_permission(file, MAY_READ);
>         30         if (res)
>         31                 goto out;
>        -------------------------------------------------------------------
>
> Best Regards,
> Steven
>
>
> On Mon, 2010-08-30 at 15:00 +0800, Hui Zhu wrote:
>> http://kgtp.googlecode.com/files/kgtp_20100830.tar.bz2
>> or
>> svn co https://kgtp.googlecode.com/svn/tags/20100830
>> to get it.
>>
>> Fix bug in ref16, ref32, ref64 in issue
>> https://code.google.com/p/kgtp/issues/detail?id=2
>> Fix bug that disable some tracepoint will make "tstart" get error.
>>
>> Support qtstatus. Then KGTP support GDB command "tstatus".
>> Add support for "make install" and "make uninstall".
>> Add support for qtro. Fix a bug about GTP_GDBRSP_REG_SIZE.
>>
>> Change gtp_list make it more efficient.
>>
>> Please goto http://code.google.com/p/kgtp/wiki/HOWTO to get more info
>> about how to use KGTP.
>
>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-03 14:05   ` Frank Ch. Eigler
@ 2010-09-04  4:29     ` Hui Zhu
  2010-09-04  5:11       ` Frank Ch. Eigler
  2010-09-04 16:34     ` Hui Zhu
  1 sibling, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04  4:29 UTC (permalink / raw)
  To: Frank Ch. Eigler
  Cc: Steven, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann

Hi Frank,

Looks systemtap are very cool.

Could you talk about how it do call stack dump like following?
(gdb) trace vfs_readdir
Tracepoint 1 at 0xffffffff8113f7fc: file
/home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect *(unsigned char *)$rsp@512
>end
(gdb) tstart
(gdb) shell ls
2      block    firmware  i        ipc     Makefile
modules.order   scripts   source      t~    vmlinux
a.out  crypto   fs        include  kernel  mm
Module.symvers  security  System.map  usr   vmlinux.o
arch   drivers  gdb.txt   init     lib     modules.builtin  net
     sound     t           virt
(gdb) tstop
(gdb) tfind
Found trace frame 0, tracepoint 1
#0  0xffffffff8113f7fd in vfs_readdir (file=0xffff880075f00780,
filler=0xffffffff8113f630 <filldir>, buf=0xffff880005785f38)
    at /home/teawater/kernel/linux-2.6/fs/readdir.c:24
24      {
(gdb) bt
#0  0xffffffff8113f7fd in vfs_readdir (file=0xffff880075f00780,
filler=0xffffffff8113f630 <filldir>, buf=0xffff880005785f38)
    at /home/teawater/kernel/linux-2.6/fs/readdir.c:24
#1  0xffffffff8113fa14 in sys_getdents (fd=<value optimized out>,
dirent=0x801108, count=32768)
    at /home/teawater/kernel/linux-2.6/fs/readdir.c:214
#2  0xffffffff8100af42 in ?? () at
/home/teawater/kernel/linux-2.6/arch/x86/kernel/entry_64.S:487

BTW, I was not find out which ARCH of the systemtap support in its
website?  It support all the arch that kprobe support?

Thanks,
Hui

On Fri, Sep 3, 2010 at 22:05, Frank Ch. Eigler <fche@redhat.com> wrote:
>
> Steven <mqyoung@gmail.com> writes:
>
>> [...]
>>         (gdb) trace vfs_readdir
>>         Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
>>         (gdb) actions
>>         Enter actions for tracepoint 3, one per line.
>>         End with a line saying just "end".
>>         > collect jiffies_64
>>         > collect *file
>>         > end
>
> By the way, the systemtap equivalent would be:
>
> #! /usr/bin/stap -g
> probe kernel.function("vfs_readdir") {
>      println(%{ jiffies_64 %})
>      println($file$)
> }
>
>
>> 2) I can not collect local variable, despite I rebuild the kernel with
>> -O0 optimization option. what is the problem? Many thanks
>>         -------------------------------------------------------------------
>>         (gdb) trace fs/readdir.c:29
>>         Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
>>         (gdb) actions
>>         Enter actions for tracepoint 2, one per line.
>>         End with a line saying just "end".
>>         > collect res
>>         > end
>
>
> #! /usr/bin/stap
> probe kernel.statement("*@fs/readdir.c:29") {
>      println($res)
> }
>
>
> - FChE
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  4:29     ` Hui Zhu
@ 2010-09-04  5:11       ` Frank Ch. Eigler
  2010-09-04 15:04         ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Frank Ch. Eigler @ 2010-09-04  5:11 UTC (permalink / raw)
  To: Hui Zhu
  Cc: Steven, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann

Hi -

On Sat, Sep 04, 2010 at 12:29:56PM +0800, Hui Zhu wrote:

> [...] Could you talk about how it do call stack dump like following?
> (gdb) trace vfs_readdir
> Tracepoint 1 at 0xffffffff8113f7fc: file
> /home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
> (gdb) actions
> >collect *(unsigned char *)$rsp@512

probe kernel.function("vfs_readdir") {
   // if you want the whole kernel-side backtrace, dwarf-unwound
   print_backtrace() 
   // or else just hex-dump a region
   printf("%*M\n", 512, register("rsp"))
}


> BTW, I was not find out which ARCH of the systemtap support in its
> website?  It support all the arch that kprobe support?

Yes, basically, though it's mostly tested on RHELy platforms (x86,
powerpc, s390, ia64).

- FChE

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  3:41   ` Hui Zhu
@ 2010-09-04  7:47     ` Hui Zhu
  2010-09-04  9:01       ` Steven
  2010-09-04  8:39     ` Steven
       [not found]     ` <1283590584.1685.39.camel@steven>
  2 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04  7:47 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, Sep 4, 2010 at 11:41, Hui Zhu <teawater@gmail.com> wrote:
> Hi Steven,
>
> On Fri, Sep 3, 2010 at 17:06, Steven <mqyoung@gmail.com> wrote:
>> Dear Hui,
>>
>> I encountered two issue when I use your GTP.
>>
>> 1) Following your HOWTO, I collect the two variables jiffies_64(global),
>> *file(argument), the result are as following, where you may see
>> jiffies_64 = 4298520928, that's OK, but the members of *file are all 0.
>> What's the problem? Thank you very much!
>>        -------------------------------------------------------------------
>>        (gdb) trace vfs_readdir
>>        Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
>>        (gdb) actions
>>        Enter actions for tracepoint 3, one per line.
>>        End with a line saying just "end".
>>        > collect jiffies_64
>>        > collect *file
>>        > end
>>        (gdb) tstart
>>        (gdb) tstop
>>        (gdb) tfind
>>        #0  0xc1175691 i (file=0x0, filler=0, buf=0x0) at
>>        fs/readdir.c:23
>>        23      {
>>        (gdb) p jiffies_64
>>        $7 = 4298520928
>>        (gdb) p *file
>>        $8 = {f_u = {fu_list = {next = 0x0, prev = 0x0}, fu_rcuhead =
>>        {next = 0x0, func = 0}}, f_path = {mnt = 0x0, dentry = 0x0},
>>        f_op = 0x0, f_lock = {{ rlock = {raw_lock = {slock = 0}}}},
>>        f_count = {counter = 0}, f_flags = 0, f_mode = 0, f_pos = 0,
>>        f_owner = {lock = {raw_lock = { lock = 0}}, pid = 0x0, pid_type
>>        = PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred = 0x0,
>>        f_ra = {stra_pages = 00, f_security = 0x0, private_data = 0x0,
>>        f_ep_links = {next = 0x0, prev = 0x0}, f_mapping = 0x0}
>>        -------------------------------------------------------------------
>>
>
> It looks like a old bug that I have fixed in new version.
> I try it in 20100830 version cannot reproduce this issue:
> (gdb) target remote /proc/gtp
> Remote debugging using /proc/gtp
> 0x0000000000000000 in ?? ()
> (gdb) trace vfs_readdir
> Tracepoint 1 at 0xffffffff81147d3c: file
> /home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
> (gdb) actions
> Enter actions for tracepoint 1, one per line.
> End with a line saying just "end".
>>collect jiffies_64
>>collect *file
>>end
> (gdb) tstart
> (gdb) sh
> sharedlibrary  shell          show
> (gdb) shell ls
> 2      block    firmware  i        ipc     Makefile         modules.order
> scripts   source          t~    vmlinux
> a.out  crypto   fs        include  kernel  mm               Module.symvers  security
> System.map  usr vmlinux.o
> arch   drivers  gdb.txt   init     lib     modules.builtin  net
> sound     t               virt
> (gdb) tstop
> (gdb) tfind
> Found trace frame 0, tracepoint 1
> #0  0xffffffff81147d3d in vfs_readdir (file=0xffff88007b22bcc0,
> filler=0xffffffff81147ba0 <filldir>, buf=0xffff88006cc31f38)
>    at /home/teawater/kernel/linux-2.6/fs/readdir.c:24
> 24      {
> (gdb) p jiffies_64
> $1 = 4295113995
> (gdb) p *file
> $2 = {f_u = {fu_list = {next = 0xffff88007b22b480, prev =
> 0xffffe8ffffc86960}, fu_rcuhead = {next = 0xffff88007b22b480,
>      func = 0xffffe8ffffc86960}}, f_path = {mnt = 0xffff880037bd6b00,
> dentry = 0xffff88007e15b6c0}, f_op = 0xffffffff81622b00, f_lock = {{
>      rlock = {raw_lock = {slock = 0}}}}, f_sb_list_cpu = 1, f_count =
> {counter = 2}, f_flags = 624640, f_mode = 29, f_pos = 0, f_owner = {
>    lock = {raw_lock = {lock = 16777216}}, pid = 0x0, pid_type =
> PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred =
> 0xffff88007ae6f780,
>  f_ra = {start = 0, size = 0, async_size = 0, ra_pages = 32,
> mmap_miss = 0, prev_pos = -1}, f_version = 0, f_security = 0x0,
>  private_data = 0x0, f_ep_links = {next = 0xffff88007b22bd68, prev =
> 0xffff88007b22bd68}, f_mapping = 0xffff880036662590}
>
>
> Could you try the new version?  I think it will work OK.
>
> If you still meet this issue, maybe you can try with the new GDB from
> http://www.gnu.org/software/gdb/download/ANNOUNCEMENT
>
>
>>
>> 2) I can not collect local variable, despite I rebuild the kernel with
>> -O0 optimization option. what is the problem? Many thanks
>>        -------------------------------------------------------------------
>>        (gdb) trace fs/readdir.c:29
>>        Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
>>        (gdb) actions
>>        Enter actions for tracepoint 2, one per line.
>>        End with a line saying just "end".
>>        > collect res
>>        > end
>>        (gdb) tstart
>>        res: don't know symbol class 20
>
> This error is from GDB, I think it's a GDB bug, I will try to find out
> the root cause.
>
> BTW, looks GCC and GDB don't want handle the optimization debug
> trouble (all they want is rewrite the GCC in C++ :P).
> So I think make linux kernel can close optimization is better idea, do
> you know some way or some patch to do it?
>
>
> The MIPS support that you interest is check in to the KGTP truck.  I
> just try it with a mips32el board.
> To cross-compile it, you need set the CROSS_COMPILE ,KERNELDIR and
> ARCH in Makefile.

Forgot 1 thing, if you want remote debug the MIPS board, you can use
call netcat in board for example:
nc -l -p 1234 < /proc/gtp > /proc/gtp

And debug with GDB command:
target remote board_ip:1234

Thanks,
Hui


>
> Thanks,
> Hui
>
>
>
>
>
>>        -------------------------------------------------------------------
>>
>>        Code fragment of readdir.c
>>        -------------------------------------------------------------------
>>         22 int vfs_readdir(struct file *file, filldir_t filler, void
>>        *buf)
>>         23 {
>>         24         struct inode *inode = file->f_path.dentry->d_inode;
>>         25         int res = -ENOTDIR;
>>         26         if (!file->f_op || !file->f_op->readdir)
>>         27                 goto out;
>>         28
>>         29         res = security_file_permission(file, MAY_READ);
>>         30         if (res)
>>         31                 goto out;
>>        -------------------------------------------------------------------
>>
>> Best Regards,
>> Steven
>>
>>
>> On Mon, 2010-08-30 at 15:00 +0800, Hui Zhu wrote:
>>> http://kgtp.googlecode.com/files/kgtp_20100830.tar.bz2
>>> or
>>> svn co https://kgtp.googlecode.com/svn/tags/20100830
>>> to get it.
>>>
>>> Fix bug in ref16, ref32, ref64 in issue
>>> https://code.google.com/p/kgtp/issues/detail?id=2
>>> Fix bug that disable some tracepoint will make "tstart" get error.
>>>
>>> Support qtstatus. Then KGTP support GDB command "tstatus".
>>> Add support for "make install" and "make uninstall".
>>> Add support for qtro. Fix a bug about GTP_GDBRSP_REG_SIZE.
>>>
>>> Change gtp_list make it more efficient.
>>>
>>> Please goto http://code.google.com/p/kgtp/wiki/HOWTO to get more info
>>> about how to use KGTP.
>>
>>
>>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  3:41   ` Hui Zhu
  2010-09-04  7:47     ` Hui Zhu
@ 2010-09-04  8:39     ` Steven
       [not found]     ` <1283590584.1685.39.camel@steven>
  2 siblings, 0 replies; 22+ messages in thread
From: Steven @ 2010-09-04  8:39 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
> Hi Steven,
> 
> On Fri, Sep 3, 2010 at 17:06, Steven <mqyoung@gmail.com> wrote:
> > Dear Hui,
> >
> > I encountered two issue when I use your GTP.
> >
> > 1) Following your HOWTO, I collect the two variables
> jiffies_64(global),
> > *file(argument), the result are as following, where you may see
> > jiffies_64 = 4298520928, that's OK, but the members of *file are all
> 0.
> > What's the problem? Thank you very much!
> >
>  -------------------------------------------------------------------
> >        (gdb) trace vfs_readdir
> >        Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
> >        (gdb) actions
> >        Enter actions for tracepoint 3, one per line.
> >        End with a line saying just "end".
> >        > collect jiffies_64
> >        > collect *file
> >        > end
> >        (gdb) tstart
> >        (gdb) tstop
> >        (gdb) tfind
> >        #0  0xc1175691 i (file=0x0, filler=0, buf=0x0) at
> >        fs/readdir.c:23
> >        23      {
> >        (gdb) p jiffies_64
> >        $7 = 4298520928
> >        (gdb) p *file
> >        $8 = {f_u = {fu_list = {next = 0x0, prev = 0x0}, fu_rcuhead =
> >        {next = 0x0, func = 0}}, f_path = {mnt = 0x0, dentry = 0x0},
> >        f_op = 0x0, f_lock = {{ rlock = {raw_lock = {slock = 0}}}},
> >        f_count = {counter = 0}, f_flags = 0, f_mode = 0, f_pos = 0,
> >        f_owner = {lock = {raw_lock = { lock = 0}}, pid = 0x0,
> pid_type
> >        = PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred = 0x0,
> >        f_ra = {stra_pages = 00, f_security = 0x0, private_data =
> 0x0,
> >        f_ep_links = {next = 0x0, prev = 0x0}, f_mapping = 0x0}
> >
>  -------------------------------------------------------------------
> >
> 
> It looks like a old bug that I have fixed in new version.
> I try it in 20100830 version cannot reproduce this issue:
> (gdb) target remote /proc/gtp
> Remote debugging using /proc/gtp
> 0x0000000000000000 in ?? ()
> (gdb) trace vfs_readdir
> Tracepoint 1 at 0xffffffff81147d3c: file
> /home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
> (gdb) actions
> Enter actions for tracepoint 1, one per line.
> End with a line saying just "end".
> >collect jiffies_64
> >collect *file
> >end
> (gdb) tstart
> (gdb) sh
> sharedlibrary  shell          show
> (gdb) shell ls
> 2      block    firmware  i        ipc     Makefile
> modules.order
> scripts   source          t~    vmlinux
> a.out  crypto   fs        include  kernel  mm
> Module.symvers  security
> System.map  usr vmlinux.o
> arch   drivers  gdb.txt   init     lib     modules.builtin
> net         
> sound     t               virt
> (gdb) tstop
> (gdb) tfind
> Found trace frame 0, tracepoint 1
> #0  0xffffffff81147d3d in vfs_readdir (file=0xffff88007b22bcc0,
> filler=0xffffffff81147ba0 <filldir>, buf=0xffff88006cc31f38)
>     at /home/teawater/kernel/linux-2.6/fs/readdir.c:24
> 24      {
> (gdb) p jiffies_64
> $1 = 4295113995
> (gdb) p *file
> $2 = {f_u = {fu_list = {next = 0xffff88007b22b480, prev =
> 0xffffe8ffffc86960}, fu_rcuhead = {next = 0xffff88007b22b480,
>       func = 0xffffe8ffffc86960}}, f_path = {mnt = 0xffff880037bd6b00,
> dentry = 0xffff88007e15b6c0}, f_op = 0xffffffff81622b00, f_lock = {{
>       rlock = {raw_lock = {slock = 0}}}}, f_sb_list_cpu = 1, f_count =
> {counter = 2}, f_flags = 624640, f_mode = 29, f_pos = 0, f_owner = {
>     lock = {raw_lock = {lock = 16777216}}, pid = 0x0, pid_type =
> PIDTYPE_PID, uid = 0, euid = 0, signum = 0}, f_cred =
> 0xffff88007ae6f780,
>   f_ra = {start = 0, size = 0, async_size = 0, ra_pages = 32,
> mmap_miss = 0, prev_pos = -1}, f_version = 0, f_security = 0x0,
>   private_data = 0x0, f_ep_links = {next = 0xffff88007b22bd68, prev =
> 0xffff88007b22bd68}, f_mapping = 0xffff880036662590}
> 
> 
> Could you try the new version?  I think it will work OK. 


I use the latest GTP, the same problem, while I use the latest GDB(7.2),
I get the correct value of *file(the version of my old gdb is 6.8).
(Intel P3 CPU)

Many thanks to ALL,
Steven


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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  7:47     ` Hui Zhu
@ 2010-09-04  9:01       ` Steven
  2010-09-04  9:10         ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Steven @ 2010-09-04  9:01 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Dear Hui,

Thank you verch much!
My board is 64-bit MIPS, is KGTP available on 64-bit MIPS?


Best Regards,
Steven


On Sat, 2010-09-04 at 15:47 +0800, Hui Zhu wrote:
> > The MIPS support that you interest is check in to the KGTP truck.  I
> > just try it with a mips32el board.
> > To cross-compile it, you need set the CROSS_COMPILE ,KERNELDIR and
> > ARCH in Makefile.
> 
> Forgot 1 thing, if you want remote debug the MIPS board, you can use
> call netcat in board for example:
> nc -l -p 1234 < /proc/gtp > /proc/gtp
> 
> And debug with GDB command:
> target remote board_ip:1234 


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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  9:01       ` Steven
@ 2010-09-04  9:10         ` Hui Zhu
  0 siblings, 0 replies; 22+ messages in thread
From: Hui Zhu @ 2010-09-04  9:10 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, Sep 4, 2010 at 17:01, Steven <mqyoung@gmail.com> wrote:
> Dear Hui,
>
> Thank you verch much!
> My board is 64-bit MIPS, is KGTP available on 64-bit MIPS?
>
>

The code is done.  But it isn't be tested.  Maybe you can be the first
mips64 user.  :)

Thanks,
Hui


> Best Regards,
> Steven
>
>
> On Sat, 2010-09-04 at 15:47 +0800, Hui Zhu wrote:
>> > The MIPS support that you interest is check in to the KGTP truck.  I
>> > just try it with a mips32el board.
>> > To cross-compile it, you need set the CROSS_COMPILE ,KERNELDIR and
>> > ARCH in Makefile.
>>
>> Forgot 1 thing, if you want remote debug the MIPS board, you can use
>> call netcat in board for example:
>> nc -l -p 1234 < /proc/gtp > /proc/gtp
>>
>> And debug with GDB command:
>> target remote board_ip:1234
>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
       [not found]     ` <1283590584.1685.39.camel@steven>
@ 2010-09-04  9:17       ` Hui Zhu
  2010-09-04  9:26         ` Steven
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04  9:17 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
> On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
>> BTW, looks GCC and GDB don't want handle the optimization debug
>> trouble (all they want is rewrite the GCC in C++ :P).
>> So I think make linux kernel can close optimization is better idea, do
>> you know some way or some patch to do it?
>>
>
> Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
> kernel:
> KBUILD_CFLAGS   += -O2
> to
> KBUILD_CFLAGS   += -O0

Cool,  :)

I try just change the compile option of readdir.c to without -O2, it
works OK.  I think maybe it's a GDB bug too.
Could you try the second issue with gdb 7.2?

BTW, I think I need add some words let all the KGTP user use gdb 7.2
with KGTP in howto.  :)

Thanks for help me with this big issue.  :)

Best,
Hui

>
> Sometime gcc will still optimize out some variables even I compile a
> program with -O0, so volatile is required sometimes.
>
> Thanks,
> Steven
>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  9:17       ` Hui Zhu
@ 2010-09-04  9:26         ` Steven
  2010-09-04 14:58           ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Steven @ 2010-09-04  9:26 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
> >> BTW, looks GCC and GDB don't want handle the optimization debug
> >> trouble (all they want is rewrite the GCC in C++ :P).
> >> So I think make linux kernel can close optimization is better idea, do
> >> you know some way or some patch to do it?
> >>
> >
> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
> > kernel:
> > KBUILD_CFLAGS   += -O2
> > to
> > KBUILD_CFLAGS   += -O0
> 
> Cool,  :)
> 
> I try just change the compile option of readdir.c to without -O2, it
> works OK.  I think maybe it's a GDB bug too.
> Could you try the second issue with gdb 7.2?

I have covered the two issues in the previous mail that I could collect
both global variables and locals(-O0 kernel + gdb7.2):

        --------
        (gdb) trace vfs_readdir 
        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
        (gdb) actions 
        Enter actions for tracepoint 3, one per line.
        End with a line saying just "end".
        >collect *file
        >end
        (gdb) trace fs/readdir.c:29
        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
        (gdb) actions 
        Enter actions for tracepoint 4, one per line.
        End with a line saying just "end".
        >collect res
        >end
        (gdb) tstart
        (gdb) tstop
        (gdb) tfind
        Found trace frame 0, tracepoint 3
        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
        buf=0x0)
            at fs/readdir.c:24
        24              struct inode *inode =
        file->f_path.dentry->d_inode;
        (gdb) p *file
        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
        fu_rcuhead = {
              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
        0xc6c05300, 
            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
        {raw_lock = {
                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
        624640, 
          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
        16777216}}, 
           = 0start = 0, size = 0, async_size = 0, 
            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
        0, 
          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
        0xc761c74c}
        (gdb) p res
        $5 = 0
        (gdb) tfind
        Found trace frame 1, tracepoint 4
        0xc11756cb      29              res =
        security_file_permission(file, MAY_READ);
        (gdb) p res
        $6 = -20
        --------



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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  9:26         ` Steven
@ 2010-09-04 14:58           ` Hui Zhu
  2010-09-04 16:01             ` Steven
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04 14:58 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
> On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
>> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
>> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
>> >> BTW, looks GCC and GDB don't want handle the optimization debug
>> >> trouble (all they want is rewrite the GCC in C++ :P).
>> >> So I think make linux kernel can close optimization is better idea, do
>> >> you know some way or some patch to do it?
>> >>
>> >
>> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
>> > kernel:
>> > KBUILD_CFLAGS   += -O2
>> > to
>> > KBUILD_CFLAGS   += -O0
>>
>> Cool,  :)
>>
>> I try just change the compile option of readdir.c to without -O2, it
>> works OK.  I think maybe it's a GDB bug too.
>> Could you try the second issue with gdb 7.2?
>
> I have covered the two issues in the previous mail that I could collect
> both global variables and locals(-O0 kernel + gdb7.2):
>
>        --------
>        (gdb) trace vfs_readdir
>        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
>        (gdb) actions
>        Enter actions for tracepoint 3, one per line.
>        End with a line saying just "end".
>        >collect *file
>        >end
>        (gdb) trace fs/readdir.c:29
>        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
>        (gdb) actions
>        Enter actions for tracepoint 4, one per line.
>        End with a line saying just "end".
>        >collect res
>        >end
>        (gdb) tstart
>        (gdb) tstop
>        (gdb) tfind
>        Found trace frame 0, tracepoint 3
>        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
>        buf=0x0)
>            at fs/readdir.c:24
>        24              struct inode *inode =
>        file->f_path.dentry->d_inode;
>        (gdb) p *file
>        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
>        fu_rcuhead = {
>              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
>        0xc6c05300,
>            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
>        {raw_lock = {
>                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
>        624640,
>          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
>        16777216}},
>           = 0start = 0, size = 0, async_size = 0,
>            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
>        0,
>          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
>            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
>        0xc761c74c}
>        (gdb) p res
>        $5 = 0
>        (gdb) tfind
>        Found trace frame 1, tracepoint 4
>        0xc11756cb      29              res =
>        security_file_permission(file, MAY_READ);
>        (gdb) p res
>        $6 = -20
>        --------
>
>
>

Great.  :)

Hui

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04  5:11       ` Frank Ch. Eigler
@ 2010-09-04 15:04         ` Hui Zhu
  0 siblings, 0 replies; 22+ messages in thread
From: Hui Zhu @ 2010-09-04 15:04 UTC (permalink / raw)
  To: Frank Ch. Eigler
  Cc: Steven, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann

Hi Frank,

I met a issue with build systemtap.  Build it need (install
elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel), but ubuntu
looks don't have it.

I try to build elfutils-0.148 with myself, but after I install it,
when I compile other code, I got:
/usr/local/bin/ld: /usr/lib/libelf.so.1: version `ELFUTILS_1.5' not
found (required by /usr/local/bin/ld)
collect2: ld returned 1 exit status
It really scared me.

Did you meet this issue in before?

Thanks,
Hui

On Sat, Sep 4, 2010 at 13:11, Frank Ch. Eigler <fche@redhat.com> wrote:
> Hi -
>
> On Sat, Sep 04, 2010 at 12:29:56PM +0800, Hui Zhu wrote:
>
>> [...] Could you talk about how it do call stack dump like following?
>> (gdb) trace vfs_readdir
>> Tracepoint 1 at 0xffffffff8113f7fc: file
>> /home/teawater/kernel/linux-2.6/fs/readdir.c, line 24.
>> (gdb) actions
>> >collect *(unsigned char *)$rsp@512
>
> probe kernel.function("vfs_readdir") {
>   // if you want the whole kernel-side backtrace, dwarf-unwound
>   print_backtrace()
>   // or else just hex-dump a region
>   printf("%*M\n", 512, register("rsp"))
> }
>
>
>> BTW, I was not find out which ARCH of the systemtap support in its
>> website?  It support all the arch that kprobe support?
>
> Yes, basically, though it's mostly tested on RHELy platforms (x86,
> powerpc, s390, ia64).
>
> - FChE
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04 14:58           ` Hui Zhu
@ 2010-09-04 16:01             ` Steven
  2010-09-04 16:42               ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Steven @ 2010-09-04 16:01 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Dear All,

As I mentioned before, I could collect the variables of kernel function
such as vfs_readdir(ext3 is built in kernel not module). And I tried I
could collect variables of kernel's module(such as my ethernet card
driver 3c59x.ko). I will collect these info later.

BUT, I can not collect the value of my testing module, neither global
nor local. I think there is some thing wrong with my compile option or
Makefile, any one know it? Thanks very much.

Program:
-------------------------------------------------
  6 volatile struct timeval tv;
  7 int year;
  8 
  9 int test_thread(void *data)
 10 {
 11         volatile int cnt = 0;
 12         set_current_state(TASK_INTERRUPTIBLE);
 13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
 14 
 15         while(1){
 16                 set_current_state(TASK_INTERRUPTIBLE); 
 17                 if(kthread_should_stop()) break;
 18 
 19                 year = 2010;
 20                 do_gettimeofday (&tv);
 21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
 22                 cnt++;
 23 
 24                 do_gettimeofday (&tv);
 25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
 26                 cnt++;
 27 
 28                 //reschedule after 5 seconds(approximately)
 29                 schedule_timeout(60 * HZ);
 30         }
 31 
 32         return 0;
 33 }
-------------------------------------------------

Makefile
-------------------------------------------------
obj-m := hello.o

KERNELBUILD := /lib/modules/`uname -r`/build

default:
        make -C $(KERNELBUILD) M=$(shell pwd) modules
-------------------------------------------------


Screen log
-------------------------------------------------
debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118] 
[ 3909.310124] tv_sec: 1283648666 - 16
[ 3909.315385] tv_sec: 1283648666 - 2010
done.
(gdb) target remote /proc/gtp
Remote debugging using /proc/gtp
0x00000000 in ?? ()
(gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
add symbol table from file "/home/steven/hello/hello.ko" at
        .text_addr = 0xc8b2b000
(y or n) y
Reading symbols from /home/steven/hello/hello.ko...done.
(gdb) trace /home/steven/hello/hello.c:22
Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
(gdb) trace /home/steven/hello/hello.c:26
Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
(gdb) actions 1
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>
>collect tv, year, cnt
>end
(gdb) actions 2
Enter actions for tracepoint 2, one per line.
End with a line saying just "end".
>collect tv, year, cnt
>end
(gdb) tstart
[ 4029.328129] 
[ 4029.328136] tv_sec: 1283648786 - 20
[ 4029.333456] tv_sec: 1283648786 - 2010
tstop
(gdb) tfind
Found trace frame 0, tracepoint 1
#0  0xc8b2b095 in test_thread (data=0x0)
at /home/steven/hello/hello.c:22
22                      cnt++;
(gdb) p tv
$1 = {tv_sec = 0, tv_usec = 0}
(gdb) p cnt
$2 = 0
(gdb) p year
$3 = 0
(gdb) tfind
Found trace frame 1, tracepoint 2
0xc8b2b0c2      26                      cnt++;
(gdb) p cnt
$4 = 0
(gdb) p tv
$5 = {tv_sec = 0, tv_usec = 0}
(gdb) p year
$6 = 0
-------------------------------------------------

Thanks,
Steven

On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
> >> >> trouble (all they want is rewrite the GCC in C++ :P).
> >> >> So I think make linux kernel can close optimization is better idea, do
> >> >> you know some way or some patch to do it?
> >> >>
> >> >
> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
> >> > kernel:
> >> > KBUILD_CFLAGS   += -O2
> >> > to
> >> > KBUILD_CFLAGS   += -O0
> >>
> >> Cool,  :)
> >>
> >> I try just change the compile option of readdir.c to without -O2, it
> >> works OK.  I think maybe it's a GDB bug too.
> >> Could you try the second issue with gdb 7.2?
> >
> > I have covered the two issues in the previous mail that I could collect
> > both global variables and locals(-O0 kernel + gdb7.2):
> >
> >        --------
> >        (gdb) trace vfs_readdir
> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
> >        (gdb) actions
> >        Enter actions for tracepoint 3, one per line.
> >        End with a line saying just "end".
> >        >collect *file
> >        >end
> >        (gdb) trace fs/readdir.c:29
> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
> >        (gdb) actions
> >        Enter actions for tracepoint 4, one per line.
> >        End with a line saying just "end".
> >        >collect res
> >        >end
> >        (gdb) tstart
> >        (gdb) tstop
> >        (gdb) tfind
> >        Found trace frame 0, tracepoint 3
> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
> >        buf=0x0)
> >            at fs/readdir.c:24
> >        24              struct inode *inode =
> >        file->f_path.dentry->d_inode;
> >        (gdb) p *file
> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
> >        fu_rcuhead = {
> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
> >        0xc6c05300,
> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
> >        {raw_lock = {
> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
> >        624640,
> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
> >        16777216}},
> >           = 0start = 0, size = 0, async_size = 0,
> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
> >        0,
> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
> >        0xc761c74c}
> >        (gdb) p res
> >        $5 = 0
> >        (gdb) tfind
> >        Found trace frame 1, tracepoint 4
> >        0xc11756cb      29              res =
> >        security_file_permission(file, MAY_READ);
> >        (gdb) p res
> >        $6 = -20
> >        --------
> >
> >
> >
> 
> Great.  :)
> 
> Hui


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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-03 14:05   ` Frank Ch. Eigler
  2010-09-04  4:29     ` Hui Zhu
@ 2010-09-04 16:34     ` Hui Zhu
  2010-09-04 18:22       ` Frank Ch. Eigler
  1 sibling, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04 16:34 UTC (permalink / raw)
  To: Frank Ch. Eigler
  Cc: Steven, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann

Hi Frank,

I try systemtrap but got some error:

On Fri, Sep 3, 2010 at 22:05, Frank Ch. Eigler <fche@redhat.com> wrote:
>
> Steven <mqyoung@gmail.com> writes:
>
>> [...]
>>         (gdb) trace vfs_readdir
>>         Tracepoint 3 at 0xc1175690: file fs/readdir.c, line 23.
>>         (gdb) actions
>>         Enter actions for tracepoint 3, one per line.
>>         End with a line saying just "end".
>>         > collect jiffies_64
>>         > collect *file
>>         > end
>
> By the way, the systemtap equivalent would be:
>
> #! /usr/bin/stap -g
> probe kernel.function("vfs_readdir") {
>      println(%{ jiffies_64 %})
>      println($file$)
> }

parse error: expected literal string or number
	saw: embedded-code at ./1.sh:3:14
     source:      println(%{ jiffies_64 %})
                          ^
parse error: expected statement
	saw: ./1.sh EOF
2 parse error(s).
Pass 1: parse failed.  Try again with another '--vp 1' option.


>
>
>> 2) I can not collect local variable, despite I rebuild the kernel with
>> -O0 optimization option. what is the problem? Many thanks
>>         -------------------------------------------------------------------
>>         (gdb) trace fs/readdir.c:29
>>         Tracepoint 2 at 0xc11756ca: file fs/readdir.c, line 29.
>>         (gdb) actions
>>         Enter actions for tracepoint 2, one per line.
>>         End with a line saying just "end".
>>         > collect res
>>         > end
>
>
> #! /usr/bin/stap
> probe kernel.statement("*@fs/readdir.c:29") {
>      println($res)
> }
>

semantic error: not accessible at this address: identifier '$res' at ./1.sh:3:14
        source:      println($res)
                             ^
Pass 2: analysis failed.  Try again with another '--vp 01' option.
[1]+  Done                    gedit 1.sh


Could you help me with it?

Thanks,
Hui

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04 16:01             ` Steven
@ 2010-09-04 16:42               ` Hui Zhu
  2010-09-04 16:47                 ` Steven
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-04 16:42 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Could you post the other part of this code?  Then I can try to reproduce on it.

Thanks,
Hui

On Sun, Sep 5, 2010 at 00:01, Steven <mqyoung@gmail.com> wrote:
> Dear All,
>
> As I mentioned before, I could collect the variables of kernel function
> such as vfs_readdir(ext3 is built in kernel not module). And I tried I
> could collect variables of kernel's module(such as my ethernet card
> driver 3c59x.ko). I will collect these info later.
>
> BUT, I can not collect the value of my testing module, neither global
> nor local. I think there is some thing wrong with my compile option or
> Makefile, any one know it? Thanks very much.
>
> Program:
> -------------------------------------------------
>  6 volatile struct timeval tv;
>  7 int year;
>  8
>  9 int test_thread(void *data)
>  10 {
>  11         volatile int cnt = 0;
>  12         set_current_state(TASK_INTERRUPTIBLE);
>  13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
>  14
>  15         while(1){
>  16                 set_current_state(TASK_INTERRUPTIBLE);
>  17                 if(kthread_should_stop()) break;
>  18
>  19                 year = 2010;
>  20                 do_gettimeofday (&tv);
>  21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
>  22                 cnt++;
>  23
>  24                 do_gettimeofday (&tv);
>  25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
>  26                 cnt++;
>  27
>  28                 //reschedule after 5 seconds(approximately)
>  29                 schedule_timeout(60 * HZ);
>  30         }
>  31
>  32         return 0;
>  33 }
> -------------------------------------------------
>
> Makefile
> -------------------------------------------------
> obj-m := hello.o
>
> KERNELBUILD := /lib/modules/`uname -r`/build
>
> default:
>        make -C $(KERNELBUILD) M=$(shell pwd) modules
> -------------------------------------------------
>
>
> Screen log
> -------------------------------------------------
> debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
> GNU gdb (GDB) 7.2
> Copyright (C) 2010 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show
> copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118]
> [ 3909.310124] tv_sec: 1283648666 - 16
> [ 3909.315385] tv_sec: 1283648666 - 2010
> done.
> (gdb) target remote /proc/gtp
> Remote debugging using /proc/gtp
> 0x00000000 in ?? ()
> (gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
> add symbol table from file "/home/steven/hello/hello.ko" at
>        .text_addr = 0xc8b2b000
> (y or n) y
> Reading symbols from /home/steven/hello/hello.ko...done.
> (gdb) trace /home/steven/hello/hello.c:22
> Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
> (gdb) trace /home/steven/hello/hello.c:26
> Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
> (gdb) actions 1
> Enter actions for tracepoint 1, one per line.
> End with a line saying just "end".
>>
>>collect tv, year, cnt
>>end
> (gdb) actions 2
> Enter actions for tracepoint 2, one per line.
> End with a line saying just "end".
>>collect tv, year, cnt
>>end
> (gdb) tstart
> [ 4029.328129]
> [ 4029.328136] tv_sec: 1283648786 - 20
> [ 4029.333456] tv_sec: 1283648786 - 2010
> tstop
> (gdb) tfind
> Found trace frame 0, tracepoint 1
> #0  0xc8b2b095 in test_thread (data=0x0)
> at /home/steven/hello/hello.c:22
> 22                      cnt++;
> (gdb) p tv
> $1 = {tv_sec = 0, tv_usec = 0}
> (gdb) p cnt
> $2 = 0
> (gdb) p year
> $3 = 0
> (gdb) tfind
> Found trace frame 1, tracepoint 2
> 0xc8b2b0c2      26                      cnt++;
> (gdb) p cnt
> $4 = 0
> (gdb) p tv
> $5 = {tv_sec = 0, tv_usec = 0}
> (gdb) p year
> $6 = 0
> -------------------------------------------------
>
> Thanks,
> Steven
>
> On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
>> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
>> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
>> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
>> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
>> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
>> >> >> trouble (all they want is rewrite the GCC in C++ :P).
>> >> >> So I think make linux kernel can close optimization is better idea, do
>> >> >> you know some way or some patch to do it?
>> >> >>
>> >> >
>> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
>> >> > kernel:
>> >> > KBUILD_CFLAGS   += -O2
>> >> > to
>> >> > KBUILD_CFLAGS   += -O0
>> >>
>> >> Cool,  :)
>> >>
>> >> I try just change the compile option of readdir.c to without -O2, it
>> >> works OK.  I think maybe it's a GDB bug too.
>> >> Could you try the second issue with gdb 7.2?
>> >
>> > I have covered the two issues in the previous mail that I could collect
>> > both global variables and locals(-O0 kernel + gdb7.2):
>> >
>> >        --------
>> >        (gdb) trace vfs_readdir
>> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
>> >        (gdb) actions
>> >        Enter actions for tracepoint 3, one per line.
>> >        End with a line saying just "end".
>> >        >collect *file
>> >        >end
>> >        (gdb) trace fs/readdir.c:29
>> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
>> >        (gdb) actions
>> >        Enter actions for tracepoint 4, one per line.
>> >        End with a line saying just "end".
>> >        >collect res
>> >        >end
>> >        (gdb) tstart
>> >        (gdb) tstop
>> >        (gdb) tfind
>> >        Found trace frame 0, tracepoint 3
>> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
>> >        buf=0x0)
>> >            at fs/readdir.c:24
>> >        24              struct inode *inode =
>> >        file->f_path.dentry->d_inode;
>> >        (gdb) p *file
>> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
>> >        fu_rcuhead = {
>> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
>> >        0xc6c05300,
>> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
>> >        {raw_lock = {
>> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
>> >        624640,
>> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
>> >        16777216}},
>> >           = 0start = 0, size = 0, async_size = 0,
>> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
>> >        0,
>> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
>> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
>> >        0xc761c74c}
>> >        (gdb) p res
>> >        $5 = 0
>> >        (gdb) tfind
>> >        Found trace frame 1, tracepoint 4
>> >        0xc11756cb      29              res =
>> >        security_file_permission(file, MAY_READ);
>> >        (gdb) p res
>> >        $6 = -20
>> >        --------
>> >
>> >
>> >
>>
>> Great.  :)
>>
>> Hui
>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04 16:42               ` Hui Zhu
@ 2010-09-04 16:47                 ` Steven
  2010-09-06  7:21                   ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Steven @ 2010-09-04 16:47 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

On Sun, 2010-09-05 at 00:42 +0800, Hui Zhu wrote:
> Could you post the other part of this code?  Then I can try to reproduce on it.

hello.c
------------------------------------------------
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/init.h>

static struct task_struct *test_task;
volatile struct timeval tv;
int year;

int test_thread(void *data)
{
        volatile int cnt = 0;
        set_current_state(TASK_INTERRUPTIBLE);
        schedule_timeout(1 * HZ); /* wait for the terminal ready */

        while(1){
                set_current_state(TASK_INTERRUPTIBLE); /* this is
required, or thread never sleep*/
                if(kthread_should_stop()) break;

                year = 2010;
                do_gettimeofday (&tv);
                printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
                cnt++;

                do_gettimeofday (&tv);
                printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
                cnt++;

                //reschedule after 5 seconds(approximately)
                schedule_timeout(60 * HZ);
        }

        return 0;
}

static int __init mt_init(void)
{
        int err;
        test_task = kthread_create(test_thread, NULL, "test_task");
        if(IS_ERR(test_task)){
                printk("Unable to start kernel thread.\n");
                printk("Unable to start kernel thread.\n");
                err = PTR_ERR(test_task);
                test_task = NULL;
                return err;
        }
        wake_up_process(test_task);
        return 0;
}


static void __exit mt_cleanup(void)
{
        if(test_task){
                kthread_stop(test_task);
                test_task = NULL;
        }
}

module_init(mt_init);
module_exit(mt_cleanup);

MODULE_LICENSE("GPL");
------------------------------------------------


Makefile
------------------------------------------------
obj-m := hello.o

KERNELBUILD := /lib/modules/`uname -r`/build

default:
        make -C $(KERNELBUILD) M=$(shell pwd) modules

clean:
        rm -rf *.o *.cmd *.ko *.mod.c .tmp-versions *.symvers
------------------------------------------------



> Thanks,
> Hui
> 
> On Sun, Sep 5, 2010 at 00:01, Steven <mqyoung@gmail.com> wrote:
> > Dear All,
> >
> > As I mentioned before, I could collect the variables of kernel function
> > such as vfs_readdir(ext3 is built in kernel not module). And I tried I
> > could collect variables of kernel's module(such as my ethernet card
> > driver 3c59x.ko). I will collect these info later.
> >
> > BUT, I can not collect the value of my testing module, neither global
> > nor local. I think there is some thing wrong with my compile option or
> > Makefile, any one know it? Thanks very much.
> >
> > Program:
> > -------------------------------------------------
> >  6 volatile struct timeval tv;
> >  7 int year;
> >  8
> >  9 int test_thread(void *data)
> >  10 {
> >  11         volatile int cnt = 0;
> >  12         set_current_state(TASK_INTERRUPTIBLE);
> >  13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
> >  14
> >  15         while(1){
> >  16                 set_current_state(TASK_INTERRUPTIBLE);
> >  17                 if(kthread_should_stop()) break;
> >  18
> >  19                 year = 2010;
> >  20                 do_gettimeofday (&tv);
> >  21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
> >  22                 cnt++;
> >  23
> >  24                 do_gettimeofday (&tv);
> >  25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
> >  26                 cnt++;
> >  27
> >  28                 //reschedule after 5 seconds(approximately)
> >  29                 schedule_timeout(60 * HZ);
> >  30         }
> >  31
> >  32         return 0;
> >  33 }
> > -------------------------------------------------
> >
> > Makefile
> > -------------------------------------------------
> > obj-m := hello.o
> >
> > KERNELBUILD := /lib/modules/`uname -r`/build
> >
> > default:
> >        make -C $(KERNELBUILD) M=$(shell pwd) modules
> > -------------------------------------------------
> >
> >
> > Screen log
> > -------------------------------------------------
> > debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
> > GNU gdb (GDB) 7.2
> > Copyright (C) 2010 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later
> > <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.  Type "show
> > copying"
> > and "show warranty" for details.
> > This GDB was configured as "i686-pc-linux-gnu".
> > For bug reporting instructions, please see:
> > <http://www.gnu.org/software/gdb/bugs/>...
> > Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118]
> > [ 3909.310124] tv_sec: 1283648666 - 16
> > [ 3909.315385] tv_sec: 1283648666 - 2010
> > done.
> > (gdb) target remote /proc/gtp
> > Remote debugging using /proc/gtp
> > 0x00000000 in ?? ()
> > (gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
> > add symbol table from file "/home/steven/hello/hello.ko" at
> >        .text_addr = 0xc8b2b000
> > (y or n) y
> > Reading symbols from /home/steven/hello/hello.ko...done.
> > (gdb) trace /home/steven/hello/hello.c:22
> > Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
> > (gdb) trace /home/steven/hello/hello.c:26
> > Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
> > (gdb) actions 1
> > Enter actions for tracepoint 1, one per line.
> > End with a line saying just "end".
> >>
> >>collect tv, year, cnt
> >>end
> > (gdb) actions 2
> > Enter actions for tracepoint 2, one per line.
> > End with a line saying just "end".
> >>collect tv, year, cnt
> >>end
> > (gdb) tstart
> > [ 4029.328129]
> > [ 4029.328136] tv_sec: 1283648786 - 20
> > [ 4029.333456] tv_sec: 1283648786 - 2010
> > tstop
> > (gdb) tfind
> > Found trace frame 0, tracepoint 1
> > #0  0xc8b2b095 in test_thread (data=0x0)
> > at /home/steven/hello/hello.c:22
> > 22                      cnt++;
> > (gdb) p tv
> > $1 = {tv_sec = 0, tv_usec = 0}
> > (gdb) p cnt
> > $2 = 0
> > (gdb) p year
> > $3 = 0
> > (gdb) tfind
> > Found trace frame 1, tracepoint 2
> > 0xc8b2b0c2      26                      cnt++;
> > (gdb) p cnt
> > $4 = 0
> > (gdb) p tv
> > $5 = {tv_sec = 0, tv_usec = 0}
> > (gdb) p year
> > $6 = 0
> > -------------------------------------------------
> >
> > Thanks,
> > Steven
> >
> > On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
> >> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
> >> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
> >> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
> >> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
> >> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
> >> >> >> trouble (all they want is rewrite the GCC in C++ :P).
> >> >> >> So I think make linux kernel can close optimization is better idea, do
> >> >> >> you know some way or some patch to do it?
> >> >> >>
> >> >> >
> >> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
> >> >> > kernel:
> >> >> > KBUILD_CFLAGS   += -O2
> >> >> > to
> >> >> > KBUILD_CFLAGS   += -O0
> >> >>
> >> >> Cool,  :)
> >> >>
> >> >> I try just change the compile option of readdir.c to without -O2, it
> >> >> works OK.  I think maybe it's a GDB bug too.
> >> >> Could you try the second issue with gdb 7.2?
> >> >
> >> > I have covered the two issues in the previous mail that I could collect
> >> > both global variables and locals(-O0 kernel + gdb7.2):
> >> >
> >> >        --------
> >> >        (gdb) trace vfs_readdir
> >> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
> >> >        (gdb) actions
> >> >        Enter actions for tracepoint 3, one per line.
> >> >        End with a line saying just "end".
> >> >        >collect *file
> >> >        >end
> >> >        (gdb) trace fs/readdir.c:29
> >> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
> >> >        (gdb) actions
> >> >        Enter actions for tracepoint 4, one per line.
> >> >        End with a line saying just "end".
> >> >        >collect res
> >> >        >end
> >> >        (gdb) tstart
> >> >        (gdb) tstop
> >> >        (gdb) tfind
> >> >        Found trace frame 0, tracepoint 3
> >> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
> >> >        buf=0x0)
> >> >            at fs/readdir.c:24
> >> >        24              struct inode *inode =
> >> >        file->f_path.dentry->d_inode;
> >> >        (gdb) p *file
> >> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
> >> >        fu_rcuhead = {
> >> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
> >> >        0xc6c05300,
> >> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
> >> >        {raw_lock = {
> >> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
> >> >        624640,
> >> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
> >> >        16777216}},
> >> >           = 0start = 0, size = 0, async_size = 0,
> >> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
> >> >        0,
> >> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
> >> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
> >> >        0xc761c74c}
> >> >        (gdb) p res
> >> >        $5 = 0
> >> >        (gdb) tfind
> >> >        Found trace frame 1, tracepoint 4
> >> >        0xc11756cb      29              res =
> >> >        security_file_permission(file, MAY_READ);
> >> >        (gdb) p res
> >> >        $6 = -20
> >> >        --------
> >> >
> >> >
> >> >
> >>
> >> Great.  :)
> >>
> >> Hui
> >
> >



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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04 16:34     ` Hui Zhu
@ 2010-09-04 18:22       ` Frank Ch. Eigler
  0 siblings, 0 replies; 22+ messages in thread
From: Frank Ch. Eigler @ 2010-09-04 18:22 UTC (permalink / raw)
  To: Hui Zhu
  Cc: Steven, gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann

Hi -


Hui Zhu <teawater@gmail.com> wrote:

> I met a issue with build systemtap.  Build it need (install
> elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel), but
> ubuntu looks don't have it.

It is there (apt-get builddep systemtap), but you can also use the
bundled-elfutils mode in the README, which uses a private source
tarball / build of elfutils.


> > #! /usr/bin/stap -g
> > probe kernel.function("vfs_readdir") {
> >  �println(%{ jiffies_64 %})
> >  �println($file$)
> > }
> 
> parse error: expected literal string or number
> 	saw: embedded-code at ./1.sh:3:14
>      source:      println(%{ jiffies_64 %})

This particular script needs to be run with "stap -g" (guru mode)
because it uses embedded-C to access the jiffies_64 value instead of
debuginfo.


> > #! /usr/bin/stap
> > probe kernel.statement("*@fs/readdir.c:29") {
> >  �println($res)
> > }
> >
> 
> semantic error: not accessible at this address: identifier '$res' at ./1.sh:3:14
>         source:      println($res)

That can happen if your line number is not quite right, or if you're
using a version of gcc prior to the VTA (better debuginfo for local
variables) code released in 4.5 (backported to 4.4 in Red Hat
distros).  (More recent versions of systemtap may also help.)

If OTOH gdb can access the variable there but systemtap can't, then we
have a bug (and I'd appreciate your time helping collect some extra
data to help fix it).


- FChE

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-04 16:47                 ` Steven
@ 2010-09-06  7:21                   ` Hui Zhu
  2010-09-06  7:50                     ` Hui Zhu
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-06  7:21 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Sep  6 15:17:06 teawater kernel: [514552.780031] gtp_kp_pre_handler:
tracepoint 1
Sep  6 15:17:06 teawater kernel: [514552.780034] gtp_parse_x: cmd 23
Sep  6 15:17:06 teawater kernel: [514552.780035] gtp_parse_x: cmd 22
Sep  6 15:17:06 teawater kernel: [514552.780037] gtp_parse_x: cmd c
Sep  6 15:17:06 teawater kernel: [514552.780039]
gtp_action_memory_read: id:1 0000054c 8
Sep  6 15:17:06 teawater kernel: [514552.780043]
gtp_action_memory_read: id:1 read 0000054c 8 get error.
Sep  6 15:17:06 teawater kernel: [514552.780048] gtp_kp_pre_handler:
tracepoint 1 stop.
Sep  6 15:17:06 teawater kernel: [514552.780051] tv_sec: 1283757426 - 2010
Sep  6 15:17:06 teawater kernel: [514552.780053] gtp_kp_pre_handler:
tracepoint 2
Sep  6 15:17:06 teawater kernel: [514552.780055] gtp_parse_x: cmd 23
Sep  6 15:17:06 teawater kernel: [514552.780056] gtp_parse_x: cmd 22
Sep  6 15:17:06 teawater kernel: [514552.780057] gtp_parse_x: cmd c
Sep  6 15:17:06 teawater kernel: [514552.780058]
gtp_action_memory_read: id:2 0000054c 8
Sep  6 15:17:06 teawater kernel: [514552.780061]
gtp_action_memory_read: id:2 read 0000054c 8 get error.
Sep  6 15:17:06 teawater kernel: [514552.780063] gtp_kp_pre_handler:
tracepoint 2 stop.
Sep  6 15:17:06 teawater kernel: [514552.780068] gtp_stop: tracepoint 1
Sep  6 15:17:06 teawater kernel: [514552.792059] gtp_stop: tracepoint 2

(gdb) add-symbol-file ~/kernel/tmp/h/hello.ko 0xf81b9000
add symbol table from file "/home/teawater/kernel/tmp/h/hello.ko" at
	.text_addr = 0xf81b9000
(y or n) y
Reading symbols from /home/teawater/kernel/tmp/h/hello.ko...done.
(gdb) p year
Cannot access memory at address 0x554
(gdb) p tv
Cannot access memory at address 0x54c

Looks GDB didn't get the right address of this val.

Export them maybe handle this issue.

Thanks,
Hui



On Sun, Sep 5, 2010 at 00:47, Steven <mqyoung@gmail.com> wrote:
> On Sun, 2010-09-05 at 00:42 +0800, Hui Zhu wrote:
>> Could you post the other part of this code?  Then I can try to reproduce on it.
>
> hello.c
> ------------------------------------------------
> #include <linux/kthread.h>
> #include <linux/module.h>
> #include <linux/init.h>
>
> static struct task_struct *test_task;
> volatile struct timeval tv;
> int year;
>
> int test_thread(void *data)
> {
>        volatile int cnt = 0;
>        set_current_state(TASK_INTERRUPTIBLE);
>        schedule_timeout(1 * HZ); /* wait for the terminal ready */
>
>        while(1){
>                set_current_state(TASK_INTERRUPTIBLE); /* this is
> required, or thread never sleep*/
>                if(kthread_should_stop()) break;
>
>                year = 2010;
>                do_gettimeofday (&tv);
>                printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
>                cnt++;
>
>                do_gettimeofday (&tv);
>                printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
>                cnt++;
>
>                //reschedule after 5 seconds(approximately)
>                schedule_timeout(60 * HZ);
>        }
>
>        return 0;
> }
>
> static int __init mt_init(void)
> {
>        int err;
>        test_task = kthread_create(test_thread, NULL, "test_task");
>        if(IS_ERR(test_task)){
>                printk("Unable to start kernel thread.\n");
>                printk("Unable to start kernel thread.\n");
>                err = PTR_ERR(test_task);
>                test_task = NULL;
>                return err;
>        }
>        wake_up_process(test_task);
>        return 0;
> }
>
>
> static void __exit mt_cleanup(void)
> {
>        if(test_task){
>                kthread_stop(test_task);
>                test_task = NULL;
>        }
> }
>
> module_init(mt_init);
> module_exit(mt_cleanup);
>
> MODULE_LICENSE("GPL");
> ------------------------------------------------
>
>
> Makefile
> ------------------------------------------------
> obj-m := hello.o
>
> KERNELBUILD := /lib/modules/`uname -r`/build
>
> default:
>        make -C $(KERNELBUILD) M=$(shell pwd) modules
>
> clean:
>        rm -rf *.o *.cmd *.ko *.mod.c .tmp-versions *.symvers
> ------------------------------------------------
>
>
>
>> Thanks,
>> Hui
>>
>> On Sun, Sep 5, 2010 at 00:01, Steven <mqyoung@gmail.com> wrote:
>> > Dear All,
>> >
>> > As I mentioned before, I could collect the variables of kernel function
>> > such as vfs_readdir(ext3 is built in kernel not module). And I tried I
>> > could collect variables of kernel's module(such as my ethernet card
>> > driver 3c59x.ko). I will collect these info later.
>> >
>> > BUT, I can not collect the value of my testing module, neither global
>> > nor local. I think there is some thing wrong with my compile option or
>> > Makefile, any one know it? Thanks very much.
>> >
>> > Program:
>> > -------------------------------------------------
>> >  6 volatile struct timeval tv;
>> >  7 int year;
>> >  8
>> >  9 int test_thread(void *data)
>> >  10 {
>> >  11         volatile int cnt = 0;
>> >  12         set_current_state(TASK_INTERRUPTIBLE);
>> >  13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
>> >  14
>> >  15         while(1){
>> >  16                 set_current_state(TASK_INTERRUPTIBLE);
>> >  17                 if(kthread_should_stop()) break;
>> >  18
>> >  19                 year = 2010;
>> >  20                 do_gettimeofday (&tv);
>> >  21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
>> >  22                 cnt++;
>> >  23
>> >  24                 do_gettimeofday (&tv);
>> >  25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
>> >  26                 cnt++;
>> >  27
>> >  28                 //reschedule after 5 seconds(approximately)
>> >  29                 schedule_timeout(60 * HZ);
>> >  30         }
>> >  31
>> >  32         return 0;
>> >  33 }
>> > -------------------------------------------------
>> >
>> > Makefile
>> > -------------------------------------------------
>> > obj-m := hello.o
>> >
>> > KERNELBUILD := /lib/modules/`uname -r`/build
>> >
>> > default:
>> >        make -C $(KERNELBUILD) M=$(shell pwd) modules
>> > -------------------------------------------------
>> >
>> >
>> > Screen log
>> > -------------------------------------------------
>> > debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
>> > GNU gdb (GDB) 7.2
>> > Copyright (C) 2010 Free Software Foundation, Inc.
>> > License GPLv3+: GNU GPL version 3 or later
>> > <http://gnu.org/licenses/gpl.html>
>> > This is free software: you are free to change and redistribute it.
>> > There is NO WARRANTY, to the extent permitted by law.  Type "show
>> > copying"
>> > and "show warranty" for details.
>> > This GDB was configured as "i686-pc-linux-gnu".
>> > For bug reporting instructions, please see:
>> > <http://www.gnu.org/software/gdb/bugs/>...
>> > Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118]
>> > [ 3909.310124] tv_sec: 1283648666 - 16
>> > [ 3909.315385] tv_sec: 1283648666 - 2010
>> > done.
>> > (gdb) target remote /proc/gtp
>> > Remote debugging using /proc/gtp
>> > 0x00000000 in ?? ()
>> > (gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
>> > add symbol table from file "/home/steven/hello/hello.ko" at
>> >        .text_addr = 0xc8b2b000
>> > (y or n) y
>> > Reading symbols from /home/steven/hello/hello.ko...done.
>> > (gdb) trace /home/steven/hello/hello.c:22
>> > Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
>> > (gdb) trace /home/steven/hello/hello.c:26
>> > Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
>> > (gdb) actions 1
>> > Enter actions for tracepoint 1, one per line.
>> > End with a line saying just "end".
>> >>
>> >>collect tv, year, cnt
>> >>end
>> > (gdb) actions 2
>> > Enter actions for tracepoint 2, one per line.
>> > End with a line saying just "end".
>> >>collect tv, year, cnt
>> >>end
>> > (gdb) tstart
>> > [ 4029.328129]
>> > [ 4029.328136] tv_sec: 1283648786 - 20
>> > [ 4029.333456] tv_sec: 1283648786 - 2010
>> > tstop
>> > (gdb) tfind
>> > Found trace frame 0, tracepoint 1
>> > #0  0xc8b2b095 in test_thread (data=0x0)
>> > at /home/steven/hello/hello.c:22
>> > 22                      cnt++;
>> > (gdb) p tv
>> > $1 = {tv_sec = 0, tv_usec = 0}
>> > (gdb) p cnt
>> > $2 = 0
>> > (gdb) p year
>> > $3 = 0
>> > (gdb) tfind
>> > Found trace frame 1, tracepoint 2
>> > 0xc8b2b0c2      26                      cnt++;
>> > (gdb) p cnt
>> > $4 = 0
>> > (gdb) p tv
>> > $5 = {tv_sec = 0, tv_usec = 0}
>> > (gdb) p year
>> > $6 = 0
>> > -------------------------------------------------
>> >
>> > Thanks,
>> > Steven
>> >
>> > On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
>> >> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
>> >> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
>> >> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
>> >> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
>> >> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
>> >> >> >> trouble (all they want is rewrite the GCC in C++ :P).
>> >> >> >> So I think make linux kernel can close optimization is better idea, do
>> >> >> >> you know some way or some patch to do it?
>> >> >> >>
>> >> >> >
>> >> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
>> >> >> > kernel:
>> >> >> > KBUILD_CFLAGS   += -O2
>> >> >> > to
>> >> >> > KBUILD_CFLAGS   += -O0
>> >> >>
>> >> >> Cool,  :)
>> >> >>
>> >> >> I try just change the compile option of readdir.c to without -O2, it
>> >> >> works OK.  I think maybe it's a GDB bug too.
>> >> >> Could you try the second issue with gdb 7.2?
>> >> >
>> >> > I have covered the two issues in the previous mail that I could collect
>> >> > both global variables and locals(-O0 kernel + gdb7.2):
>> >> >
>> >> >        --------
>> >> >        (gdb) trace vfs_readdir
>> >> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
>> >> >        (gdb) actions
>> >> >        Enter actions for tracepoint 3, one per line.
>> >> >        End with a line saying just "end".
>> >> >        >collect *file
>> >> >        >end
>> >> >        (gdb) trace fs/readdir.c:29
>> >> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
>> >> >        (gdb) actions
>> >> >        Enter actions for tracepoint 4, one per line.
>> >> >        End with a line saying just "end".
>> >> >        >collect res
>> >> >        >end
>> >> >        (gdb) tstart
>> >> >        (gdb) tstop
>> >> >        (gdb) tfind
>> >> >        Found trace frame 0, tracepoint 3
>> >> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
>> >> >        buf=0x0)
>> >> >            at fs/readdir.c:24
>> >> >        24              struct inode *inode =
>> >> >        file->f_path.dentry->d_inode;
>> >> >        (gdb) p *file
>> >> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
>> >> >        fu_rcuhead = {
>> >> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
>> >> >        0xc6c05300,
>> >> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
>> >> >        {raw_lock = {
>> >> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
>> >> >        624640,
>> >> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
>> >> >        16777216}},
>> >> >           = 0start = 0, size = 0, async_size = 0,
>> >> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
>> >> >        0,
>> >> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
>> >> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
>> >> >        0xc761c74c}
>> >> >        (gdb) p res
>> >> >        $5 = 0
>> >> >        (gdb) tfind
>> >> >        Found trace frame 1, tracepoint 4
>> >> >        0xc11756cb      29              res =
>> >> >        security_file_permission(file, MAY_READ);
>> >> >        (gdb) p res
>> >> >        $6 = -20
>> >> >        --------
>> >> >
>> >> >
>> >> >
>> >>
>> >> Great.  :)
>> >>
>> >> Hui
>> >
>> >
>
>
>

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

* Re: Linux Kernel GDB tracepoint module 2010-8-30 release
  2010-09-06  7:21                   ` Hui Zhu
@ 2010-09-06  7:50                     ` Hui Zhu
  2010-09-06  9:30                       ` Log of Using KGTP Steven
  0 siblings, 1 reply; 22+ messages in thread
From: Hui Zhu @ 2010-09-06  7:50 UTC (permalink / raw)
  To: Steven
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

cat /sys/module/hello/sections/.bss
0xf81b92ec
add-symbol-file ~/kernel/tmp/h/hello.ko 0xf81b9000 -s .bss 0xf81b92ec

(gdb) tstart
(gdb) tstatus
Trace is running on the target.
Collected 0 trace frames.
Trace buffer has 86255744 bytes of 86255744 bytes free (0% full).
Trace will stop if GDB disconnects.
Not looking at any trace frame.
(gdb) tstop
(gdb) tfind
Found trace frame 0, tracepoint 1
#0  0xf81b9068 in test_thread (data=<value optimized out>) at
/home/teawater/kernel/tmp/h/hello.c:22
22	               cnt++;
(gdb) p cnt
$1 = 106
(gdb) p tv
$2 = {tv_sec = 1283760246, tv_usec = 784020}
(gdb) p year
$3 = 2010
(gdb)

Looks I need update HOWTO now.


To get all the module message with hand is uncool.
I will make it more automated when I have time.

Thanks,
Hui

On Mon, Sep 6, 2010 at 15:21, Hui Zhu <teawater@gmail.com> wrote:
> Sep  6 15:17:06 teawater kernel: [514552.780031] gtp_kp_pre_handler:
> tracepoint 1
> Sep  6 15:17:06 teawater kernel: [514552.780034] gtp_parse_x: cmd 23
> Sep  6 15:17:06 teawater kernel: [514552.780035] gtp_parse_x: cmd 22
> Sep  6 15:17:06 teawater kernel: [514552.780037] gtp_parse_x: cmd c
> Sep  6 15:17:06 teawater kernel: [514552.780039]
> gtp_action_memory_read: id:1 0000054c 8
> Sep  6 15:17:06 teawater kernel: [514552.780043]
> gtp_action_memory_read: id:1 read 0000054c 8 get error.
> Sep  6 15:17:06 teawater kernel: [514552.780048] gtp_kp_pre_handler:
> tracepoint 1 stop.
> Sep  6 15:17:06 teawater kernel: [514552.780051] tv_sec: 1283757426 - 2010
> Sep  6 15:17:06 teawater kernel: [514552.780053] gtp_kp_pre_handler:
> tracepoint 2
> Sep  6 15:17:06 teawater kernel: [514552.780055] gtp_parse_x: cmd 23
> Sep  6 15:17:06 teawater kernel: [514552.780056] gtp_parse_x: cmd 22
> Sep  6 15:17:06 teawater kernel: [514552.780057] gtp_parse_x: cmd c
> Sep  6 15:17:06 teawater kernel: [514552.780058]
> gtp_action_memory_read: id:2 0000054c 8
> Sep  6 15:17:06 teawater kernel: [514552.780061]
> gtp_action_memory_read: id:2 read 0000054c 8 get error.
> Sep  6 15:17:06 teawater kernel: [514552.780063] gtp_kp_pre_handler:
> tracepoint 2 stop.
> Sep  6 15:17:06 teawater kernel: [514552.780068] gtp_stop: tracepoint 1
> Sep  6 15:17:06 teawater kernel: [514552.792059] gtp_stop: tracepoint 2
>
> (gdb) add-symbol-file ~/kernel/tmp/h/hello.ko 0xf81b9000
> add symbol table from file "/home/teawater/kernel/tmp/h/hello.ko" at
>        .text_addr = 0xf81b9000
> (y or n) y
> Reading symbols from /home/teawater/kernel/tmp/h/hello.ko...done.
> (gdb) p year
> Cannot access memory at address 0x554
> (gdb) p tv
> Cannot access memory at address 0x54c
>
> Looks GDB didn't get the right address of this val.
>
> Export them maybe handle this issue.
>
> Thanks,
> Hui
>
>
>
> On Sun, Sep 5, 2010 at 00:47, Steven <mqyoung@gmail.com> wrote:
>> On Sun, 2010-09-05 at 00:42 +0800, Hui Zhu wrote:
>>> Could you post the other part of this code?  Then I can try to reproduce on it.
>>
>> hello.c
>> ------------------------------------------------
>> #include <linux/kthread.h>
>> #include <linux/module.h>
>> #include <linux/init.h>
>>
>> static struct task_struct *test_task;
>> volatile struct timeval tv;
>> int year;
>>
>> int test_thread(void *data)
>> {
>>        volatile int cnt = 0;
>>        set_current_state(TASK_INTERRUPTIBLE);
>>        schedule_timeout(1 * HZ); /* wait for the terminal ready */
>>
>>        while(1){
>>                set_current_state(TASK_INTERRUPTIBLE); /* this is
>> required, or thread never sleep*/
>>                if(kthread_should_stop()) break;
>>
>>                year = 2010;
>>                do_gettimeofday (&tv);
>>                printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
>>                cnt++;
>>
>>                do_gettimeofday (&tv);
>>                printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
>>                cnt++;
>>
>>                //reschedule after 5 seconds(approximately)
>>                schedule_timeout(60 * HZ);
>>        }
>>
>>        return 0;
>> }
>>
>> static int __init mt_init(void)
>> {
>>        int err;
>>        test_task = kthread_create(test_thread, NULL, "test_task");
>>        if(IS_ERR(test_task)){
>>                printk("Unable to start kernel thread.\n");
>>                printk("Unable to start kernel thread.\n");
>>                err = PTR_ERR(test_task);
>>                test_task = NULL;
>>                return err;
>>        }
>>        wake_up_process(test_task);
>>        return 0;
>> }
>>
>>
>> static void __exit mt_cleanup(void)
>> {
>>        if(test_task){
>>                kthread_stop(test_task);
>>                test_task = NULL;
>>        }
>> }
>>
>> module_init(mt_init);
>> module_exit(mt_cleanup);
>>
>> MODULE_LICENSE("GPL");
>> ------------------------------------------------
>>
>>
>> Makefile
>> ------------------------------------------------
>> obj-m := hello.o
>>
>> KERNELBUILD := /lib/modules/`uname -r`/build
>>
>> default:
>>        make -C $(KERNELBUILD) M=$(shell pwd) modules
>>
>> clean:
>>        rm -rf *.o *.cmd *.ko *.mod.c .tmp-versions *.symvers
>> ------------------------------------------------
>>
>>
>>
>>> Thanks,
>>> Hui
>>>
>>> On Sun, Sep 5, 2010 at 00:01, Steven <mqyoung@gmail.com> wrote:
>>> > Dear All,
>>> >
>>> > As I mentioned before, I could collect the variables of kernel function
>>> > such as vfs_readdir(ext3 is built in kernel not module). And I tried I
>>> > could collect variables of kernel's module(such as my ethernet card
>>> > driver 3c59x.ko). I will collect these info later.
>>> >
>>> > BUT, I can not collect the value of my testing module, neither global
>>> > nor local. I think there is some thing wrong with my compile option or
>>> > Makefile, any one know it? Thanks very much.
>>> >
>>> > Program:
>>> > -------------------------------------------------
>>> >  6 volatile struct timeval tv;
>>> >  7 int year;
>>> >  8
>>> >  9 int test_thread(void *data)
>>> >  10 {
>>> >  11         volatile int cnt = 0;
>>> >  12         set_current_state(TASK_INTERRUPTIBLE);
>>> >  13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
>>> >  14
>>> >  15         while(1){
>>> >  16                 set_current_state(TASK_INTERRUPTIBLE);
>>> >  17                 if(kthread_should_stop()) break;
>>> >  18
>>> >  19                 year = 2010;
>>> >  20                 do_gettimeofday (&tv);
>>> >  21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
>>> >  22                 cnt++;
>>> >  23
>>> >  24                 do_gettimeofday (&tv);
>>> >  25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
>>> >  26                 cnt++;
>>> >  27
>>> >  28                 //reschedule after 5 seconds(approximately)
>>> >  29                 schedule_timeout(60 * HZ);
>>> >  30         }
>>> >  31
>>> >  32         return 0;
>>> >  33 }
>>> > -------------------------------------------------
>>> >
>>> > Makefile
>>> > -------------------------------------------------
>>> > obj-m := hello.o
>>> >
>>> > KERNELBUILD := /lib/modules/`uname -r`/build
>>> >
>>> > default:
>>> >        make -C $(KERNELBUILD) M=$(shell pwd) modules
>>> > -------------------------------------------------
>>> >
>>> >
>>> > Screen log
>>> > -------------------------------------------------
>>> > debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
>>> > GNU gdb (GDB) 7.2
>>> > Copyright (C) 2010 Free Software Foundation, Inc.
>>> > License GPLv3+: GNU GPL version 3 or later
>>> > <http://gnu.org/licenses/gpl.html>
>>> > This is free software: you are free to change and redistribute it.
>>> > There is NO WARRANTY, to the extent permitted by law.  Type "show
>>> > copying"
>>> > and "show warranty" for details.
>>> > This GDB was configured as "i686-pc-linux-gnu".
>>> > For bug reporting instructions, please see:
>>> > <http://www.gnu.org/software/gdb/bugs/>...
>>> > Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118]
>>> > [ 3909.310124] tv_sec: 1283648666 - 16
>>> > [ 3909.315385] tv_sec: 1283648666 - 2010
>>> > done.
>>> > (gdb) target remote /proc/gtp
>>> > Remote debugging using /proc/gtp
>>> > 0x00000000 in ?? ()
>>> > (gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
>>> > add symbol table from file "/home/steven/hello/hello.ko" at
>>> >        .text_addr = 0xc8b2b000
>>> > (y or n) y
>>> > Reading symbols from /home/steven/hello/hello.ko...done.
>>> > (gdb) trace /home/steven/hello/hello.c:22
>>> > Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
>>> > (gdb) trace /home/steven/hello/hello.c:26
>>> > Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
>>> > (gdb) actions 1
>>> > Enter actions for tracepoint 1, one per line.
>>> > End with a line saying just "end".
>>> >>
>>> >>collect tv, year, cnt
>>> >>end
>>> > (gdb) actions 2
>>> > Enter actions for tracepoint 2, one per line.
>>> > End with a line saying just "end".
>>> >>collect tv, year, cnt
>>> >>end
>>> > (gdb) tstart
>>> > [ 4029.328129]
>>> > [ 4029.328136] tv_sec: 1283648786 - 20
>>> > [ 4029.333456] tv_sec: 1283648786 - 2010
>>> > tstop
>>> > (gdb) tfind
>>> > Found trace frame 0, tracepoint 1
>>> > #0  0xc8b2b095 in test_thread (data=0x0)
>>> > at /home/steven/hello/hello.c:22
>>> > 22                      cnt++;
>>> > (gdb) p tv
>>> > $1 = {tv_sec = 0, tv_usec = 0}
>>> > (gdb) p cnt
>>> > $2 = 0
>>> > (gdb) p year
>>> > $3 = 0
>>> > (gdb) tfind
>>> > Found trace frame 1, tracepoint 2
>>> > 0xc8b2b0c2      26                      cnt++;
>>> > (gdb) p cnt
>>> > $4 = 0
>>> > (gdb) p tv
>>> > $5 = {tv_sec = 0, tv_usec = 0}
>>> > (gdb) p year
>>> > $6 = 0
>>> > -------------------------------------------------
>>> >
>>> > Thanks,
>>> > Steven
>>> >
>>> > On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
>>> >> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
>>> >> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
>>> >> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
>>> >> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
>>> >> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
>>> >> >> >> trouble (all they want is rewrite the GCC in C++ :P).
>>> >> >> >> So I think make linux kernel can close optimization is better idea, do
>>> >> >> >> you know some way or some patch to do it?
>>> >> >> >>
>>> >> >> >
>>> >> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
>>> >> >> > kernel:
>>> >> >> > KBUILD_CFLAGS   += -O2
>>> >> >> > to
>>> >> >> > KBUILD_CFLAGS   += -O0
>>> >> >>
>>> >> >> Cool,  :)
>>> >> >>
>>> >> >> I try just change the compile option of readdir.c to without -O2, it
>>> >> >> works OK.  I think maybe it's a GDB bug too.
>>> >> >> Could you try the second issue with gdb 7.2?
>>> >> >
>>> >> > I have covered the two issues in the previous mail that I could collect
>>> >> > both global variables and locals(-O0 kernel + gdb7.2):
>>> >> >
>>> >> >        --------
>>> >> >        (gdb) trace vfs_readdir
>>> >> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
>>> >> >        (gdb) actions
>>> >> >        Enter actions for tracepoint 3, one per line.
>>> >> >        End with a line saying just "end".
>>> >> >        >collect *file
>>> >> >        >end
>>> >> >        (gdb) trace fs/readdir.c:29
>>> >> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
>>> >> >        (gdb) actions
>>> >> >        Enter actions for tracepoint 4, one per line.
>>> >> >        End with a line saying just "end".
>>> >> >        >collect res
>>> >> >        >end
>>> >> >        (gdb) tstart
>>> >> >        (gdb) tstop
>>> >> >        (gdb) tfind
>>> >> >        Found trace frame 0, tracepoint 3
>>> >> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
>>> >> >        buf=0x0)
>>> >> >            at fs/readdir.c:24
>>> >> >        24              struct inode *inode =
>>> >> >        file->f_path.dentry->d_inode;
>>> >> >        (gdb) p *file
>>> >> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
>>> >> >        fu_rcuhead = {
>>> >> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
>>> >> >        0xc6c05300,
>>> >> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
>>> >> >        {raw_lock = {
>>> >> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
>>> >> >        624640,
>>> >> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
>>> >> >        16777216}},
>>> >> >           = 0start = 0, size = 0, async_size = 0,
>>> >> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
>>> >> >        0,
>>> >> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
>>> >> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
>>> >> >        0xc761c74c}
>>> >> >        (gdb) p res
>>> >> >        $5 = 0
>>> >> >        (gdb) tfind
>>> >> >        Found trace frame 1, tracepoint 4
>>> >> >        0xc11756cb      29              res =
>>> >> >        security_file_permission(file, MAY_READ);
>>> >> >        (gdb) p res
>>> >> >        $6 = -20
>>> >> >        --------
>>> >> >
>>> >> >
>>> >> >
>>> >>
>>> >> Great.  :)
>>> >>
>>> >> Hui
>>> >
>>> >
>>
>>
>>
>

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

* Log of  Using KGTP
  2010-09-06  7:50                     ` Hui Zhu
@ 2010-09-06  9:30                       ` Steven
  0 siblings, 0 replies; 22+ messages in thread
From: Steven @ 2010-09-06  9:30 UTC (permalink / raw)
  To: Hui Zhu
  Cc: gdb, linux-kernel, Michael Snyder, Marc Khouzam,
	Thiago Jung Bauermann, Frank Ch. Eigler

Great! Many thanks. I collect all the information and write a howto, 
hope it could help you.

http://dslab.lzu.edu.cn/modules/lifetype/index.php?op=ViewArticle&articleId=31&blogId=22

Best Regards
Steven

On Mon, 2010-09-06 at 15:50 +0800, Hui Zhu wrote:
> cat /sys/module/hello/sections/.bss
> 0xf81b92ec
> add-symbol-file ~/kernel/tmp/h/hello.ko 0xf81b9000 -s .bss 0xf81b92ec
> 
> (gdb) tstart
> (gdb) tstatus
> Trace is running on the target.
> Collected 0 trace frames.
> Trace buffer has 86255744 bytes of 86255744 bytes free (0% full).
> Trace will stop if GDB disconnects.
> Not looking at any trace frame.
> (gdb) tstop
> (gdb) tfind
> Found trace frame 0, tracepoint 1
> #0  0xf81b9068 in test_thread (data=<value optimized out>) at
> /home/teawater/kernel/tmp/h/hello.c:22
> 22	               cnt++;
> (gdb) p cnt
> $1 = 106
> (gdb) p tv
> $2 = {tv_sec = 1283760246, tv_usec = 784020}
> (gdb) p year
> $3 = 2010
> (gdb)
> 
> Looks I need update HOWTO now.
> 
> 
> To get all the module message with hand is uncool.
> I will make it more automated when I have time.
> 
> Thanks,
> Hui
> 
> On Mon, Sep 6, 2010 at 15:21, Hui Zhu <teawater@gmail.com> wrote:
> > Sep  6 15:17:06 teawater kernel: [514552.780031] gtp_kp_pre_handler:
> > tracepoint 1
> > Sep  6 15:17:06 teawater kernel: [514552.780034] gtp_parse_x: cmd 23
> > Sep  6 15:17:06 teawater kernel: [514552.780035] gtp_parse_x: cmd 22
> > Sep  6 15:17:06 teawater kernel: [514552.780037] gtp_parse_x: cmd c
> > Sep  6 15:17:06 teawater kernel: [514552.780039]
> > gtp_action_memory_read: id:1 0000054c 8
> > Sep  6 15:17:06 teawater kernel: [514552.780043]
> > gtp_action_memory_read: id:1 read 0000054c 8 get error.
> > Sep  6 15:17:06 teawater kernel: [514552.780048] gtp_kp_pre_handler:
> > tracepoint 1 stop.
> > Sep  6 15:17:06 teawater kernel: [514552.780051] tv_sec: 1283757426 - 2010
> > Sep  6 15:17:06 teawater kernel: [514552.780053] gtp_kp_pre_handler:
> > tracepoint 2
> > Sep  6 15:17:06 teawater kernel: [514552.780055] gtp_parse_x: cmd 23
> > Sep  6 15:17:06 teawater kernel: [514552.780056] gtp_parse_x: cmd 22
> > Sep  6 15:17:06 teawater kernel: [514552.780057] gtp_parse_x: cmd c
> > Sep  6 15:17:06 teawater kernel: [514552.780058]
> > gtp_action_memory_read: id:2 0000054c 8
> > Sep  6 15:17:06 teawater kernel: [514552.780061]
> > gtp_action_memory_read: id:2 read 0000054c 8 get error.
> > Sep  6 15:17:06 teawater kernel: [514552.780063] gtp_kp_pre_handler:
> > tracepoint 2 stop.
> > Sep  6 15:17:06 teawater kernel: [514552.780068] gtp_stop: tracepoint 1
> > Sep  6 15:17:06 teawater kernel: [514552.792059] gtp_stop: tracepoint 2
> >
> > (gdb) add-symbol-file ~/kernel/tmp/h/hello.ko 0xf81b9000
> > add symbol table from file "/home/teawater/kernel/tmp/h/hello.ko" at
> >        .text_addr = 0xf81b9000
> > (y or n) y
> > Reading symbols from /home/teawater/kernel/tmp/h/hello.ko...done.
> > (gdb) p year
> > Cannot access memory at address 0x554
> > (gdb) p tv
> > Cannot access memory at address 0x54c
> >
> > Looks GDB didn't get the right address of this val.
> >
> > Export them maybe handle this issue.
> >
> > Thanks,
> > Hui
> >
> >
> >
> > On Sun, Sep 5, 2010 at 00:47, Steven <mqyoung@gmail.com> wrote:
> >> On Sun, 2010-09-05 at 00:42 +0800, Hui Zhu wrote:
> >>> Could you post the other part of this code?  Then I can try to reproduce on it.
> >>
> >> hello.c
> >> ------------------------------------------------
> >> #include <linux/kthread.h>
> >> #include <linux/module.h>
> >> #include <linux/init.h>
> >>
> >> static struct task_struct *test_task;
> >> volatile struct timeval tv;
> >> int year;
> >>
> >> int test_thread(void *data)
> >> {
> >>        volatile int cnt = 0;
> >>        set_current_state(TASK_INTERRUPTIBLE);
> >>        schedule_timeout(1 * HZ); /* wait for the terminal ready */
> >>
> >>        while(1){
> >>                set_current_state(TASK_INTERRUPTIBLE); /* this is
> >> required, or thread never sleep*/
> >>                if(kthread_should_stop()) break;
> >>
> >>                year = 2010;
> >>                do_gettimeofday (&tv);
> >>                printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
> >>                cnt++;
> >>
> >>                do_gettimeofday (&tv);
> >>                printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
> >>                cnt++;
> >>
> >>                //reschedule after 5 seconds(approximately)
> >>                schedule_timeout(60 * HZ);
> >>        }
> >>
> >>        return 0;
> >> }
> >>
> >> static int __init mt_init(void)
> >> {
> >>        int err;
> >>        test_task = kthread_create(test_thread, NULL, "test_task");
> >>        if(IS_ERR(test_task)){
> >>                printk("Unable to start kernel thread.\n");
> >>                printk("Unable to start kernel thread.\n");
> >>                err = PTR_ERR(test_task);
> >>                test_task = NULL;
> >>                return err;
> >>        }
> >>        wake_up_process(test_task);
> >>        return 0;
> >> }
> >>
> >>
> >> static void __exit mt_cleanup(void)
> >> {
> >>        if(test_task){
> >>                kthread_stop(test_task);
> >>                test_task = NULL;
> >>        }
> >> }
> >>
> >> module_init(mt_init);
> >> module_exit(mt_cleanup);
> >>
> >> MODULE_LICENSE("GPL");
> >> ------------------------------------------------
> >>
> >>
> >> Makefile
> >> ------------------------------------------------
> >> obj-m := hello.o
> >>
> >> KERNELBUILD := /lib/modules/`uname -r`/build
> >>
> >> default:
> >>        make -C $(KERNELBUILD) M=$(shell pwd) modules
> >>
> >> clean:
> >>        rm -rf *.o *.cmd *.ko *.mod.c .tmp-versions *.symvers
> >> ------------------------------------------------
> >>
> >>
> >>
> >>> Thanks,
> >>> Hui
> >>>
> >>> On Sun, Sep 5, 2010 at 00:01, Steven <mqyoung@gmail.com> wrote:
> >>> > Dear All,
> >>> >
> >>> > As I mentioned before, I could collect the variables of kernel function
> >>> > such as vfs_readdir(ext3 is built in kernel not module). And I tried I
> >>> > could collect variables of kernel's module(such as my ethernet card
> >>> > driver 3c59x.ko). I will collect these info later.
> >>> >
> >>> > BUT, I can not collect the value of my testing module, neither global
> >>> > nor local. I think there is some thing wrong with my compile option or
> >>> > Makefile, any one know it? Thanks very much.
> >>> >
> >>> > Program:
> >>> > -------------------------------------------------
> >>> >  6 volatile struct timeval tv;
> >>> >  7 int year;
> >>> >  8
> >>> >  9 int test_thread(void *data)
> >>> >  10 {
> >>> >  11         volatile int cnt = 0;
> >>> >  12         set_current_state(TASK_INTERRUPTIBLE);
> >>> >  13         schedule_timeout(1 * HZ); /* wait for the terminal ready */
> >>> >  14
> >>> >  15         while(1){
> >>> >  16                 set_current_state(TASK_INTERRUPTIBLE);
> >>> >  17                 if(kthread_should_stop()) break;
> >>> >  18
> >>> >  19                 year = 2010;
> >>> >  20                 do_gettimeofday (&tv);
> >>> >  21                 printk("\ntv_sec: %d - %d\n", (int)tv.tv_sec, cnt);
> >>> >  22                 cnt++;
> >>> >  23
> >>> >  24                 do_gettimeofday (&tv);
> >>> >  25                 printk("tv_sec: %d - %d\n", (int)tv.tv_sec, year);
> >>> >  26                 cnt++;
> >>> >  27
> >>> >  28                 //reschedule after 5 seconds(approximately)
> >>> >  29                 schedule_timeout(60 * HZ);
> >>> >  30         }
> >>> >  31
> >>> >  32         return 0;
> >>> >  33 }
> >>> > -------------------------------------------------
> >>> >
> >>> > Makefile
> >>> > -------------------------------------------------
> >>> > obj-m := hello.o
> >>> >
> >>> > KERNELBUILD := /lib/modules/`uname -r`/build
> >>> >
> >>> > default:
> >>> >        make -C $(KERNELBUILD) M=$(shell pwd) modules
> >>> > -------------------------------------------------
> >>> >
> >>> >
> >>> > Screen log
> >>> > -------------------------------------------------
> >>> > debian:/home/linux-2.6.33.6# /usr/local/bin/gdb vmlinux
> >>> > GNU gdb (GDB) 7.2
> >>> > Copyright (C) 2010 Free Software Foundation, Inc.
> >>> > License GPLv3+: GNU GPL version 3 or later
> >>> > <http://gnu.org/licenses/gpl.html>
> >>> > This is free software: you are free to change and redistribute it.
> >>> > There is NO WARRANTY, to the extent permitted by law.  Type "show
> >>> > copying"
> >>> > and "show warranty" for details.
> >>> > This GDB was configured as "i686-pc-linux-gnu".
> >>> > For bug reporting instructions, please see:
> >>> > <http://www.gnu.org/software/gdb/bugs/>...
> >>> > Reading symbols from /home/linux-2.6.33.6/vmlinux...[ 3909.310118]
> >>> > [ 3909.310124] tv_sec: 1283648666 - 16
> >>> > [ 3909.315385] tv_sec: 1283648666 - 2010
> >>> > done.
> >>> > (gdb) target remote /proc/gtp
> >>> > Remote debugging using /proc/gtp
> >>> > 0x00000000 in ?? ()
> >>> > (gdb) add-symbol-file /home/steven/hello/hello.ko 0xc8b2b000
> >>> > add symbol table from file "/home/steven/hello/hello.ko" at
> >>> >        .text_addr = 0xc8b2b000
> >>> > (y or n) y
> >>> > Reading symbols from /home/steven/hello/hello.ko...done.
> >>> > (gdb) trace /home/steven/hello/hello.c:22
> >>> > Tracepoint 1 at 0xc8b2b094: file /home/steven/hello/hello.c, line 22.
> >>> > (gdb) trace /home/steven/hello/hello.c:26
> >>> > Tracepoint 2 at 0xc8b2b0c1: file /home/steven/hello/hello.c, line 26.
> >>> > (gdb) actions 1
> >>> > Enter actions for tracepoint 1, one per line.
> >>> > End with a line saying just "end".
> >>> >>
> >>> >>collect tv, year, cnt
> >>> >>end
> >>> > (gdb) actions 2
> >>> > Enter actions for tracepoint 2, one per line.
> >>> > End with a line saying just "end".
> >>> >>collect tv, year, cnt
> >>> >>end
> >>> > (gdb) tstart
> >>> > [ 4029.328129]
> >>> > [ 4029.328136] tv_sec: 1283648786 - 20
> >>> > [ 4029.333456] tv_sec: 1283648786 - 2010
> >>> > tstop
> >>> > (gdb) tfind
> >>> > Found trace frame 0, tracepoint 1
> >>> > #0  0xc8b2b095 in test_thread (data=0x0)
> >>> > at /home/steven/hello/hello.c:22
> >>> > 22                      cnt++;
> >>> > (gdb) p tv
> >>> > $1 = {tv_sec = 0, tv_usec = 0}
> >>> > (gdb) p cnt
> >>> > $2 = 0
> >>> > (gdb) p year
> >>> > $3 = 0
> >>> > (gdb) tfind
> >>> > Found trace frame 1, tracepoint 2
> >>> > 0xc8b2b0c2      26                      cnt++;
> >>> > (gdb) p cnt
> >>> > $4 = 0
> >>> > (gdb) p tv
> >>> > $5 = {tv_sec = 0, tv_usec = 0}
> >>> > (gdb) p year
> >>> > $6 = 0
> >>> > -------------------------------------------------
> >>> >
> >>> > Thanks,
> >>> > Steven
> >>> >
> >>> > On Sat, 2010-09-04 at 22:58 +0800, Hui Zhu wrote:
> >>> >> On Sat, Sep 4, 2010 at 17:26, Steven <mqyoung@gmail.com> wrote:
> >>> >> > On Sat, 2010-09-04 at 17:17 +0800, Hui Zhu wrote:
> >>> >> >> On Sat, Sep 4, 2010 at 16:56, Steven <mqyoung@gmail.com> wrote:
> >>> >> >> > On Sat, 2010-09-04 at 11:41 +0800, Hui Zhu wrote:
> >>> >> >> >> BTW, looks GCC and GDB don't want handle the optimization debug
> >>> >> >> >> trouble (all they want is rewrite the GCC in C++ :P).
> >>> >> >> >> So I think make linux kernel can close optimization is better idea, do
> >>> >> >> >> you know some way or some patch to do it?
> >>> >> >> >>
> >>> >> >> >
> >>> >> >> > Just disable CONFIG_CC_OPTIMIZE_FOR_SIZE and modify the Makefile of
> >>> >> >> > kernel:
> >>> >> >> > KBUILD_CFLAGS   += -O2
> >>> >> >> > to
> >>> >> >> > KBUILD_CFLAGS   += -O0
> >>> >> >>
> >>> >> >> Cool,  :)
> >>> >> >>
> >>> >> >> I try just change the compile option of readdir.c to without -O2, it
> >>> >> >> works OK.  I think maybe it's a GDB bug too.
> >>> >> >> Could you try the second issue with gdb 7.2?
> >>> >> >
> >>> >> > I have covered the two issues in the previous mail that I could collect
> >>> >> > both global variables and locals(-O0 kernel + gdb7.2):
> >>> >> >
> >>> >> >        --------
> >>> >> >        (gdb) trace vfs_readdir
> >>> >> >        Tracepoint 3 at 0xc11756a0: file fs/readdir.c, line 24.
> >>> >> >        (gdb) actions
> >>> >> >        Enter actions for tracepoint 3, one per line.
> >>> >> >        End with a line saying just "end".
> >>> >> >        >collect *file
> >>> >> >        >end
> >>> >> >        (gdb) trace fs/readdir.c:29
> >>> >> >        Tracepoint 4 at 0xc11756ca: file fs/readdir.c, line 29.
> >>> >> >        (gdb) actions
> >>> >> >        Enter actions for tracepoint 4, one per line.
> >>> >> >        End with a line saying just "end".
> >>> >> >        >collect res
> >>> >> >        >end
> >>> >> >        (gdb) tstart
> >>> >> >        (gdb) tstop
> >>> >> >        (gdb) tfind
> >>> >> >        Found trace frame 0, tracepoint 3
> >>> >> >        #0  0xc11756a1 in vfs_readdir (file=0xc7b2cf00, filler=0,
> >>> >> >        buf=0x0)
> >>> >> >            at fs/readdir.c:24
> >>> >> >        24              struct inode *inode =
> >>> >> >        file->f_path.dentry->d_inode;
> >>> >> >        (gdb) p *file
> >>> >> >        $4 = {f_u = {fu_list = {next = 0xc6dca500, prev = 0xc7ade480},
> >>> >> >        fu_rcuhead = {
> >>> >> >              next = 0xc6dca500, func = 0xc7ade480}}, f_path = {mnt =
> >>> >> >        0xc6c05300,
> >>> >> >            dentry = 0xc761d440}, f_op = 0xc1709a20, f_lock = {{rlock =
> >>> >> >        {raw_lock = {
> >>> >> >                  slock = 0}}}}, f_count = {counter = 2}, f_flags =
> >>> >> >        624640,
> >>> >> >          f_mode = 29, f_pos = 0, f_owner = {lock = {raw_lock = {lock =
> >>> >> >        16777216}},
> >>> >> >           = 0start = 0, size = 0, async_size = 0,
> >>> >> >            ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version =
> >>> >> >        0,
> >>> >> >          f_security = 0xc7b30120, private_data = 0x0, f_ep_links = {
> >>> >> >            next = 0xc7b2cf74, prev = 0xc7b2cf74}, f_mapping =
> >>> >> >        0xc761c74c}
> >>> >> >        (gdb) p res
> >>> >> >        $5 = 0
> >>> >> >        (gdb) tfind
> >>> >> >        Found trace frame 1, tracepoint 4
> >>> >> >        0xc11756cb      29              res =
> >>> >> >        security_file_permission(file, MAY_READ);
> >>> >> >        (gdb) p res
> >>> >> >        $6 = -20
> >>> >> >        --------
> >>> >> >
> >>> >> >
> >>> >> >
> >>> >>
> >>> >> Great.  :)
> >>> >>
> >>> >> Hui
> >>> >
> >>> >
> >>
> >>
> >>
> >



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

end of thread, other threads:[~2010-09-06  9:30 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30  7:00 Linux Kernel GDB tracepoint module 2010-8-30 release Hui Zhu
2010-09-03  9:06 ` Steven
2010-09-03 14:05   ` Frank Ch. Eigler
2010-09-04  4:29     ` Hui Zhu
2010-09-04  5:11       ` Frank Ch. Eigler
2010-09-04 15:04         ` Hui Zhu
2010-09-04 16:34     ` Hui Zhu
2010-09-04 18:22       ` Frank Ch. Eigler
2010-09-04  3:41   ` Hui Zhu
2010-09-04  7:47     ` Hui Zhu
2010-09-04  9:01       ` Steven
2010-09-04  9:10         ` Hui Zhu
2010-09-04  8:39     ` Steven
     [not found]     ` <1283590584.1685.39.camel@steven>
2010-09-04  9:17       ` Hui Zhu
2010-09-04  9:26         ` Steven
2010-09-04 14:58           ` Hui Zhu
2010-09-04 16:01             ` Steven
2010-09-04 16:42               ` Hui Zhu
2010-09-04 16:47                 ` Steven
2010-09-06  7:21                   ` Hui Zhu
2010-09-06  7:50                     ` Hui Zhu
2010-09-06  9:30                       ` Log of Using KGTP Steven

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.