Introduction

The GDBServerFoundation framework provides a set of convenient C++ classes for implementing custom gdbserver-compatible stubs. The library depends on the BazisLib library for socket and synchronization primitive implementation.

Quickstart

In order to make your own GDB server with this framework, follow these steps:

  1. Look up the order in which GDB expects the register values for your target architecture by checking the <target>-tdep.c file in GDB directory.
  2. Define a global instance of the PlatformRegisterList struct describing the supported registers in the order GDB expects them. See this example for more details..
  3. Create a class implementing the ISyncGDBTarget interface (including the members defined in IStoppedGDBTarget).
  4. Create a class implementing the IGDBStubFactory interface. The CreateStub method should create return an instance of GDBServerFoundation::GDBStub class created with a pointer to your ISyncGDBTarget implementation. E.g.:
    virtual IGDBStub *CreateStub(GDBServer *pServer)
    {
    return new GDBStub(new Win32GDBTarget(m_Process.hProcess, m_Process.hThread));
    }
  5. In the main() function create an instance of GDBServer class, call the Start() method to start listening and then call WaitForTermination() method to wait until the server is shut down.

Example

The GDBServerFoundation comes with a simple example - a simple debug server based on the Win32 debug API located in the Samples\SimpleWin32Server directory.

Main classes

The main GDBServerFoundation classes are:

  1. GDBServer implements a TCP server supporting the packet layer of the gdbserver protocol (including RLE encoding and escaping).
  2. GDBStub handles common packets defined in the gdbserver protocol by calling the methods of the ISyncGDBTarget interface. In most cases you need to implement the ISyncGDBTarget interface and reuse the GDBServer and GDBStub classes. However, if you want to add support for more gdbserver packets, you can easily make your own stub implementation inheriting from the GDBStub class.

License

The GDBServerFoundation framework is dual-licensed:

  1. You can use it under the terms of the LGPL license (i.e. publish the source of all statically linked code).
  2. You can alternatively purchase a commercial license from Sysprogs to use it in your closed-source stubs.

Support

We provide email support for the customers that purchased the commercial license.