mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
2 files changed
+21
-30
No files matched your search
+12
-21
@@ -21,16 +21,13 @@
|
||||
#include "UI/ImDebugger/ImDebugger.h"
|
||||
#include "UI/ImDebugger/ImMemView.h"
|
||||
|
||||
static const char* searchtypes[] = {"u8", "u16", "u32", "u64", "float", "string", "string16","bytesequence"};
|
||||
static const char* searchtypes[] = {"u8", "u16", "u32", "u64", "float", "string", "string16", "bytesequence"};
|
||||
|
||||
ImMemView::ImMemView() {
|
||||
windowStart_ = curAddress_;
|
||||
selectRangeStart_ = curAddress_;
|
||||
selectRangeEnd_ = curAddress_ + 1;
|
||||
lastSelectReset_ = curAddress_;
|
||||
memSearch_.matchAddress = 0xFFFFFFFF;
|
||||
memSearch_.searching = false;
|
||||
memSearch_.status = SEARCH_INITIAL;
|
||||
}
|
||||
|
||||
ImMemView::~ImMemView() {}
|
||||
@@ -159,7 +156,7 @@ void ImMemView::Draw(ImDrawList *drawList) {
|
||||
const ImColor zeroColor = 0x888888ff;
|
||||
const ImColor searchResBg = 0xFF108010;
|
||||
|
||||
if (address + j >= selectRangeStart_ && address + j < selectRangeEnd_ && !memSearch_.searching) {
|
||||
if (address + j >= selectRangeStart_ && address + j < selectRangeEnd_) {
|
||||
if (asciiSelected_) {
|
||||
hexBGCol = secondarySelBg;
|
||||
hexTextCol = secondarySelFg;
|
||||
@@ -177,7 +174,7 @@ void ImMemView::Draw(ImDrawList *drawList) {
|
||||
continueRect = true;
|
||||
}
|
||||
} else if (!tag.empty()) {
|
||||
if (memSearch_.status == SEARCH_OK && address+j>= memSearch_.matchAddress && address +j < memSearch_.matchAddress + memSearch_.fast_size && !memSearch_.searching) {
|
||||
if (memSearch_.status == SEARCH_OK && address+j >= memSearch_.matchAddress && address +j < memSearch_.matchAddress + memSearch_.data.size()) {
|
||||
hexBGCol = searchResBg;
|
||||
} else {
|
||||
hexBGCol = pickTagColor(tag);
|
||||
@@ -810,9 +807,6 @@ bool ImMemView::ParseSearchString(const char* query, MemorySearchType mode) {
|
||||
break;
|
||||
}
|
||||
|
||||
memSearch_.fast_data = memSearch_.data.data();
|
||||
memSearch_.fast_size = memSearch_.data.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
@@ -866,13 +860,15 @@ MemorySearchStatus ImMemView::search(bool continueSearch) {
|
||||
memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd());
|
||||
memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd());
|
||||
|
||||
memSearch_.searching = true;
|
||||
// NOTE:
|
||||
// this currently stops at the first found value
|
||||
// we could look for all matches
|
||||
// and put them in a matches list
|
||||
// and display as;
|
||||
// <match idx><memory region><addr><what matched>
|
||||
const u8 *data = memSearch_.data.data();
|
||||
const size_t size = memSearch_.data.size();
|
||||
|
||||
for (size_t i = 0; i < memoryAreas.size(); i++) {
|
||||
memSearch_.segmentStart = memoryAreas[i].first;
|
||||
memSearch_.segmentEnd = memoryAreas[i].second;
|
||||
@@ -888,16 +884,10 @@ MemorySearchStatus ImMemView::search(bool continueSearch) {
|
||||
continue;
|
||||
|
||||
int index = memSearch_.searchAddress - memSearch_.segmentStart;
|
||||
int endIndex = memSearch_.segmentEnd - memSearch_.segmentStart - (int)memSearch_.fast_size;
|
||||
int endIndex = memSearch_.segmentEnd - memSearch_.segmentStart - size;
|
||||
while (index < endIndex) {
|
||||
// cancel search
|
||||
if ((index % 256) == 0 && ImGui::IsKeyDown(ImGuiKey_Escape)) {
|
||||
memSearch_.searching = false;
|
||||
return SEARCH_CANCEL;
|
||||
}
|
||||
if (memcmp(&dataPointer[index], memSearch_.fast_data, memSearch_.fast_size) == 0) {
|
||||
if (memcmp(&dataPointer[index], data, size) == 0) {
|
||||
memSearch_.matchAddress = index + memSearch_.segmentStart;
|
||||
memSearch_.searching = false;
|
||||
gotoAddr(memSearch_.matchAddress);
|
||||
return SEARCH_OK;
|
||||
}
|
||||
@@ -906,7 +896,6 @@ MemorySearchStatus ImMemView::search(bool continueSearch) {
|
||||
}
|
||||
|
||||
statusMessage_ = "Not found";
|
||||
memSearch_.searching = false;
|
||||
return SEARCH_NOTFOUND;
|
||||
}
|
||||
|
||||
@@ -1107,7 +1096,7 @@ void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &
|
||||
ImGui::SetKeyboardFocusHere(0);
|
||||
focusSearchValueInput_ = false;
|
||||
}
|
||||
if (ImGui::InputText("data", searchStr_, IM_ARRAYSIZE(searchStr_), ImGuiInputTextFlags_EnterReturnsTrue) || ImGui::Button("Search")) {
|
||||
if (ImGui::InputText("data", searchStr_, IM_ARRAYSIZE(searchStr_), ImGuiInputTextFlags_EnterReturnsTrue) | ImGui::Button("Search")) {
|
||||
memView_.initSearch(searchStr_, selectedSearchType_);
|
||||
// TODO: transfer focus on the memview.
|
||||
}
|
||||
@@ -1183,7 +1172,9 @@ void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &
|
||||
StatusBar(memView_.StatusMessage());
|
||||
|
||||
ImGui::End();
|
||||
ProcessKeyboardShortcuts();
|
||||
if (!ImGui::GetIO().WantTextInput) {
|
||||
ProcessKeyboardShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
const char *ImMemWindow::Title(int index) {
|
||||
|
||||
@@ -18,8 +18,9 @@ enum CommonToggles {
|
||||
Off,
|
||||
};
|
||||
|
||||
enum MemorySearchStatus {SEARCH_PSP_NOT_INIT=-1, SEARCH_INITIAL, SEARCH_OK, SEARCH_NOTFOUND, SEARCH_CANCEL};
|
||||
enum MemorySearchType {BITS_8, BITS_16, BITS_32, BITS_64, FLOAT_32, STRING, STRING_16, BYTE_SEQ};
|
||||
enum MemorySearchStatus {SEARCH_PSP_NOT_INIT=-1, SEARCH_INITIAL, SEARCH_OK, SEARCH_NOTFOUND};
|
||||
enum MemorySearchType {BITS_8, BITS_16, BITS_32, BITS_64, FLOAT_32, STRING, STRING_16, BYTE_SEQ};
|
||||
|
||||
class ImMemView {
|
||||
public:
|
||||
ImMemView();
|
||||
@@ -81,15 +82,12 @@ private:
|
||||
struct MemorySearch{
|
||||
// keep search related variables grouped
|
||||
std::vector<u8> data;
|
||||
uint8_t* fast_data;
|
||||
size_t fast_size;
|
||||
u32 searchAddress;
|
||||
u32 matchAddress;
|
||||
u32 matchAddress = 0xFFFFFFFF;
|
||||
u32 segmentStart;
|
||||
u32 segmentEnd;
|
||||
bool searching;
|
||||
MemorySearchStatus status;
|
||||
} memSearch_;
|
||||
MemorySearchStatus status = SEARCH_INITIAL;
|
||||
} memSearch_{};
|
||||
|
||||
std::vector<u8> byteClipboard_;
|
||||
void CopyToByteClipboard();
|
||||
@@ -175,6 +173,9 @@ private:
|
||||
// Corresponds to the CMemView dialog
|
||||
class ImMemWindow {
|
||||
public:
|
||||
ImMemWindow() {
|
||||
searchStr_[0] = 0;
|
||||
}
|
||||
void Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, int index);
|
||||
ImMemView &View() {
|
||||
return memView_;
|
||||
@@ -209,7 +210,6 @@ private:
|
||||
char searchStr_[512];
|
||||
// store the state of the search form
|
||||
ImMemView memView_;
|
||||
char searchTerm_[64]{};
|
||||
|
||||
u32 gotoAddr_ = 0x08800000;
|
||||
};
|
||||
Reference in new issue
Block a user