I’m implementing a debugger backend, which talks to lldb using the (extended) gdb protocol. To provide further functionality we use the gdbserver “monitor” command to provide “custom” commands to the debugger.
I couldn’t find anything similar in lldb in the help or the web. Is there another way of getting the same functionality in lldb?
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
can you do something about this message? I don’t think it’s helpful for mailing lists, esp. since records are being made of this message on the Web for the public to read...
On topic, you’d probably want to use Python to extend the command set. You can read about custom commands here:
Check out “Create a new LLDB command using a Python function.”
The “process plugin packet send” command looks like the right backend to use when sending data back and forth from your custom debugserver implementation.
The GDB plug-in installs two GDB remote specific commands under "process plugin":
The monitor command you need is actually implemented using the "qRcmd" packet:
(lldb) process plugin packet monitor foo=1
And if you need to send any other raw command, you can:
(lldb) process plugin packet send qRcmd,666f6f3d31
This just sent the monitor command manually. You can actually load a new python module that creates new python commands. See the http://lldb.llvm.org/python-reference.html page and check out the section named "CREATE A NEW LLDB COMMAND USING A PYTHON FUNCTION". There is also a template file you can use to create your new python command at http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/cmdtemplate.py.
The theory goes, you can install a new python command and say name it "monitor". In your python command you would do whatever you would need to do and then call:
result = lldb.SBCommandReturnObject()
debugger.GetCommandInterpreter().HandleCommand("process plugin packet monitor foo=1", result)
print result.GetOutput() # The response from the command as a GDB remote packet with no leading '$' or the checksum "#XX"