Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/renderlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,5 @@ void RegisterRenderLayers()
static TTDCoverageRenderLayer* g_ttdCoverageRenderLayer = new TTDCoverageRenderLayer();

RenderLayer::Register(g_debuggerRenderLayer, BNRenderLayerDefaultEnableState::AlwaysEnabledRenderLayerDefaultEnableState);
RenderLayer::Register(g_ttdCoverageRenderLayer, BNRenderLayerDefaultEnableState::DisabledByDefaultRenderLayerDefaultEnableState);
RenderLayer::Register(g_ttdCoverageRenderLayer, BNRenderLayerDefaultEnableState::EnabledByDefaultRenderLayerDefaultEnableState);
}
26 changes: 24 additions & 2 deletions ui/ttdanalysisdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
#include <QJsonDocument>
#include <QJsonObject>
#include <QApplication>
#include "uicontext.h"
#include "linearview.h"

TTDAnalysisWorker::TTDAnalysisWorker(DbgRef<DebuggerController> controller, TTDAnalysisType type, QObject* parent)
: QThread(parent), m_controller(controller), m_analysisType(type), m_useRange(false), m_startAddress(0), m_endAddress(0)
Expand Down Expand Up @@ -91,8 +93,8 @@ void TTDAnalysisWorker::run()
emit analysisCompleted(success, message, resultCount);
}

TTDAnalysisDialog::TTDAnalysisDialog(BinaryViewRef data, QWidget* parent)
: QDialog(parent), m_data(data), m_currentWorker(nullptr)
TTDAnalysisDialog::TTDAnalysisDialog(UIContext* context, BinaryViewRef data, QWidget* parent)
: QDialog(parent), m_context(context), m_data(data), m_currentWorker(nullptr)
{
m_controller = DebuggerController::GetController(data);

Expand Down Expand Up @@ -550,6 +552,11 @@ void TTDAnalysisDialog::onAnalysisCompleted(bool success, const QString& message
{
QMessageBox::warning(this, "Analysis Failed", message);
}
else
{
// Refresh the view to make coverage visible immediately
refreshView();
}
}

void TTDAnalysisDialog::onSaveResults()
Expand Down Expand Up @@ -591,6 +598,9 @@ void TTDAnalysisDialog::onLoadResults()

populateAnalysisList();
QMessageBox::information(this, "Load Results", "Analysis results loaded successfully");

// Refresh the view to show the loaded coverage
refreshView();
}
else
{
Expand Down Expand Up @@ -774,3 +784,15 @@ bool TTDAnalysisDialog::loadAnalysisResults(TTDAnalysisResult& result)

return true;
}

void TTDAnalysisDialog::refreshView()
{
// Use the stored UI context to refresh the view
if (!m_context)
return;

// Refresh the current view contents to show the coverage immediately
// The TTD Coverage render layer is always enabled and will automatically
// display coverage highlights when coverage data is available
m_context->refreshCurrentViewContents();
}
6 changes: 5 additions & 1 deletion ui/ttdanalysisdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ limitations under the License.
#include <QThread>
#include <QMutex>
#include "binaryninjaapi.h"
#include "uicontext.h"
#include "viewframe.h"
#include "debuggerapi.h"
#include <uitypes.h>

Expand Down Expand Up @@ -94,7 +96,7 @@ class TTDAnalysisDialog : public QDialog
Q_OBJECT

public:
TTDAnalysisDialog(BinaryViewRef data, QWidget* parent = nullptr);
TTDAnalysisDialog(UIContext* context, BinaryViewRef data, QWidget* parent = nullptr);
~TTDAnalysisDialog();

private slots:
Expand All @@ -115,7 +117,9 @@ private slots:
QString getDefaultCachePath(TTDAnalysisType type);
bool saveAnalysisResults(const TTDAnalysisResult& result);
bool loadAnalysisResults(TTDAnalysisResult& result);
void refreshView();

UIContext* m_context;
BinaryViewRef m_data;
DbgRef<DebuggerController> m_controller;

Expand Down
8 changes: 8 additions & 0 deletions ui/ttdcoveragerenderlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ void TTDCoverageRenderLayer::ApplyToBlock(Ref<BasicBlock> block, std::vector<Dis
if (!controller->IsTTD())
return;

// Quick check: if no coverage data has been loaded, return immediately
if (controller->GetExecutedInstructionCount() == 0)
return;

for (auto& line : lines)
{
// Do not highlight empty lines or comments
Expand Down Expand Up @@ -76,6 +80,10 @@ void TTDCoverageRenderLayer::ApplyToHighLevelILBody(Ref<Function> function, std:
if (!controller->IsTTD())
return;

// Quick check: if no coverage data has been loaded, return immediately
if (controller->GetExecutedInstructionCount() == 0)
return;

for (auto& linearLine : lines)
{
DisassemblyTextLine& line = linearLine.contents;
Expand Down
2 changes: 1 addition & 1 deletion ui/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ void GlobalDebuggerUI::SetupMenu(UIContext* context)
if (!controller || !controller->IsTTD())
return;

auto dialog = new TTDAnalysisDialog(ctxt.binaryView, nullptr);
auto dialog = new TTDAnalysisDialog(ctxt.context, ctxt.binaryView, nullptr);
dialog->show();
dialog->raise();
dialog->activateWindow();
Expand Down