wiki:Debugging/GdbSerialMonitor

GdbSerialMonitor

GDB Serial Monitors

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

https://www.sourceware.org/gdb/

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

https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html#Remote-Protocol

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 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 others 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.

Last modified on Jan 5, 2016 at 8:17:10 PM Last modified on Jan 5, 2016, 8:17:10 PM