gdbgui icon indicating copy to clipboard operation
gdbgui copied to clipboard

Add support for LLDB

Open gnzlbg opened this issue 8 years ago • 19 comments
trafficstars

I mostly use lldb on mac and gdb on linux. Could this be made to work with lldb as well?

The mapping in commands from gdb to lldb is 1:1, the commands are often just named slightly differently. I'd like to use something that gives me a smooth experience with both.

gnzlbg avatar Mar 01 '17 13:03 gnzlbg

Absolutely, I'll take a look at lldb and see how hard it would accommodate it.

cs01 avatar Mar 01 '17 18:03 cs01

gdbgui relies on gdb's machine interface (mi) output. lldb does not have this as a built in option, but it looks like someone wrote an intermediate application to provide mi-like output: https://www.codeplay.com/portal/lldb-mi-driver---part-1-introduction. Looks like it won't be as easy as I was hoping, but still seems possible to do.

cs01 avatar Mar 02 '17 22:03 cs01

I think you just need to call lldb-mi instead of lldb. The lldb-mi driver is part of LLVM and is built by default when you build lldb.

gnzlbg avatar Mar 03 '17 09:03 gnzlbg

Thanks, lldb-mi is what I was looking for. Documentation and implementation are a little sparse for lldb-mi. I did make a lot of progress, but there are some commands that don't seem to have a gdb-mi equivalent.

You can try it out now with, for example, gdbgui/backend.py -g lldb-mi-3.8.

Where gdbgui works with lldb:

  • Loading and running files
  • Viewing Locals
  • Viewing Expressions
  • Console
  • Registers
  • Memory

Where gdbgui has issues or partial functionality with lldb:

  • Breakpoints
  • Threads/Stack rendering
  • Disassembly

I marked all areas of the source code that have such issues with TODOLLDB.

Any help in these areas would be appreciated.

cs01 avatar Mar 04 '17 21:03 cs01

@cs01 IIUC lldb-mi should be 1:1 exactly compatible with gdb-mi, but the project is not that old, so maybe the features that you mention are just not implemented yet. I think that you could show your work on the llvm mailing list, and ask for help about the remaining lldb-mi commands that right now do not work. I see that you are using llvm 3.8, so maybe those issues are already fixed in 3.9 or 4.0. I'm sure the LLDB guys will be keen to help!

gnzlbg avatar Mar 04 '17 22:03 gnzlbg

@gnzlbg I updated and tried with

>> lldb-mi-4.0 --version
Version: GNU gdb (GDB) 7.4 
(This is a MI stub on top of LLDB and not GDB)
All rights reserved.

It seemed a little improved but certainly still not 1:1. The earliest version of gdb that gdbgui was tested with was 7.7.1, and it looks like this lldb-mi api is compatible with gdb 7.4. I'll try sending an email to the mailing list, thanks.

cs01 avatar Mar 08 '17 01:03 cs01

@cs01 thanks!

gnzlbg avatar Mar 08 '17 10:03 gnzlbg

@gnzlbg I sent two emails to the mailing list and haven't heard anything back.

lldb-mi compatibility with gdb 7.12 mi2 interpreter

lldb-mi functionality

cs01 avatar Mar 13 '17 23:03 cs01

pinging: @codeplaysoftware , @zjturner , @abidh , they might be able to help.

gnzlbg avatar Mar 14 '17 14:03 gnzlbg

Thanks @gnzlbg, @zjturner tried to get something going for me on the lldb-dev mailing list, but still no responses.

It looks like another path forward would be to use the LLDB Python Reference: http://lldb.llvm.org/python-reference.html.

Rather than extending lldb-mi to fully implement gdb-mi, the lldb Python interface may be useful. I would like to try to use some existing code that does this. Perhaps from the voltron project. Other recommendations for lldb/python script api's are welcome.

Once that's implemented, gdbgui can choose which controller to use depending on if the user wants to use gdb or lldb.

cs01 avatar Mar 22 '17 22:03 cs01

Might be worth it to hit up the LLVM IRC channel. They're very responsive in there.

Qix- avatar Aug 13 '17 08:08 Qix-

@Qix- thanks. I might try that at some point. I think my best bet might be to look up gdb mi's 7.4 documentation and try to use that API, but I'll keep the IRC channel in mind too.

cs01 avatar Aug 14 '17 22:08 cs01

is anyone working on it?

scontini76 avatar Jul 17 '18 11:07 scontini76

Unfortunately no, and it is not something that I plan to work on anytime soon. Are you interested in giving it a go? I could help you navigate gdbgui's codebase and understand the architecture.

In the long term I would like to use VSCode Debug Adapters so that the entire front end is provided data from a VSCode Debug Adapter. This will enable gdbgui to work with any language and become a generic browser based debugger. So gdb and LLDB would work, but so would Python debuggers, and any other language that had its debugger protocol translated to VSCode's Protocol. This would required updating pygdbmi, which shouldn't be so hard since its already structured, and making it work (or forking it to work) to work with LLDB.

https://github.com/vadimcn/vscode-lldb already exists for VSCode; maybe some of that code could be reused.

Making gdbgui work with VSCode adapters would IMO be a huge benefit for the programming world.

cs01 avatar Jul 17 '18 17:07 cs01

I came across this issue a while ago and this week I saw an interesting mail passing by on the llvm mailing list. Thought it might be interesting/relevant for you guys: http://lists.llvm.org/pipermail/llvm-dev/2018-August/125262.html

Travolter avatar Aug 14 '18 08:08 Travolter

For anyone reading this who has lldb-mi installed, gdbgui does kinda work with it. It might be enough to get you want you want (and it's certainly easier than trying to get gdb installed and codesigned on a mac if you haven't already done that).

gdbgui -g <path to lldb-mi>

cs01 avatar Feb 27 '19 00:02 cs01

When you download clang binaries for Windows from here - https://releases.llvm.org/download.html

They already come with a compiled lldb - that works! Well, kinda, you need to downoad a python dll manually - https://stackoverflow.com/questions/61731940/lldb-windows-errors-with-clang-10/

Still, this is the only "native" way to have a C++ debugger on Windows. Would be sweet to be able to use it with gdbgui..

@gnzlbg I sent two emails to the mailing list and haven't heard anything back.

lldb-mi compatibility with gdb 7.12 mi2 interpreter

lldb-mi functionality

Having to contact them via some mailing list, that is so ancient and weird.. I can understand why you got dissuaded :/

h5rdly avatar May 21 '20 07:05 h5rdly

Unfortunately no, and it is not something that I plan to work on anytime soon. Are you interested in giving it a go? I could help you navigate gdbgui's codebase and understand the architecture.

In the long term I would like to use VSCode Debug Adapters so that the entire front end is provided data from a VSCode Debug Adapter. This will enable gdbgui to work with any language and become a generic browser based debugger. So gdb and LLDB would work, but so would Python debuggers, and any other language that had its debugger protocol translated to VSCode's Protocol. This would required updating pygdbmi, which shouldn't be so hard since its already structured, and making it work (or forking it to work) to work with LLDB.

https://github.com/vadimcn/vscode-lldb already exists for VSCode; maybe some of that code could be reused.

Making gdbgui work with VSCode adapters would IMO be a huge benefit for the programming world.

Any advances on the Debug Adapter implementation? That thing would be a game changer for sure!

MayushKumar avatar Apr 18 '21 12:04 MayushKumar

Unfortunately, no. I am the only maintainer of this tool, and I am only doing critical bug fixes as they arise. I’m not opposed to more people jumping in with pull requests though.

cs01 avatar May 20 '21 19:05 cs01