2024-02-13 00:20:00 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui_MemorySearchWidget.h"
|
|
|
|
|
|
|
|
#include "DebugTools/DebugInterface.h"
|
|
|
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#include <QtCore/QTimer>
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
#include <QtCore/QMap>
|
2024-02-13 00:20:00 +00:00
|
|
|
|
|
|
|
class MemorySearchWidget final : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
MemorySearchWidget(QWidget* parent);
|
|
|
|
~MemorySearchWidget() = default;
|
|
|
|
void setCpu(DebugInterface* cpu);
|
|
|
|
|
|
|
|
enum class SearchType
|
|
|
|
{
|
|
|
|
ByteType,
|
|
|
|
Int16Type,
|
|
|
|
Int32Type,
|
|
|
|
Int64Type,
|
|
|
|
FloatType,
|
|
|
|
DoubleType,
|
|
|
|
StringType,
|
|
|
|
ArrayType
|
|
|
|
};
|
|
|
|
|
|
|
|
// Note: The order of these enum values must reflect the order in thee Search Comparison combobox.
|
|
|
|
enum class SearchComparison
|
|
|
|
{
|
|
|
|
Equals,
|
|
|
|
NotEquals,
|
|
|
|
GreaterThan,
|
|
|
|
GreaterThanOrEqual,
|
|
|
|
LessThan,
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
LessThanOrEqual,
|
|
|
|
Increased,
|
|
|
|
IncreasedBy,
|
|
|
|
Decreased,
|
|
|
|
DecreasedBy,
|
|
|
|
Changed,
|
|
|
|
ChangedBy,
|
|
|
|
NotChanged,
|
|
|
|
Invalid
|
|
|
|
};
|
|
|
|
|
|
|
|
class SearchComparisonLabelMap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SearchComparisonLabelMap()
|
|
|
|
{
|
|
|
|
insert(SearchComparison::Equals, tr("Equals"));
|
|
|
|
insert(SearchComparison::NotEquals, tr("Not Equals"));
|
|
|
|
insert(SearchComparison::GreaterThan, tr("Greater Than"));
|
|
|
|
insert(SearchComparison::GreaterThanOrEqual, tr("Greater Than Or Equal"));
|
|
|
|
insert(SearchComparison::LessThan, tr("Less Than"));
|
|
|
|
insert(SearchComparison::LessThanOrEqual, tr("Less Than Or Equal"));
|
|
|
|
insert(SearchComparison::Increased, tr("Increased"));
|
|
|
|
insert(SearchComparison::IncreasedBy, tr("Increased By"));
|
|
|
|
insert(SearchComparison::Decreased, tr("Decreased"));
|
|
|
|
insert(SearchComparison::DecreasedBy, tr("Decreased By"));
|
|
|
|
insert(SearchComparison::Changed, tr("Changed"));
|
|
|
|
insert(SearchComparison::ChangedBy, tr("Changed By"));
|
|
|
|
insert(SearchComparison::NotChanged, tr("Not Changed"));
|
|
|
|
insert(SearchComparison::Invalid, "");
|
|
|
|
}
|
|
|
|
SearchComparison labelToEnum(QString comparisonLabel)
|
|
|
|
{
|
|
|
|
return labelToEnumMap.value(comparisonLabel, SearchComparison::Invalid);
|
|
|
|
}
|
|
|
|
QString enumToLabel(SearchComparison comparison) {
|
|
|
|
return enumToLabelMap.value(comparison, "");
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
QMap<SearchComparison, QString> enumToLabelMap;
|
|
|
|
QMap<QString, SearchComparison> labelToEnumMap;
|
|
|
|
void insert(SearchComparison comparison, QString comparisonLabel)
|
|
|
|
{
|
|
|
|
enumToLabelMap.insert(comparison, comparisonLabel);
|
|
|
|
labelToEnumMap.insert(comparisonLabel, comparison);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class SearchResult
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
u32 address;
|
|
|
|
QVariant value;
|
|
|
|
SearchType type;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchResult() {}
|
|
|
|
SearchResult(u32 address, const QVariant& value, SearchType type)
|
|
|
|
: address(address), value(value), type(type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool isIntegerValue() const { return type == SearchType::ByteType || type == SearchType::Int16Type || type == SearchType::Int32Type || type == SearchType::Int64Type; }
|
|
|
|
bool isFloatValue() const { return type == SearchType::FloatType; }
|
|
|
|
bool isDoubleValue() const { return type == SearchType::DoubleType; }
|
|
|
|
bool isArrayValue() const { return type == SearchType::ArrayType || type == SearchType::StringType; }
|
|
|
|
u32 getAddress() const { return address; }
|
|
|
|
SearchType getType() const { return type; }
|
|
|
|
QByteArray getArrayValue() const { return isArrayValue() ? value.toByteArray() : QByteArray(); }
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T getValue() const
|
|
|
|
{
|
|
|
|
return value.value<T>();
|
|
|
|
}
|
2024-02-13 00:20:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onSearchButtonClicked();
|
|
|
|
void onSearchResultsListScroll(u32 value);
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
void onSearchTypeChanged(int newIndex);
|
2024-02-13 00:20:00 +00:00
|
|
|
void loadSearchResults();
|
|
|
|
void contextSearchResultGoToDisassembly();
|
|
|
|
void contextRemoveSearchResult();
|
|
|
|
void contextCopySearchResultAddress();
|
|
|
|
void onListSearchResultsContextMenu(QPoint pos);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void addAddressToSavedAddressesList(u32 address);
|
|
|
|
void goToAddressInDisassemblyView(u32 address);
|
|
|
|
void goToAddressInMemoryView(u32 address);
|
|
|
|
void switchToMemoryViewTab();
|
|
|
|
|
|
|
|
private:
|
2024-03-07 04:33:04 +00:00
|
|
|
std::vector<SearchResult> m_searchResults;
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
SearchComparisonLabelMap m_searchComparisonLabelMap;
|
|
|
|
Ui::MemorySearchWidget m_ui;
|
|
|
|
DebugInterface* m_cpu;
|
|
|
|
QTimer m_resultsLoadTimer;
|
2024-02-13 00:20:00 +00:00
|
|
|
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
u32 m_initialResultsLoadLimit = 20000;
|
2024-02-13 00:20:00 +00:00
|
|
|
u32 m_numResultsAddedPerLoad = 10000;
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
|
|
|
|
void updateSearchComparisonSelections();
|
2024-03-07 04:33:04 +00:00
|
|
|
std::vector<SearchComparison> getValidSearchComparisonsForState(SearchType type, std::vector<SearchResult> &existingResults);
|
Debugger: Memory search expansions + results count
Adds memory search comparisons for Increased, Increased By, Decreased, Decreased By, Changed, Not Changed, Changed By.
For arrays, adds not equals, changed, not changed for filter searches.
Now only shows the comparison types that are currently valid for the given search type and if there's prior search results.
Also refactors to allow holding the prior set of search results rather than just the addresses, needed for these search comparisons to work.
Also adds a ui label to show that the debugger is searching after clicking the search button which then gets replaced with the results count when the search completes.
2024-02-11 23:53:12 +00:00
|
|
|
SearchType getCurrentSearchType();
|
|
|
|
SearchComparison getCurrentSearchComparison();
|
2024-02-13 00:20:00 +00:00
|
|
|
};
|