[haiku-commits] haiku: hrev52789 - src/system/libroot/posix

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 Jan 2019 22:05:13 -0500 (EST)

hrev52789 adds 1 changeset to branch 'master'
old head: 7282d46cef469c371d8a0e4645e2a0065f19b932
new head: 2b4b2018475ae9dad9eb467a2cf9e19b99a54acf
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=2b4b2018475a+%5E7282d46cef46

----------------------------------------------------------------------------

2b4b2018475a: libroot: Call abort() only if a signal handler is installed.
  
  Preserving the assert failure message in debug reports is desirable,
  so if possible we should do so, not just print it to stderr. So
  now we reuse the same trick from abort() directly.
  
  Sorry for the extra noise; I should have combined these commits.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev52789
Commit:      2b4b2018475ae9dad9eb467a2cf9e19b99a54acf
URL:         https://git.haiku-os.org/haiku/commit/?id=2b4b2018475a
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Wed Jan 23 03:02:59 2019 UTC

----------------------------------------------------------------------------

2 files changed, 13 insertions(+), 5 deletions(-)
src/system/libroot/posix/Jamfile                  |  2 +-
src/system/libroot/posix/{assert.c => assert.cpp} | 16 ++++++++++++----

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/Jamfile b/src/system/libroot/posix/Jamfile
index 2079067016..6aa077ab8a 100644
--- a/src/system/libroot/posix/Jamfile
+++ b/src/system/libroot/posix/Jamfile
@@ -18,7 +18,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
                        PWD_BACKEND = pwd.cpp grp.cpp shadow.cpp 
user_group_common.cpp ;
                }
                MergeObject <$(architecture)>posix_main.o :
-                       assert.c
+                       assert.cpp
                        dlfcn.c
                        dirent.c
                        errno.c
diff --git a/src/system/libroot/posix/assert.c 
b/src/system/libroot/posix/assert.cpp
similarity index 55%
rename from src/system/libroot/posix/assert.c
rename to src/system/libroot/posix/assert.cpp
index c840b54bdd..851ca17bf7 100644
--- a/src/system/libroot/posix/assert.c
+++ b/src/system/libroot/posix/assert.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2004, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx. All rights reserved.
+ * Copyright 2019, Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
 
@@ -10,6 +11,7 @@
 #include <OS.h>
 
 #include <assert.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -18,11 +20,19 @@ extern char* __progname;
 
 
 void
-__assert_fail(const char *assertion, const char* file, unsigned int line,
+__assert_fail(const char* assertion, const char* file, unsigned int line,
        const char* function)
 {
        fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function,
                assertion);
+
+       // If there's no handler installed for SIGABRT, call debugger().
+       struct sigaction signalAction;
+       if (sigaction(SIGABRT, NULL, &signalAction) == 0
+                       && signalAction.sa_handler == SIG_DFL) {
+               debugger(assertion);
+       }
+
        abort();
 }
 
@@ -31,7 +41,5 @@ void
 __assert_perror_fail(int error, const char* file, unsigned int line,
        const char* function)
 {
-       fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function,
-               strerror(error));
-       abort();
+       __assert_fail(strerror(error), file, line, function);
 }


Other related posts:

  • » [haiku-commits] haiku: hrev52789 - src/system/libroot/posix - waddlesplash