@@ -352,6 +352,16 @@ Ref<Settings> DbgEngTTDAdapterType::RegisterAdapterSettings()
352352 "readOnly" : false,
353353 "uiSelectionAction" : "file"
354354 })" );
355+ settings->RegisterSetting (" ttd.maxQueryResults" ,
356+ R"( {
357+ "title" : "Max Query Results",
358+ "type" : "number",
359+ "default" : 10000,
360+ "minValue" : 1,
361+ "maxValue" : 1000000,
362+ "description" : "Maximum number of results to return from TTD Memory and TTD Calls queries to prevent performance issues with large traces",
363+ "readOnly" : false
364+ })" );
355365
356366 return settings;
357367}
@@ -497,8 +507,13 @@ bool DbgEngTTDAdapter::QueryMemoryAccessByAddress(uint64_t startAddress, uint64_
497507 return false ;
498508 }
499509
500- // Create the actual TTD memory query expression
501- std::string expression = fmt::format (" @$cursession.TTD.Memory(0x{:x},0x{:x},\" {}\" )" , startAddress, endAddress, accessTypeStr);
510+ // Get the max results setting
511+ auto adapterSettings = GetAdapterSettings ();
512+ BNSettingsScope scope = SettingsResourceScope;
513+ auto maxResults = adapterSettings->Get <uint64_t >(" ttd.maxQueryResults" , GetData (), &scope);
514+
515+ // Create the actual TTD memory query expression with result limit
516+ std::string expression = fmt::format (" @$cursession.TTD.Memory(0x{:x},0x{:x},\" {}\" ).Take({})" , startAddress, endAddress, accessTypeStr, maxResults);
502517
503518 LogInfo (" Executing TTD memory query: %s" , expression.c_str ());
504519
@@ -509,7 +524,7 @@ bool DbgEngTTDAdapter::QueryMemoryAccessByAddress(uint64_t startAddress, uint64_
509524 return false ;
510525 }
511526
512- LogInfo (" Successfully retrieved %zu TTD memory events" , events.size ());
527+ LogInfo (" Successfully retrieved %zu TTD memory events (limited to %llu) " , events.size (), maxResults );
513528 return true ;
514529 }
515530 catch (const std::exception& e)
@@ -982,6 +997,13 @@ bool DbgEngTTDAdapter::QueryCallsForSymbols(const std::vector<std::string>& symb
982997 fmt::format (" {:x}" , endReturnAddress) + " )" ;
983998 }
984999
1000+ // Get the max results setting and add Take() to limit results
1001+ auto adapterSettings = GetAdapterSettings ();
1002+ BNSettingsScope scope = SettingsResourceScope;
1003+ auto maxResults = adapterSettings->Get <uint64_t >(" ttd.maxQueryResults" , GetData (), &scope);
1004+
1005+ expression += fmt::format (" .Take({})" , maxResults);
1006+
9851007 LogInfo (" Executing TTD calls query: %s" , expression.c_str ());
9861008
9871009 return ParseTTDCallObjects (expression, events);
0 commit comments