diff --git a/README.org b/README.org index 041a82e7..c7195d89 100644 --- a/README.org +++ b/README.org @@ -152,9 +152,36 @@ Configure debug adapter port under "Editor" > "Editor Settings" > "Debug Adapter ** Dart - flutter See for installation https://docs.flutter.dev/get-started/install -** C# - netcoredbg +** C# - netcoredb + +netcoredbg is an open-source debugger for .NET that implements the Debug +Adapter Protocol. + See https://github.com/Samsung/netcoredbg for installation +Example configuration: + +#+begin_src emacs-lisp +(add-to-list 'dape-configs + `(netcoredbg + modes (csharp-mode csharp-ts-mode) + ensure dape-ensure-command + command "netcoredbg" + command-args ("--interpreter=vscode") + normalize-path-separator 'windows ;; Required for proper breakpoint binding + :type "coreclr" + :request "launch" + :cwd dape-cwd + :program dape-cwd + :stopAtEntry nil)) +#+end_src + +*Note:* The =normalize-path-separator= option is important for netcoredbg on +Windows. netcoredbg requires exact path matching between source files and PDB +symbol files. Since PDB files store paths with backslashes (=\=), but Emacs +uses forward slashes (=/=), this option ensures paths are converted to the +format expected by the debugger. + ** Ruby - rdbg Install with ~gem install debug~. diff --git a/dape.el b/dape.el index 0549750a..71948108 100644 --- a/dape.el +++ b/dape.el @@ -312,6 +312,7 @@ ensure dape-ensure-command command "netcoredbg" command-args ["--interpreter=vscode"] + normalize-path-separator 'windows :request "launch" :cwd dape-cwd :program (if-let* ((dlls @@ -446,6 +447,11 @@ Symbol keys (Used by dape): stderr output from debugged program. - prefix-local: Path prefix for Emacs file access. - prefix-remote: Path prefix for debugger file access. +- normalize-path-separator: Normalize path separators when sending to adapter. + When set to `'windows', converts forward slashes to backslashes. + When set to `'unix', converts backslashes to forward slashes. + nil (default) means no normalization. Useful for adapters like + netcoredbg that require exact path matching with symbol files. - host: Host of the debug adapter. - port: Port of the debug adapter. - modes: List of modes where the configuration is active in `dape' @@ -494,6 +500,10 @@ Functions and symbols: ((const :tag "Working directory for command" command-cwd) (choice string symbol)) ((const :tag "Path prefix for Emacs file access" prefix-local) string) ((const :tag "Path prefix for debugger file access" prefix-remote) string) + ((const :tag "Normalize path separators" normalize-path-separator) + (choice (const :tag "No normalization" nil) + (const :tag "Convert to backslashes (Windows)" 'windows) + (const :tag "Convert to forward slashes (Unix)" 'unix))) ((const :tag "Host of debug adapter" host) string) ((const :tag "Port of debug adapter" port) natnum) ((const :tag "Compile cmd" compile) string) @@ -1043,9 +1053,18 @@ See `dape--file-name-1'." (dape--file-name-1 conn filename nil)) (defun dape--file-name-remote (conn filename) - "Return FILENAME string for adapter configured by CONN. + "Return translate FILENAME to remote format by CONN. +Normalizes path separators according to `normalize-path-separator' config option. See `dape--file-name-1'." - (dape--file-name-1 conn filename 'remote)) + (let* ((result (dape--file-name-1 conn filename 'remote)) + (config (dape--config conn)) + (normalize (plist-get config 'normalize-path-separator))) + (if (and result normalize) + (pcase normalize + ('windows (replace-regexp-in-string "/" "\\\\" result)) + ('unix (replace-regexp-in-string "\\\\" "/" result)) + (_ result)) + result))) (defun dape--capable-p (conn thing) "Return non-nil if CONN capable of THING."