#ifndef _BPKTMANAGER_H_ #define _BPKTMANAGER_H_ #include "ThreadContext.h" #include "ProcessContext.h" #include "codesnipmanager.h" #include #include #include enum bpt_types { BPT_EMULATE, BPT_BRANCH, BPT_EMULATEPC, BPT_USERREQUEST }; class breakpoint_manager; class breakpoint_action { protected: breakpoint_manager& _bpm; ThreadContext& _td; public: breakpoint_action(breakpoint_manager& bpm, ThreadContext& td) : _bpm(bpm), _td(td) { } virtual void action() const=0; virtual int type() const=0; virtual std::string description() const=0; bool temporary() { return type()!=BPT_USERREQUEST; } }; typedef boost::shared_ptr breakpoint_action_ptr; class breakpoint_manager { // todo: change to multi_map, to allow multiple breakpoints to be active per address typedef std::map breakpointmap_t; breakpointmap_t _bpts; codesnip_manager& _codemgr; public: breakpoint_manager(codesnip_manager& codemgr) : _codemgr(codemgr) { } void reg_bpt(VirtualAddress bpaddr, breakpoint_action* action); void del_bpt(VirtualAddress bpaddr); void handle_bpt(ThreadContext& td); void removecode(VirtualAddress ofs) { _codemgr.remove(ofs); } uint32_t codeforinsn(ProcessContext_ptr proc, uint32_t insn) { return _codemgr.codeforinsn(proc, insn); } // uint32_t codeforinsn(ProcessContext_ptr proc, uint32_t insn1, uint32_t insn2); }; #endif