Skip to content

Commit 17a8883

Browse files
authored
Merge pull request #1809 from rocketz/Breakpoints-improvements
Breakpoint improvements
2 parents 5ee1dd1 + e2096cd commit 17a8883

File tree

10 files changed

+997
-156
lines changed

10 files changed

+997
-156
lines changed

src/core/debug.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Debug {
3737
static bool isInKernel(uint32_t address, bool biosIsKernel = true);
3838
static inline std::function<const char*()> s_breakpoint_type_names[] = {l_("Exec"), l_("Read"), l_("Write")};
3939
enum class BreakpointType { Exec, Read, Write };
40+
enum class BreakpointCondition { Always, Change, Greater, Less, Equal };
4041

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

69-
typedef std::function<bool(const Breakpoint*, uint32_t address, unsigned width, const char* cause)>
70+
typedef std::function<bool(Breakpoint*, uint32_t address, unsigned width, const char* cause)>
7071
BreakpointInvoker;
7172

7273
class Breakpoint : public BreakpointTreeType::Node,
@@ -78,6 +79,10 @@ class Debug {
7879
: m_type(type), m_source(source), m_invoker(invoker), m_base(base), m_label(label) {}
7980
std::string name() const;
8081
BreakpointType type() const { return m_type; }
82+
BreakpointCondition condition() const { return m_condition; }
83+
void setCondition(BreakpointCondition condition) { m_condition = condition; }
84+
uint32_t conditionData() const { return m_conditionData; }
85+
void setConditionData(uint32_t data) { m_conditionData = data; }
8186
unsigned width() const { return getHigh() - getLow() + 1; }
8287
uint32_t address() const { return getLow(); }
8388
bool enabled() const { return m_enabled; }
@@ -95,6 +100,8 @@ class Debug {
95100
}
96101

97102
const BreakpointType m_type;
103+
BreakpointCondition m_condition = BreakpointCondition::Always;
104+
uint32_t m_conditionData = 0;
98105
const std::string m_source;
99106
const BreakpointInvoker m_invoker;
100107
mutable std::string m_label;
@@ -158,6 +165,10 @@ class Debug {
158165
if (m_lastBP == bp) m_lastBP = nullptr;
159166
delete const_cast<Breakpoint*>(bp);
160167
}
168+
void removeAllBreakpoints() {
169+
m_breakpoints.clear();
170+
m_lastBP = nullptr;
171+
}
161172

162173
private:
163174
bool triggerBP(Breakpoint* bp, uint32_t address, unsigned width, const char* reason = "");

src/core/r3000a.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "core/psxmem.h"
3535
#include "support/file.h"
3636
#include "support/hashtable.h"
37+
#include "mips/common/util/mips.hh"
3738

3839
#if defined(__i386__) || defined(_M_IX86)
3940
#define DYNAREC_NONE // Hahano
@@ -89,20 +90,7 @@ typedef union {
8990
int32_t sd;
9091
} PAIR;
9192

92-
typedef union {
93-
struct {
94-
uint32_t r0, at, v0, v1, a0, a1, a2, a3;
95-
uint32_t t0, t1, t2, t3, t4, t5, t6, t7;
96-
uint32_t s0, s1, s2, s3, s4, s5, s6, s7;
97-
uint32_t t8, t9, k0, k1, gp, sp, s8, ra;
98-
uint32_t lo, hi;
99-
} n;
100-
uint32_t r[34]; /* Lo, Hi in r[32] and r[33] */
101-
PAIR p[34];
102-
} psxGPRRegs;
103-
104-
// Make sure no packing is inserted anywhere
105-
static_assert(sizeof(psxGPRRegs) == 34 * sizeof(uint32_t));
93+
using psxGPRRegs = Mips::GPRRegs;
10694

10795
typedef union {
10896
struct {

src/gui/widgets/assembly.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ void PCSX::Widgets::Assembly::addMemoryEditorContext(uint32_t addr, int size) {
340340
itemLabel = fmt::format(f_("Go to in Memory Editor #{}"), i + 1);
341341
if (ImGui::MenuItem(itemLabel.c_str())) jumpToMemory(addr, size, i, true);
342342
}
343+
if (ImGui::MenuItem(_("Create Memory Read Breakpoint"))) {
344+
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Read, size, _("GUI"));
345+
}
346+
if (ImGui::MenuItem(_("Create Memory Write Breakpoint"))) {
347+
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Write, size, _("GUI"));
348+
}
343349
ImGui::EndPopup();
344350
}
345351
}

0 commit comments

Comments
 (0)