Jump to page: 1 2
Thread overview
mago-mi: GDB/MI compatible frontend for Mago debugger
May 17, 2016
Vadim Lopatin
May 17, 2016
Bruno Medeiros
May 17, 2016
Vadim Lopatin
May 18, 2016
Bruno Medeiros
May 19, 2016
Vadim Lopatin
May 19, 2016
Bruno Medeiros
May 20, 2016
E.S. Quinn
May 20, 2016
Vadim Lopatin
May 20, 2016
Vadim Lopatin
May 24, 2016
Vadim Lopatin
May 24, 2016
Rainer Schuetze
May 24, 2016
Vadim Lopatin
May 24, 2016
Rainer Schuetze
May 24, 2016
Vadim Lopatin
Jun 01, 2016
Bruno Medeiros
Jun 01, 2016
Vadim Lopatin
May 17, 2016
Hello,

I'm working on GDB/MI compatible interface for Mago debugger on Windows.

GDB/MI is line based machine interface for debugger. IDEs are using GDB via this interface.

GDB/MI docs: https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html

Project page (mago fork) https://github.com/buggins/mago

Currently mago-mi supports subset of GDB commands enough for current DlangIDE functionality.

Tested on DMD generated 32bit executables.

See readme details list of implemented commands: https://github.com/buggins/mago/tree/master/MagoMI/mago-mi

Difference from baseline https://github.com/rainers/mago files are minimal:
- Static linking for MagoNatDE and MagoNatEE
- Disabled some Mago debug logging

Building mago-mi from source is easy. I've tried MS Visual Studio 2013 and 2015. Don't forget to edit properties in mago/PropSheets. Buld mago-mi project.

Since DlangIDE v0.6.1, it includes prebuilt mago-mi.exe (it will be copied into bin directory by dub build) and default Debugger settings are changed from gdb to mago-mi by default on Windows. If you already used DlangIDE on your computer, check Edit/Preferences/Debugger setting - change to "mago-mi" if "gdb" is specified.

If you want to try mago-mi and DlangIDE which is using it, you can download binaries from https://sourceforge.net/projects/crengine/files/DlangUI/dlangide-v061-magomi-v010-x86.zip/download (or just sync to latest dlangide and use `dub run`). Bundle includes DlangIDE, mago-mi, dub, and sample workspaces (helloworld and tetris). Download size is 5.4Mb (seems small enough for IDE+debugger).

I hope my work will be useful for other IDE developers who is targeting on Windows.
(Any IDE which uses gdb/mi interface)
I tried gdb and lldb-mi before, but did not managed to find working compiler + debugger configuration. (Best combination was gdb + gdc, but it was showing global variables instead of locals. For lldb-mi, I haven't managed to find compiler which produces compatible debug info).

Best regards,
    Vadim
May 17, 2016
On 17/05/2016 09:06, Vadim Lopatin wrote:
> Hello,
>
> I'm working on GDB/MI compatible interface for Mago debugger on Windows.
>
> GDB/MI is line based machine interface for debugger. IDEs are using GDB
> via this interface.
>
> GDB/MI docs: https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html
>
> Project page (mago fork) https://github.com/buggins/mago
>
> Currently mago-mi supports subset of GDB commands enough for current
> DlangIDE functionality.
>
> Tested on DMD generated 32bit executables.
>
> See readme details list of implemented commands:
> https://github.com/buggins/mago/tree/master/MagoMI/mago-mi
>
> Difference from baseline https://github.com/rainers/mago files are minimal:
> - Static linking for MagoNatDE and MagoNatEE
> - Disabled some Mago debug logging
>
> Building mago-mi from source is easy. I've tried MS Visual Studio 2013
> and 2015. Don't forget to edit properties in mago/PropSheets. Buld
> mago-mi project.
>
> Since DlangIDE v0.6.1, it includes prebuilt mago-mi.exe (it will be
> copied into bin directory by dub build) and default Debugger settings
> are changed from gdb to mago-mi by default on Windows. If you already
> used DlangIDE on your computer, check Edit/Preferences/Debugger setting
> - change to "mago-mi" if "gdb" is specified.
>
> If you want to try mago-mi and DlangIDE which is using it, you can
> download binaries from
> https://sourceforge.net/projects/crengine/files/DlangUI/dlangide-v061-magomi-v010-x86.zip/download
> (or just sync to latest dlangide and use `dub run`). Bundle includes
> DlangIDE, mago-mi, dub, and sample workspaces (helloworld and tetris).
> Download size is 5.4Mb (seems small enough for IDE+debugger).
>
> I hope my work will be useful for other IDE developers who is targeting
> on Windows.
> (Any IDE which uses gdb/mi interface)
> I tried gdb and lldb-mi before, but did not managed to find working
> compiler + debugger configuration. (Best combination was gdb + gdc, but
> it was showing global variables instead of locals. For lldb-mi, I
> haven't managed to find compiler which produces compatible debug info).
>
> Best regards,
>     Vadim


Interesting. I was about to ask what was the main advantage over GDB? I reckon it is that Mago can debug executables with the COFF and/or OMF formats, right? (as opposed to GDB's DWARF format)

-- 
Bruno Medeiros
https://twitter.com/brunodomedeiros
May 17, 2016
On Tuesday, 17 May 2016 at 13:04:23 UTC, Bruno Medeiros wrote:
> Interesting. I was about to ask what was the main advantage over GDB? I reckon it is that Mago can debug executables with the COFF and/or OMF formats, right? (as opposed to GDB's DWARF format)

Mago currently has the best D language support on Windows. Can debug DMD generated executables.

Do you know any GDB version + compiler version which works ok on Windows?
Even w/o D demangling. At least able to create breakpoints, step, continue, examining threads, stack frames, local variables. In gdb+gdc combination I tried, gdb shows global variables instead of stack variables.

Does DDT work ok with GDB on Windows? What compiler can be used to get GDB debugging working?

May 18, 2016
On 17/05/2016 17:56, Vadim Lopatin wrote:
> On Tuesday, 17 May 2016 at 13:04:23 UTC, Bruno Medeiros wrote:
>> Interesting. I was about to ask what was the main advantage over GDB?
>> I reckon it is that Mago can debug executables with the COFF and/or
>> OMF formats, right? (as opposed to GDB's DWARF format)
>
> Mago currently has the best D language support on Windows. Can debug DMD
> generated executables.
>
> Do you know any GDB version + compiler version which works ok on Windows?
> Even w/o D demangling. At least able to create breakpoints, step,
> continue, examining threads, stack frames, local variables. In gdb+gdc
> combination I tried, gdb shows global variables instead of stack variables.
>
> Does DDT work ok with GDB on Windows? What compiler can be used to get
> GDB debugging working?
>

While DDT technically work oks with GDB (the GDB from mingw-w64 that is), you are right, there isn't a compiler on Windows that supplies debug info in the way GDB understands. See https://wiki.dlang.org/Debuggers.

DMD produces debug info COFF or OMF format, which GDB doesn't know anything about (nor ever will). LDC should in theory work with DWARF info, but this is broken somehow. Not because of LLVM though, since for example Rust on Windows works. As for GDC, it doesn't even supply binaries for Windows (that target Windows) -  it is not a supported platform.

BTW, Eclipse/DDT should in theory work with mago-mi as well, at least if the protocol is implemented correctly. Have you tried it? I dunno how complete your MI implementation is.

-- 
Bruno Medeiros
https://twitter.com/brunodomedeiros
May 19, 2016
On Wednesday, 18 May 2016 at 18:02:12 UTC, Bruno Medeiros wrote:
> While DDT technically work oks with GDB (the GDB from mingw-w64 that is), you are right, there isn't a compiler on Windows that supplies debug info in the way GDB understands. See https://wiki.dlang.org/Debuggers.
>
> DMD produces debug info COFF or OMF format, which GDB doesn't know anything about (nor ever will). LDC should in theory work with DWARF info, but this is broken somehow. Not because of LLVM though, since for example Rust on Windows works. As for GDC, it doesn't even supply binaries for Windows (that target Windows) -  it is not a supported platform.
>
> BTW, Eclipse/DDT should in theory work with mago-mi as well, at least if the protocol is implemented correctly. Have you tried it? I dunno how complete your MI implementation is.

So it looks like mago-mi might be helpful for DDT on Windows.
mago-mi supports subset of GDB/MI commands enough for DlangIDE, but it can be easy extended.

Currenlty supported commands can be shown using help command (use --interpreter=mi2 when running mago-mi, otherwise it will print non-MI commands). Also commands are listed in readme file https://github.com/buggins/mago/blob/master/MagoMI/mago-mi/README.md

I didn't try DDT with mago-mi, and so I'm not sure which commands must be supported by debugger to get it working with DDT.

To get list of commands DDT tries to use you can either add --log-file=magomi.log --log-level=TRACE to mago-mi command line or use debug build of mago-mi.
It will all STDIN data to log file, and report errors for unsupported commands.

May 19, 2016
On 19/05/2016 08:41, Vadim Lopatin wrote:
> On Wednesday, 18 May 2016 at 18:02:12 UTC, Bruno Medeiros wrote:
>> While DDT technically work oks with GDB (the GDB from mingw-w64 that
>> is), you are right, there isn't a compiler on Windows that supplies
>> debug info in the way GDB understands. See
>> https://wiki.dlang.org/Debuggers.
>>
>> DMD produces debug info COFF or OMF format, which GDB doesn't know
>> anything about (nor ever will). LDC should in theory work with DWARF
>> info, but this is broken somehow. Not because of LLVM though, since
>> for example Rust on Windows works. As for GDC, it doesn't even supply
>> binaries for Windows (that target Windows) -  it is not a supported
>> platform.
>>
>> BTW, Eclipse/DDT should in theory work with mago-mi as well, at least
>> if the protocol is implemented correctly. Have you tried it? I dunno
>> how complete your MI implementation is.
>
> So it looks like mago-mi might be helpful for DDT on Windows.
> mago-mi supports subset of GDB/MI commands enough for DlangIDE, but it
> can be easy extended.
>
> Currenlty supported commands can be shown using help command (use
> --interpreter=mi2 when running mago-mi, otherwise it will print non-MI
> commands). Also commands are listed in readme file
> https://github.com/buggins/mago/blob/master/MagoMI/mago-mi/README.md
>
> I didn't try DDT with mago-mi, and so I'm not sure which commands must
> be supported by debugger to get it working with DDT.
>
> To get list of commands DDT tries to use you can either add
> --log-file=magomi.log --log-level=TRACE to mago-mi command line or use
> debug build of mago-mi.
> It will all STDIN data to log file, and report errors for unsupported
> commands.
>

I also don't know which MI commands need to be supported to have it work with DDT. The thing is I didn't write the GDB debugger integration for DDT, I just reused the one from CDT. So I'm not that familiar with those internals.

BTW, the MI integration is fairly language agnostic, so in theory your debugger could be used by CDT to debug C/C++ programs too, no? At least those generated by DMC. Maybe Visual Studio ones too?

-- 
Bruno Medeiros
https://twitter.com/brunodomedeiros
May 20, 2016
Unfortunately in this particular case, CDT's debugging is pretty fancy and is going to need most if not all of the MI.

On Thursday, 19 May 2016 at 13:29:14 UTC, Bruno Medeiros wrote:
> On 19/05/2016 08:41, Vadim Lopatin wrote:
>> On Wednesday, 18 May 2016 at 18:02:12 UTC, Bruno Medeiros wrote:
>>> While DDT technically work oks with GDB (the GDB from mingw-w64 that
>>> is), you are right, there isn't a compiler on Windows that supplies
>>> debug info in the way GDB understands. See
>>> https://wiki.dlang.org/Debuggers.
>>>
>>> DMD produces debug info COFF or OMF format, which GDB doesn't know
>>> anything about (nor ever will). LDC should in theory work with DWARF
>>> info, but this is broken somehow. Not because of LLVM though, since
>>> for example Rust on Windows works. As for GDC, it doesn't even supply
>>> binaries for Windows (that target Windows) -  it is not a supported
>>> platform.
>>>
>>> BTW, Eclipse/DDT should in theory work with mago-mi as well, at least
>>> if the protocol is implemented correctly. Have you tried it? I dunno
>>> how complete your MI implementation is.
>>
>> So it looks like mago-mi might be helpful for DDT on Windows.
>> mago-mi supports subset of GDB/MI commands enough for DlangIDE, but it
>> can be easy extended.
>>
>> Currenlty supported commands can be shown using help command (use
>> --interpreter=mi2 when running mago-mi, otherwise it will print non-MI
>> commands). Also commands are listed in readme file
>> https://github.com/buggins/mago/blob/master/MagoMI/mago-mi/README.md
>>
>> I didn't try DDT with mago-mi, and so I'm not sure which commands must
>> be supported by debugger to get it working with DDT.
>>
>> To get list of commands DDT tries to use you can either add
>> --log-file=magomi.log --log-level=TRACE to mago-mi command line or use
>> debug build of mago-mi.
>> It will all STDIN data to log file, and report errors for unsupported
>> commands.
>>
>
> I also don't know which MI commands need to be supported to have it work with DDT. The thing is I didn't write the GDB debugger integration for DDT, I just reused the one from CDT. So I'm not that familiar with those internals.
>
> BTW, the MI integration is fairly language agnostic, so in theory your debugger could be used by CDT to debug C/C++ programs too, no? At least those generated by DMC. Maybe Visual Studio ones too?

I'm experimenting with the build of mago-mi that comes with the current ~master for dlangide, and it seems to throw an unrecognized parameter error when on the --log-level=TRACE parameter.

And it seems that the version string it returns upsets eclipse, as it throws the following error:

 Could not determine GDB version using command: D:\WinHome\<redacted>\AppData\Roaming\dub\packages\dlangide-master\bin\mago-mi.exe --version
 Unexpected output format:

 mago-mi debugger v0.1


Though, from my experience using it in Linux, eclipse-CDT's debugger seems pretty full-featured; it will likely require large swaths of mi functionality to be fully useful.
May 20, 2016
On Friday, 20 May 2016 at 03:15:46 UTC, E.S. Quinn wrote:
> Unfortunately in this particular case, CDT's debugging is pretty fancy and is going to need most if not all of the MI.
>
>> I also don't know which MI commands need to be supported to have it work with DDT. The thing is I didn't write the GDB debugger integration for DDT, I just reused the one from CDT. So I'm not that familiar with those internals.
>>
>> BTW, the MI integration is fairly language agnostic, so in theory your debugger could be used by CDT to debug C/C++ programs too, no? At least those generated by DMC. Maybe Visual Studio ones too?
>
> I'm experimenting with the build of mago-mi that comes with the current ~master for dlangide, and it seems to throw an unrecognized parameter error when on the --log-level=TRACE parameter.
>
> And it seems that the version string it returns upsets eclipse, as it throws the following error:
>
>  Could not determine GDB version using command: D:\WinHome\<redacted>\AppData\Roaming\dub\packages\dlangide-master\bin\mago-mi.exe --version
>  Unexpected output format:
>
>  mago-mi debugger v0.1
>
>
> Though, from my experience using it in Linux, eclipse-CDT's debugger seems pretty full-featured; it will likely require large swaths of mi functionality to be fully useful.

Need to show version like lldb-mi does - writes gnu gdb version, then says that really it's not a GDB

Let me check problem with --log-level

May 20, 2016
On Friday, 20 May 2016 at 03:15:46 UTC, E.S. Quinn wrote:
>> I also don't know which MI commands need to be supported to have it work with DDT. The thing is I didn't write the GDB debugger integration for DDT, I just reused the one from CDT. So I'm not that familiar with those internals.
>>
>> BTW, the MI integration is fairly language agnostic, so in theory your debugger could be used by CDT to debug C/C++ programs too, no? At least those generated by DMC. Maybe Visual Studio ones too?
>
> I'm experimenting with the build of mago-mi that comes with the current ~master for dlangide, and it seems to throw an unrecognized parameter error when on the --log-level=TRACE parameter.
>
> And it seems that the version string it returns upsets eclipse, as it throws the following error:
>
>  Could not determine GDB version using command: D:\WinHome\<redacted>\AppData\Roaming\dub\packages\dlangide-master\bin\mago-mi.exe --version
>  Unexpected output format:
>
>  mago-mi debugger v0.1
>
>
> Though, from my experience using it in Linux, eclipse-CDT's debugger seems pretty full-featured; it will likely require large swaths of mi functionality to be fully useful.

I've fixed some CDT incompatibilities.
Now it's possible to start debugging program from Eclipse/DDT, set breakpoints, start execution.
Execution is stopped on breakpoint, but Eclipse does not see that program is stopped - does not enable step buttons, does not try to fetch current threads/frames/variables.
I see no visible difference between GDBs and mago-mi responses to commands.

Binaries can be downloaded here:
https://github.com/buggins/dlangide/releases/tag/v0.6.4

Now logs are forced, and written to mago-mi-debug.log file in the same directory where mago-mi.exe is located.

May 24, 2016
On Wednesday, 18 May 2016 at 18:02:12 UTC, Bruno Medeiros wrote:
> While DDT technically work oks with GDB (the GDB from mingw-w64 that is), you are right, there isn't a compiler on Windows that supplies debug info in the way GDB understands. See https://wiki.dlang.org/Debuggers.
>
> DMD produces debug info COFF or OMF format, which GDB doesn't know anything about (nor ever will). LDC should in theory work with DWARF info, but this is broken somehow. Not because of LLVM though, since for example Rust on Windows works. As for GDC, it doesn't even supply binaries for Windows (that target Windows) -  it is not a supported platform.
>
> BTW, Eclipse/DDT should in theory work with mago-mi as well, at least if the protocol is implemented correctly. Have you tried it? I dunno how complete your MI implementation is.

mago-mi v0.2.1 is released.

Precompiled binaries are available in DlangIDE release bundle.
https://github.com/buggins/dlangide/releases/tag/v0.6.5

Added support for a lot of GDB/MI commands.
Compatibility with GDB fixed.
Tested with Eclipse/DDT.

You can build dmd/x86 project in Eclipse/DDT, start debugging, use breakpoints, step in/out/over, see threads, stack frames, variables.
Just change Debug Configuration / Debugger setting - from GDB to mago-mi

Best regards,
     Vadim
« First   ‹ Prev
1 2