From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#12316: Simplify redefinition of 'abort'. Date: Thu, 30 Aug 2012 20:14:51 -0700 Organization: UCLA Computer Science Department Message-ID: <50402C2B.5020800@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1346382963 31098 80.91.229.3 (31 Aug 2012 03:16:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Aug 2012 03:16:03 +0000 (UTC) Cc: Juanma Barranquero To: 12316@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 31 05:16:03 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T7HiA-0005Pk-AL for geb-bug-gnu-emacs@m.gmane.org; Fri, 31 Aug 2012 05:15:58 +0200 Original-Received: from localhost ([::1]:51562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7Hi7-0000e8-M2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Aug 2012 23:15:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7Hi3-0000dv-UC for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:15:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7Hi2-0006uD-DN for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:15:51 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7Hi2-0006u9-9e for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:15:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T7HjD-0003Z6-0c for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:17:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Aug 2012 03:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12316 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.134638298213654 (code B ref -1); Fri, 31 Aug 2012 03:17:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Aug 2012 03:16:22 +0000 Original-Received: from localhost ([127.0.0.1]:58744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T7HiX-0003YA-QJ for submit@debbugs.gnu.org; Thu, 30 Aug 2012 23:16:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48328) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T7HiU-0003Y1-Fn for submit@debbugs.gnu.org; Thu, 30 Aug 2012 23:16:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7HhH-0006Kd-Lf for submit@debbugs.gnu.org; Thu, 30 Aug 2012 23:15:05 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:32786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7HhH-0006KO-JD for submit@debbugs.gnu.org; Thu, 30 Aug 2012 23:15:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7HhE-0000Tp-PS for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:15:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7HhC-0006De-Qu for bug-gnu-emacs@gnu.org; Thu, 30 Aug 2012 23:15:00 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:46199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7HhC-0006Be-Fu; Thu, 30 Aug 2012 23:14:58 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4D1FE39E8013; Thu, 30 Aug 2012 20:14:50 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EMrYKi8DSAsR; Thu, 30 Aug 2012 20:14:48 -0700 (PDT) Original-Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D532A39E800E; Thu, 30 Aug 2012 20:14:47 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63621 Archived-At: Tags: patch Here's a patch I'd like to install after a bit more testing. It simplifies how 'abort' is configured, on POSIX hosts. This affects the Windows port but I haven't tested that part. I'm CC'ing this to Eli and Juanma to give them a heads-up. =3D=3D=3D modified file 'ChangeLog' --- ChangeLog 2012-08-28 16:01:59 +0000 +++ ChangeLog 2012-08-31 03:06:13 +0000 @@ -1,3 +1,8 @@ +2012-08-31 Paul Eggert + + Simplify redefinition of 'abort'. + * configure.ac (NO_ABRT): Remove. + 2012-08-26 Paul Eggert =20 * configure.ac (CFLAGS): Prefer -g3 to -g if -g3 works =3D=3D=3D modified file 'admin/CPP-DEFINES' --- admin/CPP-DEFINES 2012-08-18 21:36:13 +0000 +++ admin/CPP-DEFINES 2012-08-31 03:06:13 +0000 @@ -428,7 +428,6 @@ MAIL_USE_SYSTEM_LOCK MAXPATHLEN NLIST_STRUCT -NO_ABORT NO_EDITRES NO_MATHERR NO_TERMIO =3D=3D=3D modified file 'admin/ChangeLog' --- admin/ChangeLog 2012-08-28 19:26:41 +0000 +++ admin/ChangeLog 2012-08-31 03:06:13 +0000 @@ -1,3 +1,8 @@ +2012-08-31 Paul Eggert + + Simplify redefinition of 'abort'. + * CPP-DEFINES (NO_ABORT): Remove. + 2012-08-28 Glenn Morris =20 * bzrmerge.el (bzrmerge-merges): Allow unversioned files in the tree. =3D=3D=3D modified file 'configure.ac' --- configure.ac 2012-08-28 16:01:59 +0000 +++ configure.ac 2012-08-31 03:06:13 +0000 @@ -3321,12 +3321,6 @@ AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to work around an issue when reading from a PTY.]) ;; - - dnl Define the following so emacs symbols will not conflict with those - dnl in the System framework. Otherwise -prebind will not work. - darwin) - AC_DEFINE(NO_ABORT, 1, [Do not define abort in emacs.c.]) - ;; esac =20 case $opsys in =3D=3D=3D modified file 'nt/ChangeLog' --- nt/ChangeLog 2012-08-28 16:01:59 +0000 +++ nt/ChangeLog 2012-08-31 03:06:13 +0000 @@ -1,3 +1,9 @@ +2012-08-31 Paul Eggert + + Simplify redefinition of 'abort'. + * inc/ms-w32.h (w32_abort): Remove. + * inc/unistd.h: Include , for 'environ'. + 2012-08-22 Juanma Barranquero =20 * config.nt: Sync with autogen/config.in. =3D=3D=3D modified file 'nt/inc/ms-w32.h' --- nt/inc/ms-w32.h 2012-08-07 11:03:48 +0000 +++ nt/inc/ms-w32.h 2012-08-31 03:06:13 +0000 @@ -334,16 +334,7 @@ #include #endif =20 -/* stdlib.h must be included after redefining malloc & friends, but - before redefining abort. Isn't library redefinition funny? */ #include - -/* Redefine abort. */ -#ifdef HAVE_NTGUI -#define abort w32_abort -extern _Noreturn void w32_abort (void); -#endif - #include =20 /* Define for those source files that do not include enough NT system fi= les. */ =3D=3D=3D modified file 'nt/inc/unistd.h' --- nt/inc/unistd.h 2011-02-27 19:48:31 +0000 +++ nt/inc/unistd.h 2012-08-31 03:06:13 +0000 @@ -3,8 +3,9 @@ #ifndef _UNISTD_H #define _UNISTD_H =20 +#include /* for 'environ' */ + extern ssize_t readlink (const char *, char *, size_t); extern int symlink (char const *, char const *); =20 #endif /* _UNISTD_H */ - =3D=3D=3D modified file 'src/.gdbinit' --- src/.gdbinit 2012-08-20 17:32:31 +0000 +++ src/.gdbinit 2012-08-31 03:06:13 +0000 @@ -1222,14 +1222,9 @@ set $tem =3D (struct Lisp_String *) $ptr set $tem =3D (char *) $tem->data =20 - # Don't let abort actually run, as it will make stdio stop working and - # therefore the `pr' command above as well. - if $tem[0] =3D=3D 'w' && $tem[1] =3D=3D 'i' && $tem[2] =3D=3D 'n' && $= tem[3] =3D=3D 'd' - # The windows-nt build replaces abort with its own function. - break w32_abort - else - break abort - end + # Don't let emacs_abort actually run, as it will make stdio stop + # working and therefore the 'pr' command above as well. + break emacs_abort end =20 # x_error_quitter is defined only on X. But window-system is set up =3D=3D=3D modified file 'src/ChangeLog' --- src/ChangeLog 2012-08-30 16:07:44 +0000 +++ src/ChangeLog 2012-08-31 03:06:13 +0000 @@ -1,3 +1,23 @@ +2012-08-31 Paul Eggert + + Simplify redefinition of 'abort'. + Do not try to redefine the 'abort' function. Instead, redo + 'emacs' so that it calls 'emacs_abort' rather than 'abort'. + This removes the need for the NO_ABORT configure-time macro + and makes it easier to change the abort code to do a backtrace. + * .gdbinit: Just stop at emacs_abort, not at w32_abort or abort. + * conf_post.h: Include and toward the end, + so that we can use NO_INLINE here and can define 'abort' cleanly. + (emacs_abort) [emacs]: New decl. + (abort) [emacs]: New macro. + * emacs.c (abort) [!DOS_NT && !NO_ABORT]: + Remove; sysdep.c's emacs_abort now takes its place. + * msdos.c (dos_abort) [defined abort]: Remove; not used. + (abort) [!defined abort]: Rename to ... + (emacs_abort) [HAVE_NTGUI]: ... new name. + * sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking + the place of the old 'abort' in emacs.c. + 2012-08-30 Jan Dj=C3=A4rv =20 * gtkutil.c (x_wm_set_size_hint): Use 1 col for base_width so it =3D=3D=3D modified file 'src/conf_post.h' --- src/conf_post.h 2012-08-20 16:48:10 +0000 +++ src/conf_post.h 2012-08-31 03:06:13 +0000 @@ -177,12 +177,6 @@ #endif #endif =20 -#include -/* If you think about removing the line below, note that the - MS-Windows build relies on it for declaration of 'environ' needed - by a few source files. */ -#include - #if __GNUC__ >=3D 3 /* On GCC 3.0 we might get a warning. */ #define NO_INLINE __attribute__((noinline)) #else @@ -233,4 +227,14 @@ # define lint_assume(cond) ((void) (0 && (cond))) #endif =20 +#include +#include +/* Under Emacs, arrange for 'abort ()' to call a function that is + breakpointable via GDB. */ +#ifdef emacs +extern _Noreturn void emacs_abort (void) NO_INLINE; +# undef abort +# define abort() emacs_abort () +#endif + /* conf_post.h ends here */ =3D=3D=3D modified file 'src/emacs.c' --- src/emacs.c 2012-08-25 06:38:43 +0000 +++ src/emacs.c 2012-08-31 03:10:04 +0000 @@ -344,22 +344,6 @@ force_auto_save_soon (); } #endif - -/* We define abort, rather than using it from the library, - so that GDB can return from a breakpoint here. - MSDOS has its own definition in msdos.c. */ - -#if ! defined (DOS_NT) && ! defined (NO_ABORT) - -void -abort (void) -{ - kill (getpid (), SIGABRT); - /* This shouldn't be executed, but it prevents a warning. */ - exit (1); -} -#endif - =0C /* Code for dealing with Lisp access to the Unix command line. */ =20 =3D=3D=3D modified file 'src/msdos.c' --- src/msdos.c 2012-08-21 10:21:04 +0000 +++ src/msdos.c 2012-08-31 03:06:13 +0000 @@ -4215,26 +4215,9 @@ } #endif =20 -#ifdef abort -#undef abort -void -dos_abort (char *file, int line) -{ - char buffer1[200], buffer2[400]; - int i, j; - - sprintf (buffer1, "", file, line); - for (i =3D j =3D 0; buffer1[i]; i++) { - buffer2[j++] =3D buffer1[i]; - buffer2[j++] =3D 0x70; - } - dosmemput (buffer2, j, (int)ScreenPrimary); - ScreenSetCursor (2, 0); - abort (); -} -#else -void -abort (void) +#ifdef HAVE_NTGUI +void +emacs_abort (void) { dos_ttcooked (); ScreenSetCursor (10, 0); =3D=3D=3D modified file 'src/sysdep.c' --- src/sysdep.c 2012-08-18 02:49:24 +0000 +++ src/sysdep.c 2012-08-31 03:06:13 +0000 @@ -1838,6 +1838,15 @@ } #endif =0C +#ifndef HAVE_NTGUI +/* Using emacs_abort lets GDB return from a breakpoint here. */ +void +emacs_abort (void) +{ + (abort) (); +} +#endif + int emacs_open (const char *path, int oflag, int mode) {