unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14182: 24.2; [PATCH] gud: perldb works with eval-ed subs
@ 2013-04-11 10:50 Dima Kogan
  2013-04-18  7:48 ` bug#14182: updated patch Dima Kogan
  0 siblings, 1 reply; 3+ messages in thread
From: Dima Kogan @ 2013-04-11 10:50 UTC (permalink / raw)
  To: 14182

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

Hi.

This is a patch to fix a specific case that makes 'M-x perldb' unable to
step through some code.

When debugging through a subroutine defined in an eval, perldb uses a slightly
different string to communicate the debugger position. This patch updates the
regex in gud-perldb-marker-filter to be able to parse this string.

An example of a "normal" string:
 ^Z^Z/tmp/tst.pl:6:0

An example of a sub-in-eval string that can now be parsed:
 ^Z^Z(eval 5)[/tmp/tst.pl:6]:3:0

Sample perl source that couldn't be stepped through before, and now can be:

 eval 'sub f
 {
   print 34;
 }
 ';

 f();


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1309 bytes --]

From 4d95d04798ef4055758c7538275086d77cf10474 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Thu, 11 Apr 2013 03:39:41 -0700
Subject: [PATCH] gud: perldb works with eval-ed subs

When debugging through a subroutine defined in an eval, perldb uses a slightly
different string to communicate the debugger position. This patch updates the
regex in gud-perldb-marker-filter to be able to parse this string.

The "normal" string:
 ^Z^Z/tmp/tst.pl:6:0

The sub-in-eval string that can now be parsed:
 ^Z^Z(eval 5)[/tmp/tst.pl:6]:3:0

Sample perl source that couldn't be stepped through before, and now can be:

 eval 'sub f
 {
   print 34;
 }
 ';

 f();
---
 lisp/progmodes/gud.el |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index d339495..83b5fb6 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1487,7 +1487,7 @@ into one that invokes an Emacs-enabled debugging session.
   (let ((output ""))
 
     ;; Process all the complete markers in this chunk.
-    (while (string-match "\032\032\\(\\([a-zA-Z]:\\)?[^:\n]*\\):\\([0-9]*\\):.*\n"
+    (while (string-match "\032\032\\(?:(eval [0-9]+)\\[\\)?\\(\\([a-zA-Z]:\\)?[^:\n]*\\):\\([0-9]*\\)\\]?:.*\n"
 			 gud-marker-acc)
       (setq
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#14182: updated patch
  2013-04-11 10:50 bug#14182: 24.2; [PATCH] gud: perldb works with eval-ed subs Dima Kogan
@ 2013-04-18  7:48 ` Dima Kogan
  2013-04-19 15:59   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Dima Kogan @ 2013-04-18  7:48 UTC (permalink / raw)
  To: 14182

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

I used the patch in the original report for a while, and stumbled on
another, related case that emacs doesn't handle. I'm attaching an
updated patch that handles both cases (described in the patch). I've
also broken up the regex for improved readability.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3083 bytes --]

From 7ead460b535a84692057ddb8d36cec2203d5c3b4 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Thu, 11 Apr 2013 03:39:41 -0700
Subject: [PATCH] gud: perldb works with eval-ed subs

When debugging through a subroutine defined in an eval, perldb uses a
slightly different string to communicate the debugger position. This
patch updates the regex matching in gud-perldb-marker-filter to be
able to parse this string.

The "normal" string:
 ^Z^Z/tmp/tst.pl:6:0

The sub-in-eval string that can now be parsed can look like either of
 ^Z^Z(eval 5)[/tmp/tst.pl:6]:3:0
 ^Z^Z(eval 17)[Basic/Core/Core.pm.PL (i.e. PDL::Core.pm):2931]:1:0

Sample perl source that couldn't be stepped through before, and now can be:

 eval 'sub f
 {
   print 34;
 }
 ';

 f();
---
 lisp/progmodes/gud.el |   32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index d339495..15e6d07 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1487,14 +1487,40 @@ into one that invokes an Emacs-enabled debugging session.
   (let ((output ""))
 
     ;; Process all the complete markers in this chunk.
-    (while (string-match "\032\032\\(\\([a-zA-Z]:\\)?[^:\n]*\\):\\([0-9]*\\):.*\n"
-			 gud-marker-acc)
+    ;;
+    ;; Here I match the string coming out of perldb.
+    ;; The strings can look like any of
+    ;;
+    ;;  "\032\032/tmp/tst.pl:6:0\n"
+    ;;  "\032\032(eval 5)[/tmp/tst.pl:6]:3:0\n"
+    ;;  "\032\032(eval 17)[Basic/Core/Core.pm.PL (i.e. PDL::Core.pm):2931]:1:0\n"
+    ;;
+    ;; From those I want the filename and the line number. I use two
+    ;; regexes. First I look for the eval case. If that doesn't match,
+    ;; I look for the "normal" case
+    (while
+        (or (string-match (concat "\032\032"
+                                  "(eval [0-9]+)"
+                                  "\\["
+                                  "\\(\\(?:[a-zA-Z]:\\)?[^:\n]*\\)" ; path
+                                  "\\(?: (i\.e\. [^)]*)\\)?"        ; optional "(i.e. ...)" line
+                                  ":"
+                                  "\\([0-9]*\\)"                    ; line number
+                                  "\\]"
+                                  ":.*\n")
+                          gud-marker-acc)
+            (string-match (concat "\032\032"
+                                  "\\(\\(?:[a-zA-Z]:\\)?[^:\n]*\\)" ; path
+                                  ":"
+                                  "\\([0-9]*\\)"                    ; line number
+                                  ":.*\n")
+                          gud-marker-acc))
       (setq
 
        ;; Extract the frame position from the marker.
        gud-last-frame
        (cons (match-string 1 gud-marker-acc)
-	     (string-to-number (match-string 3 gud-marker-acc)))
+	     (string-to-number (match-string 2 gud-marker-acc)))
 
        ;; Append any text before the marker to the output we're going
        ;; to return - we don't include the marker in this text.
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#14182: updated patch
  2013-04-18  7:48 ` bug#14182: updated patch Dima Kogan
@ 2013-04-19 15:59   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-04-19 15:59 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 14182-done

> I used the patch in the original report for a while, and stumbled on
> another, related case that emacs doesn't handle. I'm attaching an
> updated patch that handles both cases (described in the patch). I've
> also broken up the regex for improved readability.

Thanks.  Installed with a minor change (I merged the two searches into
a single one, using the \(?N:...\) form).


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-19 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 10:50 bug#14182: 24.2; [PATCH] gud: perldb works with eval-ed subs Dima Kogan
2013-04-18  7:48 ` bug#14182: updated patch Dima Kogan
2013-04-19 15:59   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).