Debugging with dape and netcoredbg, and the compiler's new options
emacs/bjolang-dape.el adds a dape configuration that builds the current file with -d and runs it under netcoredbg, launching dotnet with the program, which is a managed assembly rather than a native host. The README says what a debugger shows today. The check builds its options from Build.dependencyOptions, now that the compiler's options have grown the dump flags. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
c6f357c6f8
commit
77b8a92e03
3 changed files with 77 additions and 6 deletions
7
Check.fs
7
Check.fs
|
|
@ -98,12 +98,7 @@ let private found (file: string) (d: Diagnostics.Diagnostic) : Found =
|
|||
IsError = isError
|
||||
Message = d.Message + where }
|
||||
|
||||
let private options: Build.Options =
|
||||
{ IsLibrary = false
|
||||
Debug = false
|
||||
Runtime = []
|
||||
EmitCs = None
|
||||
Check = true }
|
||||
let private options: Build.Options = { Build.dependencyOptions with IsLibrary = false; Check = true }
|
||||
|
||||
/// Checks `file` as `bjolang --check` does, reading every file in `buffers`,
|
||||
/// by full path, from there rather than from disk: the editor's unsaved text,
|
||||
|
|
|
|||
13
README.md
13
README.md
|
|
@ -94,6 +94,19 @@ stdout, and logs to stderr.
|
|||
(add-hook 'bjo-mode-hook #'lsp)
|
||||
```
|
||||
|
||||
`emacs/bjolang-dape.el` debugs a program with `dape` and
|
||||
[netcoredbg](https://github.com/Samsung/netcoredbg/releases):
|
||||
|
||||
```elisp
|
||||
(load "/home/linis/Programmering/BjolangLsp/emacs/bjolang-dape.el")
|
||||
```
|
||||
|
||||
`M-x dape RET bjolang RET` in a file with a `main` builds it with `-d` and
|
||||
runs it under the debugger. Breakpoints in the `.bjo` file bind, stepping
|
||||
goes by its lines, and the call stack names them. The locals are the
|
||||
generated C#'s, compiler temporaries included, and values show as their C#
|
||||
types, which expand into their fields.
|
||||
|
||||
With eglot instead:
|
||||
|
||||
```elisp
|
||||
|
|
|
|||
63
emacs/bjolang-dape.el
Normal file
63
emacs/bjolang-dape.el
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
;;; bjolang-dape.el --- Debugging Bjolang programs with dape and netcoredbg -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; `M-x dape RET bjolang RET' in a Bjolang buffer builds the file with `-d'
|
||||
;; and runs it under netcoredbg. A breakpoint set in the `.bjo' file binds,
|
||||
;; stepping goes by its lines, and the call stack names them: the compiler
|
||||
;; maps the generated C# back to the source with `#line', and a debug build
|
||||
;; writes that mapping into the program's PDB.
|
||||
;;
|
||||
;; The file has to be a program, one with a `main'. The program is a
|
||||
;; managed assembly that `dotnet' runs, so that is what netcoredbg is told
|
||||
;; to start, with the program as its argument.
|
||||
;;
|
||||
;; netcoredbg: https://github.com/Samsung/netcoredbg/releases, unpacked so
|
||||
;; that `bjo-netcoredbg' names the executable.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defgroup bjolang-dape nil
|
||||
"Debugging Bjolang programs."
|
||||
:group 'tools)
|
||||
|
||||
(defcustom bjo-compiler "~/Programmering/Bjolang/bin/compiler/Bjolang.dll"
|
||||
"The Bjolang compiler, as `build_compiler.sh --path' prints it."
|
||||
:type 'file)
|
||||
|
||||
(defcustom bjo-netcoredbg "~/.local/share/netcoredbg/netcoredbg"
|
||||
"The netcoredbg executable."
|
||||
:type 'file)
|
||||
|
||||
(defun bjo--dape-source ()
|
||||
"The Bjolang file a debug session is started from."
|
||||
(or (buffer-file-name) (user-error "Not visiting a Bjolang file")))
|
||||
|
||||
(defun bjo--dape-program ()
|
||||
"The program a debug build of the current file produces."
|
||||
(concat (file-name-sans-extension (bjo--dape-source)) ".exe"))
|
||||
|
||||
(defun bjo--dape-compile-command ()
|
||||
"The debug build of the current file."
|
||||
(format "dotnet %s -d %s"
|
||||
(shell-quote-argument (expand-file-name bjo-compiler))
|
||||
(shell-quote-argument (bjo--dape-source))))
|
||||
|
||||
(with-eval-after-load 'dape
|
||||
(add-to-list 'dape-configs
|
||||
`(bjolang
|
||||
modes (bjo-mode)
|
||||
command ,(expand-file-name bjo-netcoredbg)
|
||||
command-args ["--interpreter=vscode"]
|
||||
compile bjo--dape-compile-command
|
||||
:request "launch"
|
||||
:type "coreclr"
|
||||
:cwd (lambda () (file-name-directory (bjo--dape-source)))
|
||||
:program "dotnet"
|
||||
:args [bjo--dape-program]
|
||||
:justMyCode t
|
||||
:stopAtEntry nil)))
|
||||
|
||||
(provide 'bjolang-dape)
|
||||
|
||||
;;; bjolang-dape.el ends here
|
||||
Loading…
Add table
Add a link
Reference in a new issue