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.
This commit is contained in:
parent
7282d46cef
commit
2b4b201847
@ -18,7 +18,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
PWD_BACKEND = pwd.cpp grp.cpp shadow.cpp user_group_common.cpp ;
|
PWD_BACKEND = pwd.cpp grp.cpp shadow.cpp user_group_common.cpp ;
|
||||||
}
|
}
|
||||||
MergeObject <$(architecture)>posix_main.o :
|
MergeObject <$(architecture)>posix_main.o :
|
||||||
assert.c
|
assert.cpp
|
||||||
dlfcn.c
|
dlfcn.c
|
||||||
dirent.c
|
dirent.c
|
||||||
errno.c
|
errno.c
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
|
* Copyright 2019, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -10,6 +11,7 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -18,11 +20,19 @@ extern char* __progname;
|
|||||||
|
|
||||||
|
|
||||||
void
|
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)
|
const char* function)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function,
|
fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function,
|
||||||
assertion);
|
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();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +41,5 @@ void
|
|||||||
__assert_perror_fail(int error, const char* file, unsigned int line,
|
__assert_perror_fail(int error, const char* file, unsigned int line,
|
||||||
const char* function)
|
const char* function)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function,
|
__assert_fail(strerror(error), file, line, function);
|
||||||
strerror(error));
|
|
||||||
abort();
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user