From 2a203bb072a0ff34ec5b3010db4e13e72b174337 Mon Sep 17 00:00:00 2001 From: CatchMeFastFat Date: Sun, 11 Aug 2019 22:04:41 +0200 Subject: [PATCH 1/4] Add function to excute in eshell and return pid --- dap-utils.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dap-utils.el b/dap-utils.el index 8b847fdd..53a96a0e 100644 --- a/dap-utils.el +++ b/dap-utils.el @@ -87,5 +87,18 @@ With prefix, FORCED to redownload the extension." extension-name))) (message "%s: %s debug extension are not set. You can download it with M-x %s-setup" ,dapfile ,extension-name ,dapfile))))) +(defun dap-get-process-id-executed-in-eshell (process-name) + "return pocess id that is run in eshell" + (interactive) + (if (not (get-buffer "*eshell*")) + (eshell)) + (while (ignore-errors (kill-process (file-name-nondirectory process-name))) + (sleep-for 0 1)) + (with-current-buffer "*eshell*" + (goto-char (point-max)) + (insert process-name) + (eshell-send-input)) + (number-to-string (process-id (get-buffer-process "*eshell*")))) + (provide 'dap-utils) ;;; dap-utils.el ends here From a7340a0b45e679b21c056446596ba589bce9bcd7 Mon Sep 17 00:00:00 2001 From: CatchMeFastFat Date: Sun, 11 Aug 2019 22:09:23 +0200 Subject: [PATCH 2/4] Add 'LLDB Run In Eshell' --- dap-lldb.el | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/dap-lldb.el b/dap-lldb.el index 5415f1f8..af5681f2 100644 --- a/dap-lldb.el +++ b/dap-lldb.el @@ -34,30 +34,38 @@ :group 'dap-lldb :type '(repeat string)) -(defcustom dap-lldb-debugged-program-function 'buffer-file-name - "The function to get the path of the file to be debugged." - :group 'dap-lldb - :type 'symbol) - (defun dap-lldb--populate-start-file-args (conf) "Populate CONF with the required arguments." + (if (equal (plist-get conf :request) "launch") + (dap--put-if-absent conf :program + (read-file-name + "Select file to debug.")) + (dap--put-if-absent conf :initCommands + (list (concat "process attach --pid " + (dap-get-process-id-executed-in-eshell + (read-file-name + "Select file to debug.")))))) + (-> conf (dap--put-if-absent :dap-server-path dap-lldb-debug-program) (dap--put-if-absent :type "lldb") (dap--put-if-absent :cwd default-directory) - (dap--put-if-absent :program (if (commandp dap-lldb-debugged-program-function) - (call-interactively dap-lldb-debugged-program-function) - (funcall dap-lldb-debugged-program-function))) (dap--put-if-absent :name "LLDB Debug"))) (eval-after-load "dap-mode" '(progn (dap-register-debug-provider "lldb" 'dap-lldb--populate-start-file-args) - (dap-register-debug-template "LLDB Run Configuration" + (dap-register-debug-template "LLDB Run" (list :type "lldb" :cwd nil :request "launch" :program nil + :name "LLDB::Run")) + (dap-register-debug-template "LLDB Run In Eshell" + (list :type "lldb" + :cwd nil + :request "attach" + :program nil :name "LLDB::Run")))) (provide 'dap-lldb) From e77ac7947879f68a59a24392f2d211ac438c0262 Mon Sep 17 00:00:00 2001 From: Islam Omar Date: Sun, 11 Aug 2019 22:13:31 +0200 Subject: [PATCH 3/4] Add 'LLDB Run In Eshell' --- dap-lldb.el | 1 + 1 file changed, 1 insertion(+) diff --git a/dap-lldb.el b/dap-lldb.el index af5681f2..dde36893 100644 --- a/dap-lldb.el +++ b/dap-lldb.el @@ -28,6 +28,7 @@ ;;; Code: (require 'dap-mode) +(require 'dap-utils) (defcustom dap-lldb-debug-program `(,(expand-file-name "~/.vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin/lldb-vscode")) "The path to the LLDB debugger." From b3501798cf26b6a877bf37a8ad85b0325c3422de Mon Sep 17 00:00:00 2001 From: Islam Omar Date: Sun, 11 Aug 2019 22:56:18 +0200 Subject: [PATCH 4/4] close any process in eshell --- dap-utils.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dap-utils.el b/dap-utils.el index 53a96a0e..ea83d4e9 100644 --- a/dap-utils.el +++ b/dap-utils.el @@ -92,7 +92,7 @@ With prefix, FORCED to redownload the extension." extension-name))) (interactive) (if (not (get-buffer "*eshell*")) (eshell)) - (while (ignore-errors (kill-process (file-name-nondirectory process-name))) + (while (ignore-errors (kill-process (process-name (get-buffer-process "*eshell*")))) (sleep-for 0 1)) (with-current-buffer "*eshell*" (goto-char (point-max))