[lldb-dev] LLDB Machine Interface Frontend

Eran Ifrah eran.ifrah at gmail.com
Mon May 19 13:50:13 PDT 2014


Thanks for your build Deepak, it starts without any crashes.
However, the implementation is lacking, and I suspect that making it work
with any existing IDE that uses GDB/MI will take a lot of effort.

Few comments:
On Windows, I use some extra normal commands that have no counter part in
the MI, such as "set new-console on" (which creates a new CMD.EXE and
redirects all the application's std[in|err|out]), ofc, this does not work

The replies from lldb-mi, are a bit different from gdb, for example,
consider this interaction between codelite (the IDE) and lldb-mi:

Using gdbinit file: C:\Users\PC\AppData\Local\Temp\codelite_gdbinit.txt
Current working dir: D:\src\TestArea\wxCrafterTester
Launching gdb from : ./Debug
Starting debugger  : C:\Users\PC\Desktop\MinSizeRel\lldb-mi.exe
--command="C:\Users\PC\AppData\Local\Temp\codelite_gdbinit.txt"
--interpreter=mi "./wxCrafterTester"
DEBUG>>00000001-break-insert -f -t main
DEBUG>>00000002-enable-pretty-printing
Debug session started successfully!
DEBUG>>00000003-exec-arguments
DEBUG>>00000004-exec-run
lldb-mi>>1^error,msg="Command 'break-insert'. Breakpoint 'main' invalid"
1^error,msg="Command 'break-insert'. Breakpoint 'main' invalid"


Command: 00000001: -break-insert
According to the docs, it can accept function name (its sole purpose here
is to place a temporary breakpoint at 'main' (hence, the "-t") ). It seems
like lldb-mi does not expect a function name but rather a location? (did
not try that)
Also, the reply from lldb-mi is different:
codelite prepends a transaction ID (8 digits number with fixed length) for
each command it sends over to gdb, it is expecting gdb/lldb-mi to reply
with these exact 8 digits (including all padding zeros)
this is not the case here (lldb-mi replied with '1' instead of '00000001')

After changing codelite's gdb settings (i.e. disabled the option to
temporarily break at main) I hit another obstacle: I can not place a
breakpoint:

DEBUG>>00000005-break-insert -f
"\"D:/src/TestArea/wxCrafterTester/MainFrame.cpp:15\""
...
and lldb-mi replied with:

lldb-mi>>MI: Error: Command Args. Validation failed. Not all arguments or
options were recognized:
"\"D:/src/TestArea/wxCrafterTester/MainFrame.cpp:15\""
MI: Error: Command Args. Validation failed. Not all arguments or options
were recognized: "\"D:/src/TestArea/wxCrafterTester/MainFrame.cpp:15\""
lldb-mi>>5^error,msg="Command 'break-insert'. Command Args. Validation
failed. Not all arguments or options were recognized:
"\"D:/src/TestArea/wxCrafterTester/MainFrame.cpp:15\"""
5^error,msg="Command 'break-insert'. Command Args. Validation failed. Not
all arguments or options were recognized:
"\"D:/src/TestArea/wxCrafterTester/MainFrame.cpp:15\"""

At first I thought its because of the volume ("D:") part of the file name,
so I changed the settings to send file name without full path, same error
occured ...
Also, it seems that when lldb-mi hits the first error it simply hangs ( I
don't see my application being launched )

Some more observations:
Commands that are not supported (and used by codelite IDE):

// -exec-arguments
DEBUG>>00000010-exec-arguments 1
lldb-mi>>11^error,msg="Driver. Received command '00000011-exec-arguments'.
It was not handled. Command 'exec-arguments' not in Command Factory"

// -enable-pretty-printing
DEBUG>>00000010-enable-pretty-printing
lldb-mi>>10^done,supported="0"

This was all tested on Windows 7, 64bit.
Trying to debug an executable built with g++-4.8.1 32bit, (MinGW, no MSYS)

Thanks for you work,
Eran



On Mon, May 19, 2014 at 2:26 PM, Deepak Panickal <deepak at codeplay.com>wrote:

>  Hi Eran,
>
> Here's the link to download the MinSizeRel build.
> https://db.tt/CdvFKVcN
>
> Thanks,
> Deepak
>
>
>
> On 16/05/2014 21:01, Eran Ifrah wrote:
>
>
>
>
> On Fri, May 16, 2014 at 9:55 PM, Eran Ifrah <eran.ifrah at gmail.com> wrote:
>
>>
>>
>>
>>  On Fri, May 16, 2014 at 8:23 PM, Deepak Panickal <deepak at codeplay.com>wrote:
>>
>>>  Hi Eran,
>>>
>>> I tried it here with a Debug build and a MinSizeRel build, but no
>>> crashes.
>>>
>>> Did you try to launch it from an IDE or simply ran it?
>>>
>>  ​ I tried it from the command line
>>
>>  FYI:
>>  I am using Windows 7 (64), Visual Studio 2013 (express edition)
>>  Can you upload your lldb-mi.exe / liblldb.dll somewhere so I could try
>> it here and see if its a problem with my build?
>>
>>>>
>>
>>>  Could you please try a debug build?
>>>
>>  ​ Will do
>>
>>     here is the backtrace from the crash (it crashes on a va_copy()
> call... arg) :
>
>      msvcr120d.dll!5ccefb53()    Unknown
>      [Frames below may be incorrect and/or missing, no symbols loaded for
> msvcr120d.dll]
>      [External Code]
> >    lldb-mi.exe!CMIUtilString::FormatPriv(const CMIUtilString & vrFormat,
> char * vArgs) Line 114    C++
>      lldb-mi.exe!CMIUtilString::Format(const CMIUtilString & vrFormating,
> ...) Line 139    C++
>      lldb-mi.exe!CMIDriverMgr::GetAppVersion() Line 577    C++
>      lldb-mi.exe!CMICmnLog::Initialize() Line 83    C++
>      lldb-mi.exe!MI::ModuleInit<CMICmnLog>(const int vErrorResrcId, bool &
> vwrbOk, CMIUtilString & vwrErrMsg) Line 50    C++
>      lldb-mi.exe!CMIDriverMgr::Initialize() Line 82    C++
>      lldb-mi.exe!DriverSystemInit() Line 199    C++
>      lldb-mi.exe!main(int argc, const char * * argv) Line 317    C++
>      [External Code]
>
>  And for your convenience, here is the "Locals" view during the crash:
> vrFormat    "%s\n%s\n%s"    const CMIUtilString &
> vArgs    0x00bdf334 "ÌÌÌÌ| \x15"    char *
> argsCpy    0x00bdf334 "ÌÌÌÌ| \x15"    char *
> nFinal    0    int
> pFormatted    unique_ptr 37 '%'    std::unique_ptr<char
> [0],std::default_delete<char [0]> >
> n    16    int
> strResult    ""    CMIUtilString
>
>  Hope it will give you a hint
>>
>
>>
>>> We'll look into it more to see if we can find something.
>>>
>>> Thanks,
>>> Deepak
>>>
>>>
>>> On 16/05/2014 17:04, Eran Ifrah wrote:
>>>
>>>  Hi Deepak,
>>>
>>>  I have just updated and rebuilt the tree on Windows
>>>  Starting lldb-mi.exe -> instantly crashes
>>>  for comparison, starting lldb.exe it starts normally without any crash
>>>
>>>  I built it using VS2013, I selected the 'MinSizeRel' build
>>> configuration
>>>  Unfortunately, running it under VS, gives a useless backtrace (only
>>> addresses)
>>>
>>>  I could try and build it with debug info, but it just takes too much
>>> time :D
>>>
>>>  Eran
>>>
>>>
>>>
>>>
>>> On Fri, May 16, 2014 at 6:50 PM, <jingham at apple.com> wrote:
>>>
>>>> Excellent!  Again, thanks for working on this.
>>>>
>>>> Jim
>>>>
>>>> On May 16, 2014, at 4:15 AM, Deepak Panickal <deepak at codeplay.com>
>>>> wrote:
>>>>
>>>> > Thanks Jim, have just committed it. Yeah, it works with the GDB/MI
>>>> interface.
>>>> >
>>>> > There's no GPL code, it's all written from scratch.
>>>> > Not all MI commands have been implemented yet, however it should be
>>>> enough to set breakpoints, view locals.
>>>> > We're working on adding more commands for viewing/modifying
>>>> registers, memory etc.
>>>> >
>>>> > It'll be great if more people from the community can use and test it
>>>> with other GUIs!
>>>> >
>>>> > Thanks,
>>>> > Deepak
>>>> >
>>>> >
>>>> > On 15/05/2014 18:57, jingham at apple.com wrote:
>>>> >> First off, thanks for doing this, that is great!  If this also works
>>>> with the gdb-mi mode, you will make our emacs friends happy as well.
>>>> >>
>>>> >> If this is just an independent tool that doesn't touch the core lldb
>>>> sources (and doesn't use anything directly from the gdb MI implementation,
>>>> since we don't want to mix GPL'ed code in with lldb), I see no reason not
>>>> to just check it in now, and then iterate on it in situ.  That is much
>>>> easier than handing around patch files, and since there's no chance it will
>>>> interfere with anybody working on parts of lldb that existed before the
>>>> patch, can't do any harm.  I spoke to GregC and he agrees this is a
>>>> reasonable course.
>>>> >>
>>>> >> Again, thanks for working on this.
>>>> >>
>>>> >> Jim
>>>> >>
>>>> >>
>>>> >> On May 15, 2014, at 10:17 AM, Deepak Panickal <deepak at codeplay.com>
>>>> wrote:
>>>> >>
>>>> >>> Hi Abid,
>>>> >>>
>>>> >>> Thank you, I have attached the zipped patch.
>>>> >>> You might have to the change the triple in
>>>> tools/lldb-mi/MICmnConfig.h for your target.
>>>> >>>
>>>> >>> Please let me know if you have any comments/suggestions.
>>>> >>>
>>>> >>> Thanks,
>>>> >>> Deepak
>>>> >>>
>>>> >>> On 15/05/2014 17:10, Abid, Hafiz wrote:
>>>> >>>> Hi Deepak,
>>>> >>>> I can help review/test it when you post the patch.
>>>> >>>>
>>>> >>>> Thanks,
>>>> >>>> Abid
>>>> >>>>
>>>> >>>>> -----Original Message-----
>>>> >>>>> From: lldb-dev-bounces at cs.uiuc.edu [mailto:
>>>> lldb-dev-bounces at cs.uiuc.edu]
>>>> >>>>> On Behalf Of Deepak Panickal
>>>> >>>>> Sent: 15 May 2014 12:14
>>>> >>>>> To: lldb-dev at cs.uiuc.edu
>>>> >>>>> Subject: [lldb-dev] LLDB Machine Interface Frontend
>>>> >>>>>
>>>> >>>>> Hi,
>>>> >>>>>
>>>> >>>>> We have an MI (Machine Interface) frontend to LLDB which works
>>>> out of the
>>>> >>>>> box with Eclipse, and likely will work with other GUI's based on
>>>> the GDB/MI
>>>> >>>>> interface. It's been tested on Linux and Windows.
>>>> >>>>>
>>>> >>>>> It's ready to upstream and has been developed as an independent
>>>> tool
>>>> >>>>> residing in the LLDB tools folder. It's based on the LLDB public
>>>> API without
>>>> >>>>> any changes to LLDB internals.
>>>> >>>>>
>>>> >>>>> The patch is quite large as there are many new files.
>>>> >>>>> How should we go about upstreaming? Should I create a diff review
>>>> as
>>>> >>>>> usual?
>>>> >>>>>
>>>> >>>>> Thanks,
>>>> >>>>> Deepak
>>>> >>>>> _______________________________________________
>>>> >>>>> lldb-dev mailing list
>>>> >>>>> lldb-dev at cs.uiuc.edu
>>>> >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>>> >>>
>>>> <lldb-mi-driver.patch.bz2>_______________________________________________
>>>> >>> lldb-dev mailing list
>>>> >>> lldb-dev at cs.uiuc.edu
>>>> >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>>> >
>>>>
>>>> _______________________________________________
>>>> lldb-dev mailing list
>>>> lldb-dev at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>>>
>>>
>>>
>>>
>>> --
>>> Eran Ifrah
>>> Author of codelite, a cross platform open source C/C++ IDE:
>>> http://www.codelite.org
>>>  wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
>>>
>>>
>>>
>>
>>
>> --
>> Eran Ifrah
>> Author of codelite, a cross platform open source C/C++ IDE:
>> http://www.codelite.org
>>  wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
>>
>
>
>
> --
> Eran Ifrah
> Author of codelite, a cross platform open source C/C++ IDE:
> http://www.codelite.org
>  wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
>
>
>


-- 
Eran Ifrah
Author of codelite, a cross platform open source C/C++ IDE:
http://www.codelite.org
wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140519/4e4a8f12/attachment.html>


More information about the lldb-dev mailing list