2019-03-01 20:27:49 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Breakpoint.h"
|
2019-07-25 22:22:09 -04:00
|
|
|
#include "DebugTypes.h"
|
2019-07-30 22:34:52 -04:00
|
|
|
#include "DebugUtilities.h"
|
2020-12-27 22:24:23 -05:00
|
|
|
#include "ExpressionEvaluator.h"
|
2019-03-01 20:27:49 -05:00
|
|
|
|
|
|
|
class ExpressionEvaluator;
|
|
|
|
class Debugger;
|
2020-05-21 20:57:00 -04:00
|
|
|
class IEventManager;
|
2019-03-01 20:27:49 -05:00
|
|
|
struct ExpressionData;
|
|
|
|
enum class MemoryOperationType;
|
|
|
|
|
|
|
|
class BreakpointManager
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static constexpr int BreakpointTypeCount = 3; //Read, Write, Exec
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
Debugger *_debugger;
|
2019-10-11 16:07:30 -04:00
|
|
|
CpuType _cpuType;
|
2021-03-10 11:13:28 -05:00
|
|
|
IEventManager *_eventManager;
|
|
|
|
|
2020-10-29 02:19:23 +03:00
|
|
|
unordered_map<int, Breakpoint> _breakpoints[BreakpointTypeCount];
|
|
|
|
unordered_map<int, ExpressionData> _rpnList[BreakpointTypeCount];
|
2019-10-11 16:07:30 -04:00
|
|
|
bool _hasBreakpoint;
|
|
|
|
bool _hasBreakpointType[BreakpointTypeCount] = {};
|
2019-03-01 20:27:49 -05:00
|
|
|
|
2019-10-11 16:07:30 -04:00
|
|
|
unique_ptr<ExpressionEvaluator> _bpExpEval;
|
2019-03-01 20:27:49 -05:00
|
|
|
|
|
|
|
BreakpointType GetBreakpointType(MemoryOperationType type);
|
2021-03-10 11:13:28 -05:00
|
|
|
int InternalCheckBreakpoint(MemoryOperationInfo operationInfo, AddressInfo &address);
|
2019-03-01 20:27:49 -05:00
|
|
|
|
|
|
|
public:
|
2021-03-10 11:13:28 -05:00
|
|
|
BreakpointManager(Debugger *debugger, CpuType cpuType, IEventManager* eventManager = nullptr);
|
2019-03-01 20:27:49 -05:00
|
|
|
|
|
|
|
void SetBreakpoints(Breakpoint breakpoints[], uint32_t count);
|
2020-11-01 16:52:30 +03:00
|
|
|
void GetBreakpoints(Breakpoint* breakpoints, int& execs, int& reads, int& writes);
|
2021-03-10 11:13:28 -05:00
|
|
|
__forceinline int CheckBreakpoint(MemoryOperationInfo operationInfo, AddressInfo &address);
|
2019-10-11 16:07:30 -04:00
|
|
|
};
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
__forceinline int BreakpointManager::CheckBreakpoint(MemoryOperationInfo operationInfo, AddressInfo &address)
|
2019-10-11 16:07:30 -04:00
|
|
|
{
|
2021-03-10 11:13:28 -05:00
|
|
|
if(!_hasBreakpoint) {
|
2019-10-11 16:07:30 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return InternalCheckBreakpoint(operationInfo, address);
|
2021-03-10 11:13:28 -05:00
|
|
|
}
|