Skip to content

Latest commit

 

History

History
181 lines (150 loc) · 3.95 KB

README.md

File metadata and controls

181 lines (150 loc) · 3.95 KB

dlang-debug

Pretty printers for various dlang types for GDB, LLDB and VSDBG.

TODO:

  • GDB
    • Test & make work on all OS
      • Linux x64
        • DMD
        • DMD -gc
        • LDC
        • LDC -gc
      • OSX x64
        • DMD
        • DMD -gc
        • LDC
        • LDC -gc
      • Windows x64
        • DMD
        • DMD -gc
        • LDC
        • LDC -gc
    • Associative Arrays
    • Arrays
    • Strings (bug: doesn't respect length, stops at null characters)
    • phobos types (tbd)
  • LLDB
    • Test & make work on all OS
      • Linux x64
        • DMD
        • DMD -gc
        • LDC
        • LDC -gc
      • OSX x64
        • DMD
        • DMD -gc
        • LDC
        • LDC -gc
      • Windows x64 broken (LLDB not working with D Windows binaries)
        • DMD -> LLDB broken
        • DMD -gc -> LLDB broken
        • LDC -> LLDB broken
        • LDC -gc -> LLDB broken
    • Associative Arrays
    • Arrays
    • Strings
    • phobos types (tbd)
  • VSDBG (NatVis)
    • Windows Support only
    • Make work with all Compilers
      • Windows x64
        • LDC -> broken, not implementable
        • LDC -gc
        • DMD -> broken, not implementable
        • DMD -gc -> broken, does not seem to work
    • Associative Arrays
    • Arrays
    • Strings
    • phobos types (tbd)

Due to the pretty printing API, LLDB offers better type displays.

Boilerplate code for LLDB taken from vscode-lldb.

Usage

Automatic with any installed debugger

VSCode with webfreak.code-d

(recommends extensions C/C++ on Windows or CodeLLDB on other platforms installed)

{
	"name": "Debug Program",
	"request": "launch",
	"type": "code-d",
	"program": "${command:dubTarget}",
	"cwd": "${workspaceFolder}",
	"dubBuild": true // optional, automatic builds
}

code-d has these debug configurations bundled since version 0.23.0 and automatically detects the recommended settings for the current platform with the installed debug extensions.

GDB

Enable pretty printers and source the gdb_dlang.py script.

MI Commands (for use with extensions):

-enable-pretty-printing
-interpreter-exec console "source /path/to/gdb_dlang.py"

VSCode Debug Extension Configurations:

C/C++ (ms-vscode.cpptools)

{
	"name": "Debug Program",
	"request": "launch",
	"type": "cppdbg",
	"program": "${workspaceFolder}/programname",
	"cwd": "${workspaceFolder}",
	"setupCommands": [
		{
			"description": "Enable python pretty printing",
			"ignoreFailures": false,
			"text": "-enable-pretty-printing"
		},
		{
			"description": "Load D GDB type extensions",
			"ignoreFailures": false,
			"text": "-interpreter-exec console \"source /path/to/gdb_dlang.py\""
		}
	]
}

NativeDebug (webfreak.code-debug)

{
	"name": "Debug Program",
	"request": "launch",
	"type": "gdb",
	"target": "./programname",
	"cwd": "${workspaceFolder}",
	"autorun": [
		"source /path/to/gdb_dlang.py"
	],
	"valuesFormatting": "prettyPrinters"
}

LLDB

Import the lldb script:

command script import "/path/to/lldb_dlang.py"

VSCode Debug Extension Configurations:

CodeLLDB (vadimcn.vscode-lldb)

{
	"name": "Debug Program",
	"request": "launch",
	"type": "lldb",
	"program": "${workspaceFolder}/programname",
	"cwd": "${workspaceFolder}",
	"initCommands": ["command script import \"/path/to/lldb_dlang.py\""]
}

NatVis with VSDBG

Visual Studio:

Put the natvis file in your workspace, it will be loaded automatically and just work.

VSCode Debug Extension Configurations:

C/C++ (ms-vscode.cpptools)

{
	"name": "Debug Program",
	"request": "launch",
	"type": "cppvsdbg",
	"program": "${workspaceFolder}/programname.exe",
	"cwd": "${workspaceFolder}",
	"visualizerFile": "C:\\Path\\To\\dlang.natvis"
}