Skip to content

Commit cfb69b4

Browse files
xusheng6claude
andcommitted
Add configurable wildcard symbol limit and improve JSON string parsing for esReven TTD calls
- Add ttd.maxSymbolsLimit setting (default 50, 0 = no limit) instead of hardcoded :50 - Fix extractString lambda to handle whitespace after colon in JSON Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cdb436a commit cfb69b4

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

core/adapters/esrevenadapter.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,17 @@ Ref<Settings> EsrevenAdapterType::RegisterAdapterSettings()
26802680
"readOnly" : false
26812681
})JSON");
26822682

2683+
settings->RegisterSetting("ttd.maxSymbolsLimit",
2684+
R"JSON({
2685+
"title" : "Max Symbols Wildcard Limit",
2686+
"type" : "number",
2687+
"default" : 50,
2688+
"minValue" : 0,
2689+
"maxValue" : 10000,
2690+
"description" : "Maximum number of symbols to search when using wildcard patterns (e.g. 'kernel32!C*'). Set to 0 for no limit (searches all matching symbols). Increase for broader wildcard queries at the cost of performance.",
2691+
"readOnly" : false
2692+
})JSON");
2693+
26832694
return settings;
26842695
}
26852696

@@ -2761,10 +2772,11 @@ std::vector<TTDCallEvent> EsrevenAdapter::GetTTDCallsForSymbols(const std::strin
27612772
BNSettingsScope scope = SettingsResourceScope;
27622773
auto timeoutMs = adapterSettings->Get<uint64_t>("ttd.queryTimeout", GetData(), &scope);
27632774
auto maxResults = adapterSettings->Get<uint64_t>("ttd.maxCallsQueryResults", GetData(), &scope);
2775+
auto maxSymbols = adapterSettings->Get<uint64_t>("ttd.maxSymbolsLimit", GetData(), &scope);
27642776
auto timeout = std::chrono::milliseconds(timeoutMs);
27652777

2766-
LogInfo("GetTTDCallsForSymbols: symbols='%s', timeout=%lldms, maxResults=%llu",
2767-
symbols.c_str(), timeoutMs, maxResults);
2778+
LogInfo("GetTTDCallsForSymbols: symbols='%s', timeout=%lldms, maxResults=%llu, maxSymbols=%llu",
2779+
symbols.c_str(), timeoutMs, maxResults, maxSymbols);
27682780

27692781
try
27702782
{
@@ -2778,18 +2790,20 @@ std::vector<TTDCallEvent> EsrevenAdapter::GetTTDCallsForSymbols(const std::strin
27782790
if (startReturnAddress != 0 || endReturnAddress != 0)
27792791
{
27802792
// Include return address range for server-side filtering
2793+
// maxSymbols == 0 means no limit: omit the suffix entirely
27812794
packet = fmt::format("rvn:get-calls-by-symbol:{}:{:x}:{:x}{}",
27822795
symbols,
27832796
startReturnAddress != 0 ? startReturnAddress : 0,
27842797
endReturnAddress != 0 ? endReturnAddress : 0xFFFFFFFFFFFFFFFF,
2785-
isWildcard ? ":50" : ""); // Limit wildcards to 50 symbols
2798+
(isWildcard && maxSymbols > 0) ? fmt::format(":{}", maxSymbols) : "");
27862799
}
27872800
else
27882801
{
27892802
// No filtering - query all calls
2803+
// maxSymbols == 0 means no limit: omit :::N so the server searches all symbols
27902804
packet = fmt::format("rvn:get-calls-by-symbol:{}{}",
27912805
symbols,
2792-
isWildcard ? ":::50" : ""); // Format: symbol:::max_symbols
2806+
(isWildcard && maxSymbols > 0) ? fmt::format(":::{}", maxSymbols) : "");
27932807
}
27942808

27952809
// Send with custom timeout
@@ -2859,17 +2873,30 @@ std::vector<TTDCallEvent> EsrevenAdapter::GetTTDCallsForSymbols(const std::strin
28592873

28602874
// Helper lambda to extract string field
28612875
auto extractString = [&objectStr](const std::string& fieldName) -> std::string {
2862-
std::string searchStr = "\"" + fieldName + "\":\"";
2876+
std::string searchStr = "\"" + fieldName + "\"";
28632877
size_t fieldPos = objectStr.find(searchStr);
28642878
if (fieldPos == std::string::npos)
28652879
return "";
28662880

28672881
fieldPos += searchStr.length();
2868-
size_t endQuote = objectStr.find('\"', fieldPos);
2882+
size_t colonPos = objectStr.find(':', fieldPos);
2883+
if (colonPos == std::string::npos)
2884+
return "";
2885+
2886+
// Skip whitespace after colon (handles both `":"` and `": "`)
2887+
size_t quotePos = colonPos + 1;
2888+
while (quotePos < objectStr.length() && std::isspace(objectStr[quotePos]))
2889+
quotePos++;
2890+
2891+
if (quotePos >= objectStr.length() || objectStr[quotePos] != '"')
2892+
return "";
2893+
2894+
quotePos++; // skip opening quote
2895+
size_t endQuote = objectStr.find('\"', quotePos);
28692896
if (endQuote == std::string::npos)
28702897
return "";
28712898

2872-
return objectStr.substr(fieldPos, endQuote - fieldPos);
2899+
return objectStr.substr(quotePos, endQuote - quotePos);
28732900
};
28742901

28752902
// Extract fields

0 commit comments

Comments
 (0)