Skip to content

Commit

Permalink
create debug layer
Browse files Browse the repository at this point in the history
  • Loading branch information
CeleritasCelery authored and tjhinckl committed Aug 21, 2017
1 parent 32e75c5 commit 7875f0c
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 56 deletions.
18 changes: 0 additions & 18 deletions layers/+lang/c-c++/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
- [[#clang-format][clang-format]]
- [[#company-clang-and-flycheck][Company-clang and flycheck]]
- [[#key-bindings][Key Bindings]]
- [[#debugger-realgud][Debugger (realgud)]]

* Description
This layer adds configuration for C/C++ language as well support for [[https://cmake.org/][CMake]]
Expand Down Expand Up @@ -114,20 +113,3 @@ doesn't complain about missing header files.
| ~SPC m r~ | srefactor: refactor thing at point. |

*Note:* [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] is only available for Emacs 24.4+

** Debugger (realgud)

| Key Binding | Description |
|-------------+-----------------|
| ~SPC m d d~ | open cmd buffer |
| ~SPC m d e~ | eval variable |
| ~s~ | step over |
| ~i~ | step into |
| ~b~ | set break |
| ~B~ | unset break |
| ~o~ | step out |
| ~c~ | continue |
| ~e~ | eval variable |
| ~r~ | restart |
| ~q~ | quit debug |
| ~S~ | goto cmd buffer |
9 changes: 0 additions & 9 deletions layers/+lang/c-c++/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,3 @@ and the arguments for flyckeck-clang based on a project-specific text file."
(append '("/usr/include" "/usr/local/include")
dirs))
(setq-local flycheck-clang-args flags))))


;; realgud

(defun spacemacs//short-key-state (modeon)
"Set evil-evilified-state explicitly."
(if modeon
(evil-evilified-state)
(evil-normal-state)))
29 changes: 3 additions & 26 deletions layers/+lang/c-c++/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,9 @@
(dolist (mode c-c++-modes)
(spacemacs/helm-gtags-define-keys-for-mode mode)))

(defun c-c++/init-realgud()
(use-package realgud
:defer t
:commands (realgud:gdb)
:init
(progn
(dolist (mode c-c++-modes)
(spacemacs/set-leader-keys-for-major-mode mode
"dd" 'realgud:gdb
"de" 'realgud:cmd-eval-dwim))
(advice-add 'realgud-short-key-mode-setup
:before #'spacemacs//short-key-state)
(evilified-state-evilify-map realgud:shortkey-mode-map
:eval-after-load realgud
:mode realgud-short-key-mode
:bindings
"s" 'realgud:cmd-next
"i" 'realgud:cmd-step
"b" 'realgud:cmd-break
"B" 'realgud:cmd-clear
"o" 'realgud:cmd-finish
"c" 'realgud:cmd-continue
"e" 'realgud:cmd-eval
"r" 'realgud:cmd-restart
"q" 'realgud:cmd-quit
"S" 'realgud-window-cmd-undisturb-src))))
(defun c-c++/pre-init-realgud()
(dolist (mode c-c++-modes)
(spacemacs|add-realgud-debugger mode "gdb")))

(defun c-c++/post-init-semantic ()
(spacemacs/add-to-hooks 'semantic-mode c-c++-mode-hooks))
Expand Down
8 changes: 5 additions & 3 deletions layers/+lang/perl5/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#key-bindings][Key Bindings]]
Expand All @@ -15,8 +15,10 @@
* Description
This layer adds support for the Perl5 language.

** Features
- syntactic and semantic checking using [[https://github.com/flycheck/flycheck][flycheck]]
** Features:
- syntactic and semantic checking via flycheck with =perl -c= and =perlcritic=
- jump to symbol via dump jump
- interactive debug via [[https://github.com/realgud/realgud][realgud]] with [[http://search.cpan.org/~rocky/Devel-Trepan-0.73/lib/Devel/Trepan.pm][trepan.pl]]

* Install
** Layer
Expand Down
4 changes: 4 additions & 0 deletions layers/+lang/perl5/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(cperl-mode :location built-in)
smartparens
flycheck
realgud
))

(defun perl5/init-cperl-mode ()
Expand Down Expand Up @@ -114,3 +115,6 @@

(defun perl5/post-init-flycheck ()
(spacemacs/enable-flycheck 'cperl-mode))

(defun perl5/pre-init-realgud()
(spacemacs|add-realgud-debugger 'cperl-mode "trepan.pl"))
63 changes: 63 additions & 0 deletions layers/+tools/debug/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#+TITLE: debug layer

[[file:img/debug.png]]

* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#enable-additional-debuggers][enable additional debuggers]]
- [[#key-bindings][Key bindings]]
- [[#leader][Leader]]
- [[#shortkey-mode][shortkey-mode]]

* Description
This layer adds interactive debuggers for mulitple languages using [[https://github.com/realgud/realgud][realgud]].

** Features:
- modern rewrite of the Emacs GUD debugger family
- visual interface including breakpoint and line indicators
- advanced features like stack frame navigation and mouse support
- extensible framework for [[https://github.com/realgud/realgud/wiki/How-to-add-a-new-debugger][adding]] your own external debuggers

* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =debug= to the existing =dotspacemacs-configuration-layers= list in this
file.

** enable additional debuggers
Language specific debuggers are added by the respective layers. If you want to
add additional debuggers, add them to the =debug-use-debuggers= variable.
Make sure that your debugger is compatible by checking [[https://github.com/realgud/realgud/wiki/Debuggers-Supported][here]].

#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((debug :variables debug-use-debuggers '("remake"))))
#+END_SRC

* Key bindings

** Leader

| Key Binding | Description |
|-------------+-----------------|
| ~SPC m d d~ | open cmd buffer |

** shortkey-mode

| Key Binding | Description |
|-------------+----------------------|
| ~s~ | step over |
| ~i~ | step into |
| ~o~ | step out |
| ~c~ | continue |
| ~J~ | jump to current line |
| ~e~ | eval variable |
| ~r~ | restart |
| ~q~ | quit debug |
| ~S~ | goto cmd buffer |
| ~bb~ | set break |
| ~bc~ | clear break |
| ~bd~ | delete break |
| ~bs~ | disable break |
| ~be~ | enable break |
14 changes: 14 additions & 0 deletions layers/+tools/debug/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
;;; config.el --- Debug Layer Configuration File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: troy.j.hinckley <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defvar debug-use-debuggers '()
"realgud debuggers to be autoloaded.
This variable must be populated before debug layers is loaded.")
28 changes: 28 additions & 0 deletions layers/+tools/debug/funcs.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;;; funcs.el --- Debug layer function file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: troy.j.hinckley <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defun debug-short-key-state (modeon)
"Set evil-evilified-state explicitly."
(if modeon
(evil-evilified-state)
(evil-normal-state)))

(defun debug-generate-symbol (debugger)
"create realgud interactive function name from debugger"
(intern (concat "realgud:" debugger)))

(defun spacemacs|add-realgud-debugger (mode debugger)
"add a deubbger to major mode.
Note that this function MUST be called BEFORE init-realgud.
Therefore you should add it to a pre-init-realgud definition"
(add-to-list 'debug-use-debuggers debugger)
(spacemacs/set-leader-keys-for-major-mode mode
"dd" (debug-generate-symbol debugger)))
Binary file added layers/+tools/debug/img/debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions layers/+tools/debug/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
;;; packages.el --- Debug Layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: troy.j.hinckley <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defconst debug-packages
'(realgud))

(defun debug/init-realgud()
(eval
`(use-package realgud

:commands
,(mapcar 'debug-generate-symbol
debug-use-debuggers)

:init
(advice-add 'realgud-short-key-mode-setup
:before #'debug-short-key-state)
(evilified-state-evilify-map realgud:shortkey-mode-map
:eval-after-load realgud
:mode realgud-short-key-mode
:bindings
"s" 'realgud:cmd-next
"i" 'realgud:cmd-step
"o" 'realgud:cmd-finish
"c" 'realgud:cmd-continue
"J" 'realgud:cmd-jump

"bb" 'realgud:cmd-break
"bc" 'realgud:cmd-clear
"bd" 'realgud:cmd-delete
"bs" 'realgud:cmd-disable
"be" 'realgud:cmd-enable

"e" 'realgud:cmd-eval-dwim
"r" 'realgud:cmd-restart
"q" 'realgud:cmd-quit
"S" 'realgud-window-cmd-undisturb-src))))
1 change: 1 addition & 0 deletions layers/LAYERS.org
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
- [[file:+tools/chrome/README.org][chrome]]
- [[file:+tools/command-log/README.org][command-log]]
- [[file:+tools/dash/README.org][dash]]
- [[file:+tools/debug/README.org][debug]]
- [[file:+tools/deft/README.org][deft]]
- [[file:+tools/docker/README.org][docker]]
- [[file:+tools/fasd/README.org][fasd]]
Expand Down

0 comments on commit 7875f0c

Please sign in to comment.