-
Notifications
You must be signed in to change notification settings - Fork 0
/
gdb-settings.el
90 lines (72 loc) · 3.21 KB
/
gdb-settings.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;; ===================================================================
;; Add color to the current GUD line (obrigado google)
;; ===================================================================
;; (defvar gud-overlay
;; (let* ((ov (make-overlay (point-min) (point-min))))
;; (overlay-put ov 'face 'secondary-selection)
;; ov)
;; "Overlay variable for GUD highlighting.")
;; (defadvice gud-display-line (after my-gud-highlight act)
;; "Highlight current line."
;; (let* ((ov gud-overlay)
;; (bf (gud-find-file true-file)))
;; (with-current-buffer (move-overlay ov (line-beginning-position) (line-end-position)))))
;; (defun gud-kill-buffer ()
;; (if (eq major-mode 'gud-mode)
;; (delete-overlay gud-overlay)))
;; (add-hook 'kill-buffer-hook 'gud-kill-buffer)
;; =================================
;; GDB configuration
;; =================================
(use-package gud)
(use-package gdb-mi
:config
(setq gdb-many-windows t)
(setq gdb-use-separate-io-buffer t)
;; ====================================
;; GUI layout
;; ====================================
(defun gdb-setup-windows ()
"Define layout for gdb-many-windows"
;; (gdb-get-buffer-create 'gdb-locals-buffer)
(gdb-get-buffer-create 'gdb-stack-buffer)
;; (gdb-get-buffer-create 'gdb-breakpoints-buffer)
(set-window-dedicated-p (selected-window) nil)
(switch-to-buffer gud-comint-buffer)
(delete-other-windows)
(let ((win0 (selected-window))
;; (win1 (split-window nil ( / ( * (window-height) 3) 4)))
;; (win2 (split-window nil ( / (window-height) 3)))
(win1 (split-window nil ( / (window-height) 2)))
(win2 (split-window-right)))
;; (gdb-set-window-buffer (gdb-locals-buffer-name) nil win3)
(gdb-set-window-buffer (gdb-stack-buffer-name) nil win2)
(select-window win1)
(if gud-last-last-frame
(set-window-buffer
win1
(gud-find-file (car gud-last-last-frame))))
(setq gdb-source-window (selected-window))
(let ((win3 (split-window-right)))
(gdb-set-window-buffer
(gdb-get-buffer-create 'gdb-inferior-io) nil win3))
;; (let ((win5 (split-window-right)))
;; (gdb-set-window-buffer (if gdb-show-threads-by-default
;; (gdb-threads-buffer-name)
;; (gdb-breakpoints-buffer-name))
;; nil win5))
(select-window win0)))
;; =======================================
;; Restore window layout after closing gdb
;; =======================================
;; Select a register number which is unlikely to get used elsewere
(defconst before-gdb-windows-config-register 313465989
"Internal used")
(defvar before-gdb-windows-config nil)
(defun set-before-gdb-windows-config (gdb)
(setq before-gdb-windows-config (window-configuration-to-register before-gdb-windows-config-register)))
(defun restore-before-gdb-windows-config ()
(jump-to-register before-gdb-windows-config-register))
(advice-add 'gdb :before #'set-before-gdb-windows-config)
(advice-add 'gdb-reset :after #'restore-before-gdb-windows-config))
(provide 'gdb-settings)