2015-05-24 04:32:32 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-05-24 04:32:32 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-03-03 01:07:24 +00:00
|
|
|
#include <cstddef>
|
2008-07-12 17:40:22 +00:00
|
|
|
#include <string>
|
2018-01-29 16:58:02 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2020-03-21 07:48:49 +00:00
|
|
|
#include "Common/Debug/Threads.h"
|
2019-07-08 22:07:11 +00:00
|
|
|
|
|
|
|
namespace Common::Debug
|
|
|
|
{
|
|
|
|
struct MemoryPatch;
|
|
|
|
struct Watch;
|
|
|
|
} // namespace Common::Debug
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
class CPUThreadGuard;
|
|
|
|
} // namespace Core
|
|
|
|
|
2018-07-10 01:47:50 +00:00
|
|
|
namespace Common
|
|
|
|
{
|
2008-07-12 17:40:22 +00:00
|
|
|
class DebugInterface
|
2008-08-23 15:28:24 +00:00
|
|
|
{
|
|
|
|
protected:
|
2019-07-08 21:44:56 +00:00
|
|
|
virtual ~DebugInterface() = default;
|
2018-04-12 12:18:04 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
public:
|
2018-01-29 16:58:02 +00:00
|
|
|
// Watches
|
2019-07-08 21:28:07 +00:00
|
|
|
virtual std::size_t SetWatch(u32 address, std::string name = "") = 0;
|
2019-07-08 22:07:11 +00:00
|
|
|
virtual const Debug::Watch& GetWatch(std::size_t index) const = 0;
|
|
|
|
virtual const std::vector<Debug::Watch>& GetWatches() const = 0;
|
2018-01-29 16:58:02 +00:00
|
|
|
virtual void UnsetWatch(u32 address) = 0;
|
2019-07-08 21:28:07 +00:00
|
|
|
virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0;
|
2018-01-29 16:58:02 +00:00
|
|
|
virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0;
|
2019-07-08 21:28:07 +00:00
|
|
|
virtual void UpdateWatchName(std::size_t index, std::string name) = 0;
|
2022-12-23 05:17:09 +00:00
|
|
|
virtual void UpdateWatchLockedState(std::size_t index, bool locked) = 0;
|
2018-01-29 16:58:02 +00:00
|
|
|
virtual void EnableWatch(std::size_t index) = 0;
|
|
|
|
virtual void DisableWatch(std::size_t index) = 0;
|
|
|
|
virtual bool HasEnabledWatch(u32 address) const = 0;
|
|
|
|
virtual void RemoveWatch(std::size_t index) = 0;
|
|
|
|
virtual void LoadWatchesFromStrings(const std::vector<std::string>& watches) = 0;
|
|
|
|
virtual std::vector<std::string> SaveWatchesToStrings() const = 0;
|
|
|
|
virtual void ClearWatches() = 0;
|
|
|
|
|
2018-05-21 14:46:03 +00:00
|
|
|
// Memory Patches
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual void SetPatch(const Core::CPUThreadGuard& guard, u32 address, u32 value) = 0;
|
|
|
|
virtual void SetPatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value) = 0;
|
|
|
|
virtual void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, u32 value) = 0;
|
|
|
|
virtual void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address,
|
|
|
|
std::vector<u8> value) = 0;
|
2019-07-08 22:07:11 +00:00
|
|
|
virtual const std::vector<Debug::MemoryPatch>& GetPatches() const = 0;
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual void UnsetPatch(const Core::CPUThreadGuard& guard, u32 address) = 0;
|
|
|
|
virtual void EnablePatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
|
|
|
virtual void DisablePatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
2018-05-21 14:46:03 +00:00
|
|
|
virtual bool HasEnabledPatch(u32 address) const = 0;
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual void RemovePatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
|
|
|
virtual void ClearPatches(const Core::CPUThreadGuard& guard) = 0;
|
|
|
|
virtual void ApplyExistingPatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
2018-05-21 14:46:03 +00:00
|
|
|
|
2020-03-21 07:48:49 +00:00
|
|
|
// Threads
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual Debug::Threads GetThreads(const Core::CPUThreadGuard& guard) const = 0;
|
2020-03-21 07:48:49 +00:00
|
|
|
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual std::string Disassemble(const Core::CPUThreadGuard* /*guard*/, u32 /*address*/) const
|
|
|
|
{
|
|
|
|
return "NODEBUGGER";
|
|
|
|
}
|
|
|
|
virtual std::string GetRawMemoryString(const Core::CPUThreadGuard& /*guard*/, int /*memory*/,
|
|
|
|
u32 /*address*/) const
|
2016-01-21 19:46:25 +00:00
|
|
|
{
|
2016-10-07 13:56:02 +00:00
|
|
|
return "NODEBUGGER";
|
2016-01-21 19:46:25 +00:00
|
|
|
}
|
2019-07-08 22:25:14 +00:00
|
|
|
virtual bool IsAlive() const { return true; }
|
|
|
|
virtual bool IsBreakpoint(u32 /*address*/) const { return false; }
|
2019-07-08 21:53:47 +00:00
|
|
|
virtual void SetBreakpoint(u32 /*address*/) {}
|
|
|
|
virtual void ClearBreakpoint(u32 /*address*/) {}
|
2014-03-03 05:39:08 +00:00
|
|
|
virtual void ClearAllBreakpoints() {}
|
2019-07-08 21:53:47 +00:00
|
|
|
virtual void ToggleBreakpoint(u32 /*address*/) {}
|
2014-03-06 01:51:27 +00:00
|
|
|
virtual void ClearAllMemChecks() {}
|
2019-07-08 22:25:14 +00:00
|
|
|
virtual bool IsMemCheck(u32 /*address*/, size_t /*size*/) const { return false; }
|
2019-07-08 21:53:47 +00:00
|
|
|
virtual void ToggleMemCheck(u32 /*address*/, bool /*read*/, bool /*write*/, bool /*log*/) {}
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual u32 ReadMemory(const Core::CPUThreadGuard& /*guard*/, u32 /*address*/) const { return 0; }
|
|
|
|
virtual void WriteExtraMemory(const Core::CPUThreadGuard& /*guard*/, int /*memory*/,
|
|
|
|
u32 /*value*/, u32 /*address*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual u32 ReadExtraMemory(const Core::CPUThreadGuard& /*guard*/, int /*memory*/,
|
|
|
|
u32 /*address*/) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
virtual u32 ReadInstruction(const Core::CPUThreadGuard& /*guard*/, u32 /*address*/) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2022-03-17 19:53:38 +00:00
|
|
|
virtual std::optional<u32>
|
|
|
|
GetMemoryAddressFromInstruction(const std::string& /*instruction*/) const
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2019-07-08 22:25:14 +00:00
|
|
|
virtual u32 GetPC() const { return 0; }
|
2019-07-08 21:53:47 +00:00
|
|
|
virtual void SetPC(u32 /*address*/) {}
|
2014-03-03 05:39:08 +00:00
|
|
|
virtual void Step() {}
|
|
|
|
virtual void RunToBreakpoint() {}
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual u32 GetColor(const Core::CPUThreadGuard* /*guard*/, u32 /*address*/) const
|
|
|
|
{
|
|
|
|
return 0xFFFFFFFF;
|
|
|
|
}
|
2019-07-08 22:25:14 +00:00
|
|
|
virtual std::string GetDescription(u32 /*address*/) const = 0;
|
2023-02-12 10:07:11 +00:00
|
|
|
virtual void Clear(const Core::CPUThreadGuard& guard) = 0;
|
2008-07-12 17:40:22 +00:00
|
|
|
};
|
2018-07-10 01:47:50 +00:00
|
|
|
} // namespace Common
|