edit · history · print

Intro.Tips History

Hide minor edits - Show changes to markup

October 16, 2006, at 10:43 PM EST by pjd -
Deleted lines 13-43:

Setting up KGDB under VMWare, Windows Hhost

  1. get the kgdb patches for kernel 2.6.15 here: http://kgdb.linsyssoft.com/downloads/kgdb-2/linux-2.6.15.5-kgdb-2.4.tar.bz2
  2. untar them and then apply them:
      cd linux-2.6.15.6
      patch -b -p1 < ../linux-2.6.15.5-kgdb-2.4/core-lite.patch
      patch -b -p1 < ../ ... core.patch
      patch -b -p1 < ../ ... i386-lite.patch
                             i386.patch
                             8250.patch 
  3. configure and build your kernel. Under "kernel hacking" enable kgdb, with serial port set to "1" (i.e. /dev/ttyS1, or COM2), and enable kernel debug info.
  4. Add 2 virtual serial ports to your virtual machine. Configure the second one to connect to a named pipe named \\.\pipe\com_2. Under advanced settings, check the box for "yield CPU on poll"
  5. Download and install the Named Pipe TCP Proxy utility: nptp_setup.zip
  6. Start the proxy, and establish a connector between some port on the local machine (e.g. 8111) and \\.\pipe\com_2. Check the box to enable non-local systems access.
  7. Add the command "kgdbwait" to the kernel command line for the kgdb kernel, and boot it. After printing "Booting the kernel" it should hang.
  8. In another virtual machine run 'gdb vmlinux'. (you'll have to work out how to share the source tree between the two VMs - clearly you can't use NFS from the VM that you're debugging)
  9. type target remote ip_addr:8111 where ip_addr is the windows host IP address that this virtual machine sees. (e.g. on my machine 192.168.149.1, and the VM gets address 192.168.149.128)

KGDB should connect, and away you go.

Caveats - note that I've had a lot of trouble with the DHCP server in VMWare if I'm running multiple machines at once, as it tends to give the same address to each one. You may wish to hardcode the ip address, route, and DNS resolver instead on each VM.

KGDB for kernel 2.4

You will need to download a 2.4 kgdb patch: linux-2.4.23-kgdb-1.9.patch

This is a single patch - apply it with -p1 in the same way as the separate patches for 2.6. Configure your kernel and enable KGDB. You will need to add the kernel command line argument "gdb" to get it to halt on boot, and by default it will use COM1.

KGDB for Linux host

I haven't tested it yet, but you can create a named pipe for a serial port - make it something like /tmp/com_1, and then in gdb you should be able to just use the command target remote /tmp/com_1.

October 16, 2006, at 04:48 PM EST by pjd -
Added line 3:
Changed line 24 from:
  1. configure and build your kernel. Under "kernel hacking" enable kgdb, with serial port set to "1", and enable kernel debug info.
to:
  1. configure and build your kernel. Under "kernel hacking" enable kgdb, with serial port set to "1" (i.e. /dev/ttyS1, or COM2), and enable kernel debug info.
Changed line 36 from:
to:

Changed lines 39-40 from:

This is a single patch - apply it with -p1 in the same way as the separate patches for 2.6. Configure your kernel and enable KGDB. (note - I tested the 1.8 patch, and you have to configure thread analysis or else it won't compile properly)

to:

This is a single patch - apply it with -p1 in the same way as the separate patches for 2.6. Configure your kernel and enable KGDB. You will need to add the kernel command line argument "gdb" to get it to halt on boot, and by default it will use COM1.

October 16, 2006, at 09:01 AM EST by pjd -
Added lines 34-43:

KGDB for kernel 2.4

You will need to download a 2.4 kgdb patch: linux-2.4.23-kgdb-1.9.patch

This is a single patch - apply it with -p1 in the same way as the separate patches for 2.6. Configure your kernel and enable KGDB. (note - I tested the 1.8 patch, and you have to configure thread analysis or else it won't compile properly)

KGDB for Linux host

I haven't tested it yet, but you can create a named pipe for a serial port - make it something like /tmp/com_1, and then in gdb you should be able to just use the command target remote /tmp/com_1.

October 15, 2006, at 10:59 AM EST by pjd -
Changed line 25 from:
  1. Download and install the Named Pipe TCP Proxy utility: Attach:nptp_setup.zip
to:
  1. Download and install the Named Pipe TCP Proxy utility: nptp_setup.zip
October 15, 2006, at 10:51 AM EST by pjd -
Added line 2:
Added lines 13-33:

Setting up KGDB under VMWare, Windows Hhost

  1. get the kgdb patches for kernel 2.6.15 here: http://kgdb.linsyssoft.com/downloads/kgdb-2/linux-2.6.15.5-kgdb-2.4.tar.bz2
  2. untar them and then apply them:
      cd linux-2.6.15.6
      patch -b -p1 < ../linux-2.6.15.5-kgdb-2.4/core-lite.patch
      patch -b -p1 < ../ ... core.patch
      patch -b -p1 < ../ ... i386-lite.patch
                             i386.patch
                             8250.patch 
  3. configure and build your kernel. Under "kernel hacking" enable kgdb, with serial port set to "1", and enable kernel debug info.
  4. Add 2 virtual serial ports to your virtual machine. Configure the second one to connect to a named pipe named \\.\pipe\com_2. Under advanced settings, check the box for "yield CPU on poll"
  5. Download and install the Named Pipe TCP Proxy utility: Attach:nptp_setup.zip
  6. Start the proxy, and establish a connector between some port on the local machine (e.g. 8111) and \\.\pipe\com_2. Check the box to enable non-local systems access.
  7. Add the command "kgdbwait" to the kernel command line for the kgdb kernel, and boot it. After printing "Booting the kernel" it should hang.
  8. In another virtual machine run 'gdb vmlinux'. (you'll have to work out how to share the source tree between the two VMs - clearly you can't use NFS from the VM that you're debugging)
  9. type target remote ip_addr:8111 where ip_addr is the windows host IP address that this virtual machine sees. (e.g. on my machine 192.168.149.1, and the VM gets address 192.168.149.128)

KGDB should connect, and away you go.

Caveats - note that I've had a lot of trouble with the DHCP server in VMWare if I'm running multiple machines at once, as it tends to give the same address to each one. You may wish to hardcode the ip address, route, and DNS resolver instead on each VM.

October 14, 2006, at 11:46 PM EST by pjd -
Added lines 1-11:

Logging console output in VMWare

After powering down the virtual machine, edit the hardware settings to add a serial port, and direct its output to a file.

Add console=tty0 console=ttyS0 to the kernel command line in /boot/grub/menu.lst (or /etc/lilo.conf). This will make the screen be the primary console, but copy all messages to the serial port as well.

Changed lines 13-14 from:
to:

September 24, 2006, at 11:38 PM EST by pjd -
Changed line 27 from:

mountd[1818]: mount request from unknown host 127.0.0.1 for / (/)

to:

mountd[1818]: mount request from unknown host #.#.#.# for / (/)

September 24, 2006, at 11:37 PM EST by pjd -
Changed lines 1-2 from:

Host <-> Virtual machine access

to:

Host <-> Virtual machine access, Linux host

Added lines 29-37:

Host <-> Virtual machine access, Windows host

If you are running a Windows host, you'll want to do your compilation on the virtual machine. However, other than just using the vmware console, there are two ways in which you might wish to access your files on the virtual machine:

  1. Export the files to Windows and edit them there. Either export them via NFS, as above, and install Windows Services for Unix (here), or install Samba on your virtual machine.
  2. Connect to your virtual machine via ssh and do all your work within the VM. Good terminal programs include Putty and rxvt from the Cygwin toolkit. (install both rxvt and openssh)

In the second case you may wish to install another editor besides VI in your virtual machine; you can get the Emacs package here and install it with the pkgadd command.

Note that in addition to enabling the ssh server (add sshd to SERVICES in /etc/rc.conf) you will want to remove the ALL: ALL: DENY line from /etc/hosts.deny, or tcpwrappers will not let you connect to ssh.

September 24, 2006, at 11:18 PM EST by pjd -
Changed lines 22-28 from:
to:

Troubleshooting

RPC: Program not registered The NFS server is not running nfssvc: Function not implemented (in /var/log/messages) - NFS server support is not compiled into your kernel or available as a module. mountd[1818]: mount request from unknown host 127.0.0.1 for / (/) You haven't set up /etc/exports properly. (or you have, but you haven't rebooted yet. In that case, run exportfs -r to resync your exports, and see if it works.)

September 24, 2006, at 12:29 PM EST by pjd -
Changed lines 8-9 from:
  / *(rw,all_squash,anonuid=0,anongid=0)

@] # Enable the NFS server on boot - change the SERVICES line in /etc/rc.conf to:

to:
  / *(rw,all_squash,anonuid=0,anongid=0) @] 
  1. Enable the NFS server on boot - change the SERVICES line in /etc/rc.conf to:
Changed line 12 from:

[=

to:

[@

Changed lines 16-17 from:
  172.16.211.129:/ on /mnt/1 type nfs (rw,addr=172.16.211.129)

=]

to:
  172.16.211.129:/ on /mnt/1 type nfs (rw,addr=172.16.211.129) @]
September 24, 2006, at 12:28 PM EST by pjd -
Added line 7:

[@

Changed line 9 from:
  1. Enable the NFS server on boot - change the SERVICES line in /etc/rc.conf to:
to:

@] # Enable the NFS server on boot - change the SERVICES line in /etc/rc.conf to:

September 24, 2006, at 12:28 PM EST by pjd -
Deleted line 6:

[@

Deleted line 7:

@]

September 24, 2006, at 12:27 PM EST by pjd -
Changed line 7 from:

[=

to:

[@

Changed line 9 from:

=]

to:

@]

September 24, 2006, at 12:27 PM EST by pjd -
Changed lines 6-7 from:
  1. Set up /etc/exports. This entry maps all NFS access to a single user, root. (uid 0, gid 0)
to:
  1. Set up /etc/exports. This entry maps all NFS access to a single user, root. (uid 0, gid 0)

    [=
Added line 9:

=]

Changed line 12 from:
  1. Reboot the virtual machine, and then mount its filesystem from the host:
to:
  1. Reboot the virtual machine, and then mount its filesystem from the host:\\\
September 24, 2006, at 12:26 PM EST by pjd -
Added line 11:

[=

Added line 16:

=]

September 24, 2006, at 12:25 PM EST by pjd -
Added lines 1-20:

Host <-> Virtual machine access

If you are running VMware under Linux, it may be easier to compile and edit on the host machine. The simplest way to do this is by NFS-mounting the virtual machine filesystem:

  1. Enable NFS in your VM kernel: in menuconfig: file systems -> network file systems -> NFS server support. Rebuild your kernel and copy it to /boot/vmlinuz; if you enabled NFS server as a module, then you'll need to do make modules_install to install the modules.
  2. Set up /etc/exports. This entry maps all NFS access to a single user, root. (uid 0, gid 0) / *(rw,all_squash,anonuid=0,anongid=0)
  3. Enable the NFS server on boot - change the SERVICES line in /etc/rc.conf to: SERVICES=(net sshd portmap nfsserver)
  4. Reboot the virtual machine, and then mount its filesystem from the host: [pjd@justforkix ~]$ sudo mount 172.16.211.129:/ /mnt/1 [pjd@justforkix ~]$ mount
   [...]
172.16.211.129:/ on /mnt/1 type nfs (rw,addr=172.16.211.129)

(type ifconfig eth0 on the virtual machine to find its IP address)

The virtual machine filesystem may now be accessed on /mnt/1. If you want to do all your development work on the host machine, you can install modules onto the virtual machine with the following command:

  make INSTALL_MOD_PATH=/mnt/1 modules_install

where /mnt/1 is the location the virtual machine filesystem has been mounted on.

edit · history · print
Page last modified on October 16, 2006, at 10:43 PM EST