1 ;;; Copyright (C) 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
4 (eval-when-compile (require 'cl))
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
9 (defvar realgud-pat-hash)
10 (declare-function make-realgud-loc-pat (realgud-loc))
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")
17 (declare-function make-realgud-loc "realgud-loc" (a b c d e f))
19 (defconst realgud:gdb-frame-file-regexp
20 "\\(.+\\):\\([0-9]+\\)")
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)
26 :regexp (format "^
\1a\1a%s:\\([0-9]+\\):beg:0x\\([0-9a-f]+\\)"
27 realgud:gdb-frame-file-regexp)
30 :char-offset-group 3))
32 (setf (gethash "prompt" realgud:gdb-pat-hash)
37 ;; regular expression that describes a "breakpoint set" line
38 (setf (gethash "brkpt-set" realgud:gdb-pat-hash)
40 :regexp "^Breakpoint \\([0-9]+\\) at 0x\\([0-9a-f]*\\): file \\(.+\\), line \\([0-9]+\\).\n"
45 (defconst realgud:gdb-frame-start-regexp
48 (defconst realgud:gdb-frame-num-regexp
51 ;; Regular expression that describes a gdb "backtrace" command line.
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)
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
60 (setf (gethash "debugger-backtrace" realgud:gdb-pat-hash)
62 :regexp (concat realgud:gdb-frame-start-regexp
63 realgud:gdb-frame-num-regexp
64 "\\(?:.\\|\\(?:[\n] \\)\\)+[ ]+at "
65 realgud:gdb-frame-file-regexp
72 (setf (gethash "font-lock-keywords" realgud:gdb-pat-hash)
74 ;; #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
76 ("[ \n]+at \\(.*\\):\\([0-9]+\\)"
77 (1 realgud-file-name-face)
78 (2 realgud-line-number-face))
80 ;; The frame number and first type name, if present.
81 ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
83 ( "#\\(?:^\\|\n\\)\\([0-9]+\\) "
84 (1 realgud-backtrace-number-face))
87 (setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
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'")
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)
101 (setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
103 (provide-me "realgud:gdb-")