1 // license:BSD-3-Clause 2 // copyright-holders:Aaron Giles 3 /*************************************************************************** 4 5 points.h 6 7 Debugger breakpoints, watchpoints, etc. 8 9 ***************************************************************************/ 10 11 #ifndef MAME_EMU_DEBUG_POINTS_H 12 #define MAME_EMU_DEBUG_POINTS_H 13 14 #pragma once 15 16 #include "debugcpu.h" 17 #include "express.h" 18 19 20 //************************************************************************** 21 // TYPE DEFINITIONS 22 //************************************************************************** 23 24 25 // ======================> debug_breakpoint 26 27 class debug_breakpoint 28 { 29 friend class device_debug; 30 31 public: 32 // construction/destruction 33 debug_breakpoint( 34 device_debug* debugInterface, 35 symbol_table &symbols, 36 int index, 37 offs_t address, 38 const char *condition = nullptr, 39 const char *action = nullptr); 40 41 // getters debugInterface()42 const device_debug *debugInterface() const { return m_debugInterface; } index()43 int index() const { return m_index; } enabled()44 bool enabled() const { return m_enabled; } address()45 offs_t address() const { return m_address; } condition()46 const char *condition() const { return m_condition.original_string(); } action()47 const char *action() const { return m_action.c_str(); } 48 49 // setters setEnabled(bool value)50 void setEnabled(bool value) { m_enabled = value; } 51 52 private: 53 // internals 54 bool hit(offs_t pc); 55 const device_debug * m_debugInterface; // the interface we were created from 56 int m_index; // user reported index 57 bool m_enabled; // enabled? 58 offs_t m_address; // execution address 59 parsed_expression m_condition; // condition 60 std::string m_action; // action 61 }; 62 63 // ======================> debug_watchpoint 64 65 class debug_watchpoint 66 { 67 friend class device_debug; 68 69 public: 70 // construction/destruction 71 debug_watchpoint( 72 device_debug* debugInterface, 73 symbol_table &symbols, 74 int index, 75 address_space &space, 76 read_or_write type, 77 offs_t address, 78 offs_t length, 79 const char *condition = nullptr, 80 const char *action = nullptr); 81 ~debug_watchpoint(); 82 83 // getters debugInterface()84 const device_debug *debugInterface() const { return m_debugInterface; } space()85 address_space &space() const { return m_space; } index()86 int index() const { return m_index; } type()87 read_or_write type() const { return m_type; } enabled()88 bool enabled() const { return m_enabled; } address()89 offs_t address() const { return m_address; } length()90 offs_t length() const { return m_length; } condition()91 const char *condition() const { return m_condition.original_string(); } action()92 const std::string &action() const { return m_action; } 93 94 // setters 95 void setEnabled(bool value); 96 97 // internals 98 bool hit(int type, offs_t address, int size); 99 100 private: 101 void install(read_or_write mode); 102 void triggered(read_or_write type, offs_t address, u64 data, u64 mem_mask); 103 104 device_debug * m_debugInterface; // the interface we were created from 105 memory_passthrough_handler *m_phr; // passthrough handler reference, read access 106 memory_passthrough_handler *m_phw; // passthrough handler reference, write access 107 address_space & m_space; // address space 108 int m_index; // user reported index 109 bool m_enabled; // enabled? 110 read_or_write m_type; // type (read/write) 111 offs_t m_address; // start address 112 offs_t m_length; // length of watch area 113 parsed_expression m_condition; // condition 114 std::string m_action; // action 115 int m_notifier; // address map change notifier id 116 117 offs_t m_start_address[3]; // the start addresses of the checks to install 118 offs_t m_end_address[3]; // the end addresses 119 u64 m_masks[3]; // the access masks 120 bool m_installing; // prevent recursive multiple installs 121 }; 122 123 // ======================> debug_registerpoint 124 125 class debug_registerpoint 126 { 127 friend class device_debug; 128 129 public: 130 // construction/destruction 131 debug_registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = nullptr); 132 133 // getters index()134 int index() const { return m_index; } enabled()135 bool enabled() const { return m_enabled; } condition()136 const char *condition() const { return m_condition.original_string(); } action()137 const char *action() const { return m_action.c_str(); } 138 139 private: 140 // internals 141 bool hit(); 142 143 int m_index; // user reported index 144 bool m_enabled; // enabled? 145 parsed_expression m_condition; // condition 146 std::string m_action; // action 147 }; 148 149 #endif // MAME_EMU_DEBUG_POINTS_H 150