1 ;;; Copyright (C) 2012 Rocky Bernstein <rocky@gnu.org>
2 ;;; Stock Python debugger pdb
4 (eval-when-compile (require 'cl))
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp"
11 (require-relative-list '("../../lang/python") "dbgr-lang-")
13 (defvar dbgr-pat-hash)
14 (declare-function make-dbgr-loc-pat (dbgr-loc))
16 (defvar dbgr-pdb-pat-hash (make-hash-table :test 'equal)
17 "Hash key is the what kind of pattern we want to match:
18 backtrace, prompt, etc. The values of a hash entry is a
21 (declare-function make-dbgr-loc "dbgr-loc" (a b c d e f))
23 ;; Regular expression that describes a pdb location generally shown
24 ;; before a command prompt.
26 ;; Program-location lines look like this:
27 ;; > /usr/bin/zonetab2pot.py(15)<module>()
29 ;; > c:\\mydirectory\\gcd.py(10)<module>
30 (setf (gethash "loc" dbgr-pdb-pat-hash)
32 :regexp "^> \\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\)(\\([0-9]+\\))"
36 (setf (gethash "prompt" dbgr-pdb-pat-hash)
38 :regexp "^[(]+Pdb[)]+ "
41 ;; Regular expression that describes a Python backtrace line.
42 (setf (gethash "lang-backtrace" dbgr-pdb-pat-hash)
43 dbgr-python-backtrace-loc-pat)
45 ;; Regular expression that describes a "breakpoint set" line. For example:
46 ;; Breakpoint 1 at /usr/bin/pdb:7
47 (setf (gethash "brkpt-set" dbgr-pdb-pat-hash)
49 :regexp "^Breakpoint \\([0-9]+\\) at[ \t\n]+\\(.+\\):\\([0-9]+\\)\\(\n\\|$\\)"
54 ;; Regular expression that describes a "delete breakpoint" line
55 (setf (gethash "brkpt-del" dbgr-pdb-pat-hash)
57 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
60 (setf (gethash "font-lock-keywords" dbgr-pdb-pat-hash)
62 ;; The frame number and first type name, if present.
63 ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)? *\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
64 (2 dbgr-backtrace-number-face)
65 (4 font-lock-function-name-face nil t)) ; t means optional.
67 ;; Parameter sequence, E.g. gcd(a=3, b=5)
70 (1 font-lock-variable-name-face))
72 ;; File name. E.g file '/test/gcd.py'
73 ;; ------^^^^^^^^^^^^-
74 ("[ \t]+file '\\([^ ]+*\\)'"
75 (1 dbgr-file-name-face))
77 ;; Line number. E.g. at line 28
79 ("[ \t]+at line \\([0-9]+\\)$"
80 (1 dbgr-line-number-face))
83 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
84 (1 font-lock-type-face)
85 (2 font-lock-function-name-face))
86 ;; (pdb-frames-match-current-line
87 ;; (0 pdb-frames-current-frame-face append))
90 (setf (gethash "pdb" dbgr-pat-hash) dbgr-pdb-pat-hash)
92 (defvar dbgr-pdb-command-hash (make-hash-table :test 'equal)
93 "Hash key is command name like 'shell' and the value is
94 the pdb command to use, like 'python'")
96 (setf (gethash "shell" dbgr-pdb-command-hash) "python")
97 (setf (gethash "pdb" dbgr-command-hash) dbgr-pdb-command-hash)
99 (provide-me "dbgr-pdb-")