[Qt-creator] Adding a new debugger or emulating a gdbserver interface in the existing home-made debugger

André Pönitz apoenitz at t-online.de
Wed Dec 4 20:43:39 CET 2019


On Wed, Dec 04, 2019 at 09:06:32AM +0000, Pierre FICHEPOIL wrote:
> I’m working on QtCreator 4.9
> and adding support for the LuaJIT  language.
> 
> I already got a home-made Lua debugger that is split into a debugging
> server (code is ran in it’s own thread in the app you want to debug),
> and debugging clients (Each lua threads got it’s own debugging client
> to read and send messages to the server)
> 
> 
> The debugging server is acting like a bridge between the actual
> debugger frontend (That is supposed to be QtCreator) and the Lua
> threads I’m debugging.
> 
> 
> The communication is using a TCP Socket, with no auth.
> 
> 
> [cid:image001.png at 01D5AA8A.21B7CC80]
> 
> 
> Right now the server handle this kind of commands, I tested the
> following commands using the « raw » communication mode from Putty and
> using a custom client.
> 
> BREAKPOINT_ADD "c:/file_path/file.lua" 42
> BREAKPOINT_REMOVE "c:/file_path/file.lua" 42
> 
> CONTINUE
> 
> SET_LOCAL 4 X 42
> SET_UPVALUE HOOK_KEY "KEY_F"
> 
>    Etc…
> 
>    Each command ends with a new line.
> 
>    Right now the only missing part of this project is linking the
>    Debugging Frontend (QtCreator) to the debugging server.
> 
>    Would It be easier/more elegant to implement the gdbserver
>    interface/protocol in my debugging server [1]as suggested by aha_1980
>    or to make my own plugin ?

>    If the first solution is the one to choose, do you have any tip or easy
>    to understand documentation on the gdbserver protocol/behavior ?

Both approaches are feasible, and both have pros and cons.

The gdbserver protocol is a bit of an unstructured mess where pretty much
each command has a different syntax and produces similarly messy output.

On the other hand it is also a de-facto standard, and is well-understood
by GDB itself so if your server "speaks" that protocol, your setup is
magically supported by several IDEs at once.

>    Else, is there some « clean » and « easy » way to add my debugger,
>    without recoding the UI that already exists in the existing plugin.

For adding a new debugger "backend" in Creator you do not need to do
any UI. The views are all generic.

A minimal "native Qt Creator" implementation would be very similar to
the Python debugging support which is effectively ~600 lines of
C++ in src/plugins/debugger/pdb/* and some 1700 lines of python "bridge"
code in share/qtcreator/debugger/pdbbridge.py.

In your case that's likely even less as the pdbbridge.py is kind of
special as it contains the actual debugger, too. A slim bridge is
cdbbridge.py with about 500 lines.

So all with you might get away with about 600 lines C++ plus 600 lines of
Python for a "proper" integration of your LUA debug server into Qt Creator.

Andre'


More information about the Qt-creator mailing list