#pragma once
#include <folly/Range.h>
#include <folly/debugging/symbolizer/DwarfUtil.h>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
namespace folly {
namespace symbolizer {
#if FOLLY_HAVE_DWARF && FOLLY_HAVE_ELF
class DwarfLineNumberVM {
public:
DwarfLineNumberVM(
folly::StringPiece data,
folly::StringPiece compilationDirectory,
const DebugSections& debugSections);
bool findAddress(uintptr_t target, Path& file, uint64_t& line);
Path getFullFileName(uint64_t index) const;
private:
bool init();
void reset();
bool next(folly::StringPiece& program);
enum StepResult {
CONTINUE,
COMMIT,
END,
};
StepResult step(folly::StringPiece& program);
struct FileName {
folly::StringPiece relativeName;
uint64_t directoryIndex;
};
static bool readFileName(folly::StringPiece& program, FileName& fn);
FileName getFileName(uint64_t index) const;
folly::StringPiece getIncludeDirectory(uint64_t index) const;
bool nextDefineFile(folly::StringPiece& program, FileName& fn) const;
bool initializationSuccess_ = false;
bool is64Bit_;
folly::StringPiece data_;
folly::StringPiece compilationDirectory_;
const DebugSections& debugSections_;
uint16_t version_;
uint8_t minLength_;
bool defaultIsStmt_;
int8_t lineBase_;
uint8_t lineRange_;
uint8_t opcodeBase_;
const uint8_t* standardOpcodeLengths_;
struct {
size_t includeDirectoryCount;
folly::StringPiece includeDirectories;
size_t fileNameCount;
folly::StringPiece fileNames;
} v4_;
struct {
uint8_t directoryEntryFormatCount;
folly::StringPiece directoryEntryFormat;
uint64_t directoriesCount;
folly::StringPiece directories;
uint8_t fileNameEntryFormatCount;
folly::StringPiece fileNameEntryFormat;
uint64_t fileNamesCount;
folly::StringPiece fileNames;
} v5_;
uint64_t address_;
uint64_t file_;
uint64_t line_;
uint64_t column_;
bool isStmt_;
bool basicBlock_;
bool endSequence_;
bool prologueEnd_;
bool epilogueBegin_;
uint64_t isa_;
uint64_t discriminator_;
};
#endif
}
}