unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Extend gdb to filter registers
Date: Sun, 6 Oct 2019 00:24:26 -0400	[thread overview]
Message-ID: <253E46C6-9141-492C-918E-7218172BA9FC@gmail.com> (raw)
In-Reply-To: <83sgo72f0i.fsf@gnu.org>

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

Thanks for your kind reply, Eli. Here are some more questions:

* If I found a problem in existing code that is unrelated to my new
  feature but is quite trivial to fix (2~3 lines), should I create a
  new branch and send it as an separate patch to bug tracker, or
  include it in my new feature?

* IIUC, I send the patch to the bug tracker and people will review it,
  is that correct?

* If the patch is a fix, should I first create a bug report and reply
  to that report?

I'm still not quite sure how everything works, hope I'm not too
garrulous.

Attached is the patch for the bug fix. Changes are:

1. gdb-mi uses a buffer to store and parse output from gdb process
   and it is cleared after each complete conversation, however
   the cleanup function is not protected against call to `error'
   in handlers who process the output's content and do various things to it.

2. gdb-mi uses `error' for error messages from gdb, I think it should
   use `user-error' instead because the gdb-mi code is running well,
   the error is from gdb and are normal errors like "symbol not
   found in current context". We shouldn't drop a user into a backtrace
   for errors like this
   
Yuan


[-- Attachment #2: unwind-protect.patch --]
[-- Type: application/octet-stream, Size: 2321 bytes --]

From 1bbfaa19081c34167722b0806550696f219e261b Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Sat, 5 Oct 2019 23:29:17 -0400
Subject: [PATCH 1/2] Add unwind-protect to error handling function

lisp/progmodes/gdb-mi.el (gdb-done-or-error): add unwind-protect
---
 lisp/progmodes/gdb-mi.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 60852e4ad6..042c49c737 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -2644,13 +2644,13 @@ gdb-done-or-error
     ;; We are done concatenating to the output sink.  Restore it to user sink:
     (setq gdb-output-sink 'user)
 
-    (when (and token-number is-complete)
-      (with-current-buffer
-	  (gdb-get-buffer-create 'gdb-partial-output-buffer)
-	(gdb-handle-reply (string-to-number token-number))))
-
-  (when is-complete
-    (gdb-clear-partial-output))))
+    (unwind-protect (when (and token-number is-complete)
+                      (with-current-buffer
+	                  (gdb-get-buffer-create 'gdb-partial-output-buffer)
+	                (gdb-handle-reply (string-to-number token-number))))
+      ;; protect against handler-emitted errors
+      (when is-complete
+        (gdb-clear-partial-output)))))
 
 (defun gdb-concat-output (so-far new)
   (cond
-- 
2.23.0


From d76fdd533594153e144f78d47cdb6c2968041a99 Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Sat, 5 Oct 2019 23:39:05 -0400
Subject: [PATCH 2/2] Change error to user-error

lisp/progmodes/gdb-mi.el
  (gdb-read-memory-custom): Change error to user-error
---
 lisp/progmodes/gdb-mi.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 042c49c737..1bc451df8e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -3500,7 +3500,8 @@ gdb-read-memory-custom
       (progn
         (let ((gdb-memory-address gdb-memory-last-address))
           (gdb-invalidate-memory 'update)
-          (error err-msg))))))
+          ;; an error from gdb should be considered a user error
+          (user-error err-msg))))))
 
 (defvar gdb-memory-mode-map
   (let ((map (make-sparse-keymap)))
-- 
2.23.0


  reply	other threads:[~2019-10-06  4:24 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 16:40 Extend gdb to filter registers Yuan Fu
2019-10-04 16:13 ` Fu Yuan
2019-10-04 19:32   ` Eli Zaretskii
2019-10-04 19:49 ` Stefan Monnier
2019-10-04 21:55   ` Yuan Fu
2019-10-05  3:15     ` Yuan Fu
2019-10-05  7:08       ` Eli Zaretskii
2019-10-05 13:15         ` Yuan Fu
2019-10-05 13:53           ` Eli Zaretskii
2019-10-05 17:51             ` Yuan Fu
2019-10-05 19:01               ` Eli Zaretskii
2019-10-06  4:24                 ` Yuan Fu [this message]
2019-10-06 17:36                   ` Eli Zaretskii
2019-10-08  2:23                     ` Yuan Fu
2019-10-06  4:43               ` Michael Welsh Duggan
2019-10-07 15:50                 ` Yuan Fu
2019-10-07 16:19                   ` Michael Welsh Duggan
2019-10-08  0:19                     ` Yuan Fu
2019-10-08 17:26       ` Stefan Monnier
2019-10-09  3:44         ` Yuan Fu
2019-10-09  3:51           ` Yuan Fu
2019-10-15  3:05           ` Yuan Fu
2019-10-15  9:48             ` martin rudalics
2019-10-17  3:14               ` Yuan Fu
2019-10-17  3:27                 ` Yuan Fu
2019-10-17  8:26                 ` martin rudalics
2019-10-15 18:10             ` Juri Linkov
2019-10-15 20:51               ` Stefan Monnier
2019-10-17  3:08               ` Yuan Fu
2019-10-17  8:19                 ` Eli Zaretskii
2019-10-26 21:56                   ` Yuan Fu
2019-10-27  7:47                     ` martin rudalics
2019-10-27 17:38                       ` Yuan Fu
2020-01-16  4:25                         ` Yuan Fu
2020-01-16 14:51                           ` Eli Zaretskii
2020-01-16 15:04                             ` Yuan Fu
     [not found]                               ` <CAO0xp5w8PwAiy=JNVmCK652rCs_06cMAO5_+1ppHwppQ2js4VQ@mail.gmail.com>
2020-01-17 23:31                                 ` Yuan Fu
2020-01-18 11:15                               ` Eli Zaretskii
2020-01-18 13:32                                 ` Yuan Fu
2020-01-18 15:21                                   ` Eli Zaretskii
2020-01-18 15:41                                     ` Yuan Fu
2020-01-18 16:50                                       ` Eli Zaretskii
2020-01-18 16:20                                 ` John Yates
2020-01-18 16:53                                   ` Eli Zaretskii
2020-01-18 17:53                                     ` Yuan Fu
2020-01-18 17:56                                       ` Eli Zaretskii
2020-01-18 18:21                                     ` martin rudalics
2020-01-18 18:33                                       ` Eli Zaretskii
2020-01-18 18:36                                         ` Yuan Fu
2020-01-18 18:48                                           ` Eli Zaretskii
2020-01-18 20:10                                             ` Yuan Fu
2020-01-18 18:41                                         ` martin rudalics
2020-01-18 19:18                                           ` Eli Zaretskii
2020-01-18 21:43                                             ` martin rudalics
2020-01-19 15:40                                               ` Eli Zaretskii
2020-01-19 17:33                                                 ` Yuan Fu
2020-01-19 17:42                                                   ` Eli Zaretskii
2020-01-19 17:57                                                     ` Yuan Fu
2020-01-19 18:43                                                       ` Eli Zaretskii
2020-01-19 19:35                                                         ` Yuan Fu
2020-01-19 20:07                                                           ` Eli Zaretskii
2020-01-20  1:22                                                             ` Yuan Fu
2020-01-20 18:03                                                               ` Eli Zaretskii
2020-01-22  1:50                                                                 ` Yuan Fu
2020-01-24  7:16                                                                   ` Eli Zaretskii
2020-01-24 20:12                                                                     ` Yuan Fu
2020-01-24 22:37                                                                       ` John Yates
2020-01-25  7:45                                                                         ` Eli Zaretskii
2020-01-25 14:33                                                                           ` John Yates
2020-01-25 17:10                                                                             ` Eli Zaretskii
2020-01-25  8:43                                                                         ` martin rudalics
2020-01-25 14:56                                                                           ` John Yates
2020-01-25 17:14                                                                             ` martin rudalics
2020-01-25 20:17                                                                               ` John Yates
2020-01-26  8:41                                                                                 ` martin rudalics
2020-01-26  4:18                                                                         ` Richard Stallman
2020-01-26  5:09                                                                           ` Drew Adams
2020-01-26  5:31                                                                             ` Yuan Fu
2020-01-26 17:12                                                                           ` Eli Zaretskii
2020-01-25  8:24                                                                       ` Eli Zaretskii
2020-01-25  8:58                                                                         ` martin rudalics
2020-01-25 10:25                                                                           ` Eli Zaretskii
2020-01-25 10:30                                                                             ` Eli Zaretskii
2020-01-25 22:34                                                                         ` Yuan Fu
2020-01-26  8:42                                                                           ` martin rudalics
2020-01-26 16:12                                                                             ` Yuan Fu
2020-01-26 16:57                                                                               ` martin rudalics
2020-01-27 15:56                                                                                 ` Yuan Fu
2020-01-27 19:18                                                                                   ` martin rudalics
2020-01-27 19:53                                                                                     ` Yuan Fu
2020-01-28  9:49                                                                                       ` martin rudalics
2020-01-28 20:01                                                                                         ` Yuan Fu
2020-01-28 20:33                                                                                           ` John Yates
2020-01-31 13:58                                                                           ` Eli Zaretskii
2020-01-31 15:25                                                                             ` Yuan Fu
2020-01-31 15:35                                                                               ` Eli Zaretskii
2020-01-25  8:43                                                                       ` martin rudalics
2020-01-25 10:21                                                                         ` Eli Zaretskii
2020-01-25 12:11                                                                           ` martin rudalics
2020-01-25 13:35                                                                             ` Eli Zaretskii
2020-01-25  8:42                                                                     ` martin rudalics
2020-01-19 18:30                                                   ` martin rudalics
2020-01-19 18:47                                                     ` Eli Zaretskii
2020-01-19 18:05                                                 ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=253E46C6-9141-492C-918E-7218172BA9FC@gmail.com \
    --to=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).