summaryrefslogtreecommitdiff
path: root/libsanitizer/sanitizer_common/sanitizer_common.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libsanitizer/sanitizer_common/sanitizer_common.cc')
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_common.cc43
1 files changed, 9 insertions, 34 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_common.cc b/libsanitizer/sanitizer_common/sanitizer_common.cc
index 8d7e9fae64e..7f0f47c005d 100644
--- a/libsanitizer/sanitizer_common/sanitizer_common.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_common.cc
@@ -12,11 +12,10 @@
#include "sanitizer_common.h"
#include "sanitizer_allocator_interface.h"
#include "sanitizer_allocator_internal.h"
+#include "sanitizer_atomic.h"
#include "sanitizer_flags.h"
#include "sanitizer_libc.h"
#include "sanitizer_placement_new.h"
-#include "sanitizer_stacktrace_printer.h"
-#include "sanitizer_symbolizer.h"
namespace __sanitizer {
@@ -24,6 +23,7 @@ const char *SanitizerToolName = "SanitizerTool";
atomic_uint32_t current_verbosity;
uptr PageSizeCached;
+u32 NumberOfCPUsCached;
// PID of the tracer task in StopTheWorld. It shares the address space with the
// main process, but has a different PID and thus requires special handling.
@@ -32,15 +32,14 @@ uptr stoptheworld_tracer_pid = 0;
// writing to the same log file.
uptr stoptheworld_tracer_ppid = 0;
-StaticSpinMutex CommonSanitizerReportMutex;
-
void NORETURN ReportMmapFailureAndDie(uptr size, const char *mem_type,
const char *mmap_type, error_t err,
bool raw_report) {
static int recursion_count;
- if (raw_report || recursion_count) {
- // If raw report is requested or we went into recursion, just die.
- // The Report() and CHECK calls below may call mmap recursively and fail.
+ if (SANITIZER_RTEMS || raw_report || recursion_count) {
+ // If we are on RTEMS or raw report is requested or we went into recursion,
+ // just die. The Report() and CHECK calls below may call mmap recursively
+ // and fail.
RawWrite("ERROR: Failed to mmap\n");
Die();
}
@@ -57,19 +56,6 @@ void NORETURN ReportMmapFailureAndDie(uptr size, const char *mem_type,
typedef bool UptrComparisonFunction(const uptr &a, const uptr &b);
typedef bool U32ComparisonFunction(const u32 &a, const u32 &b);
-template<class T>
-static inline bool CompareLess(const T &a, const T &b) {
- return a < b;
-}
-
-void SortArray(uptr *array, uptr size) {
- InternalSort<uptr*, UptrComparisonFunction>(&array, size, CompareLess);
-}
-
-void SortArray(u32 *array, uptr size) {
- InternalSort<u32*, U32ComparisonFunction>(&array, size, CompareLess);
-}
-
const char *StripPathPrefix(const char *filepath,
const char *strip_path_prefix) {
if (!filepath) return nullptr;
@@ -106,18 +92,6 @@ void ReportErrorSummary(const char *error_message, const char *alt_tool_name) {
__sanitizer_report_error_summary(buff.data());
}
-#if !SANITIZER_GO
-void ReportErrorSummary(const char *error_type, const AddressInfo &info,
- const char *alt_tool_name) {
- if (!common_flags()->print_summary) return;
- InternalScopedString buff(kMaxSummaryLength);
- buff.append("%s ", error_type);
- RenderFrame(&buff, "%L %F", 0, info, common_flags()->symbolize_vs_style,
- common_flags()->strip_path_prefix);
- ReportErrorSummary(buff.data(), alt_tool_name);
-}
-#endif
-
// Removes the ANSI escape sequences from the input string (in-place).
void RemoveANSIEscapeSequencesFromString(char *str) {
if (!str)
@@ -357,8 +331,9 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_report_error_summary,
}
SANITIZER_INTERFACE_ATTRIBUTE
-void __sanitizer_set_death_callback(void (*callback)(void)) {
- SetUserDieCallback(callback);
+int __sanitizer_acquire_crash_state() {
+ static atomic_uint8_t in_crash_state = {};
+ return !atomic_exchange(&in_crash_state, 1, memory_order_relaxed);
}
SANITIZER_INTERFACE_ATTRIBUTE