   (interactive "d")
   (save-excursion
     (goto-char pt)
-    (let ((s (concat "-->" (buffer-substring (point-at-bol) (point-at-eol)))))
-      (when (string-match rdebug--stack-frame-regexp s)
+    (let ((s (concat "-->" (buffer-substring (line-beginning-position) (line-end-position))))
+	  (s2 (if (= (line-number-at-pos (line-end-position 2)) (line-number-at-pos (point-max)))
+		  nil
+		;else 
+		  (buffer-substring (line-beginning-position 2) (line-end-position 2)))))
+      (when (or (string-match rdebug--stack-frame-regexp s)
+		; need to match 1st line last to get the match position right
+		(and s2 (string-match rdebug--stack-frame-2nd-regexp s2)
+		     (string-match rdebug--stack-frame-1st-regexp s)))
         (let ((frame (substring s (match-beginning 2) (match-end 2))))
           (gud-call (concat "frame " frame)))))))
 

  (interactive "d")
  (save-excursion
    (goto-char pt)
    (let ((s (buffer-substring (point-at-bol) (point-at-eol)))
	  (gud-comint-buffer (current-buffer)))
      (when (string-match rdebug-traceback-line-re s)
        (rdebug-display-line

    map)
  "Keymap to navigate rdebug stack frames.")

(defun rdebug-frames-mode ()
  "Major mode for rdebug frames.

\\{rdebug-frames-mode-map}"
  ; (kill-all-local-variables)
  (interactive "")
  (setq major-mode 'rdebug-frames-mode)
  (setq mode-name "RDEBUG Stack Frames")
  (use-local-map rdebug-frames-mode-map)
  ; (set (make-local-variable 'font-lock-defaults)
  ;     '(gdb-locals-font-lock-keywords))
  (run-mode-hooks 'rdebug-frames-mode-hook))

(defconst rdebug--stack-frame-1st-regexp
  "^\\(-->\\|   \\) +#\\([0-9]+\\)\\(.*\\)"
  "Regexp to recognize the first line of a a stack frame line in rdebug stack buffers.")

(defconst rdebug--stack-frame-2nd-regexp
  "\s+at line +\\([^:]+\\):\\([0-9]+\\)$"
  "Regexp to recognize the second line of a a stack frame line in rdebug stack buffers.")

(defconst rdebug--stack-frame-regexp
  (concat rdebug--stack-frame-1st-regexp rdebug--stack-frame-2nd-regexp)
  "Regexp to recognize a stack frame line in rdebug stack buffers.")

(defun rdebug--setup-stack-buffer (buf)
  "Detects stack frame lines and sets up mouse navigation."
