Skip to content

Commit

Permalink
Merge pull request #1809 from rocketz/Breakpoints-improvements
Browse files Browse the repository at this point in the history
Breakpoint improvements
  • Loading branch information
nicolasnoble authored Mar 4, 2025
2 parents 5ee1dd1 + e2096cd commit 17a8883
Show file tree
Hide file tree
Showing 10 changed files with 997 additions and 156 deletions.
13 changes: 12 additions & 1 deletion src/core/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Debug {
static bool isInKernel(uint32_t address, bool biosIsKernel = true);
static inline std::function<const char*()> s_breakpoint_type_names[] = {l_("Exec"), l_("Read"), l_("Write")};
enum class BreakpointType { Exec, Read, Write };
enum class BreakpointCondition { Always, Change, Greater, Less, Equal };

void checkDMAread(unsigned c, uint32_t address, uint32_t len) {
std::string cause = fmt::format("DMA channel {} read", c);
Expand Down Expand Up @@ -66,7 +67,7 @@ class Debug {
struct InternalTemporaryList {};
typedef Intrusive::List<Breakpoint, InternalTemporaryList> BreakpointTemporaryListType;

typedef std::function<bool(const Breakpoint*, uint32_t address, unsigned width, const char* cause)>
typedef std::function<bool(Breakpoint*, uint32_t address, unsigned width, const char* cause)>
BreakpointInvoker;

class Breakpoint : public BreakpointTreeType::Node,
Expand All @@ -78,6 +79,10 @@ class Debug {
: m_type(type), m_source(source), m_invoker(invoker), m_base(base), m_label(label) {}
std::string name() const;
BreakpointType type() const { return m_type; }
BreakpointCondition condition() const { return m_condition; }
void setCondition(BreakpointCondition condition) { m_condition = condition; }
uint32_t conditionData() const { return m_conditionData; }
void setConditionData(uint32_t data) { m_conditionData = data; }
unsigned width() const { return getHigh() - getLow() + 1; }
uint32_t address() const { return getLow(); }
bool enabled() const { return m_enabled; }
Expand All @@ -95,6 +100,8 @@ class Debug {
}

const BreakpointType m_type;
BreakpointCondition m_condition = BreakpointCondition::Always;
uint32_t m_conditionData = 0;
const std::string m_source;
const BreakpointInvoker m_invoker;
mutable std::string m_label;
Expand Down Expand Up @@ -158,6 +165,10 @@ class Debug {
if (m_lastBP == bp) m_lastBP = nullptr;
delete const_cast<Breakpoint*>(bp);
}
void removeAllBreakpoints() {
m_breakpoints.clear();
m_lastBP = nullptr;
}

private:
bool triggerBP(Breakpoint* bp, uint32_t address, unsigned width, const char* reason = "");
Expand Down
16 changes: 2 additions & 14 deletions src/core/r3000a.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "core/psxmem.h"
#include "support/file.h"
#include "support/hashtable.h"
#include "mips/common/util/mips.hh"

#if defined(__i386__) || defined(_M_IX86)
#define DYNAREC_NONE // Hahano
Expand Down Expand Up @@ -89,20 +90,7 @@ typedef union {
int32_t sd;
} PAIR;

typedef union {
struct {
uint32_t r0, at, v0, v1, a0, a1, a2, a3;
uint32_t t0, t1, t2, t3, t4, t5, t6, t7;
uint32_t s0, s1, s2, s3, s4, s5, s6, s7;
uint32_t t8, t9, k0, k1, gp, sp, s8, ra;
uint32_t lo, hi;
} n;
uint32_t r[34]; /* Lo, Hi in r[32] and r[33] */
PAIR p[34];
} psxGPRRegs;

// Make sure no packing is inserted anywhere
static_assert(sizeof(psxGPRRegs) == 34 * sizeof(uint32_t));
using psxGPRRegs = Mips::GPRRegs;

typedef union {
struct {
Expand Down
6 changes: 6 additions & 0 deletions src/gui/widgets/assembly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ void PCSX::Widgets::Assembly::addMemoryEditorContext(uint32_t addr, int size) {
itemLabel = fmt::format(f_("Go to in Memory Editor #{}"), i + 1);
if (ImGui::MenuItem(itemLabel.c_str())) jumpToMemory(addr, size, i, true);
}
if (ImGui::MenuItem(_("Create Memory Read Breakpoint"))) {
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Read, size, _("GUI"));
}
if (ImGui::MenuItem(_("Create Memory Write Breakpoint"))) {
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Write, size, _("GUI"));
}
ImGui::EndPopup();
}
}
Expand Down
Loading

0 comments on commit 17a8883

Please sign in to comment.