How to debug pc386 compiled program with gdb?

Chris Johns chrisj at rtems.org
Thu Aug 30 22:20:47 UTC 2012


SAeeD wrote:
>     I debug i386 programs using a basic serial port which is means most
>     recent motherboards do not work because serial ports are not common
>     and USB serial ports are no help. If you do have a serial port the
>     set up I use is:
>
>
> Can you talk more about this way of debugging Chris? As I understood,
> you run the RTEMS application on a PC with serial port (say A). Then you
> connect the other side of serial port cable to another computer (say B)
> which runs the code that you sent the links in your email? And are you
> able to place breakpoint or to step code execution with serial port? Can
> you explain more about the mechanism and setup?
>

I have a server running DHCP and TFTP servers. A build script copies the 
RTEMS executable image to the server where the TFTP server can see it. 
The PC I have uses a Grub PXE network boot loader configured to load a 
grub configuration file over the network using TFTP. The config file 
contains:

  #!gpxe
  kernel tftp://10.10.10.10/sw/ul/rtld --gdb --console=com1,115200
  --ide=0,1
  boot rtld

Grub will load RTEMS into the PC over the network and start it running 
and the code will break here:

  http://git.rtems.org/chrisj/rtl.git/tree/pc386-gdb.c#n36

In the code referenced above I connect to COM2 (the console is COM1). 
The --gdb option on the kernel boot arguments is handled here:

  http://git.rtems.org/chrisj/rtl.git/tree/main.c#n381

The grub setup can be a little complex and there are notes in the README 
in the PC bsp. They may be a bit out of date but the ideas are there and 
a base to start playing. I tend to hang onto old motherboards with 
serial ports, floppy disk connectors and PCI slots I can install a basic 
networking card to do this type of development.

The host I run gdb on has the COM2 serial port from the target PC 
connected to a USB to serial converted. This is the gdb initialization file:

  http://git.rtems.org/chrisj/rtl.git/tree/pc586-gdbinit-script

The checked in version is for qemu. If you uncomment lines 5 and 6 and 
comment line 7 the serial port will be used. Just copy this file to 
.gdbinit next to the RTEMS executable you get gdb to load.

Chris



More information about the users mailing list