wiki:Debugging/GdbSerialMonitor
Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Version 1 (modified by JoelSherrill, on 06/16/10 at 19:23:50) (diff)

/* Thread-Aware GDB Stubs */ Update for ViewVC

GdbSerialMonitor

GDB Serial Monitors

The GNU debugger GDB allows you to debug your RTEMS application, BSP, and RTEMS itself. GDB can be found here -

http://sources.redhat.com/gdb/

GDB comes with a remote protocol. You can find detail about the protocol in the GDB documentation -

http://sources.redhat.com/gdb/current/onlinedocs/gdb_18.html#SEC149

The remote protocol can be used over a serial port to a target or using TCP/IP. Here we look at a GDB serial monitor that lets you connect to your target.

Thread-Aware GDB Stubs

The RTEMS source tree includes thread aware GDB serial stubs for some of the supported CPU families. The shared portion of this code is located in http://www.rtems.com/viewvc/rtems/c/src/lib/libbsp/shared/gdbstub. Code adapting the shared portion to particular CPU families is available for the following processors:

  • i386
  • lm32
  • m68k
  • MIPS

If you adapt this support to another processor family, please submit that work. If you are interested in working on TCP/IP based gdb stubs, there is a set of those available at SLAC.

Non-Thread Aware GDB Stubs

If an RTEMS thread-aware GDB stub is not available for your processor, GDB itself supplies a few working stubs for the following processors:

  • i386
  • m68k
  • sh
  • sparc

Check GDB for newer stubs. You may find other on the net, for example http://sourceforge.net/projects/gdbstubs/.

Copy the GDB stub into your BSP and get it to compile. You need to write a putDebugChar and getDebugChar routine that interfaces to your target's serial port. You also need to provide a exceptionHandler routine and the m68k stub require you declare the exceptionHook variable. The GDB documentation provides the detail needed to achieve this.

The putDebugChar and getDebugChar require a polled serial type driver similar to one used by printk. The exceptionHandler routine interfaces to the processors vector table. Do not use the RTEMS interrupt catch API.

The above should provide you with a working GDB stub that is not thread aware. It is highly recommended that you put the effort into making the RTEMS thread-aware stubs support the CPU you are interested and submit it. in.