From: Steven <mqyoung@gmail.com>
To: Hui Zhu <teawater@gmail.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>,
linux-kernel@vger.kernel.org, Michael Snyder <msnyder@vmware.com>,
Marc Khouzam <marc.khouzam@ericsson.com>,
Thiago Jung Bauermann <thiago.bauermann@gmail.com>,
"Frank Ch. Eigler" <fche@redhat.com>
Subject: Re: Linux Kernel GDB tracepoint module 2010-8-30 release
Date: Sun, 05 Sep 2010 00:01:49 +0800 [thread overview]
Message-ID: <1283616109.1685.98.camel@steven> (raw)
In-Reply-To: <AANLkTim5_vf9Tg1g13HAmiO7zAjPzR6QaJ3k2edQzkCv@mail.gmail.com>
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
next prev parent reply other threads:[~2010-09-04 16:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283616109.1685.98.camel@steven \
--to=mqyoung@gmail.com \
--cc=fche@redhat.com \
--cc=gdb@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.khouzam@ericsson.com \
--cc=msnyder@vmware.com \
--cc=teawater@gmail.com \
--cc=thiago.bauermann@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox