qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Debugging vmlinux with qemu and gdb. Unable to step, next,


From: Keilhau Timo ( Student )
Subject: [Qemu-devel] Debugging vmlinux with qemu and gdb. Unable to step, next, print or to get any information..
Date: Thu, 8 May 2008 09:53:52 +0200

Hello List!

I am trying to debug linux 2.6.25 kernel with qemu -s and gdb on 64 bit
amd system.
But I am experiencing strange behaviour with qemu and gdb..
Gdb stops at a given breakpoint but I cant step, next, print etc..

Software:
Host OS used:                   opensuse 10.3
Host kernelversion:             2.6.22.5-31-default
guest:                          Debian Etch 4.0r3 amd64 with 2.6.25
The kernel used to debug:       linux-2.6.25.tar.bz2
Virtualization Software:        qemu pc emulator version 0.9.0
Host make utillity              GNU Make 3.81
Host debugger:                  GNU gdb 6.6.50.20070726-cvs
(Also tried gdb 6.6, gdb 6.8 compiled from source)

Look here:

// Starting qemu on host:

$ qemu-system-x86_64 -s -kernel bzImage -hda
qemu_mini_debian_root_fs.img -append "root=/dev/hda1" -initrd
debian_boot/initrd.img-2.6.25-customtk-i -no-kqemu -redir
tcp:10022:10.0.2.15:22

// Boots fine.
// vmlinux is compiled with CFLAGS=-g3 -ggdb, I have also tried only
with -g
// On host:

$ nm vmlinux | grep sys_sendmsg
ffffffff803e9ac5 T sys_sendmsg


// Starting gdb on host and setting a breakpoint:

$ gdb vmlinux

GNU gdb 6.6.50.20070726-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "x86_64-suse-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) l sys_sendmsg
1783    /*
1784     *      BSD sendmsg interface
1785     */
1786
1787    asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg,
unsigned flags)
1788    {
1789            struct compat_msghdr __user *msg_compat =
1790                (struct compat_msghdr __user *)msg;
1791            struct socket *sock;
1792            char address[MAX_SOCK_ADDR];
(gdb) b 1787
Breakpoint 1 at 0xffffffff803e9ac5: file net/socket.c, line 1787.
(gdb)

// Now connect to qemu's gdb-stub:

(gdb) target remote :1234
Remote debugging using :1234
0x0000000000000000 in ?? ()
(gdb) c
Continuing.

// On guest launching a ping for example, to trigger the breakpoint:

$ ping 212.76.144.43

// On Host gdb stops, but it looks strange no address info etc is
shown?!?!

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0000000000000000 in ?? ()
(gdb) info locals
No symbol table info available.
(gdb) info source
Current source file is net/socket.c
Compilation directory is /usr/src/linux
Located in /home/keilhaut/kernel_qemu/linux-2.6.25/net/socket.c
Contains 2356 lines.
Source language is c.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
(gdb) info breakpoints
Num Type           Disp Enb Address            What
1   breakpoint     keep y   0xffffffff803e9ac5 in sys_sendmsg at
net/socket.c:1787
(gdb) disable 1
(gdb) c
Continuing.

// Looking up the address on guest (the address is exactly the same!):

$ cat /proc/kallsyms | grep sys_sendmsg
ffffffff803e9ac5 T sys_sendmsg

// another attemp enabling the last breakpoint and launching the ping
again:
...

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0000000000000000 in ?? ()
(gdb) set debug remote 1
(gdb) p *this
No symbol "this" in current context.
(gdb) bt
#0  0x0000000000000000 in ?? ()
Sending packet: $m0,8#01...Ack
Packet received: E14
Cannot access memory at address 0x0
(gdb) info registers
rax            0x2e     46
rbx            0x0      0
rcx            0x40050c9f80     274962620288
rdx            0x300507920      12890175776
rsi            0x297803e9ac5    2849714903749
rdi            0x1800000010     103079215120
rbp            0x0      0x0
rsp            0x0      0x0
r8             0x0      0
r9             0x0      0
r10            0x0      0
r11            0x0      0
r12            0x0      0
r13            0x0      0
r14            0x0      0
r15            0x0      0
rip            0x0      0
eflags         0x8000000        [ #27 ]
cs             0x4019cd58       1075432792
ss             0x37f    895
ds             0x3800   14336
es             0x0      0
fs             0x0      0
gs             0x0      0
fctrl          0x0      0
fstat          0x0      0
ftag           0x0      0
fiseg          0x0      0
fioff          0x0      0
foseg          0x0      0
fooff          0x0      0
fop            0x0      0
mxcsr          0x0      [ ]
(gdb) step
Cannot find bounds of current function
(gdb) next
Cannot find bounds of current function
(gdb) quit
The program is running.  Exit anyway? (y or n) y
Sending packet: $k#6b...Ack


"info reg" is the only command that I can use to get information from
guest.
I cant inspect variables, cant step etc etc...
Ive read many howtos and faqs. But ive found no solution to this
problem.
Maybe Ive missed something to do?!
Ive compiled the 2.6.25 kernel on guest with:
 [*] Compile the kernel with frame pointers
 [*] Compile the kernel with debug info
additionally CFLAGS="-g3 -ggdb"

Does somebody have had same problems?
Does somebody have an idea what else I can try?

I am glad for any help!!

Thanks, timo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]