2 (require 'load-relative)
3 (load-file "../realgud/common/buffer/command.el")
4 (load-file "../realgud/debugger/gdb/init.el")
5 (load-file "./regexp-helper.el")
7 (declare-function __FILE__ 'load-relative)
12 (defvar dbg-name) (defvar realgud-pat-hash) (defvar realgud-bt-hash)
13 (defvar loc-pat) (defvar prompt-pat) (defvar s1)
14 (defvar file-group) (defvar line-group) (defvar pos)
15 (defvar test-dbgr) (defvar test-text)
18 ; Some setup usually done in setting up the buffer.
19 ; We customize this for this debugger.
20 ; FIXME: encapsulate this.
23 (setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
24 (setq test-dbgr (make-realgud-cmdbuf-info
25 :debugger-name dbg-name
26 :loc-regexp (realgud-loc-pat-regexp loc-pat)
27 :file-group (realgud-loc-pat-file-group loc-pat)
28 :line-group (realgud-loc-pat-line-group loc-pat)))
30 ;; FIXME: we get a void variable somewhere in here when running
31 ;; even though we define it in lexical-let. Dunno why.
32 ;; setq however will workaround this.
33 (setq test-text "
\1a\1a/home/rocky/c/ctest.c:80:2000:beg:0x8048748>")
34 (note "traceback location matching")
36 (assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
37 (assert-equal "/home/rocky/c/ctest.c"
38 (match-string (realgud-cmdbuf-info-file-group test-dbgr)
39 test-text) "extract file name")
41 (match-string (realgud-cmdbuf-info-line-group test-dbgr)
42 test-text) "extract line number")
43 (note "debugger-backtrace")
44 (setq realgud-bt-pat (gethash "debugger-backtrace"
45 realgud:gdb-pat-hash))
47 "#0 main (argc=2, argv=0xbffff564, envp=0xbffff570) at main.c:935
48 #1 0xb7e9f4a5 in *__GI___strdup (s=0xbffff760 \"/tmp/remake/remake\") at strdup.c:42
49 #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
51 #46 0xb7f51b87 in vm_call_cfunc (th=0x804d188, reg_cfp=0xb7ba9e88, num=0,
52 recv=157798080, blockptr=0x0, me=0x80d12a0) at vm_insnhelper.c:410
54 (setq realgud-bt-re (realgud-loc-pat-regexp realgud-bt-pat))
55 (setq file-group (realgud-loc-pat-file-group realgud-bt-pat))
56 (setq line-group (realgud-loc-pat-line-group realgud-bt-pat))
57 (assert-equal 0 (string-match realgud-bt-re s1))
58 (assert-equal "main.c"
60 (match-beginning file-group)
61 (match-end file-group)))
64 (match-beginning line-group)
65 (match-end line-group)))
67 (setq pos (match-end 0))
69 (assert-equal 65 (string-match realgud-bt-re s1 pos))
70 (assert-equal "strdup.c"
72 (match-beginning file-group)
73 (match-end file-group)))
76 (match-beginning line-group)
77 (match-end line-group)))
79 (setq pos (match-end 0))
80 (assert-equal 149 pos)
81 (assert-equal 149 (string-match realgud-bt-re s1 pos))
82 (assert-equal "main.c"
84 (match-beginning file-group)
85 (match-end file-group)))
88 (match-beginning line-group)
89 (match-end line-group)))
91 (setq pos (match-end 0))
92 (assert-equal 233 pos)
93 (assert-equal 233 (string-match realgud-bt-re s1 pos))
94 (assert-equal "vm_insnhelper.c"
96 (match-beginning file-group)
97 (match-end file-group)))
100 (match-beginning line-group)
101 (match-end line-group)))
104 (set (make-local-variable 'prompt-pat)
105 (gethash "prompt" realgud:gdb-pat-hash))
106 (prompt-match "(gdb) ")