#ifndef _LIBUNWINDSTACK_LOCAL_UNWINDER_H
#define _LIBUNWINDSTACK_LOCAL_UNWINDER_H
#include <pthread.h>
#include <stdint.h>
#include <sys/types.h>
#include <memory>
#include <string>
#include <vector>
#include <unwindstack/Error.h>
#include <unwindstack/Maps.h>
#include <unwindstack/Memory.h>
namespace unwindstack {
class Elf;
struct MapInfo;
struct LocalFrameData {
LocalFrameData(MapInfo* map_info, uint64_t pc, uint64_t rel_pc, const std::string& function_name,
uint64_t function_offset)
: map_info(map_info),
pc(pc),
rel_pc(rel_pc),
function_name(function_name),
function_offset(function_offset) {}
MapInfo* map_info;
uint64_t pc;
uint64_t rel_pc;
std::string function_name;
uint64_t function_offset;
};
class LocalUnwinder {
public:
LocalUnwinder() = default;
LocalUnwinder(const std::vector<std::string>& skip_libraries) : skip_libraries_(skip_libraries) {}
~LocalUnwinder() = default;
bool Init();
bool Unwind(std::vector<LocalFrameData>* frame_info, size_t max_frames);
bool ShouldSkipLibrary(const std::string& map_name);
MapInfo* GetMapInfo(uint64_t pc);
ErrorCode LastErrorCode() { return last_error_.code; }
uint64_t LastErrorAddress() { return last_error_.address; }
private:
pthread_rwlock_t maps_rwlock_;
std::unique_ptr<LocalUpdatableMaps> maps_ = nullptr;
std::shared_ptr<Memory> process_memory_;
std::vector<std::string> skip_libraries_;
ErrorData last_error_;
};
}
#endif