// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details #pragma once #include "Luau/RegisterX64.h" #include "UnwindBuilder.h" #include namespace Luau { namespace CodeGen { struct UnwindFunctionDwarf2 { uint32_t beginOffset; uint32_t endOffset; uint32_t fdeEntryStartPos; }; class UnwindBuilderDwarf2 : public UnwindBuilder { public: void setBeginOffset(size_t beginOffset) override; size_t getBeginOffset() const override; void startInfo(Arch arch) override; void startFunction() override; void finishFunction(uint32_t beginOffset, uint32_t endOffset) override; void finishInfo() override; void prologueA64(uint32_t prologueSize, uint32_t stackSize, std::initializer_list regs) override; void prologueX64(uint32_t prologueSize, uint32_t stackSize, bool setupFrame, std::initializer_list regs) override; size_t getSize() const override; size_t getFunctionCount() const override; void finalize(char* target, size_t offset, void* funcAddress, size_t funcSize) const override; private: size_t beginOffset = 0; std::vector unwindFunctions; static const unsigned kRawDataLimit = 1024; uint8_t rawData[kRawDataLimit]; uint8_t* pos = rawData; // We will remember the FDE location to write some of the fields like entry length, function start and size later uint8_t* fdeEntryStart = nullptr; }; } // namespace CodeGen } // namespace Luau