2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 23:09:55 -04:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-03-02 20:07:24 -05:00
|
|
|
#include <cstddef>
|
2008-07-12 17:40:22 +00:00
|
|
|
#include <string>
|
2014-02-17 05:18:15 -05:00
|
|
|
#include <vector>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2018-07-09 21:47:50 -04:00
|
|
|
namespace Common
|
|
|
|
{
|
2009-06-28 12:15:31 +00:00
|
|
|
class DebugInterface;
|
2018-07-09 21:47:50 -04:00
|
|
|
}
|
2009-06-28 12:15:31 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
struct TBreakPoint
|
|
|
|
{
|
2017-01-11 08:27:45 -05:00
|
|
|
u32 address = 0;
|
|
|
|
bool is_enabled = false;
|
|
|
|
bool is_temporary = false;
|
2020-07-06 18:16:32 -04:00
|
|
|
bool log_on_hit = false;
|
|
|
|
bool break_on_hit = false;
|
2008-07-12 17:40:22 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
struct TMemCheck
|
|
|
|
{
|
2017-01-11 08:27:45 -05:00
|
|
|
u32 start_address = 0;
|
|
|
|
u32 end_address = 0;
|
2014-08-30 16:14:56 -04:00
|
|
|
|
2021-02-28 08:04:50 +00:00
|
|
|
bool is_enabled = true;
|
2017-01-11 08:27:45 -05:00
|
|
|
bool is_ranged = false;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-11 08:27:45 -05:00
|
|
|
bool is_break_on_read = false;
|
|
|
|
bool is_break_on_write = false;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-11 08:27:45 -05:00
|
|
|
bool log_on_hit = false;
|
|
|
|
bool break_on_hit = false;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-11 08:27:45 -05:00
|
|
|
u32 num_hits = 0;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2015-04-23 01:22:35 -04:00
|
|
|
// returns whether to break
|
2018-07-09 21:47:50 -04:00
|
|
|
bool Action(Common::DebugInterface* dbg_interface, u32 value, u32 addr, bool write, size_t size,
|
|
|
|
u32 pc);
|
2008-07-12 17:40:22 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2008-12-20 14:00:33 +00:00
|
|
|
// Code breakpoints.
|
|
|
|
class BreakPoints
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
2008-07-17 20:08:01 +00:00
|
|
|
public:
|
2017-01-11 07:59:43 -05:00
|
|
|
using TBreakPoints = std::vector<TBreakPoint>;
|
|
|
|
using TBreakPointsStr = std::vector<std::string>;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-11 09:31:21 -05:00
|
|
|
const TBreakPoints& GetBreakPoints() const { return m_breakpoints; }
|
2011-02-25 09:35:56 +00:00
|
|
|
TBreakPointsStr GetStrings() const;
|
2017-01-11 08:27:45 -05:00
|
|
|
void AddFromStrings(const TBreakPointsStr& bp_strings);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
// is address breakpoint
|
|
|
|
bool IsAddressBreakPoint(u32 address) const;
|
2021-02-28 08:04:50 +00:00
|
|
|
bool IsBreakPointEnable(u32 adresss) const;
|
2011-02-25 09:35:56 +00:00
|
|
|
bool IsTempBreakPoint(u32 address) const;
|
2020-07-06 18:16:32 -04:00
|
|
|
bool IsBreakPointBreakOnHit(u32 address) const;
|
|
|
|
bool IsBreakPointLogOnHit(u32 address) const;
|
2011-02-25 09:35:56 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
// Add BreakPoint
|
2020-07-06 18:16:32 -04:00
|
|
|
void Add(u32 address, bool temp, bool break_on_hit, bool log_on_hit);
|
2017-01-11 08:27:45 -05:00
|
|
|
void Add(u32 address, bool temp = false);
|
2015-04-15 00:38:21 -04:00
|
|
|
void Add(const TBreakPoint& bp);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2021-02-28 08:04:50 +00:00
|
|
|
// Modify Breakpoint
|
|
|
|
bool ToggleBreakPoint(u32 address);
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
// Remove Breakpoint
|
2017-01-11 08:27:45 -05:00
|
|
|
void Remove(u32 address);
|
2012-03-15 21:48:19 +11:00
|
|
|
void Clear();
|
2014-10-18 11:02:26 +11:00
|
|
|
void ClearAllTemporary();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2008-07-17 20:08:01 +00:00
|
|
|
private:
|
2017-01-11 08:27:45 -05:00
|
|
|
TBreakPoints m_breakpoints;
|
2008-12-20 14:00:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Memory breakpoints
|
|
|
|
class MemChecks
|
|
|
|
{
|
|
|
|
public:
|
2017-01-11 07:59:43 -05:00
|
|
|
using TMemChecks = std::vector<TMemCheck>;
|
|
|
|
using TMemChecksStr = std::vector<std::string>;
|
2013-03-19 21:51:12 -04:00
|
|
|
|
2017-01-11 09:31:21 -05:00
|
|
|
const TMemChecks& GetMemChecks() const { return m_mem_checks; }
|
2011-02-25 09:35:56 +00:00
|
|
|
TMemChecksStr GetStrings() const;
|
2017-01-11 08:27:45 -05:00
|
|
|
void AddFromStrings(const TMemChecksStr& mc_strings);
|
2011-02-25 09:35:56 +00:00
|
|
|
|
2017-01-11 08:27:45 -05:00
|
|
|
void Add(const TMemCheck& memory_check);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2021-02-28 08:04:50 +00:00
|
|
|
bool ToggleBreakPoint(u32 address);
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
// memory breakpoint
|
2017-03-02 20:07:24 -05:00
|
|
|
TMemCheck* GetMemCheck(u32 address, size_t size = 1);
|
2018-05-22 09:42:16 -04:00
|
|
|
bool OverlapsMemcheck(u32 address, u32 length) const;
|
2017-01-11 08:27:45 -05:00
|
|
|
void Remove(u32 address);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2020-03-14 21:57:09 +09:00
|
|
|
void Clear();
|
2017-01-11 08:27:45 -05:00
|
|
|
bool HasAny() const { return !m_mem_checks.empty(); }
|
2018-04-12 14:18:04 +02:00
|
|
|
|
2017-01-11 08:01:01 -05:00
|
|
|
private:
|
2017-01-11 08:27:45 -05:00
|
|
|
TMemChecks m_mem_checks;
|
2008-07-12 17:40:22 +00:00
|
|
|
};
|