#include #include #include #include #include #include #include #include #include #include DwarfInterpret::DwarfInterpret(const std::string& elf_path) : root_die(fileno(std::ifstream(elf_path))) { //std::ifstream file_in(elf_path); //root_die = dwarf::core::root_die(fileno(file_in)); // FIXME this ^ deserves some checks. But this looks tedious. GElf_Ehdr ehdr; GElf_Ehdr *ret = gelf_getehdr(root_die.get_elf(), &ehdr); assert(ret != 0); elf_machine = ehdr.e_machine; } DwarfInterpret& DwarfInterpret::acquire() { if(DwarfInterpret::instance == nullptr) throw NotInstanciated(); return *(DwarfInterpret::instance); } DwarfInterpret& DwarfInterpret::instanciate(const std::string& elf_path) { if(DwarfInterpret::instance != nullptr) throw AlreadyInstanciated(); DwarfInterpret::instance = std::unique_ptr( new DwarfInterpret(elf_path)); return *(DwarfInterpret::instance); }