Vmware 6 includes kernel-debugging option which can replaced the kdb usage, Here's some explanation of this process:
The kernel source preparation:
Before the debugging we will have to prepare the source code and the debug image of the “debugged” kernel.
In my target machine (Inside the VMware) I'm using linux kernel 2.6.25.9-76.fc9.i686, first we will need to download the source code of this version and the vmlinux image file with debug symbols.
Thedownload location for this release is :
http://kojipkgs.fedoraproject.org/packages/kernel/2.6.25.9/76.fc9/,
From there I downloaded the following files:
i686/kernel-devel-2.6.25.9-76.fc9.i686.rpm
i686/kernel-debuginfo-common-2.6.25.9-76.fc9.i686.rpm
i686/kernel-debuginfo-2.6.25.9-76.fc9.i686.rpm
src/kernel-2.6.25.9-76.fc9.src.rpm
Next, we need to install those packages, but before, We need to create the build directory tree for the source, The next command will create the SOURCES, SPECS and BUILD directories under ${HOME}/rpmbuild
#rpmdev-setuptree
Package installation (root user) :
# rpm -i <the packages>
Now, we need to prepare the source directories with all the patches:
# cd ~/rpmbuild/SPECS
# rpmbuild -bp --target=`uname -m` kernel.spec
Open the VMware configuration file (/etc/vmware/config) and add the following line:
debugStub.listen.guest32=1
Now, We will see the following line in the vmware log file, which mean that we are ready for debug:
VMware Workstation is listening for debug connection on port 8832.
The GDB preparation:Instead of running the gdb with all the debugging arguments every time, we can edit the .gdbinit file with the initial configuration,
This file should be located either in the current directory or in the
home directory.
Add to the .gdbinit the following line to determine the file to launch:
file /usr/lib/debug/lib/modules/2.6.25.9-76.fc9.i686/vmlinux
Add the .gdbinit the following line in order to tell gdb to connect the remote host:
target remote localhost:8832
Now we will configure the source-code directories, After the previous
steps, the source code is located under ${HOME}/rpmbuild/BUILD/kernel-2.6.25/linux-2.6.25.i686 , to automatically insert all the sub directories, run the following command on bash:
Debugging !!!
Now, all we need to do is to type#gdb
(or ddd) In order to launch the debugger.
One issue I faced is that if I'm pausing the vmware guest machne to long, its shut down and I need to restart the guest OS again, still need to figure out this one ........