Skip to content

Commit

Permalink
Added missing code for change-type BPs.
Browse files Browse the repository at this point in the history
Various small fixes
  • Loading branch information
rocketz committed Nov 29, 2024
1 parent fcf092f commit c964647
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/core/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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 Down
60 changes: 17 additions & 43 deletions src/gui/widgets/breakpoints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ static uint32_t getValueAboutToWrite() {
static const char* getBreakpointConditionName(PCSX::Debug::BreakpointCondition condition) {
switch (condition) {
case PCSX::Debug::BreakpointCondition::Always:
return "Always";
return _("Always");
case PCSX::Debug::BreakpointCondition::Greater:
return "Greater";
return _("Greater");
case PCSX::Debug::BreakpointCondition::Less:
return "Less";
return _("Less");
case PCSX::Debug::BreakpointCondition::Change:
return "Change";
return _("Change");
case PCSX::Debug::BreakpointCondition::Equal:
return "Equal";
return _("Equal");
}
return "Unknown";
return _("Unknown");
}

static uint32_t getMemoryValue(uint32_t addr, int width, bool isSigned) {
Expand Down Expand Up @@ -85,21 +85,6 @@ static uint32_t getMemoryValue(uint32_t addr, int width, bool isSigned) {
return final.uVal;
}

void PCSX::Widgets::Breakpoints::showEditLabelPopup(const Debug::Breakpoint* bp, int counter) {
std::string name = bp->name();
std::string title = fmt::format(f_("Edit label of breakpoint {}##{}"), name, counter);
if (ImGui::BeginPopupModal(title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text(_("Change the label of breakpoint %s:"), name.c_str());
if (ImGui::InputText(_("Label"), m_bpEditPopupLabel, sizeof(m_bpEditPopupLabel),
ImGuiInputTextFlags_EnterReturnsTrue)) {
bp->label(m_bpEditPopupLabel);
ImGui::CloseCurrentPopup();
}
if (ImGui::Button(_("Cancel"))) ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
}

static ImVec4 s_normalColor = ImColor(0xff, 0xff, 0xff);
static ImVec4 s_hitColor = ImColor(0xff, 0x00, 0x00);

Expand All @@ -117,16 +102,10 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {

int counter = 0;
if (!tree.empty()) {
/*
static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable |
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV |
ImGuiTableFlags_ContextMenuInBody;
*/
static ImGuiTableFlags flags = ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable |
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV |
ImGuiTableFlags_ContextMenuInBody;

int row = 0;
if (ImGui::BeginTable("Breakpoints", 5, flags)) {
ImGui::TableSetupColumn("#");
ImGui::TableSetupColumn("Address");
Expand All @@ -137,6 +116,7 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {

const uint32_t pc = PCSX::g_emulator->m_cpu->m_regs.pc;

int row = 0;
for (auto bp = tree.begin(); bp != tree.end(); bp++, row++) {
ImGui::TableNextRow();

Expand Down Expand Up @@ -205,9 +185,8 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
}

if (ImGui::BeginPopupContextItem("BreakpointPopup")) {
bool addBreakpoint =
ImGui::InputText(_("Address"), m_bpAddressString, sizeof(m_bpAddressString),
ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_AutoSelectAll);
ImGui::InputText(_("Address"), m_bpAddressString, sizeof(m_bpAddressString),
ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_AutoSelectAll);
if (ImGui::BeginCombo(_("Type"), Debug::s_breakpoint_type_names[m_breakpointType]())) {
for (int i = 0; i < 3; i++) {
if (ImGui::Selectable(Debug::s_breakpoint_type_names[i](), m_breakpointType == i)) {
Expand All @@ -226,7 +205,7 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
ImGui::RadioButton(_("Range"), &width, 0);

if (width == 0) {
ImGui::InputInt("Byte Width", &range);
ImGui::InputInt(_("Byte Width"), &range);
}
}

Expand All @@ -238,12 +217,10 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
static int breakCondition2 = 0;
static int conditionVal = 0;

bool isSigned = false;

Debug::BreakpointCondition breakCondition;
Debug::BreakpointType type = (Debug::BreakpointType)m_breakpointType;
if (type != Debug::BreakpointType::Exec) {
ImGui::Combo(_("Break Condition"), &breakCondition2, "Always\0Change\0Greater\0Less\0Exact\0");
ImGui::Combo(_("Break Condition"), &breakCondition2, _("Always\0Change\0Greater\0Less\0Equal\0"));
breakCondition = (Debug::BreakpointCondition)breakCondition2;

switch (breakCondition) {
Expand All @@ -256,13 +233,13 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
case Debug::BreakpointCondition::Less:
case Debug::BreakpointCondition::Greater:
ImGui::InputInt(_("Value"), &conditionVal);
uint32_t curVal = getMemoryValue(breakpointAddress, actualWidth, isSigned);
uint32_t curVal = getMemoryValue(breakpointAddress, actualWidth, false);
std::string buttonStr = fmt::format("{:08x} ({})", curVal, curVal);
if (ImGui::Button(buttonStr.c_str())) {
conditionVal = curVal;
}
ImGui::SameLine();
ImGui::Text("Current Value");
ImGui::Text(_("Current Value"));
break;
}
}
Expand All @@ -273,7 +250,7 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
if (*m_bpAddressString && !*endPtr) {
Debug::BreakpointType bpType = Debug::BreakpointType(m_breakpointType);

Debug::BreakpointInvoker invoker = [](const Debug::Breakpoint* self, uint32_t address, unsigned width,
Debug::BreakpointInvoker invoker = [](Debug::Breakpoint* self, uint32_t address, unsigned width,
const char* cause) {

switch (self->type())
Expand All @@ -299,9 +276,8 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
break;
case Debug::BreakpointCondition::Change:
doBreak = curVal != self->conditionData();
if (doBreak)
{
// TODO: can't update since 'self' is const
if (doBreak) {
self->setConditionData(curVal);
}
break;
case Debug::BreakpointCondition::Equal:
Expand Down Expand Up @@ -332,8 +308,7 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
case Debug::BreakpointCondition::Change:
doBreak = curVal != self->conditionData();
if (doBreak) {
// TODO: can't update since 'self' is const
// self->setConditionData(curVal);
self->setConditionData(curVal);
}
break;
case Debug::BreakpointCondition::Equal:
Expand All @@ -353,7 +328,6 @@ void PCSX::Widgets::Breakpoints::draw(const char* title) {
};

uint32_t conditionData = 0;
uint32_t exactVal = 0;
switch (breakCondition) {
default:
case Debug::BreakpointCondition::Always:
Expand Down

0 comments on commit c964647

Please sign in to comment.