Changes imported from Abseil "staging" branch:
- b7ac57541b07fadc3ed054cc3d62bc192a2098a7 Redefine arithmetic assign operators in terms of the bina... by Alex Strelnikov <strel@google.com> - bb2bf3fd86eb9f24420376aad1b9fe84068ad7e4 Cmake CI for Ubuntu by Jon Cohen <cohenjon@google.com> - 3ff3e6d6b4d99627f0785cad5b562362bdf1ae37 Fix internal namespace (debug_internal -> debugging_inter... by Derek Mauro <dmauro@google.com> - b50753d757c95a3430cc2d6cfc0272af1e5c219c Internal change. by Alex Strelnikov <strel@google.com> GitOrigin-RevId: b7ac57541b07fadc3ed054cc3d62bc192a2098a7 Change-Id: I7561639e296d1cc5dc7ee75e6645e8dae3f1bf97
This commit is contained in:
parent
bf7fc9986e
commit
3917120a4c
12 changed files with 116 additions and 86 deletions
|
|
@ -20,12 +20,12 @@
|
|||
#if !defined(__linux__) || defined(__ANDROID__)
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
// On platforms other than Linux, just return true.
|
||||
bool AddressIsReadable(const void* /* addr */) { return true; }
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#else
|
||||
|
|
@ -40,7 +40,7 @@ bool AddressIsReadable(const void* /* addr */) { return true; }
|
|||
#include "absl/base/internal/raw_logging.h"
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
// Pack a pid and two file descriptors into a 64-bit word,
|
||||
// using 16, 24, and 24 bits for each respectively.
|
||||
|
|
@ -127,7 +127,7 @@ bool AddressIsReadable(const void *addr) {
|
|||
return bytes_written == 1;
|
||||
}
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
#define ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
// Return whether the byte at *addr is readable, without faulting.
|
||||
// Save and restores errno.
|
||||
bool AddressIsReadable(const void *addr);
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#define VERSYM_VERSION 0x7fff
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
@ -392,7 +392,7 @@ void ElfMemImage::SymbolIterator::Update(int increment) {
|
|||
info_.symbol = symbol;
|
||||
}
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HAVE_ELF_MEM_IMAGE
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include <link.h> // for ElfW
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
// An in-memory ELF image (may not exist on disk).
|
||||
class ElfMemImage {
|
||||
|
|
@ -122,7 +122,7 @@ class ElfMemImage {
|
|||
ElfW(Addr) link_base_; // Link-time base (p_vaddr of first PT_LOAD).
|
||||
};
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HAVE_ELF_MEM_IMAGE
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ static const unsigned char* GetKernelRtSigreturnAddress() {
|
|||
address = reinterpret_cast<uintptr_t>(nullptr);
|
||||
|
||||
#ifdef ABSL_HAVE_VDSO_SUPPORT
|
||||
absl::debug_internal::VDSOSupport vdso;
|
||||
absl::debugging_internal::VDSOSupport vdso;
|
||||
if (vdso.IsPresent()) {
|
||||
absl::debug_internal::VDSOSupport::SymbolInfo symbol_info;
|
||||
absl::debugging_internal::VDSOSupport::SymbolInfo symbol_info;
|
||||
if (!vdso.LookupSymbol("__kernel_rt_sigreturn", "LINUX_2.6.39", STT_FUNC,
|
||||
&symbol_info) ||
|
||||
symbol_info.address == nullptr) {
|
||||
|
|
@ -90,7 +90,7 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc) {
|
|||
// Check that alleged frame pointer is actually readable. This is to
|
||||
// prevent "double fault" in case we hit the first fault due to e.g.
|
||||
// stack corruption.
|
||||
if (!absl::debug_internal::AddressIsReadable(
|
||||
if (!absl::debugging_internal::AddressIsReadable(
|
||||
pre_signal_frame_pointer))
|
||||
return nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ static void **NextStackFrame(void **old_sp, const void *uc) {
|
|||
// possibly be there.
|
||||
static const unsigned char *kernel_sigtramp_rt64_address = nullptr;
|
||||
if (kernel_symbol_status == kNotInitialized) {
|
||||
absl::debug_internal::VDSOSupport vdso;
|
||||
absl::debugging_internal::VDSOSupport vdso;
|
||||
if (vdso.IsPresent()) {
|
||||
absl::debug_internal::VDSOSupport::SymbolInfo
|
||||
absl::debugging_internal::VDSOSupport::SymbolInfo
|
||||
sigtramp_rt64_symbol_info;
|
||||
if (!vdso.LookupSymbol(
|
||||
"__kernel_sigtramp_rt64", "LINUX_2.6.15",
|
||||
absl::debug_internal::VDSOSupport::kVDSOSymbolType,
|
||||
absl::debugging_internal::VDSOSupport::kVDSOSymbolType,
|
||||
&sigtramp_rt64_symbol_info) ||
|
||||
sigtramp_rt64_symbol_info.address == nullptr) {
|
||||
// Unexpected: VDSO is present, yet the expected symbol is missing
|
||||
|
|
@ -137,7 +137,7 @@ static void **NextStackFrame(void **old_sp, const void *uc) {
|
|||
// Check that alleged stack pointer is actually readable. This is to
|
||||
// prevent a "double fault" in case we hit the first fault due to e.g.
|
||||
// a stack corruption.
|
||||
if (absl::debug_internal::AddressIsReadable(sp_before_signal)) {
|
||||
if (absl::debugging_internal::AddressIsReadable(sp_before_signal)) {
|
||||
// Alleged stack pointer is readable, use it for further unwinding.
|
||||
new_sp = sp_before_signal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,11 +170,11 @@ static void **NextStackFrame(void **old_fp, const void *uc) {
|
|||
static const unsigned char *kernel_rt_sigreturn_address = nullptr;
|
||||
static const unsigned char *kernel_vsyscall_address = nullptr;
|
||||
if (num_push_instructions == -1) {
|
||||
absl::debug_internal::VDSOSupport vdso;
|
||||
absl::debugging_internal::VDSOSupport vdso;
|
||||
if (vdso.IsPresent()) {
|
||||
absl::debug_internal::VDSOSupport::SymbolInfo
|
||||
absl::debugging_internal::VDSOSupport::SymbolInfo
|
||||
rt_sigreturn_symbol_info;
|
||||
absl::debug_internal::VDSOSupport::SymbolInfo vsyscall_symbol_info;
|
||||
absl::debugging_internal::VDSOSupport::SymbolInfo vsyscall_symbol_info;
|
||||
if (!vdso.LookupSymbol("__kernel_rt_sigreturn", "LINUX_2.5", STT_FUNC,
|
||||
&rt_sigreturn_symbol_info) ||
|
||||
!vdso.LookupSymbol("__kernel_vsyscall", "LINUX_2.5", STT_FUNC,
|
||||
|
|
@ -221,7 +221,7 @@ static void **NextStackFrame(void **old_fp, const void *uc) {
|
|||
// "double fault" in case we hit the first fault due to e.g. stack
|
||||
// corruption.
|
||||
void *const reg_esp2 = reg_esp[num_push_instructions - 1];
|
||||
if (absl::debug_internal::AddressIsReadable(reg_esp2)) {
|
||||
if (absl::debugging_internal::AddressIsReadable(reg_esp2)) {
|
||||
// Alleged %esp is readable, use it for further unwinding.
|
||||
new_fp = reinterpret_cast<void **>(reg_esp2);
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ static void **NextStackFrame(void **old_fp, const void *uc) {
|
|||
// Note: NextStackFrame<false>() is only called while the program
|
||||
// is already on its last leg, so it's ok to be slow here.
|
||||
|
||||
if (!absl::debug_internal::AddressIsReadable(new_fp)) {
|
||||
if (!absl::debugging_internal::AddressIsReadable(new_fp)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,18 +38,18 @@
|
|||
#endif
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
ABSL_CONST_INIT
|
||||
std::atomic<const void *> VDSOSupport::vdso_base_(
|
||||
debug_internal::ElfMemImage::kInvalidBase);
|
||||
debugging_internal::ElfMemImage::kInvalidBase);
|
||||
|
||||
std::atomic<VDSOSupport::GetCpuFn> VDSOSupport::getcpu_fn_(&InitAndGetCPU);
|
||||
VDSOSupport::VDSOSupport()
|
||||
// If vdso_base_ is still set to kInvalidBase, we got here
|
||||
// before VDSOSupport::Init has been called. Call it now.
|
||||
: image_(vdso_base_.load(std::memory_order_relaxed) ==
|
||||
debug_internal::ElfMemImage::kInvalidBase
|
||||
debugging_internal::ElfMemImage::kInvalidBase
|
||||
? Init()
|
||||
: vdso_base_.load(std::memory_order_relaxed)) {}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ VDSOSupport::VDSOSupport()
|
|||
// Finally, even if there is a race here, it is harmless, because
|
||||
// the operation should be idempotent.
|
||||
const void *VDSOSupport::Init() {
|
||||
const auto kInvalidBase = debug_internal::ElfMemImage::kInvalidBase;
|
||||
const auto kInvalidBase = debugging_internal::ElfMemImage::kInvalidBase;
|
||||
#if __GLIBC_PREREQ(2, 16)
|
||||
if (vdso_base_.load(std::memory_order_relaxed) == kInvalidBase) {
|
||||
errno = 0;
|
||||
|
|
@ -120,7 +120,7 @@ const void *VDSOSupport::Init() {
|
|||
}
|
||||
|
||||
const void *VDSOSupport::SetBase(const void *base) {
|
||||
ABSL_RAW_CHECK(base != debug_internal::ElfMemImage::kInvalidBase,
|
||||
ABSL_RAW_CHECK(base != debugging_internal::ElfMemImage::kInvalidBase,
|
||||
"internal error");
|
||||
const void *old_base = vdso_base_.load(std::memory_order_relaxed);
|
||||
vdso_base_.store(base, std::memory_order_relaxed);
|
||||
|
|
@ -186,7 +186,7 @@ static class VDSOInitHelper {
|
|||
VDSOInitHelper() { VDSOSupport::Init(); }
|
||||
} vdso_init_helper;
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HAVE_VDSO_SUPPORT
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
#endif
|
||||
|
||||
namespace absl {
|
||||
namespace debug_internal {
|
||||
namespace debugging_internal {
|
||||
|
||||
// NOTE: this class may be used from within tcmalloc, and can not
|
||||
// use any memory allocation routines.
|
||||
|
|
@ -147,7 +147,7 @@ class VDSOSupport {
|
|||
// support SYS_getcpu.
|
||||
int GetCPU();
|
||||
|
||||
} // namespace debug_internal
|
||||
} // namespace debugging_internal
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HAVE_ELF_MEM_IMAGE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue