#include "components/gwp_asan/crash_handler/crash_analyzer.h"
#include <cstdint>
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/debug/stack_trace.h"
#include "base/functional/callback_helpers.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "components/gwp_asan/client/guarded_page_allocator.h"
#include "components/gwp_asan/client/gwp_asan.h"
#include "components/gwp_asan/client/lightweight_detector/poison_metadata_recorder.h"
#include "components/gwp_asan/common/allocator_state.h"
#include "components/gwp_asan/common/crash_key_name.h"
#include "components/gwp_asan/common/lightweight_detector_state.h"
#include "components/gwp_asan/crash_handler/crash.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/crashpad/crashpad/client/annotation.h"
#include "third_party/crashpad/crashpad/snapshot/annotation_snapshot.h"
#include "third_party/crashpad/crashpad/snapshot/cpu_architecture.h"
#include "third_party/crashpad/crashpad/snapshot/cpu_context.h"
#include "third_party/crashpad/crashpad/snapshot/test/test_exception_snapshot.h"
#include "third_party/crashpad/crashpad/snapshot/test/test_module_snapshot.h"
#include "third_party/crashpad/crashpad/snapshot/test/test_process_snapshot.h"
#include "third_party/crashpad/crashpad/test/process_type.h"
#include "third_party/crashpad/crashpad/util/process/process_memory_native.h"
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "third_party/crashpad/crashpad/test/linux/fake_ptrace_connection.h"
#endif
namespace gwp_asan {
namespace internal {
namespace {
void SetNonCanonicalAccessAddress(
crashpad::test::TestExceptionSnapshot& exception,
crashpad::VMAddress address) { … }
constexpr const char* kMallocHistogramName = …;
constexpr const char* kPartitionAllocHistogramName = …;
}
class BaseCrashAnalyzerTest : public testing::Test { … };
class CrashAnalyzerTest : public BaseCrashAnalyzerTest { … };
#if !BUILDFLAG(IS_ANDROID) || !BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
TEST_F(CrashAnalyzerTest, DISABLED_StackTraceCollection) { … }
#endif
TEST_F(CrashAnalyzerTest, InternalError) { … }
#if defined(ARCH_CPU_64_BITS)
class LightweightDetectorAnalyzerTest
: public BaseCrashAnalyzerTest,
public testing::WithParamInterface<LightweightDetectorMode> { … };
extern Crash_Mode LightweightDetectorModeToGwpAsanMode(
LightweightDetectorMode mode);
TEST_P(LightweightDetectorAnalyzerTest, UseAfterFree) { … }
TEST_P(LightweightDetectorAnalyzerTest, InternalError) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
}
}