#ifndef BASE_PROFILER_STACK_SAMPLING_PROFILER_TEST_UTIL_H_
#define BASE_PROFILER_STACK_SAMPLING_PROFILER_TEST_UTIL_H_
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "base/base_export.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/native_library.h"
#include "base/profiler/frame.h"
#include "base/profiler/module_cache.h"
#include "base/profiler/sampling_profiler_thread_token.h"
#include "base/profiler/stack_sampling_profiler.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
namespace base {
class Unwinder;
class TargetThread : public PlatformThread::Delegate { … };
struct FunctionAddressRange { … };
class UnwindScenario { … };
class TestModule : public ModuleCache::Module { … };
bool operator==(const Frame& a, const Frame& b);
FunctionAddressRange CallWithPlainFunction(OnceClosure wait_for_sample);
FunctionAddressRange CallWithAlloca(OnceClosure wait_for_sample);
FunctionAddressRange CallThroughOtherLibrary(NativeLibrary library,
OnceClosure wait_for_sample);
ProfileCallback;
void WithTargetThread(UnwindScenario* scenario,
ProfileCallback profile_callback);
UnwinderFactory;
std::vector<Frame> SampleScenario(
UnwindScenario* scenario,
ModuleCache* module_cache,
UnwinderFactory aux_unwinder_factory = UnwinderFactory());
std::string FormatSampleForDiagnosticOutput(const std::vector<Frame>& sample);
void ExpectStackContains(const std::vector<Frame>& stack,
const std::vector<FunctionAddressRange>& functions);
void ExpectStackDoesNotContain(
const std::vector<Frame>& stack,
const std::vector<FunctionAddressRange>& functions);
NativeLibrary LoadTestLibrary(std::string_view library_name);
NativeLibrary LoadOtherLibrary();
uintptr_t GetAddressInOtherLibrary(NativeLibrary library);
StackSamplingProfiler::UnwindersFactory CreateCoreUnwindersFactoryForTesting(
ModuleCache* module_cache);
}
#endif