From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Unconditional quit on SIGUSR2 Date: Sun, 24 Apr 2011 19:16:22 -0700 Message-ID: <4DB4D976.5050502@gmail.com> References: <4D90354E.9000704@gmail.com> <4D908F5F.8000303@gmail.com> <4D90C42F.9060500@gmail.com> <83bp0vrszf.fsf@gnu.org> <4D90E199.2040809@gmail.com> <83aagfrq1y.fsf@gnu.org> <4D90E661.40207@gmail.com> <8362r2sy5x.fsf@gnu.org> <4D9106E7.5010902@gmail.com> <162CA738-6205-4D86-B263-B1C6408950BD@gmail.com> <4D921D1C.30806@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEBA806592E8179F10D178026" X-Trace: dough.gmane.org 1303697794 3863 80.91.229.12 (25 Apr 2011 02:16:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 25 Apr 2011 02:16:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 25 04:16:31 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QEBLh-0004B1-Vw for ged-emacs-devel@m.gmane.org; Mon, 25 Apr 2011 04:16:30 +0200 Original-Received: from localhost ([::1]:33546 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEBLh-00005o-88 for ged-emacs-devel@m.gmane.org; Sun, 24 Apr 2011 22:16:29 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEBLf-00005j-3P for emacs-devel@gnu.org; Sun, 24 Apr 2011 22:16:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QEBLd-0001mm-Sl for emacs-devel@gnu.org; Sun, 24 Apr 2011 22:16:27 -0400 Original-Received: from mail-px0-f179.google.com ([209.85.212.179]:39512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEBLd-0001me-Jt for emacs-devel@gnu.org; Sun, 24 Apr 2011 22:16:25 -0400 Original-Received: by pxi2 with SMTP id 2so1677987pxi.38 for ; Sun, 24 Apr 2011 19:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type; bh=osg1KaaVz5kflSZLdYgwEp37jEcRRw/BmgR+w+FXRLg=; b=uly3YON8Xlgp8xPkUpTG4Kibq4XC4umHzmZNbFN+YnuXwgnmRlVLrX6X7cjgJXRE3e pGQW0kqTDSummfIc8iHUgjBl/yl2wJXIkoLQ3nWTA4dAsBf51KjQOHzrJOeQJ+HxZOCD HsW0AT1uIhiSE+zk/YYMeWgpym0NK/d2NFweg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=mIFWh8nBUPB2jJIQz7iHwhnN1i3cMc3JQ+9kriQpMFxfUGY403vcKIKkw8W5o+DABY To0JWilXJIpohHXreyDQVzYCW0HAo8NuFagGPjdck0GJEzEo17rDQtNKbHbmM2B4c7Gx 9Mbg26F9eEzniBzf/y1CZWSJJrf4PmVwq4HtQ= Original-Received: by 10.68.41.9 with SMTP id b9mr5922574pbl.436.1303697784746; Sun, 24 Apr 2011 19:16:24 -0700 (PDT) Original-Received: from edith.local (c-67-183-23-114.hsd1.wa.comcast.net [67.183.23.114]) by mx.google.com with ESMTPS id o4sm2717412pbl.98.2011.04.24.19.16.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 24 Apr 2011 19:16:23 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <4D921D1C.30806@gmail.com> X-Enigmail-Version: 1.1.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.179 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138699 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigEBA806592E8179F10D178026 Content-Type: multipart/mixed; boundary="------------000309050808050306000006" This is a multi-part message in MIME format. --------------000309050808050306000006 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 3/29/11 10:55 AM, Daniel Colascione wrote: > > Below is another version of the patch. I've changed the code so that w= e > instead inspect a new debug-on-special-event variable, which by default= > is the symbol sigusr2. This way, we can extend the mechanism and use > another kind of special event for platforms that lack signals. >=20 Does anyone have any strong objections to merging this patch? --------------000309050808050306000006 Content-Type: text/plain; name="debugsig3.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="debugsig3.patch" =3D=3D=3D modified file 'doc/emacs/trouble.texi' --- doc/emacs/trouble.texi 2011-01-25 04:08:28 +0000 +++ doc/emacs/trouble.texi 2011-03-29 17:47:26 +0000 @@ -812,6 +812,14 @@ This backtrace is useful for debugging such long loops, so if you can produce it, copy it into the bug report. =20 +@vindex debug-on-special-event +If the normal quit process is ineffective, you can try sending Emacs +the special event given in @code{debug-on-special-event}, which by +default corresponds to SIGUSR2. When Emacs receives this event, it +stops what it's doing, sets @code{debug-on-quit} to @code{t}, and +tries to break into the debugger in a variety of ways. This process +happens even in places where quitting is normally not allowed. + @item Check whether any programs you have loaded into the Lisp world, including your @file{.emacs} file, set any variables that may affect the= =3D=3D=3D modified file 'doc/lispref/debugging.texi' --- doc/lispref/debugging.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/debugging.texi 2011-03-29 17:46:44 +0000 @@ -185,6 +185,20 @@ when you quit. @xref{Quitting}. @end defopt =20 +@defopt debug-on-special-event +When this variable contains a symbol matching one of the special +events in @code{special-event-map} (@pxref{Active Keymaps}) and Emacs +receives the corresponding event, Emacs will break into the debugger +instead of processing the event normally, setting @code{debug-on-quit} +to @code{t} as a side effect. This feature is useful for terminating +infinite loops in places where quits would normally be ignored, such +as in code that runs during redisplay. + +Currently, the only events Emacs recognizes as valid values for +@code{debug-on-special-event} are @code{sigusr1} and @code{sigusr2}. + +@end defopt + @node Function Debugging @subsection Entering the Debugger on a Function Call @cindex function call debugging =3D=3D=3D modified file 'lisp/cus-start.el' --- lisp/cus-start.el 2011-03-27 10:55:07 +0000 +++ lisp/cus-start.el 2011-03-29 17:36:51 +0000 @@ -259,6 +259,11 @@ (suggest-key-bindings keyboard (choice (const :tag "off" nil) (integer :tag "time" 2) (other :tag "on"))) + (debug-on-special-event debug + (choice (const :tag "None" nil) + (const :tag "When sent SIGUSR1" sigu= sr1) + (const :tag "When sent SIGUSR2" sigu= sr2)) + "24.1") =20 ;; This is not good news because it will use the wrong ;; version-specific directories when you upgrade. We need =3D=3D=3D modified file 'src/keyboard.c' --- src/keyboard.c 2011-03-27 02:27:11 +0000 +++ src/keyboard.c 2011-03-29 17:29:47 +0000 @@ -7165,12 +7165,33 @@ { int old_errno =3D errno; struct user_signal_info *p; + const char* special_event_name =3D NULL; =20 SIGNAL_THREAD_CHECK (sig); - + =20 + if (SYMBOLP (Vdebug_on_special_event) && + STRINGP (XSYMBOL (Vdebug_on_special_event)->xname)) + { + special_event_name =3D + SSDATA (XSYMBOL (Vdebug_on_special_event)->xname); + } + =20 for (p =3D user_signals; p; p =3D p->next) if (p->sig =3D=3D sig) { + if (special_event_name && + strcmp (special_event_name, p->name) =3D=3D 0) + { + /* Enter the debugger in many ways. */ + debug_on_next_call =3D 1; + debug_on_quit =3D 1; + Vquit_flag =3D Qt; + Vinhibit_quit =3D Qnil; + + /* Eat the event. */ + break; + } + =20 p->npending++; #ifdef SIGIO if (interrupt_input) @@ -12178,6 +12199,17 @@ `deactivate-mark' call uses this to set the window selection. */); Vsaved_region_selection =3D Qnil; =20 + DEFVAR_LISP ("debug-on-special-event", + Vdebug_on_special_event, + doc: /* Enter debugger on this special event. +When Emacs receives the special event specifed by this variable, +it will try to break into the debugger as soon as possible instead of +processing the event normally through `special-event-map'. + +Currently, the only meaningful values for this +variable are `sigusr1' and `sigusr2'. */); + Vdebug_on_special_event =3D intern_c_string ("sigusr2"); + /* Create the initial keyboard. */ initial_kboard =3D (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (initial_kboard); =3D=3D=3D modified file 'src/lisp.h' --- src/lisp.h 2011-03-27 02:27:11 +0000 +++ src/lisp.h 2011-03-28 13:06:41 +0000 @@ -2814,7 +2814,7 @@ =20 /* Defined in eval.c */ extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qm= acro; -extern Lisp_Object Qinhibit_quit; +extern Lisp_Object Qinhibit_quit, Qdebug; extern Lisp_Object Vautoload_queue; extern Lisp_Object Vsignaling_function; extern int handling_signal; --------------000309050808050306000006-- --------------enigEBA806592E8179F10D178026 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk202XYACgkQ17c2LVA10VsYvACeJ0pJBmkdlRmw8O5jQQYX3lin HuYAn2QwG6G3NbfdrzStEH/Yg5BoANec =fU6E -----END PGP SIGNATURE----- --------------enigEBA806592E8179F10D178026--