Debugger: Highlight changed watches.

This commit is contained in:
Unknown W. Brackets committed 2023-04-09 00:47:36 -07:00
1 parent 85a071568c
commit c0fc2e65e0
2 files changed
+38 -3

No files matched your search

+31 -3
View File
@@ -823,7 +823,23 @@ CtrlWatchList::CtrlWatchList(HWND hwnd, DebugInterface *cpu)
}
void CtrlWatchList::RefreshValues() {
Update();
int steppingCounter = Core_GetSteppingCounter();
int changes = false;
for (auto &watch : watches_) {
if (watch.steppingCounter != steppingCounter) {
watch.lastValue = watch.currentValue;
watch.steppingCounter = steppingCounter;
changes = true;
}
uint32_t prevValue = watch.currentValue;
watch.evaluateFailed = !cpu_->parseExpression(watch.expression, watch.currentValue);
if (prevValue != watch.currentValue)
changes = true;
}
if (changes)
Update();
}
bool CtrlWatchList::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) {
@@ -902,6 +918,14 @@ void CtrlWatchList::OnRightClick(int itemIndex, int column, const POINT &pt) {
}
}
bool CtrlWatchList::OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) {
if (row >= 0 && HasWatchChanged(row)) {
msg->clrText = RGB(255, 0, 0);
return true;
}
return false;
}
void CtrlWatchList::AddWatch() {
WatchItemWindow win(nullptr, GetHandle(), cpu_);
if (win.Exec()) {
@@ -910,7 +934,7 @@ void CtrlWatchList::AddWatch() {
info.name = win.GetName();
info.originalExpression = win.GetExpression();
watches_.push_back(info);
Update();
RefreshValues();
} else {
char errorMessage[512];
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\": %s", win.GetExpression().c_str(), getExpressionError());
@@ -926,7 +950,7 @@ void CtrlWatchList::EditWatch(int pos) {
if (cpu_->initExpression(win.GetExpression().c_str(), watches_[pos].expression)) {
watches_[pos].name = win.GetName();
watches_[pos].originalExpression = win.GetExpression();
Update();
RefreshValues();
} else {
char errorMessage[512];
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\": %s", win.GetExpression().c_str(), getExpressionError());
@@ -939,3 +963,7 @@ void CtrlWatchList::DeleteWatch(int pos) {
watches_.erase(watches_.begin() + pos);
Update();
}
bool CtrlWatchList::HasWatchChanged(int pos) {
return watches_[pos].lastValue != watches_[pos].currentValue;
}
+7
View File
@@ -95,16 +95,23 @@ protected:
void GetColumnText(wchar_t *dest, int row, int col) override;
int GetRowCount() override { return (int)watches_.size(); }
void OnRightClick(int itemIndex, int column, const POINT &point) override;
bool ListenRowPrePaint() override { return true; }
bool OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) override;
private:
void AddWatch();
void EditWatch(int pos);
void DeleteWatch(int pos);
bool HasWatchChanged(int pos);
struct WatchInfo {
std::string name;
std::string originalExpression;
PostfixExpression expression;
uint32_t currentValue = 0;
uint32_t lastValue = 0;
int steppingCounter = -1;
bool evaluateFailed = false;
};
std::vector<WatchInfo> watches_;
DebugInterface *cpu_;