VirtualBox Serial Debugging on Linux

This tutorial describes using a feature of VirtualBox that writes the output of a serial port into a file on the host machine. Because Haiku, by default, writes debug information to the COM1 port, you can use it to quickly extract stacktraces to text files, for example.

This tutorial is based on following tools:

  • Debian Wheezy
  • VirtualBox 4.1.18
  • Haiku R1A4.1

It should also work on platforms other than Linux.

Result

Step 1: Configure the virtual machine

First, we will create a serial port in VirtualBox and redirect its output to file:
  1. Open machine settings.
  2. Go to the Serial Ports tab.
  3. Check Enable Serial Port.
  4. Under Port Number, chose a port and remember the one you pick.
  5. In the Port Mode menu, choose the Raw File option.
  6. In the Port/File Path field, enter the output file path.
  7. Click OK.
There is also the possibility to redirect output to a physical port:
  • Choose the Host Device option in the Port Mode menu
  • Change Port/File Path values to port file path (for example /dev/ttyS0 on Linux, COM1 on Windows).

Configuration example

Step 2: Configure Haiku

This step allows you to adjust output port and speed. If you have chosen COM1 as your virtual port and you don't want to change the default speed (115200 bps), there is no need to do anything.
  1. Launch Haiku VM.
  2. Open the /boot/home/config/settings/kernel/drivers/kernel file.
However, if your virtual port is something else, change the desired output port in this line: From
#serial_debug_port 1
to
serial_debug_port number

number” is the serial port number minus 1 (COM2 = 1).

You can also adapt the transmission speed: Change the line:

#serial_debug_speed 57600

to

serial_debug_speed speed

Possible “speed” values are: 9600, 19200, 38400, 57600, 115200.

The End

Don't forget to delete or move the output file! VirtualBox won't do it automatically and it can grow to immense sizes.