Skip to content

Commit faafd0f

Browse files
authored
Add adapter for CodeLLDB (#436)
* Add CodeLLDB adapter * Update makefile Co-authored-by: puh <->
1 parent 81643ba commit faafd0f

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ DAP-GENERAL := dap-launch.el dap-overlays.el dap-variables.el \
1111
DAP-CLIENTS := dap-chrome.el dap-cpptools.el dap-edge.el \
1212
dap-elixir.el dap-firefox.el dap-gdb-lldb.el \
1313
dap-go.el dap-lldb.el dap-netcore.el dap-node.el \
14-
dap-php.el dap-pwsh.el dap-python.el dap-ruby.el
14+
dap-php.el dap-pwsh.el dap-python.el dap-ruby.el \
15+
dap-codelldb.el
1516

1617
TEST-FILES := test/windows-bootstrap.el $(shell ls test/dap-*.el)
1718
LOAD-FILE = -l $(test-file)

dap-codelldb.el

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
;;; dap-codelldb.el --- Debug Adapter Protocol mode for CodeLLDB -*- lexical-binding: t; -*-
2+
3+
;; This program is free software; you can redistribute it and/or modify
4+
;; it under the terms of the GNU General Public License as published by
5+
;; the Free Software Foundation, either version 3 of the License, or
6+
;; (at your option) any later version.
7+
8+
;; This program is distributed in the hope that it will be useful,
9+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
;; GNU General Public License for more details.
12+
13+
;; You should have received a copy of the GNU General Public License
14+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
16+
;;; Commentary:
17+
;; Adapter for https://github.com/vadimcn/vscode-lldb
18+
19+
;;; Code:
20+
21+
(require 'dap-mode)
22+
23+
(defcustom dap-codelldb-download-url
24+
(format "https://github.com/vadimcn/vscode-lldb/releases/download/v1.6.1/codelldb-x86_64-%s.vsix"
25+
(alist-get system-type
26+
'((windows-nt . "windows")
27+
(darwin . "darwin")
28+
(gnu/linux . "linux"))))
29+
"The download url."
30+
:group 'dap-codelldb
31+
:type 'string)
32+
33+
(defcustom dap-codelldb-debug-path (expand-file-name "vscode/codelldb" dap-utils-extension-path)
34+
"The path to go vscode extension."
35+
:group 'dap-codelldb
36+
:type 'string)
37+
38+
(defcustom dap-codelldb-debug-program
39+
(concat dap-codelldb-debug-path
40+
(if (eq system-type 'windows-nt)
41+
"/extension/adapter/codelldb.exe"
42+
"/extension/adapter/codelldb"))
43+
"The path to the codelldb debugger."
44+
:group 'dap-codelldb
45+
:type 'string)
46+
47+
48+
49+
(defun dap-codelldb-setup (&optional forced)
50+
"Download and install codelldb adapter.
51+
With prefix, FORCED to redownload the extension."
52+
(interactive "P")
53+
(unless (and (not forced) (file-exists-p dap-codelldb-debug-path))
54+
(dap-utils--get-extension dap-codelldb-download-url dap-codelldb-debug-path)
55+
(message "%s: Downloading done!" "dap-codelldb")))
56+
57+
(dap-register-debug-provider
58+
"codelldb"
59+
(lambda (conf)
60+
(let ((debug-port (dap--find-available-port)))
61+
(plist-put conf :program-to-start (format "%s --port %s" dap-codelldb-debug-program debug-port))
62+
(plist-put conf :debugServer debug-port)
63+
)
64+
(plist-put conf :host "localhost")
65+
(plist-put conf :type "lldb")
66+
(plist-put conf :cargo "")
67+
conf)
68+
)
69+
70+
(provide 'dap-codelldb)
71+
;;; dap-codelldb.el ends here

0 commit comments

Comments
 (0)