1018981977
libsanitizer/ * All source files: Merge from upstream 285547. * configure.tgt (SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS): New variable. * configure.ac (SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS): Handle it. * asan/Makefile.am (asan_files): Add new files. * asan/Makefile.in: Regenerate. * ubsan/Makefile.in: Likewise. * lsan/Makefile.in: Likewise. * tsan/Makefile.am (tsan_files): Add new files. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. (EXTRA_libsanitizer_common_la_SOURCES): Define. (libsanitizer_common_la_LIBADD): Likewise. (libsanitizer_common_la_DEPENDENCIES): Likewise. * sanitizer_common/Makefile.in: Regenerate. * interception/Makefile.in: Likewise. * libbacktace/Makefile.in: Likewise. * Makefile.in: Likewise. * configure: Likewise. * merge.sh: Handle builtins/assembly.h merging. * builtins/assembly.h: New file. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r241977
73 lines
2.2 KiB
C++
73 lines
2.2 KiB
C++
//===-- asan_scariness_score.h ----------------------------------*- C++ -*-===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
//
|
|
// Compute the level of scariness of the error message.
|
|
// Don't expect any deep science here, just a set of heuristics that suggest
|
|
// that e.g. 1-byte-read-global-buffer-overflow is less scary than
|
|
// 8-byte-write-stack-use-after-return.
|
|
//
|
|
// Every error report has one or more features, such as memory access size,
|
|
// type (read or write), type of accessed memory (e.g. free-d heap, or a global
|
|
// redzone), etc. Every such feature has an int score and a string description.
|
|
// The overall score is the sum of all feature scores and the description
|
|
// is a concatenation of feature descriptions.
|
|
// Examples:
|
|
// 17 (4-byte-read-heap-buffer-overflow)
|
|
// 65 (multi-byte-write-stack-use-after-return)
|
|
// 10 (null-deref)
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef ASAN_SCARINESS_SCORE_H
|
|
#define ASAN_SCARINESS_SCORE_H
|
|
|
|
#include "asan_flags.h"
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
|
|
|
namespace __asan {
|
|
struct ScarinessScoreBase {
|
|
void Clear() {
|
|
descr[0] = 0;
|
|
score = 0;
|
|
}
|
|
void Scare(int add_to_score, const char *reason) {
|
|
if (descr[0])
|
|
internal_strlcat(descr, "-", sizeof(descr));
|
|
internal_strlcat(descr, reason, sizeof(descr));
|
|
score += add_to_score;
|
|
};
|
|
int GetScore() const { return score; }
|
|
const char *GetDescription() const { return descr; }
|
|
void Print() {
|
|
if (score && flags()->print_scariness)
|
|
Printf("SCARINESS: %d (%s)\n", score, descr);
|
|
}
|
|
static void PrintSimple(int score, const char *descr) {
|
|
ScarinessScoreBase SSB;
|
|
SSB.Clear();
|
|
SSB.Scare(score, descr);
|
|
SSB.Print();
|
|
}
|
|
|
|
private:
|
|
int score;
|
|
char descr[1024];
|
|
};
|
|
|
|
struct ScarinessScore : ScarinessScoreBase {
|
|
ScarinessScore() {
|
|
Clear();
|
|
}
|
|
};
|
|
|
|
} // namespace __asan
|
|
|
|
#endif // ASAN_SCARINESS_SCORE_H
|