aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-11-17 18:01:23 -0500
committerStefan Monnier2013-11-17 18:01:23 -0500
commit9bc67baa5ad14110529ccfc4dfcb5b41be26be53 (patch)
tree6f438f8e4dd07b4165b4057afb61dc5b81172391
parentde586f99e98f9ace3dc33933094046671ee7fa3c (diff)
downloademacs-9bc67baa5ad14110529ccfc4dfcb5b41be26be53.tar.gz
emacs-9bc67baa5ad14110529ccfc4dfcb5b41be26be53.zip
* lisp/progmodes/gdb-mi.el: Avoid backtracking in regexp matcher.
(gdb--string-regexp): New constant. (gdb-tooltip-print, gdb-var-evaluate-expression-handler) (gdbmi-bnf-stream-record, gdb-jsonify-buffer): Use it. (gdb-source-file-regexp, gdb-prompt-name-regexp): Use it and change submatch 1. (gdb-get-source-file-list, gdb-get-prompt, gdb-get-source-file): Adjust use accordingly. (gdb-breakpoints-list-handler-custom): Pre-build the y/n string.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/gdb-mi.el40
2 files changed, 39 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7017e3ffb49..f408df795a0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12013-11-17 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/gdb-mi.el: Avoid backtracking in regexp matcher.
4 (gdb--string-regexp): New constant.
5 (gdb-tooltip-print, gdb-var-evaluate-expression-handler)
6 (gdbmi-bnf-stream-record, gdb-jsonify-buffer): Use it.
7 (gdb-source-file-regexp, gdb-prompt-name-regexp): Use it and change
8 submatch 1.
9 (gdb-get-source-file-list, gdb-get-prompt, gdb-get-source-file):
10 Adjust use accordingly.
11 (gdb-breakpoints-list-handler-custom): Pre-build the y/n string.
12
12013-11-17 Adam Sokolnicki <adam.sokolnicki@gmail.com> (tiny change) 132013-11-17 Adam Sokolnicki <adam.sokolnicki@gmail.com> (tiny change)
2 14
3 * progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at 15 * progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 2f1f7b3c8d3..4b0a012e538 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1016,11 +1016,15 @@ no input, and GDB is waiting for input."
1016 1016
1017(declare-function tooltip-show "tooltip" (text &optional use-echo-area)) 1017(declare-function tooltip-show "tooltip" (text &optional use-echo-area))
1018 1018
1019(defconst gdb--string-regexp "\"\\(?:[^\\\"]\\|\\\\.\\)*\"")
1020
1019(defun gdb-tooltip-print (expr) 1021(defun gdb-tooltip-print (expr)
1020 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) 1022 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
1021 (goto-char (point-min)) 1023 (goto-char (point-min))
1022 (cond 1024 (cond
1023 ((re-search-forward ".*value=\\(\".*\"\\)" nil t) 1025 ((re-search-forward (concat ".*value=\\(" gdb--string-regexp
1026 "\\)")
1027 nil t)
1024 (tooltip-show 1028 (tooltip-show
1025 (concat expr " = " (read (match-string 1))) 1029 (concat expr " = " (read (match-string 1)))
1026 (or gud-tooltip-echo-area 1030 (or gud-tooltip-echo-area
@@ -1198,7 +1202,8 @@ With arg, enter name of variable to be watched in the minibuffer."
1198 1202
1199(defun gdb-var-evaluate-expression-handler (varnum changed) 1203(defun gdb-var-evaluate-expression-handler (varnum changed)
1200 (goto-char (point-min)) 1204 (goto-char (point-min))
1201 (re-search-forward ".*value=\\(\".*\"\\)" nil t) 1205 (re-search-forward (concat ".*value=\\(" gdb--string-regexp "\\)")
1206 nil t)
1202 (let ((var (assoc varnum gdb-var-list))) 1207 (let ((var (assoc varnum gdb-var-list)))
1203 (when var 1208 (when var
1204 (if changed (setcar (nthcdr 5 var) 'changed)) 1209 (if changed (setcar (nthcdr 5 var) 'changed))
@@ -2124,7 +2129,8 @@ a GDB/MI reply message."
2124 '&' c-string" 2129 '&' c-string"
2125 (when (< gdbmi-bnf-offset (length gud-marker-acc)) 2130 (when (< gdbmi-bnf-offset (length gud-marker-acc))
2126 (if (and (member (aref gud-marker-acc gdbmi-bnf-offset) '(?~ ?@ ?&)) 2131 (if (and (member (aref gud-marker-acc gdbmi-bnf-offset) '(?~ ?@ ?&))
2127 (string-match "\\([~@&]\\)\\(\".*?\"\\)\n" gud-marker-acc 2132 (string-match (concat "\\([~@&]\\)\\(" gdb--string-regexp "\\)\n")
2133 gud-marker-acc
2128 gdbmi-bnf-offset)) 2134 gdbmi-bnf-offset))
2129 (let ((prefix (match-string 1 gud-marker-acc)) 2135 (let ((prefix (match-string 1 gud-marker-acc))
2130 (c-string (match-string 2 gud-marker-acc))) 2136 (c-string (match-string 2 gud-marker-acc)))
@@ -2586,9 +2592,10 @@ incompatible with GDB/MI output syntax."
2586 (insert "]")))))) 2592 (insert "]"))))))
2587 (goto-char (point-min)) 2593 (goto-char (point-min))
2588 (insert "{") 2594 (insert "{")
2589 (while (re-search-forward 2595 (let ((re (concat "\\([[:alnum:]-_]+\\)=\\({\\|\\[\\|\"\"\\|"
2590 "\\([[:alnum:]-_]+\\)=\\({\\|\\[\\|\"\"\\|\".*?[^\\]\"\\)" nil t) 2596 gdb--string-regexp "\\)")))
2591 (replace-match "\"\\1\":\\2" nil nil)) 2597 (while (re-search-forward re nil t)
2598 (replace-match "\"\\1\":\\2" nil nil)))
2592 (goto-char (point-max)) 2599 (goto-char (point-max))
2593 (insert "}"))) 2600 (insert "}")))
2594 2601
@@ -2812,8 +2819,12 @@ See `def-gdb-auto-update-handler'."
2812 (or (bindat-get-field breakpoint 'disp) "") 2819 (or (bindat-get-field breakpoint 'disp) "")
2813 (let ((flag (bindat-get-field breakpoint 'enabled))) 2820 (let ((flag (bindat-get-field breakpoint 'enabled)))
2814 (if (string-equal flag "y") 2821 (if (string-equal flag "y")
2815 (propertize "y" 'font-lock-face font-lock-warning-face) 2822 (eval-when-compile
2816 (propertize "n" 'font-lock-face font-lock-comment-face))) 2823 (propertize "y" 'font-lock-face
2824 font-lock-warning-face))
2825 (eval-when-compile
2826 (propertize "n" 'font-lock-face
2827 font-lock-comment-face))))
2817 (bindat-get-field breakpoint 'addr) 2828 (bindat-get-field breakpoint 'addr)
2818 (or (bindat-get-field breakpoint 'times) "") 2829 (or (bindat-get-field breakpoint 'times) "")
2819 (if (and type (string-match ".*watchpoint" type)) 2830 (if (and type (string-match ".*watchpoint" type))
@@ -2865,7 +2876,8 @@ See `def-gdb-auto-update-handler'."
2865 (gdb-put-breakpoint-icon (string-equal flag "y") bptno 2876 (gdb-put-breakpoint-icon (string-equal flag "y") bptno
2866 (string-to-number line))))))))) 2877 (string-to-number line)))))))))
2867 2878
2868(defvar gdb-source-file-regexp "fullname=\"\\(.*?\\)\"") 2879(defconst gdb-source-file-regexp
2880 (concat "fullname=\\(" gdb--string-regexp "\\)"))
2869 2881
2870(defun gdb-get-location (bptno line flag) 2882(defun gdb-get-location (bptno line flag)
2871 "Find the directory containing the relevant source file. 2883 "Find the directory containing the relevant source file.
@@ -2874,6 +2886,7 @@ Put in buffer and place breakpoint icon."
2874 (catch 'file-not-found 2886 (catch 'file-not-found
2875 (if (re-search-forward gdb-source-file-regexp nil t) 2887 (if (re-search-forward gdb-source-file-regexp nil t)
2876 (delete (cons bptno "File not found") gdb-location-alist) 2888 (delete (cons bptno "File not found") gdb-location-alist)
2889 ;; FIXME: Why/how do we use (match-string 1) when the search failed?
2877 (push (cons bptno (match-string 1)) gdb-location-alist) 2890 (push (cons bptno (match-string 1)) gdb-location-alist)
2878 (gdb-resync) 2891 (gdb-resync)
2879 (unless (assoc bptno gdb-location-alist) 2892 (unless (assoc bptno gdb-location-alist)
@@ -4214,7 +4227,7 @@ If buffers already exist for any of these files, `gud-minor-mode'
4214is set in them." 4227is set in them."
4215 (goto-char (point-min)) 4228 (goto-char (point-min))
4216 (while (re-search-forward gdb-source-file-regexp nil t) 4229 (while (re-search-forward gdb-source-file-regexp nil t)
4217 (push (match-string 1) gdb-source-file-list)) 4230 (push (read (match-string 1)) gdb-source-file-list))
4218 (dolist (buffer (buffer-list)) 4231 (dolist (buffer (buffer-list))
4219 (with-current-buffer buffer 4232 (with-current-buffer buffer
4220 (when (member buffer-file-name gdb-source-file-list) 4233 (when (member buffer-file-name gdb-source-file-list)
@@ -4253,14 +4266,15 @@ overlay arrow in source buffer."
4253 (setq gud-overlay-arrow-position (make-marker)) 4266 (setq gud-overlay-arrow-position (make-marker))
4254 (set-marker gud-overlay-arrow-position position)))))))) 4267 (set-marker gud-overlay-arrow-position position))))))))
4255 4268
4256(defvar gdb-prompt-name-regexp "value=\"\\(.*?\\)\"") 4269(defconst gdb-prompt-name-regexp
4270 (concat "value=\\(" gdb--string-regexp "\\)"))
4257 4271
4258(defun gdb-get-prompt () 4272(defun gdb-get-prompt ()
4259 "Find prompt for GDB session." 4273 "Find prompt for GDB session."
4260 (goto-char (point-min)) 4274 (goto-char (point-min))
4261 (setq gdb-prompt-name nil) 4275 (setq gdb-prompt-name nil)
4262 (re-search-forward gdb-prompt-name-regexp nil t) 4276 (re-search-forward gdb-prompt-name-regexp nil t)
4263 (setq gdb-prompt-name (match-string 1)) 4277 (setq gdb-prompt-name (read (match-string 1)))
4264 ;; Insert first prompt. 4278 ;; Insert first prompt.
4265 (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name))) 4279 (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name)))
4266 4280
@@ -4541,7 +4555,7 @@ Kills the gdb buffers, and resets variables and the source buffers."
4541buffers, if required." 4555buffers, if required."
4542 (goto-char (point-min)) 4556 (goto-char (point-min))
4543 (if (re-search-forward gdb-source-file-regexp nil t) 4557 (if (re-search-forward gdb-source-file-regexp nil t)
4544 (setq gdb-main-file (match-string 1))) 4558 (setq gdb-main-file (read (match-string 1))))
4545 (if gdb-many-windows 4559 (if gdb-many-windows
4546 (gdb-setup-windows) 4560 (gdb-setup-windows)
4547 (gdb-get-buffer-create 'gdb-breakpoints-buffer) 4561 (gdb-get-buffer-create 'gdb-breakpoints-buffer)