Skip to contentSkip to conversation

VMWare Workstation 6 for debugging Linux Kernel (!)

DISCUSSION roland 8 participants 11 messages Apr 19, 2007 – Apr 20, 2007

lore
Share & tools
lore

roland

author
#0 lore raw

Hi !

I think this one is damn interestig for linux kernel development:

contents: see below

regards
roland

ps:
i`m not directly related to vmware - so this is no advertisement!

Tuesday, April 17, 2007
Debugging Linux kernels with Workstation 6.0
We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

To use the new feature, grab the latest build of WS6 here:

http://www.vmware.com/products/beta/ws/

Put this line into configuration file of your Linux VM:

debugStub.listen.guest32=1

Now whenever you run the virtual machine, you'll see the following on the Host console:

VMware Workstation is listening for debug connection on port 8832.

Run gdb on the Host, reference it to the kernel with symbols and attach to the virtual machine:

% gdb
(gdb) file vmlinux-2.4.21-27.EL.debug
(gdb) target remote localhost:8832

That's it. The VM is blocked now, so you can "continue" it and "^C" back to gdb. Breakpoints, single step, memory inspection - all this works as usual. If you have SMP VM, then each VCPU is mapped on a thread, so use "info threads" and "thread NN" to switch between them.

The kernels with symbols are sadly lacking on most distributions, but if you use RHEL then this website may help (look for kernel-debuginfo rpm):

http://people.redhat.com/duffy/debuginfo/index-js.html

The gdb support in WS6 is experimental, so there may be rough edges here and there. Please post on community forums if something doesn't work right or if you have a suggestion:

http://www.vmware.com/community/

There are more debugging specific features in WS6 (for example, you can use gdb hand-in-hand with Record/Replay!). I will describe them shortly.

#1 lore raw

Hi roland,
It's really an interesting feature, IMHO, maybe the UML would be no more needed.
thanks very much;-)

Regards,

2007/4/20, roland <[email protected]>:

Quoted 70 lines

Hi !

I think this one is damn interestig for linux kernel development:

contents: see below

regards
roland

ps:
i`m not directly related to vmware - so this is no advertisement!

Tuesday, April 17, 2007
Debugging Linux kernels with Workstation 6.0
We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

To use the new feature, grab the latest build of WS6 here:

http://www.vmware.com/products/beta/ws/

Put this line into configuration file of your Linux VM:

debugStub.listen.guest32=1

Now whenever you run the virtual machine, you'll see the following on the Host console:

VMware Workstation is listening for debug connection on port 8832.

Run gdb on the Host, reference it to the kernel with symbols and attach to the virtual machine:

% gdb
(gdb) file vmlinux-2.4.21-27.EL.debug
(gdb) target remote localhost:8832

That's it. The VM is blocked now, so you can "continue" it and "^C" back to gdb. Breakpoints, single step, memory inspection - all this works as usual. If you have SMP VM, then each VCPU is mapped on a thread, so use "info threads" and "thread NN" to switch between them.

The kernels with symbols are sadly lacking on most distributions, but if you use RHEL then this website may help (look for kernel-debuginfo rpm):

http://people.redhat.com/duffy/debuginfo/index-js.html

The gdb support in WS6 is experimental, so there may be rough edges here and there. Please post on community forums if something doesn't work right or if you have a suggestion:

http://www.vmware.com/community/

There are more debugging specific features in WS6 (for example, you can use gdb hand-in-hand with Record/Replay!). I will describe them shortly.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to roland
Quoted 5 lines · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

I think qemu has the exact same feature.

Xav

#3 lore raw
Quoted 9 lines · Xavier Bestel
Quoted 5 lines · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

AMD SimNow! and Virtutech Simics can do it too. But great the Vmware catches up.

-Andi

#4 lore raw
Quoted 8 lines · Andi Kleen
Quoted 4 lines · Xavier Bestel
Quoted 1 line · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

Hello,

Do you mean with qemu or with VMware? Yes, we do not support replay with 64bit guests, but debug interface should just work. Only gotcha is that for 64bit guest you need another option:

debugStub.listen.guest64 = "TRUE"

and then you need to attach gdb to port 8864 (*). Unfortunately it does not seem possible to build gdb which would support 16bit/32bit code while using 64bit gdb on-wire format, so there are two interfaces. And if you single-step switch from 64bit mode to 32bit mode or back, you also have to switch gdbs. Yes, it is a bit unintuitive, and additionally one gdb silently ignores breakpoints set up by other gdb, so you need to keep breakpoints in sync between two gdbs yourself :-(

(*) If you are using gdb which has both 32bit and 64bit support, be sure to issue appropriate 'set architecture xxx' before 'target remote localhost:88xx' (i386:x86-64 for port 8864, i386 or i8086 for port 8832). Otherwise gdb is going to die complaining it could not parse remote reply.

Best regards,
Petr Vandrovec

P.S.: Yes, I'm associated with VMware.

#5 lore raw

Hi.

Quoted 14 lines · Petr Vandrovec
Quoted 4 lines · Andi Kleen
Quoted 2 lines · Xavier Bestel

On Fri, 2007-04-20 at 00:46 +0200, roland wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

Quoted 7 lines

Hello,

Do you mean with qemu or with VMware? Yes, we do not support replay with 64bit guests, but debug interface should just work. Only gotcha is that for 64bit guest you need another option:

debugStub.listen.guest64 = "TRUE"

Ah. That might help :)

Quoted 8 lines

and then you need to attach gdb to port 8864 (*). Unfortunately it does not seem possible to build gdb which would support 16bit/32bit code while using 64bit gdb on-wire format, so there are two interfaces. And if you single-step switch from 64bit mode to 32bit mode or back, you also have to switch gdbs. Yes, it is a bit unintuitive, and additionally one gdb silently ignores breakpoints set up by other gdb, so you need to keep breakpoints in sync between two gdbs yourself :-(

Quoted 5 lines

(*) If you are using gdb which has both 32bit and 64bit support, be sure to issue appropriate 'set architecture xxx' before 'target remote localhost:88xx' (i386:x86-64 for port 8864, i386 or i8086 for port 8832). Otherwise gdb is going to die complaining it could not parse remote reply.

That too.

Thanks!

Nigel

#7 lore raw
In reply to Andi Kleen

Hi.

Quoted 10 lines · Andi Kleen
Quoted 8 lines · Xavier Bestel
Quoted 5 lines · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

Quoted 3 lines
Quoted 1 line

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

You mean the VMware one doesn't work? I tried it and got:

(gdb) target remote localhost:8832
Remote debugging using localhost:8832
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" respoonse Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Malformed response to offset query, timeout
(gdb)

Hopefully that's not too hard to fix. Made the appropriate noises :)

Nigel

#8 lore raw
In reply to Andi Kleen
Quoted 12 lines · Andi Kleen
Quoted 9 lines · Xavier Bestel
Quoted 6 lines · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

Quoted 5 lines
Quoted 2 lines

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

kvm's qemu has a patch that allows qemu to be an x86_64 gdbserver (with or without kvm).

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#9 lore raw

Hi.

Quoted 13 lines · Avi Kivity
Quoted 12 lines · Andi Kleen
Quoted 9 lines · Xavier Bestel
Quoted 6 lines · roland

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

kvm's qemu has a patch that allows qemu to be an x86_64 gdbserver (with or without kvm).

I was meaning that vmware wasn't working, but it is now - I was trying a 64 host and client, and needed to know both the different line in the config file and the different port number.

Regards,

Nigel

#10 lore raw
Quoted 27 lines · Nigel Cunningham

Hi.

Quoted 23 lines · Avi Kivity
Quoted 21 lines · Andi Kleen
Quoted 4 lines · Xavier Bestel

On Fri, 2007-04-20 at 00:46 +0200, roland wrote:

Quoted 10 lines
Quoted 7 lines

We just quietly added an exciting feature to Workstation 6.0. I believe it will make WS6 a great tool for Linux kernel development. You can now debug kernel of Linux VM with gdb running on the Host without changing anything in the Guest VM. No kdb, no recompiling and no need for second machine. All you need is a single line in VM's configuration file.

I think qemu has the exact same feature.

It doesn't seem to work for x86-64 there though.

Quoted 8 lines
Quoted 3 lines

kvm's qemu has a patch that allows qemu to be an x86_64 gdbserver (with or without kvm).

I was meaning that vmware wasn't working, but it is now - I was trying a 64 host and client, and needed to know both the different line in the config file and the different port number.

Andi was talking about qemu, not VMware, I believe.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.