1 ;;; Copyright (C) 2010-2011, 2015 Rocky Bernstein <rocky@gnu.org>
3 ;;; Common POSIX-Shell like constants and regular expressions.
4 ;;; Actually a lot of this is not about POSIX shell as it is about the
5 ;;; common-ness of bashdb, zshdb, and kshdb. But since those are the
6 ;;; *only* debuggers I know of for POSIX shells, it's not too much of
7 ;;; a stretch to think of this as for all "shell".
8 (eval-when-compile (require 'cl))
10 (require 'load-relative)
11 (require-relative-list '("../common/regexp" "../common/loc"
12 "../common/track" "../common/send")
15 (defconst realgud-shell-backtrace-loc-pat
17 :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
20 "A realgud-loc-pat struct that describes a Shell backtrace (or
23 (defconst realgud-shell-frame-start-regexp
24 "\\(?:^\\|\n\\)\\(->\\|##\\)")
26 (defconst realgud-shell-frame-num-regexp
29 (defconst realgud-shell-frame-file-regexp
30 "[ \t\n]+\\(?:in\\|from\\) file `\\(.+\\)'")
32 (defconst realgud-shell-frame-line-regexp
33 "[ \t\n]+at line \\([0-9]+\\)\\(?:\n\\|$\\)")
35 (defun realgud-posix-shell-populate-command-keys (&optional map)
36 "Bind the debugger function key layout used by many debuggers.
38 \\{realgud-example-map-standard}"
39 (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
40 (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
44 ;; Patterns common to the my POSIX shell debuggers
46 (defconst realgud:python-trepan-frame-start-regexp
47 "\\(?:^\\|\n\\)\\(->\\|##\\)")
49 (defconst realgud:python-trepan-frame-num-regexp
52 ;; Regular expression that describes a bashdb/zshdb location generally shown
53 ;; before a command prompt.
55 ;; (/etc/init.d/apparmor:35):
56 (defconst realgud:POSIX-debugger-loc-pat
58 :regexp "\\(?:^\\|\n\\)(\\([^:]+\\):\\([0-9]*\\)):\\(?:\n\\(.+\\)\\)?"
62 "A realgud-loc-pat struct that describes a POSIX shell debugger
65 ;; Regular expression that describes a debugger "backtrace" command line.
67 ;; ->0 in file `/etc/apparmor/fns' at line 24
68 ;; ##1 /etc/apparmor/fns called from file `/etc/init.d/apparmor' at line 35
69 ;; ##2 /etc/init.d/apparmor called from file `/usr/bin/zshdb' at line 129
70 (defconst realgud:POSIX-debugger-backtrace-pat
72 :regexp (concat realgud-shell-frame-start-regexp
73 realgud-shell-frame-num-regexp "[ ]?"
75 realgud-shell-frame-file-regexp
76 "\\(?:" realgud-shell-frame-line-regexp "\\)?"
81 "A realgud-loc-pat struct that describes a Python trepan
82 backtrace location line." )
84 ;; Regular expression that describes a "breakpoint set" line
85 (defconst realgud:POSIX-debugger-brkpt-set-pat
87 :regexp "^Breakpoint \\([0-9]+\\) set in file \\(.+\\), line \\([0-9]+\\).\n"
92 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
94 ;; Removed 1 breakpoint(s).
95 (defconst realgud:POSIX-debugger-brkpt-del-pat
97 :regexp "^Removed \\([0-9]+\\) breakpoint(s).\n"
100 (defconst realgud:POSIX-debugger-font-lock-keywords
102 ;; The frame number and first type name, if present.
103 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
105 ("^\\(->\\|##\\)\\([0-9]+\\) "
106 (2 realgud-backtrace-number-face))
109 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
110 ;; ---------^^^^^^^^^^^^^^^^^^^^-
111 ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
112 (2 realgud-file-name-face))
115 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
118 ("[ \t]+at line \\([0-9]+\\)$"
119 (1 realgud-line-number-face))
120 ;; (trepan-frames-match-current-line
121 ;; (0 trepan-frames-current-frame-face append))
124 (provide-me "realgud-lang-")