Skip to content

Commit 36d70a1

Browse files
Copilotxusheng6
andcommitted
Add debug adapter selection dropdown to controls widget
Co-authored-by: xusheng6 <[email protected]>
1 parent cdd86f7 commit 36d70a1

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

ui/controlswidget.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ DebugControlsWidget::DebugControlsWidget(QWidget* parent, const std::string name
4040
if (!m_controller)
4141
return;
4242

43+
// Add adapter selector dropdown at the top
44+
m_adapterSelector = new QComboBox(this);
45+
m_adapterSelector->setMinimumWidth(150);
46+
for (const std::string& adapter : DebugAdapterType::GetAvailableAdapters(m_controller->GetData()))
47+
{
48+
m_adapterSelector->addItem(QString::fromStdString(adapter));
49+
}
50+
51+
// Set current adapter
52+
if (!m_controller->GetAdapterType().empty())
53+
{
54+
m_adapterSelector->setCurrentText(QString::fromStdString(m_controller->GetAdapterType()));
55+
}
56+
else if (m_adapterSelector->count() > 0)
57+
{
58+
// Set first available adapter if none is set
59+
m_controller->SetAdapterType(m_adapterSelector->itemText(0).toStdString());
60+
m_adapterSelector->setCurrentIndex(0);
61+
}
62+
63+
connect(m_adapterSelector, &QComboBox::currentTextChanged, this, &DebugControlsWidget::selectAdapter);
64+
65+
addWidget(m_adapterSelector);
66+
addSeparator();
67+
4368
auto cyan = getThemeColor(CyanStandardHighlightColor);
4469
auto green = getThemeColor(GreenStandardHighlightColor);
4570
auto red = getThemeColor(RedStandardHighlightColor);
@@ -587,3 +612,21 @@ void DebugControlsWidget::performTimestampNavigation()
587612
auto* dialog = new TimestampNavigationDialog(this, m_controller);
588613
dialog->show();
589614
}
615+
616+
617+
void DebugControlsWidget::selectAdapter(const QString& adapter)
618+
{
619+
if (adapter.isEmpty())
620+
return;
621+
622+
auto adapterType = DebugAdapterType::GetByName(adapter.toStdString());
623+
if (!adapterType)
624+
return;
625+
626+
m_controller->SetAdapterType(adapter.toStdString());
627+
Ref<Metadata> data = new Metadata(adapter.toStdString());
628+
m_controller->GetData()->StoreMetadata("debugger.adapter_type", data);
629+
630+
// Update button states after adapter change
631+
updateButtons();
632+
}

ui/controlswidget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ limitations under the License.
2121
#include <QToolButton>
2222
#include <QIcon>
2323
#include <QLineEdit>
24+
#include <QComboBox>
2425
#include "binaryninjaapi.h"
2526
#include "uicontext.h"
2627
#include "debuggerapi.h"
@@ -36,6 +37,8 @@ class DebugControlsWidget : public QToolBar
3637
std::string m_name;
3738
DbgRef<DebuggerController> m_controller;
3839

40+
QComboBox* m_adapterSelector;
41+
3942
QAction* m_actionRun;
4043
QAction* m_actionAttachPid;
4144
QAction* m_actionRestart;
@@ -92,4 +95,5 @@ public Q_SLOTS:
9295
void performSettings();
9396
void toggleBreakpoint();
9497
void performTimestampNavigation();
98+
void selectAdapter(const QString& adapter);
9599
};

0 commit comments

Comments
 (0)