Skip to content

Commit 0cc7cc1

Browse files
Copilotxusheng6
andcommitted
Fix TTD Memory issues: use !tt command for time travel, improve context menu integration, and add missing context menu entries
Co-authored-by: xusheng6 <[email protected]>
1 parent 3773f4d commit 0cc7cc1

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

core/adapters/dbgengttdadapter.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -457,31 +457,19 @@ bool DbgEngTTDAdapter::SetTTDPosition(const TTDPosition& position)
457457
return false;
458458
}
459459

460-
// Use data model API to navigate to position
461-
std::string expression = fmt::format("@$curprocess.TTD.SetPosition(\"{:X}:{:X}\")", position.sequence, position.step);
462-
std::string output = EvaluateDataModelExpression(expression);
463-
464-
if (!output.empty())
465-
{
466-
// Check if the operation succeeded
467-
bool success = output.find("error") == std::string::npos && output.find("Error") == std::string::npos;
468-
if (success)
469-
{
470-
LogInfo("Successfully navigated to TTD position {:X}:{:X}", position.sequence, position.step);
471-
return true;
472-
}
473-
}
474-
475-
// Fallback to command interface if data model doesn't work
476-
LogWarn("Data model navigation failed, falling back to command interface");
460+
// Use InvokeBackendCommand with !tt command to navigate to position
477461
std::string command = fmt::format("!tt {:X}:{:X}", position.sequence, position.step);
478-
std::string output_fallback = InvokeBackendCommand(command);
462+
std::string output = InvokeBackendCommand(command);
479463

480464
// Check if the command succeeded (basic check)
481-
bool success = output_fallback.find("error") == std::string::npos && output_fallback.find("failed") == std::string::npos;
465+
bool success = output.find("error") == std::string::npos && output.find("failed") == std::string::npos;
482466
if (success)
483467
{
484-
LogInfo("Successfully navigated to TTD position {:X}:{:X} (fallback)", position.sequence, position.step);
468+
LogInfo("Successfully navigated to TTD position {:X}:{:X}", position.sequence, position.step);
469+
}
470+
else
471+
{
472+
LogError("Failed to navigate to TTD position {:X}:{:X}", position.sequence, position.step);
485473
}
486474
return success;
487475
}

ui/ui.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ limitations under the License.
4242
#include "debuggerinfowidget.h"
4343
#include "ttdmemorywidget.h"
4444
#include "freeversion.h"
45+
#include <QTimer>
4546

4647
#ifdef WIN32
4748
#include "ttdrecord.h"
@@ -216,9 +217,7 @@ void GlobalDebuggerUI::QueryTTDMemoryAccess(const UIActionContext& ctxt, uint64_
216217
if (!sidebar)
217218
return;
218219

219-
sidebar->activate("TTD Memory");
220-
221-
// Get the current view frame and find the TTD Memory widget
220+
// Get the current view frame
222221
ViewFrame* frame = ctxt.context->getCurrentViewFrame();
223222
if (!frame)
224223
return;
@@ -227,18 +226,25 @@ void GlobalDebuggerUI::QueryTTDMemoryAccess(const UIActionContext& ctxt, uint64_
227226
if (!controller)
228227
return;
229228

230-
// Get the TTDMemoryWidgetType and find the widget instance
231-
// For now, we'll use a simple approach: iterate through created widgets
232-
// Note: This is a simplified implementation - in production code,
233-
// we might need a more robust widget discovery mechanism
234-
235229
// Convert BNDebuggerTTDMemoryAccessType to TTDMemoryAccessType
236230
TTDMemoryAccessType accessTypeEnum = static_cast<TTDMemoryAccessType>(accessType);
237231

238-
// Try to find the TTD Memory sidebar widget
239-
// Since we just activated it, we can try to access it through global widget tracking
240-
// For this implementation, we'll use a callback approach through the widget type
232+
// Set pending query first
241233
TTDMemoryWidgetType::SetPendingQuery(frame, ctxt.binaryView, startAddr, endAddr, accessTypeEnum);
234+
235+
// Activate the sidebar widget
236+
sidebar->activate("TTD Memory");
237+
238+
// Try to find the widget that was just created/activated and apply the query immediately
239+
// We'll give it a moment to be created if needed
240+
QTimer::singleShot(100, [frame, ctxt, startAddr, endAddr, accessTypeEnum]() {
241+
// Try to find the active TTD Memory widget
242+
auto* sidebarWidget = frame->getSidebarWidget("TTD Memory");
243+
if (auto* ttdWidget = qobject_cast<TTDMemorySidebarWidget*>(sidebarWidget))
244+
{
245+
ttdWidget->setParametersAndQuery(startAddr, endAddr, accessTypeEnum);
246+
}
247+
});
242248
}
243249

244250

ui/uinotification.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,12 @@ void NotificationListener::OnContextMenuCreated(UIContext *context, View* view,
186186
menu.addAction("Debugger", "Run To Here", "Control");
187187
menu.addAction("Debugger", "Create Stack View", "Misc");
188188
menu.addAction("Debugger", "Override IP", "Misc");
189+
#ifdef WIN32
190+
// TTD Memory Access context menu items
191+
menu.addAction("Debugger", "TTD Memory Access\\Read", "TTD");
192+
menu.addAction("Debugger", "TTD Memory Access\\Write", "TTD");
193+
menu.addAction("Debugger", "TTD Memory Access\\Read/Write", "TTD");
194+
menu.addAction("Debugger", "TTD Memory Access\\Execute", "TTD");
195+
menu.addAction("Debugger", "TTD Memory Access\\Read/Write/Execute", "TTD");
196+
#endif
189197
}

0 commit comments

Comments
 (0)