branch: externals/realgud commit 1f5950280608ad40a513dac8b69d1360217f2f81 Merge: 081f7ed 2fad0c4 Author: R. Bernstein <ro...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Merge pull request #192 from dvzubarev/master Fix infinite loop in realgud:backtrace-init --- realgud/common/buffer/backtrace.el | 8 +++++--- test/test-bt-trepan2.el | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/realgud/common/buffer/backtrace.el b/realgud/common/buffer/backtrace.el index 2b68bb0..448927a 100644 --- a/realgud/common/buffer/backtrace.el +++ b/realgud/common/buffer/backtrace.el @@ -407,6 +407,8 @@ filename, line number, whether the frame is selected as text properties." ;; FIXME: Remove hack that group 1 is always the frame indicator. (frame-indicator (substring stripped-string (match-beginning 1) (match-end 1))) + (whole-match-begin (match-beginning 0)) + (whole-match-end (match-end 0)) (frame-num-pos) ) @@ -462,12 +464,12 @@ filename, line number, whether the frame is selected as text properties." (when (and (stringp filename) (numberp line-num)) (let ((loc (realgud:file-loc-from-line filename line-num cmdbuf))) - (put-text-property (match-beginning 0) (match-end 0) + (put-text-property whole-match-begin whole-match-end 'loc loc string) )) - (put-text-property (match-beginning 0) (match-end 0) + (put-text-property whole-match-begin whole-match-end 'frame-num frame-num string) - (setq last-pos (match-end 0)) + (setq last-pos whole-match-end) (if (string-match frame-indicator-re frame-indicator) (setq selected-frame-num frame-num)) diff --git a/test/test-bt-trepan2.el b/test/test-bt-trepan2.el index d3d3d0f..e1be16e 100644 --- a/test/test-bt-trepan2.el +++ b/test/test-bt-trepan2.el @@ -4,15 +4,19 @@ (require 'test-simple) (require 'load-relative) (load-file "./bt-helper.el") +(load-file "./regexp-helper.el") (load-file "../realgud/debugger/trepan2/init.el") (declare-function setup-bt 'realgud-bt-helper) +(declare-function setup-regexp-vars 'regexp-helper) (declare-function __FILE__ 'load-relative) (test-simple-start) (eval-when-compile (defvar temp-bt) + (defvar realgud-pat-bt) + (defvar realgud:trepan2-pat-hash) ) (setq temp-bt @@ -40,4 +44,34 @@ (get-text-property (point) 'face)) ) ) + + +(setup-regexp-vars realgud:trepan2-pat-hash) +(setq realgud-pat-bt (gethash "debugger-backtrace" + realgud:trepan2-pat-hash)) + + +(let* ((triple + (realgud:backtrace-add-text-properties + realgud-pat-bt "" + "->0 gcd(a=3, b=5) called from file '/test/gcd.py' at line 28 +##1 <module> exec() '/test/gcd.py' at line 41" + "->")) + (string-with-props (car triple))) + (dolist (pair + '( + ("->0" . (0 . 28) ) + ("##1" . (1 . 41) ) + )) + (string-match (car pair) string-with-props) + (assert-equal (cddr pair) + (realgud-loc-line-number (get-text-property + (match-beginning 0) 'loc + string-with-props))) + + (assert-equal (cadr pair) + (get-text-property + (match-beginning 0) 'frame-num + string-with-props)))) + (end-tests)