2018-03-28 15:33:36 +02:00
|
|
|
#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);
|
|
|
|
|
2018-03-28 16:03:43 +02:00
|
|
|
int get_elf_machine() const { return elf_machine; }
|
|
|
|
|
|
|
|
// FIXME DEBUG vvv
|
|
|
|
void dbg_dump_ra();
|
|
|
|
|
2018-03-28 15:33:36 +02:00
|
|
|
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>;
|
|
|
|
};
|