]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/gdb/init.el
fb45afc8c9f96642e2675df8c95bbf073c22cb66
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / gdb / init.el
1 ;;; Copyright (C) 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
2 ;;; gdb debugger
3
4 (eval-when-compile (require 'cl))
5
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
8
9 (defvar realgud-pat-hash)
10 (declare-function make-realgud-loc-pat (realgud-loc))
11
12 (defvar realgud:gdb-pat-hash (make-hash-table :test 'equal)
13 "hash key is the what kind of pattern we want to match:
14 backtrace, prompt, etc. the values of a hash entry is a
15 realgud-loc-pat struct")
16
17 (declare-function make-realgud-loc "realgud-loc" (a b c d e f))
18
19 (defconst realgud:gdb-frame-file-regexp
20 "\\(.+\\):\\([0-9]+\\)")
21
22 ;; regular expression that describes a gdb location generally shown
23 ;; before a command prompt. NOTE: we assume annotate 1!
24 (setf (gethash "loc" realgud:gdb-pat-hash)
25 (make-realgud-loc-pat
26 :regexp (format "^\1a\1a%s:\\([0-9]+\\):beg:0x\\([0-9a-f]+\\)"
27 realgud:gdb-frame-file-regexp)
28 :file-group 1
29 :line-group 2
30 :char-offset-group 3))
31
32 (setf (gethash "prompt" realgud:gdb-pat-hash)
33 (make-realgud-loc-pat
34 :regexp "^(gdb) "
35 ))
36
37 ;; regular expression that describes a "breakpoint set" line
38 (setf (gethash "brkpt-set" realgud:gdb-pat-hash)
39 (make-realgud-loc-pat
40 :regexp "^Breakpoint \\([0-9]+\\) at 0x\\([0-9a-f]*\\): file \\(.+\\), line \\([0-9]+\\).\n"
41 :num 1
42 :file-group 3
43 :line-group 4))
44
45 (defconst realgud:gdb-frame-start-regexp
46 "\\(?:^\\|\n\\)")
47
48 (defconst realgud:gdb-frame-num-regexp
49 "#\\([0-9]+\\) ")
50
51 ;; Regular expression that describes a gdb "backtrace" command line.
52 ;; For example:
53 ;; #0 main (argc=2, argv=0xbffff564, envp=0xbffff570) at main.c:935
54 ;; #1 0xb7e9f4a5 in *__GI___strdup (s=0xbffff760 "/tmp/remake/remake") at strdup.c:42
55 ;; #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
56 ;; at main.c:952
57 ;; #46 0xb7f51b87 in vm_call_cfunc (th=0x804d188, reg_cfp=0xb7ba9e88, num=0,
58 ;; recv=157798080, blockptr=0x0, me=0x80d12a0) at vm_insnhelper.c:410
59
60 (setf (gethash "debugger-backtrace" realgud:gdb-pat-hash)
61 (make-realgud-loc-pat
62 :regexp (concat realgud:gdb-frame-start-regexp
63 realgud:gdb-frame-num-regexp
64 "\\(?:.\\|\\(?:[\n] \\)\\)+[ ]+at "
65 realgud:gdb-frame-file-regexp
66 )
67 :num 1
68 :file-group 2
69 :line-group 3)
70 )
71
72 (setf (gethash "font-lock-keywords" realgud:gdb-pat-hash)
73 '(
74 ;; #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
75 ;; at main.c:952
76 ("[ \n]+at \\(.*\\):\\([0-9]+\\)"
77 (1 realgud-file-name-face)
78 (2 realgud-line-number-face))
79
80 ;; The frame number and first type name, if present.
81 ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
82 ;; ---^
83 ( "#\\(?:^\\|\n\\)\\([0-9]+\\) "
84 (1 realgud-backtrace-number-face))
85 ))
86
87 (setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
88
89 (defvar realgud:gdb-command-hash (make-hash-table :test 'equal)
90 "Hash key is command name like 'continue' and the value is
91 the gdb command to use, like 'continue'")
92
93 (setf (gethash "break" realgud:gdb-command-hash) "break %l")
94 (setf (gethash "clear" realgud:gdb-command-hash) "clear %l")
95 (setf (gethash "continue" realgud:gdb-command-hash) "continue")
96 (setf (gethash "quit" realgud:gdb-command-hash) "quit")
97 (setf (gethash "run" realgud:gdb-command-hash) "run")
98 (setf (gethash "step" realgud:gdb-command-hash) "step %p")
99 (setf (gethash "gdb" realgud-command-hash) realgud:gdb-command-hash)
100
101 (setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
102
103 (provide-me "realgud:gdb-")