Merge changes I7ba9cef9,Ia191be0b,I16ba3dc8 am: d791a6501e

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2336140

Change-Id: I53c1dd81aa3f3a4980a33218a5729eb55f5be1ac
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ryan Prichard 2022-12-13 01:32:45 +00:00 committed by Automerger Merge Worker
commit 4c994d5bb6
6 changed files with 57 additions and 50 deletions

View file

@ -1518,34 +1518,34 @@ LIBC_R { # introduced=R
tss_set; tss_set;
# Unwinder implementation # Unwinder implementation
__aeabi_unwind_cpp_pr0; # apex llndk arm __aeabi_unwind_cpp_pr0; # arm
__aeabi_unwind_cpp_pr1; # apex llndk arm __aeabi_unwind_cpp_pr1; # arm
__aeabi_unwind_cpp_pr2; # apex llndk arm __aeabi_unwind_cpp_pr2; # arm
__deregister_frame; # apex llndk arm64 x86 x86_64 __deregister_frame; # arm64 x86 x86_64
__gnu_unwind_frame; # apex llndk arm __gnu_unwind_frame; # arm
__register_frame; # apex llndk arm64 x86 x86_64 __register_frame; # arm64 x86 x86_64
_Unwind_Backtrace; # apex llndk _Unwind_Backtrace;
_Unwind_Complete; # apex llndk arm _Unwind_Complete; # arm
_Unwind_DeleteException; # apex llndk _Unwind_DeleteException;
_Unwind_Find_FDE; # apex llndk _Unwind_Find_FDE;
_Unwind_FindEnclosingFunction; # apex llndk _Unwind_FindEnclosingFunction;
_Unwind_ForcedUnwind; # apex llndk arm64 x86 x86_64 _Unwind_ForcedUnwind; # arm64 x86 x86_64
_Unwind_GetCFA; # apex llndk _Unwind_GetCFA;
_Unwind_GetDataRelBase; # apex llndk _Unwind_GetDataRelBase;
_Unwind_GetGR; # apex llndk _Unwind_GetGR;
_Unwind_GetIP; # apex llndk _Unwind_GetIP;
_Unwind_GetIPInfo; # apex llndk _Unwind_GetIPInfo;
_Unwind_GetLanguageSpecificData; # apex llndk _Unwind_GetLanguageSpecificData;
_Unwind_GetRegionStart; # apex llndk _Unwind_GetRegionStart;
_Unwind_GetTextRelBase; # apex llndk _Unwind_GetTextRelBase;
_Unwind_RaiseException; # apex llndk _Unwind_RaiseException;
_Unwind_Resume; # apex llndk _Unwind_Resume;
_Unwind_Resume_or_Rethrow; # apex llndk _Unwind_Resume_or_Rethrow;
_Unwind_SetGR; # apex llndk _Unwind_SetGR;
_Unwind_SetIP; # apex llndk _Unwind_SetIP;
_Unwind_VRS_Get; # apex llndk arm _Unwind_VRS_Get; # arm
_Unwind_VRS_Pop; # apex llndk arm _Unwind_VRS_Pop; # arm
_Unwind_VRS_Set; # apex llndk arm _Unwind_VRS_Set; # arm
} LIBC_Q; } LIBC_Q;
LIBC_S { # introduced=S LIBC_S { # introduced=S

View file

@ -26,6 +26,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <cxxabi.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <signal.h> #include <signal.h>
@ -54,8 +55,6 @@
#include "malloc_debug.h" #include "malloc_debug.h"
#include "UnwindBacktrace.h" #include "UnwindBacktrace.h"
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
std::atomic_uint8_t PointerData::backtrace_enabled_; std::atomic_uint8_t PointerData::backtrace_enabled_;
std::atomic_bool PointerData::backtrace_dump_; std::atomic_bool PointerData::backtrace_dump_;
@ -617,8 +616,8 @@ void PointerData::DumpLiveToFile(int fd) {
if (frame.function_name.empty()) { if (frame.function_name.empty()) {
dprintf(fd, " \"\" 0}"); dprintf(fd, " \"\" 0}");
} else { } else {
char* demangled_name = __cxa_demangle(frame.function_name.c_str(), nullptr, nullptr, char* demangled_name =
nullptr); abi::__cxa_demangle(frame.function_name.c_str(), nullptr, nullptr, nullptr);
const char* name; const char* name;
if (demangled_name != nullptr) { if (demangled_name != nullptr) {
name = demangled_name; name = demangled_name;

View file

@ -26,6 +26,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <cxxabi.h>
#include <inttypes.h> #include <inttypes.h>
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
@ -48,8 +49,6 @@
#define PAD_PTR "08" PRIx64 #define PAD_PTR "08" PRIx64
#endif #endif
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
bool Unwind(std::vector<uintptr_t>* frames, std::vector<unwindstack::FrameData>* frame_info, bool Unwind(std::vector<uintptr_t>* frames, std::vector<unwindstack::FrameData>* frame_info,
size_t max_frames) { size_t max_frames) {
[[clang::no_destroy]] static unwindstack::AndroidLocalUnwinder unwinder( [[clang::no_destroy]] static unwindstack::AndroidLocalUnwinder unwinder(
@ -89,7 +88,8 @@ void UnwindLog(const std::vector<unwindstack::FrameData>& frame_info) {
if (!info->function_name.empty()) { if (!info->function_name.empty()) {
line += " ("; line += " (";
char* demangled_name = __cxa_demangle(info->function_name.c_str(), nullptr, nullptr, nullptr); char* demangled_name =
abi::__cxa_demangle(info->function_name.c_str(), nullptr, nullptr, nullptr);
if (demangled_name != nullptr) { if (demangled_name != nullptr) {
line += demangled_name; line += demangled_name;
free(demangled_name); free(demangled_name);

View file

@ -26,6 +26,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <cxxabi.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
@ -48,8 +49,6 @@
typedef struct _Unwind_Context __unwind_context; typedef struct _Unwind_Context __unwind_context;
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
static MapData g_map_data; static MapData g_map_data;
static const MapEntry* g_current_code_map = nullptr; static const MapEntry* g_current_code_map = nullptr;
@ -145,7 +144,7 @@ std::string backtrace_string(const uintptr_t* frames, size_t frame_count) {
char buf[1024]; char buf[1024];
if (symbol != nullptr) { if (symbol != nullptr) {
char* demangled_name = __cxa_demangle(symbol, nullptr, nullptr, nullptr); char* demangled_name = abi::__cxa_demangle(symbol, nullptr, nullptr, nullptr);
const char* name; const char* name;
if (demangled_name != nullptr) { if (demangled_name != nullptr) {
name = demangled_name; name = demangled_name;

View file

@ -26,19 +26,30 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <cxxabi.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
extern "C" {
int __cxa_atexit(void (*func)(void*), void* arg, void* dso);
// TODO(b/175635923). __cxa_finalize's return type should actually be "void",
// but it is declared "int" here instead to be compatible with the declaration
// in an old version of cxxabi.h, which is included indirectly. The declarations
// of __cxa_atexit and __cxa_finalize are removed from newer versions of
// cxxabi.h, so once libc++ is updated, this return type should be changed to
// "void".
int __cxa_finalize(void* dso);
}
TEST(__cxa_atexit, simple) { TEST(__cxa_atexit, simple) {
int counter = 0; int counter = 0;
__cxxabiv1::__cxa_atexit([](void* arg) { ++*static_cast<int*>(arg); }, &counter, &counter); __cxa_atexit([](void* arg) { ++*static_cast<int*>(arg); }, &counter, &counter);
__cxxabiv1::__cxa_finalize(&counter); __cxa_finalize(&counter);
ASSERT_EQ(counter, 1); ASSERT_EQ(counter, 1);
// The handler won't be called twice. // The handler won't be called twice.
__cxxabiv1::__cxa_finalize(&counter); __cxa_finalize(&counter);
ASSERT_EQ(counter, 1); ASSERT_EQ(counter, 1);
} }
@ -54,16 +65,16 @@ TEST(__cxa_atexit, order) {
}; };
for (int i = 0; i < 500; ++i) { for (int i = 0; i < 500; ++i) {
__cxxabiv1::__cxa_atexit(append_to_actual, new int{i}, &handles[i % 2]); __cxa_atexit(append_to_actual, new int{i}, &handles[i % 2]);
} }
__cxxabiv1::__cxa_finalize(&handles[0]); __cxa_finalize(&handles[0]);
for (int i = 500; i < 750; ++i) { for (int i = 500; i < 750; ++i) {
__cxxabiv1::__cxa_atexit(append_to_actual, new int{i}, &handles[1]); __cxa_atexit(append_to_actual, new int{i}, &handles[1]);
} }
__cxxabiv1::__cxa_finalize(&handles[1]); __cxa_finalize(&handles[1]);
std::vector<int> expected; std::vector<int> expected;
for (int i = 498; i >= 0; i -= 2) expected.push_back(i); for (int i = 498; i >= 0; i -= 2) expected.push_back(i);

View file

@ -29,11 +29,9 @@
#include <cxxabi.h> #include <cxxabi.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
TEST(__cxa_demangle, cxa_demangle_fuzz_152588929) { TEST(__cxa_demangle, cxa_demangle_fuzz_152588929) {
#if defined(__aarch64__) #if defined(__aarch64__)
char* p = __cxa_demangle("1\006ILeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", 0, 0, 0); char* p = abi::__cxa_demangle("1\006ILeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", 0, 0, 0);
ASSERT_STREQ("\x6<-0x1.cecececececececececececececep+11983", p); ASSERT_STREQ("\x6<-0x1.cecececececececececececececep+11983", p);
free(p); free(p);
#endif #endif
@ -41,7 +39,7 @@ TEST(__cxa_demangle, cxa_demangle_fuzz_152588929) {
TEST(__cxa_demangle, DISABLED_cxa_demangle_fuzz_167977068) { TEST(__cxa_demangle, DISABLED_cxa_demangle_fuzz_167977068) {
#if defined(__aarch64__) #if defined(__aarch64__)
char* p = __cxa_demangle("DTLeeeeeeeeeeeeeeeeeeeeeeeeeEEEEeeEEEE", 0, 0, 0); char* p = abi::__cxa_demangle("DTLeeeeeeeeeeeeeeeeeeeeeeeeeEEEEeeEEEE", 0, 0, 0);
ASSERT_EQ(nullptr, p) << p; ASSERT_EQ(nullptr, p) << p;
free(p); free(p);
#endif #endif