summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/points.h
blob: 84cdad7720bd4c0af4837eb7ea7c159f94ae1c24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************

    points.h

    Debugger breakpoints, watchpoints, etc.

***************************************************************************/

#ifndef MAME_EMU_DEBUG_POINTS_H
#define MAME_EMU_DEBUG_POINTS_H

#pragma once

#include "debugcpu.h"
#include "express.h"


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************


// ======================> debug_breakpoint

class debug_breakpoint
{
	friend class device_debug;

public:
	// construction/destruction
	debug_breakpoint(
					device_debug* debugInterface,
					symbol_table &symbols,
					int index,
					offs_t address,
					const char *condition = nullptr,
					const char *action = nullptr);

	// getters
	const device_debug *debugInterface() const { return m_debugInterface; }
	int index() const { return m_index; }
	bool enabled() const { return m_enabled; }
	offs_t address() const { return m_address; }
	const char *condition() const { return m_condition.original_string(); }
	const char *action() const { return m_action.c_str(); }

	// setters
	void setEnabled(bool value) { m_enabled = value; } // FIXME: need to update breakpoint flags but it's a private method

private:
	// internals
	bool hit(offs_t pc);
	const device_debug * m_debugInterface;           // the interface we were created from
	int                  m_index;                    // user reported index
	bool                 m_enabled;                  // enabled?
	offs_t               m_address;                  // execution address
	parsed_expression    m_condition;                // condition
	std::string          m_action;                   // action
};

// ======================> debug_watchpoint

class debug_watchpoint
{
	friend class device_debug;

public:
	// construction/destruction
	debug_watchpoint(
					device_debug* debugInterface,
					symbol_table &symbols,
					int index,
					address_space &space,
					read_or_write type,
					offs_t address,
					offs_t length,
					const char *condition = nullptr,
					const char *action = nullptr);
	~debug_watchpoint();

	// getters
	const device_debug *debugInterface() const { return m_debugInterface; }
	address_space &space() const { return m_space; }
	int index() const { return m_index; }
	read_or_write type() const { return m_type; }
	bool enabled() const { return m_enabled; }
	offs_t address() const { return m_address; }
	offs_t length() const { return m_length; }
	const char *condition() const { return m_condition.original_string(); }
	const std::string &action() const { return m_action; }

	// setters
	void setEnabled(bool value);

	// internals
	bool hit(int type, offs_t address, int size);

private:
	void install(read_or_write mode);
	void triggered(read_or_write type, offs_t address, u64 data, u64 mem_mask);

	device_debug * m_debugInterface;                 // the interface we were created from
	memory_passthrough_handler *m_phr;               // passthrough handler reference, read access
	memory_passthrough_handler *m_phw;               // passthrough handler reference, write access
	address_space &      m_space;                    // address space
	int                  m_index;                    // user reported index
	bool                 m_enabled;                  // enabled?
	read_or_write        m_type;                     // type (read/write)
	offs_t               m_address;                  // start address
	offs_t               m_length;                   // length of watch area
	parsed_expression    m_condition;                // condition
	std::string          m_action;                   // action
	int                  m_notifier;                 // address map change notifier id

	offs_t               m_start_address[3];         // the start addresses of the checks to install
	offs_t               m_end_address[3];           // the end addresses
	u64                  m_masks[3];                 // the access masks
	bool                 m_installing;               // prevent recursive multiple installs
};

// ======================> debug_registerpoint

class debug_registerpoint
{
	friend class device_debug;

public:
	// construction/destruction
	debug_registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = nullptr);

	// getters
	int index() const { return m_index; }
	bool enabled() const { return m_enabled; }
	const char *condition() const { return m_condition.original_string(); }
	const char *action() const { return m_action.c_str(); }

private:
	// internals
	bool hit();

	int                 m_index;                    // user reported index
	bool                m_enabled;                  // enabled?
	parsed_expression   m_condition;                // condition
	std::string         m_action;                   // action
};

#endif // MAME_EMU_DEBUG_POINTS_H