[lldb-dev] Embedding lldb[server] in a CPU simulator

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Mar 17 10:47:12 PDT 2016


> On Mar 17, 2016, at 5:01 AM, Tyro Software via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> I have a simulator for a custom ["toy"] CPU running on Linux, to which I want to add at least basic debugging support (e.g. stepping instructions, reading/writing registers and memory), then driving this from lldb over a local TCP socket. 
> 
> I could implement this as a custom socket server handling the GDB Remote Serial Protocol, like GDB server stubs that I've seen. But probably there's already a suitable interface and library in LLDB for this, e.g. providing the RSP parsing and basic state maintennce with callbacks/virtuals for the target-specific actions?
> 
We have classes you can use to receive the packets. See the GDBRemoteCommunicationServerLLGS class. This is the "LLDB GDB server" class. It uses classes whose type is:

    class NativeBreakpoint;
    class NativeBreakpointList;
    class NativeProcessProtocol;
    class NativeRegisterContext;
    class NativeThreadProtocol;
    class UnixSignals;

You would subclass these and fill them in similar to what the linux implementations are doing.


> Thanks for any guidance (and apologies that I'm probably using terminology like "server" incorrectly and so overlooking the existing documentation)

Let me know if the above info makes sense and feel free to ask any questions.

Greg



More information about the lldb-dev mailing list