#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/location.h"
#include "base/compiler_specific.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/base_tracing.h"
#if defined(COMPILER_MSVC)
#include <intrin.h>
#endif
namespace base {
namespace {
constexpr size_t StrLen(const char* str) { … }
constexpr size_t StrippedFilePathPrefixLength() { … }
constexpr size_t kStrippedPrefixLength = …;
constexpr bool StrEndsWith(const char* name,
size_t prefix_len,
const char* expected) { … }
#if defined(__clang__) && defined(_MSC_VER)
static_assert(StrEndsWith(__FILE__, kStrippedPrefixLength, "base\\location.cc"),
"The file name does not match the expected prefix format.");
#else
static_assert …;
#endif
}
Location::Location() = default;
Location::Location(const Location& other) = default;
Location::Location(Location&& other) noexcept = default;
Location& Location::operator=(const Location& other) = default;
Location::Location(const char* file_name, const void* program_counter)
: … { … }
Location::Location(const char* function_name,
const char* file_name,
int line_number,
const void* program_counter)
: … { … }
std::string Location::ToString() const { … }
void Location::WriteIntoTrace(perfetto::TracedValue context) const { … }
#if defined(COMPILER_MSVC)
#define RETURN_ADDRESS …
#elif defined(COMPILER_GCC) && !BUILDFLAG(IS_NACL)
#define RETURN_ADDRESS() …
#else
#define RETURN_ADDRESS …
#endif
NOINLINE Location Location::Current(const char* function_name,
const char* file_name,
int line_number) { … }
NOINLINE const void* GetProgramCounter() { … }
}