-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libcxxabi] Rename abort_message to __abort_message #108887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is an internal API and the name should reflect that.
@llvm/pr-subscribers-libcxxabi Author: Petr Hosek (petrhosek) ChangesThis is an internal API and the name should reflect that. Full diff: https://github.com/llvm/llvm-project/pull/108887.diff 11 Files Affected:
diff --git a/libcxxabi/src/abort_message.cpp b/libcxxabi/src/abort_message.cpp
index 859a5031b93fec..299994266e26a8 100644
--- a/libcxxabi/src/abort_message.cpp
+++ b/libcxxabi/src/abort_message.cpp
@@ -26,7 +26,7 @@
# define _LIBCXXABI_USE_CRASHREPORTER_CLIENT
#endif
-void abort_message(const char* format, ...)
+void __abort_message(const char* format, ...)
{
// Write message to stderr. We do this before formatting into a
// variable-size buffer so that we still get some information if
@@ -61,7 +61,7 @@ void abort_message(const char* format, ...)
# if __ANDROID_API__ >= 21
// Show error in tombstone.
- android_set_abort_message(buffer);
+ android_set___abort_message(buffer);
// Show error in logcat.
openlog("libc++abi", 0, 0);
diff --git a/libcxxabi/src/abort_message.h b/libcxxabi/src/abort_message.h
index 97641777801919..2c12c429569d34 100644
--- a/libcxxabi/src/abort_message.h
+++ b/libcxxabi/src/abort_message.h
@@ -12,14 +12,14 @@
#include "cxxabi.h"
extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void
-abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
+__abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
#ifndef _LIBCXXABI_ASSERT
# define _LIBCXXABI_ASSERT(expr, msg) \
do { \
if (!(expr)) { \
char const* __msg = (msg); \
- ::abort_message("%s:%d: %s", __FILE__, __LINE__, __msg); \
+ ::__abort_message("%s:%d: %s", __FILE__, __LINE__, __msg); \
} \
} while (false)
diff --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp
index 60e402c55b395b..52b1aacae9932f 100644
--- a/libcxxabi/src/cxa_default_handlers.cpp
+++ b/libcxxabi/src/cxa_default_handlers.cpp
@@ -30,18 +30,18 @@ static void demangling_terminate_handler()
// If there is no uncaught exception, just note that we're terminating
if (!globals)
- abort_message("terminating");
+ __abort_message("terminating");
__cxa_exception* exception_header = globals->caughtExceptions;
if (!exception_header)
- abort_message("terminating");
+ __abort_message("terminating");
_Unwind_Exception* unwind_exception =
reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
// If we're terminating due to a foreign exception
if (!__isOurExceptionClass(unwind_exception))
- abort_message("terminating due to %s foreign exception", cause);
+ __abort_message("terminating due to %s foreign exception", cause);
void* thrown_object =
__getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?
@@ -67,19 +67,19 @@ static void demangling_terminate_handler()
{
// Include the what() message from the exception
const std::exception* e = static_cast<const std::exception*>(thrown_object);
- abort_message("terminating due to %s exception of type %s: %s", cause, name, e->what());
+ __abort_message("terminating due to %s exception of type %s: %s", cause, name, e->what());
}
else
{
// Else just note that we're terminating due to an exception
- abort_message("terminating due to %s exception of type %s", cause, name);
+ __abort_message("terminating due to %s exception of type %s", cause, name);
}
}
#else // !_LIBCXXABI_NO_EXCEPTIONS
__attribute__((noreturn))
static void demangling_terminate_handler()
{
- abort_message("terminating");
+ __abort_message("terminating");
}
#endif // !_LIBCXXABI_NO_EXCEPTIONS
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index c842da195accbd..733f0d470569a2 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -61,12 +61,12 @@ namespace {
void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
__free_with_fallback(p);
if (0 != std::__libcpp_tls_set(key_, NULL))
- abort_message("cannot zero out thread value for __cxa_get_globals()");
+ __abort_message("cannot zero out thread value for __cxa_get_globals()");
}
void construct_() {
if (0 != std::__libcpp_tls_create(&key_, destruct_))
- abort_message("cannot create thread specific key for __cxa_get_globals()");
+ __abort_message("cannot create thread specific key for __cxa_get_globals()");
}
} // namespace
@@ -80,9 +80,9 @@ extern "C" {
retVal = static_cast<__cxa_eh_globals*>(
__calloc_with_fallback(1, sizeof(__cxa_eh_globals)));
if (NULL == retVal)
- abort_message("cannot allocate __cxa_eh_globals");
+ __abort_message("cannot allocate __cxa_eh_globals");
if (0 != std::__libcpp_tls_set(key_, retVal))
- abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
+ __abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
}
return retVal;
}
@@ -94,7 +94,7 @@ extern "C" {
__cxa_eh_globals *__cxa_get_globals_fast() {
// First time through, create the key.
if (0 != std::__libcpp_execute_once(&flag_, construct_))
- abort_message("execute once failure in __cxa_get_globals_fast()");
+ __abort_message("execute once failure in __cxa_get_globals_fast()");
return static_cast<__cxa_eh_globals*>(std::__libcpp_tls_get(key_));
}
} // extern "C"
diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index 3e533054098e20..7b05bf32f3eda7 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -91,7 +91,7 @@
// the former.
#ifdef BUILDING_CXA_GUARD
# include "abort_message.h"
-# define ABORT_WITH_MESSAGE(...) ::abort_message(__VA_ARGS__)
+# define ABORT_WITH_MESSAGE(...) ::__abort_message(__VA_ARGS__)
#elif defined(TESTING_CXA_GUARD)
# define ABORT_WITH_MESSAGE(...) ::abort()
#else
diff --git a/libcxxabi/src/cxa_handlers.cpp b/libcxxabi/src/cxa_handlers.cpp
index 344250dde0c7e1..f879ff0d8ff186 100644
--- a/libcxxabi/src/cxa_handlers.cpp
+++ b/libcxxabi/src/cxa_handlers.cpp
@@ -33,7 +33,7 @@ __unexpected(unexpected_handler func)
{
func();
// unexpected handler should not return
- abort_message("unexpected_handler unexpectedly returned");
+ __abort_message("unexpected_handler unexpectedly returned");
}
__attribute__((noreturn))
@@ -58,13 +58,13 @@ __terminate(terminate_handler func) noexcept
#endif // _LIBCXXABI_NO_EXCEPTIONS
func();
// handler should not return
- abort_message("terminate_handler unexpectedly returned");
+ __abort_message("terminate_handler unexpectedly returned");
#ifndef _LIBCXXABI_NO_EXCEPTIONS
}
catch (...)
{
// handler should not throw exception
- abort_message("terminate_handler unexpectedly threw an exception");
+ __abort_message("terminate_handler unexpectedly threw an exception");
}
#endif // _LIBCXXABI_NO_EXCEPTIONS
}
diff --git a/libcxxabi/src/cxa_thread_atexit.cpp b/libcxxabi/src/cxa_thread_atexit.cpp
index c6bd0aa323f2e1..8546cfe48c3976 100644
--- a/libcxxabi/src/cxa_thread_atexit.cpp
+++ b/libcxxabi/src/cxa_thread_atexit.cpp
@@ -89,7 +89,7 @@ namespace {
// __cxa_thread_atexit() may be called arbitrarily late (for example, from
// global destructors or atexit() handlers).
if (std::__libcpp_tls_create(&dtors_key, run_dtors) != 0) {
- abort_message("std::__libcpp_tls_create() failed in __cxa_thread_atexit()");
+ __abort_message("std::__libcpp_tls_create() failed in __cxa_thread_atexit()");
}
}
diff --git a/libcxxabi/src/cxa_vector.cpp b/libcxxabi/src/cxa_vector.cpp
index 17d942a6e61c79..857ee27d065c31 100644
--- a/libcxxabi/src/cxa_vector.cpp
+++ b/libcxxabi/src/cxa_vector.cpp
@@ -121,7 +121,7 @@ void throw_bad_array_new_length() {
#ifndef _LIBCXXABI_NO_EXCEPTIONS
throw std::bad_array_new_length();
#else
- abort_message("__cxa_vec_new failed to allocate memory");
+ __abort_message("__cxa_vec_new failed to allocate memory");
#endif
}
diff --git a/libcxxabi/src/cxa_virtual.cpp b/libcxxabi/src/cxa_virtual.cpp
index c868672e00af90..8f4fdd0919f0e2 100644
--- a/libcxxabi/src/cxa_virtual.cpp
+++ b/libcxxabi/src/cxa_virtual.cpp
@@ -13,12 +13,12 @@ namespace __cxxabiv1 {
extern "C" {
_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN
void __cxa_pure_virtual(void) {
- abort_message("Pure virtual function called!");
+ __abort_message("Pure virtual function called!");
}
_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN
void __cxa_deleted_virtual(void) {
- abort_message("Deleted virtual function called!");
+ __abort_message("Deleted virtual function called!");
}
} // extern "C"
} // abi
diff --git a/libcxxabi/src/demangle/DemangleConfig.h b/libcxxabi/src/demangle/DemangleConfig.h
index d67d89bdb06927..06fd223f5553f9 100644
--- a/libcxxabi/src/demangle/DemangleConfig.h
+++ b/libcxxabi/src/demangle/DemangleConfig.h
@@ -15,7 +15,7 @@
// build systems to override this value.
// https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
#ifndef _LIBCPP_VERBOSE_ABORT
-#define _LIBCPP_VERBOSE_ABORT(...) abort_message(__VA_ARGS__)
+#define _LIBCPP_VERBOSE_ABORT(...) __abort_message(__VA_ARGS__)
#include "../abort_message.h"
#endif
diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp
index b802559d479e2c..bd576e6aeed744 100644
--- a/libcxxabi/src/stdlib_new_delete.cpp
+++ b/libcxxabi/src/stdlib_new_delete.cpp
@@ -32,14 +32,14 @@ inline void __throw_bad_alloc_shim() {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw std::bad_alloc();
#else
- abort_message("bad_alloc was thrown in -fno-exceptions mode");
+ __abort_message("bad_alloc was thrown in -fno-exceptions mode");
#endif
}
#define _LIBCPP_ASSERT_SHIM(expr, str) \
do { \
if (!expr) \
- abort_message(str); \
+ __abort_message(str); \
} while (false)
// ------------------ BEGIN COPY ------------------
|
You can test this locally with the following command:git-clang-format --diff 9fc789d922ddf1c849f62bdfbe034f3cd9354967 81095ac38efc9369baee9877712ad714453b8d03 --extensions cpp,h -- libcxxabi/src/abort_message.cpp libcxxabi/src/abort_message.h libcxxabi/src/cxa_default_handlers.cpp libcxxabi/src/cxa_exception_storage.cpp libcxxabi/src/cxa_guard_impl.h libcxxabi/src/cxa_handlers.cpp libcxxabi/src/cxa_thread_atexit.cpp libcxxabi/src/cxa_vector.cpp libcxxabi/src/cxa_virtual.cpp libcxxabi/src/demangle/DemangleConfig.h libcxxabi/src/stdlib_new_delete.cpp View the diff from clang-format here.diff --git a/libcxxabi/src/abort_message.cpp b/libcxxabi/src/abort_message.cpp
index 299994266e..b99bb09b37 100644
--- a/libcxxabi/src/abort_message.cpp
+++ b/libcxxabi/src/abort_message.cpp
@@ -26,11 +26,10 @@
# define _LIBCXXABI_USE_CRASHREPORTER_CLIENT
#endif
-void __abort_message(const char* format, ...)
-{
- // Write message to stderr. We do this before formatting into a
- // variable-size buffer so that we still get some information if
- // formatting into the variable-sized buffer fails.
+ void __abort_message(const char* format, ...) {
+ // Write message to stderr. We do this before formatting into a
+ // variable-size buffer so that we still get some information if
+ // formatting into the variable-sized buffer fails.
#if !defined(NDEBUG) || !defined(LIBCXXABI_BAREMETAL)
{
fprintf(stderr, "libc++abi: ");
@@ -76,4 +75,4 @@ void __abort_message(const char* format, ...)
#endif // __BIONIC__
abort();
-}
+ }
diff --git a/libcxxabi/src/abort_message.h b/libcxxabi/src/abort_message.h
index 2c12c42956..d7f5aa5bec 100644
--- a/libcxxabi/src/abort_message.h
+++ b/libcxxabi/src/abort_message.h
@@ -11,8 +11,8 @@
#include "cxxabi.h"
-extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void
-__abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
+extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void __abort_message(const char* format, ...)
+ __attribute__((format(printf, 1, 2)));
#ifndef _LIBCXXABI_ASSERT
# define _LIBCXXABI_ASSERT(expr, msg) \
diff --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp
index 52b1aacae9..ebdbc10c41 100644
--- a/libcxxabi/src/cxa_default_handlers.cpp
+++ b/libcxxabi/src/cxa_default_handlers.cpp
@@ -30,18 +30,18 @@ static void demangling_terminate_handler()
// If there is no uncaught exception, just note that we're terminating
if (!globals)
- __abort_message("terminating");
+ __abort_message("terminating");
__cxa_exception* exception_header = globals->caughtExceptions;
if (!exception_header)
- __abort_message("terminating");
+ __abort_message("terminating");
_Unwind_Exception* unwind_exception =
reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
// If we're terminating due to a foreign exception
if (!__isOurExceptionClass(unwind_exception))
- __abort_message("terminating due to %s foreign exception", cause);
+ __abort_message("terminating due to %s foreign exception", cause);
void* thrown_object =
__getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?
@@ -76,11 +76,7 @@ static void demangling_terminate_handler()
}
}
#else // !_LIBCXXABI_NO_EXCEPTIONS
-__attribute__((noreturn))
-static void demangling_terminate_handler()
-{
- __abort_message("terminating");
-}
+__attribute__((noreturn)) static void demangling_terminate_handler() { __abort_message("terminating"); }
#endif // !_LIBCXXABI_NO_EXCEPTIONS
__attribute__((noreturn))
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index 733f0d4705..439ec4d2c9 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -61,12 +61,12 @@ namespace {
void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
__free_with_fallback(p);
if (0 != std::__libcpp_tls_set(key_, NULL))
- __abort_message("cannot zero out thread value for __cxa_get_globals()");
+ __abort_message("cannot zero out thread value for __cxa_get_globals()");
}
void construct_() {
if (0 != std::__libcpp_tls_create(&key_, destruct_))
- __abort_message("cannot create thread specific key for __cxa_get_globals()");
+ __abort_message("cannot create thread specific key for __cxa_get_globals()");
}
} // namespace
@@ -80,9 +80,9 @@ extern "C" {
retVal = static_cast<__cxa_eh_globals*>(
__calloc_with_fallback(1, sizeof(__cxa_eh_globals)));
if (NULL == retVal)
- __abort_message("cannot allocate __cxa_eh_globals");
+ __abort_message("cannot allocate __cxa_eh_globals");
if (0 != std::__libcpp_tls_set(key_, retVal))
- __abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
+ __abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
}
return retVal;
}
@@ -94,7 +94,7 @@ extern "C" {
__cxa_eh_globals *__cxa_get_globals_fast() {
// First time through, create the key.
if (0 != std::__libcpp_execute_once(&flag_, construct_))
- __abort_message("execute once failure in __cxa_get_globals_fast()");
+ __abort_message("execute once failure in __cxa_get_globals_fast()");
return static_cast<__cxa_eh_globals*>(std::__libcpp_tls_get(key_));
}
} // extern "C"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this change, but FWIW it doesn't really matter since this doesn't leak into any public headers. I'm still fine with it just consistency-wise.
The thing we'd really really like to do is
(1) merge libc++abi into libc++ code-wise (to reduce duplication etc)
(2) use __verbose_abort
directly instead of __abort_message
But that requires doing (1), which is some engineering effort.
This reverts commit 33bc6cf. Reason: broke Android buildbot (https://lab.llvm.org/buildbot/#/builders/186/builds/2517) /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang++ -DHAVE___CXA_THREAD_ATEXIT_IMPL -DLIBCXX_BUILDING_LIBCXXABI -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS="" -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_LINK_PTHREAD_LIB -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/libcxxabi/../libcxx/src -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_aarch64/lib/fuzzer/libcxx_fuzzer_aarch64/include/c++/v1 -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/libcxxabi/include --target=aarch64-linux-android24 --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++23 -fPIC -nostdinc++ -fstrict-aliasing -fno-exceptions -D_DEBUG -UNDEBUG -Wall -Wextra -Wnewline-eof -Wshadow -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wundef -Wunused-template -Wformat-nonliteral -Wno-user-defined-literals -Wno-covered-switch-default -Wno-suggest-override -Wno-error -fvisibility=hidden -fvisibility-global-new-delete=force-hidden -MD -MT libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/abort_message.cpp.o -MF libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/abort_message.cpp.o.d -o libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/abort_message.cpp.o -c /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/libcxxabi/src/abort_message.cpp /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/libcxxabi/src/abort_message.cpp:64:5: error: use of undeclared identifier 'android_set___abort_message'; did you mean 'android_set_abort_message'? 64 | android_set___abort_message(buffer); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | android_set_abort_message /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/libcxxabi/src/abort_message.cpp:18:25: note: 'android_set_abort_message' declared here 18 | extern "C" void android_set_abort_message(const char* msg); | ^ 1 error generated.
@thurstond Next time you revert a commit, please take the time to ping the relevant people and make a note in the PR that broke something. I discovered this revert by stumbling upon it. |
@petrhosek I think this was only caused by a bad search-and-replace. |
This is an internal API and the name should reflect that. This is a reland of llvm#108887.
This is an internal API and the name should reflect that. This is a reland of #108887.
This is an internal API and the name should reflect that.