ImDebugger: add a filter box above the symbol list

A game with symbols loaded puts a few thousand functions in that list, and the
only way to reach one was to scroll. Typing part of a name now narrows it,
case-insensitively.

The filter produces a list of indices into the symbol cache rather than a
filtered copy of it, so selectedSymbol_ keeps meaning the same thing whether or
not a filter is active - the Edit Symbol box above the list needs it to index
the cache. Rebuilt when the filter text changes or the symbol map reloads, not
per frame, and the list clipper works off the match list so a filter that
matches everything costs no more to draw than before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-18 13:42:13 +02:00
1 parent f9703217fc
commit a0fbf32469
2 files changed
+27 -2

No files matched your search

+21 -2
View File
@@ -1296,6 +1296,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
if (symCache_.empty() || symsDirty_) {
symCache_ = g_symbolMap->GetAllActiveSymbols(SymbolType::ST_FUNCTION);
symsDirty_ = false;
symMatchesDirty_ = true;
}
if (selectedSymbol_ >= 0 && selectedSymbol_ < symCache_.size()) {
@@ -1310,11 +1311,29 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
}
}
ImGui::SetNextItemWidth(-1.0f);
if (ImGui::InputTextWithHint("##symfilter", "Filter symbols", symFilter_, sizeof(symFilter_))) {
symMatchesDirty_ = true;
}
if (symMatchesDirty_) {
symMatchesDirty_ = false;
symMatches_.clear();
// An empty filter still builds the index list, so the draw loop below has only one
// path to get wrong. These lists run to a few thousand entries, and this only reruns
// when the filter or the symbol map changes, not per frame.
for (int i = 0; i < (int)symCache_.size(); i++) {
if (symFilter_[0] == '\0' || containsNoCase(symCache_[i].name, symFilter_))
symMatches_.push_back(i);
}
}
if (ImGui::BeginListBox("##symbols", ImGui::GetContentRegionAvail())) {
ImGuiListClipper clipper;
clipper.Begin((int)symCache_.size(), -1);
clipper.Begin((int)symMatches_.size(), -1);
while (clipper.Step()) {
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
const int i = symMatches_[row];
if (ImGui::Selectable(symCache_[i].name.c_str(), selectedSymbol_ == i)) {
disasmView_.gotoAddr(symCache_[i].address);
disasmView_.scrollAddressIntoView();