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:
Linus Björnstam 2026-10-16 09:35:25 +02:00
parent c6f357c6f8
commit 77b8a92e03
3 changed files with 77 additions and 6 deletions

63
emacs/bjolang-dape.el Normal file
View 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