Add core-debug + realgud universal debugging platform

This commit is contained in:
Henrik Lissner 2016-03-31 03:17:15 -04:00
parent bbde8f2c70
commit 1cd492d301
7 changed files with 127 additions and 2 deletions

View file

@ -35,5 +35,40 @@
(let (message-log-max)
(message "%s%s" (if bang ">> " "") message)))
;;;###autoload (autoload 'narf:debug "defuns-debug" nil t)
(evil-define-command narf:debug (&optional path)
"Initiate debugger for current major mode"
(interactive "<f>")
(let ((default-directory (narf/project-root)))
(cond ((memq major-mode '(c-mode c++-mode))
(realgud:gdb (if path (concat "gdb " path))))
((memq major-mode '(ruby-mode enh-ruby-mode))
(narf:repl nil (format "run '%s'" (f-filename (or path buffer-file-name)))))
((eq major-mode 'sh-mode)
(let ((shell sh-shell))
(when (string= shell "sh")
(setq shell "bash"))
(cond ((string= shell "bash")
(realgud:bashdb (if path (concat "bashdb " path))))
((string= shell "zsh")
(realgud:zshdb (if path (concat "zshdb " path))))
(t (user-error "No shell debugger for %s" shell)))))
;; TODO Add python debugging
((memq major-mode '(js-mode js2-mode js3-mode))
(realgud:trepanjs))
(t (user-error "No debugger for %s" major-mode)))))
;;;###autoload (autoload 'narf:debug-toggle-breakpoint "defuns-debug" nil t)
(evil-define-command narf:debug-toggle-breakpoint (&optional bang)
(interactive "<!>")
(call-interactively (if bang 'realgud:cmd-clear 'realgud:cmd-break)))
;;;###autoload
(defun narf/debug-quit ()
(interactive)
(ignore-errors (call-interactively 'realgud:cmd-quit))
(narf/popup-close)
(evil-normal-state))
(provide 'defuns-debug)
;;; defuns-debug.el ends here