File: BreakPoints.h

package info (click to toggle)
dolphin-emu 5.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 29,052 kB
  • sloc: cpp: 213,146; java: 6,252; asm: 2,277; xml: 1,998; ansic: 1,514; python: 462; sh: 279; pascal: 247; makefile: 124; perl: 97
file content (136 lines) | stat: -rw-r--r-- 2,520 bytes parent folder | download | duplicates (2)
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
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <string>
#include <vector>

#include "Common/CommonTypes.h"

class DebugInterface;

struct TBreakPoint
{
	u32  iAddress;
	bool bOn;
	bool bTemporary;
};

struct TMemCheck
{
	TMemCheck()
	{
		numHits = 0;
		StartAddress = EndAddress = 0;
		bRange = OnRead = OnWrite = Log = Break = false;
	}

	u32 StartAddress;
	u32 EndAddress;

	bool bRange;

	bool OnRead;
	bool OnWrite;

	bool Log;
	bool Break;

	u32 numHits;

	// returns whether to break
	bool Action(DebugInterface* dbg_interface, u32 _iValue, u32 addr,
	            bool write, int size, u32 pc);
};

struct TWatch
{
	std::string name = "";
	u32  iAddress;
	bool bOn;
};

// Code breakpoints.
class BreakPoints
{
public:
	typedef std::vector<TBreakPoint> TBreakPoints;
	typedef std::vector<std::string> TBreakPointsStr;

	const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }

	TBreakPointsStr GetStrings() const;
	void AddFromStrings(const TBreakPointsStr& bps);

	// is address breakpoint
	bool IsAddressBreakPoint(u32 address) const;
	bool IsTempBreakPoint(u32 address) const;

	// Add BreakPoint
	void Add(u32 em_address, bool temp = false);
	void Add(const TBreakPoint& bp);

	// Remove Breakpoint
	void Remove(u32 _iAddress);
	void Clear();
	void ClearAllTemporary();

private:
	TBreakPoints m_BreakPoints;
};


// Memory breakpoints
class MemChecks
{
public:
	typedef std::vector<TMemCheck> TMemChecks;
	typedef std::vector<std::string> TMemChecksStr;

	TMemChecks m_MemChecks;

	const TMemChecks& GetMemChecks() { return m_MemChecks; }

	TMemChecksStr GetStrings() const;
	void AddFromStrings(const TMemChecksStr& mcs);

	void Add(const TMemCheck& _rMemoryCheck);

	// memory breakpoint
	TMemCheck* GetMemCheck(u32 address);
	void Remove(u32 _Address);

	void Clear() { m_MemChecks.clear(); }

	bool HasAny() const { return !m_MemChecks.empty(); }
};

class Watches
{
public:
	typedef std::vector<TWatch> TWatches;
	typedef std::vector<std::string> TWatchesStr;

	const TWatches& GetWatches() { return m_Watches; }

	TWatchesStr GetStrings() const;
	void AddFromStrings(const TWatchesStr& bps);

	bool IsAddressWatch(u32 _iAddress) const;

	// Add BreakPoint
	void Add(u32 em_address);
	void Add(const TWatch& bp);

	void Update(int count, u32 em_address);
	void UpdateName(int count, const std::string name);

	// Remove Breakpoint
	void Remove(u32 _iAddress);
	void Clear();

private:
	TWatches m_Watches;
};