// // Dis VM - exec program // File: exec.h // Author: arr // #ifndef _DISVM_SRC_EXEC_EXEC_H_ #define _DISVM_SRC_EXEC_EXEC_H_ #include #include #include #include #include #include #include #include #include enum class debugger_options { none = 0, break_on_enter = (1 << 0), break_on_module_load = (1 << 1), break_on_exception = (1 << 2), disable_symbol_loading = (1 << 3), }; DEFINE_ENUM_FLAG_OPERATORS(debugger_options); std::ostream& operator<<(std::ostream &ss, const debugger_options o); class debugger final : public disvm::runtime::vm_tool_t { public: debugger(const debugger_options); // Resolve all PCs in the range from begin and end (inclusive) std::vector resolve_to_function_source_line( disvm::runtime::module_id_t vm_id, disvm::runtime::vm_pc_t begin_pc, disvm::runtime::vm_pc_t end_pc, disvm::symbol::function_name_format_t fmt) const; // Return all functions for the supplied module ID. // Optionally match a function against the supplied string. std::vector get_module_functions(disvm::runtime::module_id_t vm_id, const char *match) const; // Check if the supplied module ID has symbols loaded bool symbols_exist(disvm::runtime::module_id_t vm_id) const; // Get/set debugger option std::string get_option(const std::string &option) const; void set_option(const std::string &option, std::string value); public: // vm_tool_t void on_load(disvm::runtime::vm_tool_controller_t &, std::size_t tool_id) override; void on_unload() override; public: disvm::runtime::vm_tool_controller_t *controller; std::unordered_set breakpoint_cookies; bool first_break; private: void load_symbols(const disvm::loaded_vm_module_t &); debugger_options _options; std::size_t _tool_id; std::unordered_set _event_cookies; struct symbol_info_t { std::unique_ptr data; std::unique_ptr iter; }; std::unordered_map _vm_id_to_symbol_info; std::unordered_map _debugger_options; }; #endif // _DISVM_SRC_EXEC_EXEC_H_