Difference between revisions of "Debuggers"

From D Wiki
Jump to: navigation, search
(Debugging support by compiler and platform:)
(Debugging support by compiler)
 
(39 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 +
To debug D programs you need to use a debugger that understands the format of the debug symbols information that your chosen compiler produces.
 +
The quality of the debug symbols information might vary depending on which compiler you use and its underlying debug format. For example, some compiler configurations may present the names of variables and/or functions in it's C mangled form, instead of the natural D name.
  
== Debugging support by compiler and platform: ==
+
== Debugging support by compiler ==
 
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Compiler/Platform
+
! Compiler+Platform
 
! Format
 
! Format
 
! Debugger
 
! Debugger
 
! Supported functionality
 
! Supported functionality
 
|-
 
|-
| '''DMD-Win32'''  
+
|rowspan="5"| '''DMD-Win32'''  
| OMF
+
|rowspan="5"| OMF
| [http://www.dsource.org/projects/visuald VisualD (VisualStudio)]
+
| [http://rainers.github.io/visuald/visuald/StartPage.html Mago/VisualD]
| Good support: Breakpoints; Stack frames; Mostly pretty names ('.' shows up as '@'); Variable inspection;
+
| Good support: Breakpoints; Stack frames; Mostly pretty names ('.' shows up as '@'); Variable inspection; Visual Studio based.
 +
|-
 +
| [https://github.com/buggins/mago Mago-MI]
 +
| Good support: Breakpoints; Stack frames; Variable inspection; GDB/MI compatible interface for Mago debugger.
 +
|-
 +
| [http://dlang.org/download.html WinDbg]
 +
| Supplied with the main D compiler zip file download. [http://dlang.org/windbg.html Overview]
 
|-
 
|-
| '''DMD-Win32'''
 
| OMF
 
 
| [http://ddbg.mainia.de ddbg]
 
| [http://ddbg.mainia.de ddbg]
 
| Doesn't seem to be working well. Project no longer maintained.
 
| Doesn't seem to be working well. Project no longer maintained.
 
|-
 
|-
| '''DMD-Win64'''
+
| [http://www.ollydbg.de/version2.html OllyDbg 2]
| COFF
+
| Reasonable support when assisted by [https://github.com/rainers/cv2pdb cv2pdb]; stack frames; mangled symbols; shows source code alongside disassembly. Note: v2.01 has a bug that may cause frequent crashes when reading PDB files. Details and patch [http://forum.dlang.org/post/mgyggejmutshptyycwze@forum.dlang.org here].
| [http://www.dsource.org/projects/visuald VisualD (VisualStudio)]
 
| TODO: same level of support as for win32?
 
 
|-
 
|-
| '''DMD-Linux'''  
+
|rowspan="2"|
| DWARF on PE
+
'''DMD-Win64''' <br/>
| GDB
+
'''LDC-Win64'''
| same as GDC-Linux?
+
|rowspan="2"| COFF
 +
| [http://www.dsource.org/projects/visuald Mago/VisualD]
 +
| TODO: same level of support as for win32? Has issues with structs and pointers, break on D exceptions can no longer be toggled for unknown reasons.
 +
|-
 +
| [https://remedybg.itch.io/remedybg RemedyDB]
 +
| Paid. Works better at certain duties than VS. Still in active development. Does not have an option for break on exceptions, but can be mitigated with putting a breakpoint into an exception CTOR.
 
|-
 
|-
| '''GDC-Win32/64'''
+
|rowspan="2"|
'''GDC-Linux'''
+
'''DMD-Linux''' <br/>
| DWARF
+
'''GDC-Linux''' <br/>
| GDB
+
'''LDC-Linux''' <br/>
 +
'''GDC-Win32/64'''
 +
|rowspan="2"| DWARF
 +
| [https://sourceware.org/gdb/onlinedocs/gdb/D.html#D GDB]
 
| Good support: Breakpoints; Stack frames; Pretty names; Variable inspection;
 
| Good support: Breakpoints; Stack frames; Pretty names; Variable inspection;
 
|-
 
|-
| any?
 
| DWARF
 
 
| [http://zerobugs.codeplex.com/ ZeroBUGS]
 
| [http://zerobugs.codeplex.com/ ZeroBUGS]
 
| "Modular debugger for C/C++/D programming languages (and virtually anything else that supports Stabs/DWARF debug formats)". Supported debugging functionality??
 
| "Modular debugger for C/C++/D programming languages (and virtually anything else that supports Stabs/DWARF debug formats)". Supported debugging functionality??
 
|-
 
|-
| '''GDC-MacOS'''  
+
| '''LDC-MinGW'''
| (?)
+
| DWARF
 +
| -
 +
| DWARF debug symbol info seems to be broken for LLVM compiled with MinGW  [http://forum.dlang.org/post/qsttkqzbtnhyrogekppn@forum.dlang.org note]
 +
|-
 +
|rowspan="2"|
 +
'''DMD-MacOS''' <br/>
 +
'''GDC-MacOS''' <br/>
 +
'''LDC-MacOS'''  
 +
|rowspan="2"| ?
 
| GDB
 
| GDB
 
| Limited/outdated support? According to Jacob Carlberg:
 
| Limited/outdated support? According to Jacob Carlberg:
Line 48: Line 65:
 
"Line numbers don't work."
 
"Line numbers don't work."
 
|-
 
|-
| '''LDC'''
 
| (?)
 
 
| LLDB
 
| LLDB
 
| ?
 
| ?
 
|}
 
|}
  
== Graphical debugger frontends: ==
+
<noinclude>
 +
[[Category:Stand-alone applications]]
 +
</noinclude>
  
{{Projects
+
== Graphical debugger frontends ==
| Projects =
+
Frontends providing support to a command-line debugger mentioned in the previous section.
  
{{Project
+
 
| name = '''MonoD'''
+
 
| platform = Linux only?
+
{| class="wikitable"
| license = ?
+
|-
| about = MonoDeveloped-based full D IDE. Has integration with the GDB debugger.  
+
! Debugger
 +
! Frontend
 +
! Description
 +
! Platform
 +
|-
 +
| GDB
 +
| [[Mono-D]]
 +
| MonoDeveloped-based full D IDE. Has integration with the GDB debugger.  
 
"Debugging (using MonoDevelop’s integrated gdb support on Linux currently)"
 
"Debugging (using MonoDevelop’s integrated gdb support on Linux currently)"
| url = http://mono-d.alexanderbothe.com/about/
+
| Linux?
}}
+
|-
 
+
| GDB
{{Project
+
| [http://code.google.com/p/ddt/ '''DDT''']
| name = '''CDT'''
+
| Eclipse-based IDE. Has [https://github.com/bruno-medeiros/DDT/blob/latest/documentation/Features.md#debugging-functionality integration with the GDB debugger], including D support. (Debugging support is based on Eclipse CDT)
| platform = Linux/Windows/MacOS
+
| Linux, Windows, MacOS
| license = EPL
+
|-
| about = Eclipse-based full C/C++ IDE. Has fully working integration with the GDB debugger, including D support. Can partially work with D projects if a fake C/C++ project is created in order to debug a D executable.
+
| GDB
| url = http://www.eclipse.org/cdt/
+
| [http://projects.gnome.org/nemiver/ '''Nemiver''']
}}
+
| Graphical frontend to the GDB debugger, which supports full D syntax from version 7.2.
 +
| Linux
 +
|-
 +
| GDB
 +
| [https://cgdb.github.io/ '''CGDB''']
 +
| Command line frontend to the GDB debugger, which supports full D syntax from version 7.2.Shows code and the GDB console in split windows.
 +
| Linux, MacOS
 +
|-
 +
| GDB
 +
| [http://www.gnu.org/software/ddd/ '''DDD''']
 +
| GNU DDD is a graphical front-end for command-line debuggers such as GDB. Usual front-end features such as viewing source code, viewing variables, etc.
 +
| Linux
 +
|-
 +
| GDB
 +
| [http://www.affinic.com/?page_id=109 '''Affinic Debugger''']
 +
| Affinic Debugger GUI .aka. ADG, is designed as a graphical user interface for various debuggers. This version is specifically targeted on GDB, the GNU debugger.
 +
| Linux, Windows, MacOS
 +
|-
 +
| GDB
 +
| [https://github.com/buggins/dlangide '''DlangIDE''']
 +
| D language IDE written in D. Supports GDB-MI compatible debuggers.
 +
| Linux, Windows, MacOS
 +
|-
 +
| GDB
 +
| [https://basile.b.gitlab.io/dexed/widgets_gdb_commander.html '''Dexed - GDB commander''']
 +
| Visual debugging with GDB in one of the IDE widget.
 +
| Linux
 +
|-
 +
| mago-mi
 +
| [https://github.com/buggins/dlangide '''DlangIDE''']
 +
| D language IDE written in D. Supports GDB-MI compatible debuggers.
 +
| Windows
 +
|-
 +
| mago-mi
 +
| [http://code.google.com/p/ddt/ '''DDT''']
 +
| Eclipse-based IDE. Supports mago-mi debugger using GDB-MI interface.
 +
| Windows
 +
|-
 +
| GDB / LLDB
 +
| [https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools VS Code with C/C++ Extension]
 +
| Visual Studio Code along with the C/C++ extension which allows for debugging native applications. It is possible to use the extension's debugger with D.
 +
| Linux, MacOS
 +
|-
 +
| GDB / LLDB / mago-mi
 +
| [https://marketplace.visualstudio.com/items?itemName=webfreak.debug '''Native Debug (VS Code Extension)''']
 +
| Debugging through Visual Studio Code's debugging UI.
 +
| Linux, Windows, MacOS
 +
|}
  
{{Project
+
== Specific Debugger Tutorials ==
| name = '''Nemiver'''
 
| platform = Linux
 
| license = GPL
 
| about = Graphical frontend to the GDB debugger, which supports full D syntax from version 7.2.
 
| url = http://projects.gnome.org/nemiver/
 
}}
 
{{Project
 
| name = '''CGDB'''
 
| platform = Linux
 
| license = GPL
 
| about = Command line frontend to the GDB debugger, which supports full D syntax from version 7.2.Shows code and the GDB console in split windows.
 
| url = http://cgdb.github.com/
 
}}
 
  
}}
+
Some video resources on learning debugging can be found here: [https://www.youtube.com/watch?v=NWsZrN7gXYg&list=PLvv0ScY6vfd9Fso-3cB4CGnSlW0E4btJV&index=33 '''Debugging with GDB (Linux demonstration)'''], [https://www.youtube.com/watch?v=drzvDkU-H54&list=PLvv0ScY6vfd9Fso-3cB4CGnSlW0E4btJV&index=33 '''Debugging with lldb (Mac demonstration with LDC2 and DMD)'''] (Note, as the quality of debug information improves you may get more information/abilities through your debugger over time). Please visit the [https://wiki.dlang.org/Tutorials '''Tutorials'''] which may contain further resources.

Latest revision as of 21:51, 19 November 2023

To debug D programs you need to use a debugger that understands the format of the debug symbols information that your chosen compiler produces. The quality of the debug symbols information might vary depending on which compiler you use and its underlying debug format. For example, some compiler configurations may present the names of variables and/or functions in it's C mangled form, instead of the natural D name.

Debugging support by compiler

Compiler+Platform Format Debugger Supported functionality
DMD-Win32 OMF Mago/VisualD Good support: Breakpoints; Stack frames; Mostly pretty names ('.' shows up as '@'); Variable inspection; Visual Studio based.
Mago-MI Good support: Breakpoints; Stack frames; Variable inspection; GDB/MI compatible interface for Mago debugger.
WinDbg Supplied with the main D compiler zip file download. Overview
ddbg Doesn't seem to be working well. Project no longer maintained.
OllyDbg 2 Reasonable support when assisted by cv2pdb; stack frames; mangled symbols; shows source code alongside disassembly. Note: v2.01 has a bug that may cause frequent crashes when reading PDB files. Details and patch here.

DMD-Win64
LDC-Win64

COFF Mago/VisualD TODO: same level of support as for win32? Has issues with structs and pointers, break on D exceptions can no longer be toggled for unknown reasons.
RemedyDB Paid. Works better at certain duties than VS. Still in active development. Does not have an option for break on exceptions, but can be mitigated with putting a breakpoint into an exception CTOR.

DMD-Linux
GDC-Linux
LDC-Linux
GDC-Win32/64

DWARF GDB Good support: Breakpoints; Stack frames; Pretty names; Variable inspection;
ZeroBUGS "Modular debugger for C/C++/D programming languages (and virtually anything else that supports Stabs/DWARF debug formats)". Supported debugging functionality??
LDC-MinGW DWARF - DWARF debug symbol info seems to be broken for LLVM compiled with MinGW note

DMD-MacOS
GDC-MacOS
LDC-MacOS

? GDB Limited/outdated support? According to Jacob Carlberg:

"D symbols need to be prefixed with an extra underscore." "Line numbers don't work."

LLDB ?


Graphical debugger frontends

Frontends providing support to a command-line debugger mentioned in the previous section.


Debugger Frontend Description Platform
GDB Mono-D MonoDeveloped-based full D IDE. Has integration with the GDB debugger.

"Debugging (using MonoDevelop’s integrated gdb support on Linux currently)"

Linux?
GDB DDT Eclipse-based IDE. Has integration with the GDB debugger, including D support. (Debugging support is based on Eclipse CDT) Linux, Windows, MacOS
GDB Nemiver Graphical frontend to the GDB debugger, which supports full D syntax from version 7.2. Linux
GDB CGDB Command line frontend to the GDB debugger, which supports full D syntax from version 7.2.Shows code and the GDB console in split windows. Linux, MacOS
GDB DDD GNU DDD is a graphical front-end for command-line debuggers such as GDB. Usual front-end features such as viewing source code, viewing variables, etc. Linux
GDB Affinic Debugger Affinic Debugger GUI .aka. ADG, is designed as a graphical user interface for various debuggers. This version is specifically targeted on GDB, the GNU debugger. Linux, Windows, MacOS
GDB DlangIDE D language IDE written in D. Supports GDB-MI compatible debuggers. Linux, Windows, MacOS
GDB Dexed - GDB commander Visual debugging with GDB in one of the IDE widget. Linux
mago-mi DlangIDE D language IDE written in D. Supports GDB-MI compatible debuggers. Windows
mago-mi DDT Eclipse-based IDE. Supports mago-mi debugger using GDB-MI interface. Windows
GDB / LLDB VS Code with C/C++ Extension Visual Studio Code along with the C/C++ extension which allows for debugging native applications. It is possible to use the extension's debugger with D. Linux, MacOS
GDB / LLDB / mago-mi Native Debug (VS Code Extension) Debugging through Visual Studio Code's debugging UI. Linux, Windows, MacOS

Specific Debugger Tutorials

Some video resources on learning debugging can be found here: Debugging with GDB (Linux demonstration), Debugging with lldb (Mac demonstration with LDC2 and DMD) (Note, as the quality of debug information improves you may get more information/abilities through your debugger over time). Please visit the Tutorials which may contain further resources.