Add input to memview. Use step counters to control updates.

This commit is contained in:
Henrik Rydgård committed 2024-12-12 17:47:37 +01:00
1 parent adcfffd1d6
commit 11e858f0f1
7 files changed
+75 -22

No files matched your search

+16
View File
@@ -35,6 +35,7 @@
// GPU things
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Debugger/Stepping.h"
#include "UI/ImDebugger/ImDebugger.h"
#include "UI/ImDebugger/ImGe.h"
@@ -879,6 +880,20 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
return;
}
// Watch the step counters to figure out when to update things.
if (lastCpuStepCount_ != Core_GetSteppingCounter()) {
lastCpuStepCount_ = Core_GetSteppingCounter();
disasm_.View().NotifyStep();
}
if (lastGpuStepCount_ != GPUStepping::GetSteppingCounter()) {
// A GPU step has happened since last time. This means that we should re-center the cursor.
// Snapshot();
lastGpuStepCount_ = GPUStepping::GetSteppingCounter();
geDebugger_.View().NotifyStep();
}
ImControl control{};
if (ImGui::BeginMainMenuBar()) {
@@ -1096,6 +1111,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
}
void ImDebugger::Snapshot() {
}
void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, bool *open, int index) {
+3
View File
@@ -171,6 +171,9 @@ private:
ImMemWindow mem_[4]; // We support 4 separate instances of the memory viewer.
ImStructViewer structViewer_;
int lastCpuStepCount_ = -1;
int lastGpuStepCount_ = -1;
// Open variables.
ImConfig cfg_{};
};
+12 -20
View File
@@ -450,15 +450,6 @@ void ImDisasmView::Draw(ImDrawList *drawList) {
ProcessKeyboardShortcuts(ImGui::IsItemFocused());
int coreStep = Core_GetSteppingCounter();
if (coreStep != lastSteppingCount_) {
// A step has happened since last time. This means that we should re-center the cursor.
if (followPC_) {
gotoPC();
}
lastSteppingCount_ = coreStep;
}
if (pressed) {
// INFO_LOG(Log::System, "Clicked %f,%f", mousePos.x, mousePos.y);
if (mousePos.x < rowHeight_) { // Left column
@@ -479,6 +470,12 @@ void ImDisasmView::Draw(ImDrawList *drawList) {
drawList->PopClipRect();
}
void ImDisasmView::NotifyStep() {
if (followPC_) {
gotoPC();
}
}
void ImDisasmView::ScrollRelative(int amount) {
if (amount > 0) {
windowStart_ = manager.getNthNextAddress(windowStart_, amount);
@@ -763,16 +760,6 @@ void ImDisasmView::CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructions
}
}
void ImDisasmView::NopInstructions(u32 selectRangeStart, u32 selectRangeEnd) {
for (u32 addr = selectRangeStart; addr < selectRangeEnd; addr += 4) {
Memory::Write_U32(0, addr);
}
if (currentMIPS) {
currentMIPS->InvalidateICache(selectRangeStart, selectRangeEnd - selectRangeStart);
}
}
void ImDisasmView::PopupMenu() {
bool renameFunctionPopup = false;
if (ImGui::BeginPopup("context")) {
@@ -812,7 +799,12 @@ void ImDisasmView::PopupMenu() {
assembleOpcode(curAddress_, "");
}
if (ImGui::MenuItem("NOP instructions (destructive)")) {
NopInstructions(selectRangeStart_, selectRangeEnd_);
for (u32 addr = selectRangeStart_; addr < selectRangeEnd_; addr += 4) {
Memory::Write_U32(0, addr);
}
if (currentMIPS) {
currentMIPS->InvalidateICache(selectRangeStart_, selectRangeEnd_ - selectRangeStart_);
}
}
ImGui::Separator();
if (ImGui::MenuItem("Rename function")) {
+1 -1
View File
@@ -28,6 +28,7 @@ public:
void Draw(ImDrawList *drawList);
void PopupMenu();
void NotifyStep();
void ScrollRelative(int amount);
@@ -131,7 +132,6 @@ private:
void updateStatusBarText();
void drawBranchLine(ImDrawList *list, Bounds rc, std::map<u32, float> &addressPositions, const BranchLine &line);
void CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructionsMode mode);
void NopInstructions(u32 startAddr, u32 endAddr);
std::set<std::string> getSelectedLineArguments();
void drawArguments(ImDrawList *list, Bounds rc, const DisassemblyLineInfo &line, float x, float y, ImColor textColor, const std::set<std::string> &currentArguments);
+8 -1
View File
@@ -14,6 +14,7 @@
#include "GPU/Debugger/State.h"
#include "GPU/Debugger/GECommandTable.h"
#include "GPU/Debugger/Breakpoints.h"
#include "GPU/Debugger/Stepping.h"
#include "GPU/Debugger/Debugger.h"
#include "GPU/GPUState.h"
@@ -82,6 +83,12 @@ void DrawDebugStatsWindow(ImConfig &cfg) {
ImGui::End();
}
void ImGeDisasmView::NotifyStep() {
if (followPC_) {
gotoPC_ = true;
}
}
void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) {
const u32 branchColor = 0xFFA0FFFF;
const u32 gteColor = 0xFFFFEFA0;
@@ -123,7 +130,7 @@ void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) {
}
if (pc != 0xFFFFFFFF) {
if (gotoPC_ || followPC_) {
if (gotoPC_) {
selectedAddr_ = pc;
gotoPC_ = false;
}
+2
View File
@@ -28,6 +28,8 @@ public:
selectedAddr_ = addr;
}
void NotifyStep();
private:
u32 selectedAddr_ = INVALID_ADDR;
u32 dragAddr_ = INVALID_ADDR;
+33
View File
@@ -201,6 +201,39 @@ void ImMemView::Draw(ImDrawList *drawList) {
}
}
ImGuiIO& io = ImGui::GetIO();
ImVec2 mousePos = ImVec2(io.MousePos.x - canvas_p0.x, io.MousePos.y - canvas_p0.y);
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
// INFO_LOG(Log::System, "Mousedown %f,%f active:%d hover:%d", mousePos.x, mousePos.y, is_active, is_hovered);
onMouseDown(mousePos.x, mousePos.y, 1);
}
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
// INFO_LOG(Log::CPU, "Mousedown %f,%f active:%d hover:%d", mousePos.x, mousePos.y, is_active, is_hovered);
onMouseDown(mousePos.x, mousePos.y, 2);
}
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
// INFO_LOG(Log::System, "Mouseup %f,%f active:%d hover:%d", mousePos.x, mousePos.y, is_active, is_hovered);
if (is_hovered) {
onMouseUp(mousePos.x, mousePos.y, 1);
}
}
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
// INFO_LOG(Log::System, "Mousedrag %f,%f active:%d hover:%d", mousePos.x, mousePos.y, is_active, is_hovered);
if (is_hovered) {
onMouseMove(mousePos.x, mousePos.y, 1);
}
}
if (is_hovered) {
if (io.MouseWheel > 0.0f) { // TODO: Scale steps by the value.
windowStart_ -= 4;
} else if (io.MouseWheel < 0.0f) {
windowStart_ += 4;
}
}
ProcessKeyboardShortcuts(ImGui::IsItemFocused());
ImGui_PopFont();
drawList->PopClipRect();
}