dwarfinterpret/include/DwarfInterpret.hpp

41 lines
1.1 KiB
C++

#pragma once
#include <string>
#include <memory>
#include <dwarfpp/root.hpp>
class DwarfInterpret {
/** Singleton class holding a Dwarf interpret.
* Must be first instanciated with the path to the binary being run, with a
* call to `instanciate`, and can afterwards be accessed with calls to
* `acquire`.
*/
public:
class NotInstanciated: public std::exception {};
class AlreadyInstanciated: public std::exception {};
DwarfInterpret(DwarfInterpret const&) = delete;
void operator=(DwarfInterpret const&) = delete;
static DwarfInterpret& acquire();
static DwarfInterpret& instanciate(const std::string& elf_path);
int get_elf_machine() const { return elf_machine; }
// FIXME DEBUG vvv
void dbg_dump_ra();
private:
DwarfInterpret(const std::string& elf_path);
private: // members
static std::unique_ptr<DwarfInterpret> instance;
dwarf::core::root_die root_die;
int elf_machine;
friend class std::unique_ptr<DwarfInterpret>;
};