Skip to content

Commit ff511ce

Browse files
committed
Support querying arbitrary property from the debugadapter
1 parent 093c9b6 commit ff511ce

File tree

9 files changed

+72
-4
lines changed

9 files changed

+72
-4
lines changed

api/debuggerapi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ namespace BinaryNinjaDebuggerAPI
334334

335335
static std::string GetDebugStopReasonString(DebugStopReason reason);
336336
DebugStopReason StopReason();
337+
338+
BinaryNinja::Ref<Metadata> GetAdapterProperty(const std::string& name);
339+
bool SetAdapterProperty(const std::string& name, const BinaryNinja::Ref<Metadata>& value);
337340
};
338341

339342

api/debuggercontroller.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,18 @@ DebugStopReason DebuggerController::StopReason()
665665
{
666666
return BNDebuggerGetStopReason(m_object);
667667
}
668+
669+
670+
Ref<Metadata> DebuggerController::GetAdapterProperty(const std::string& name)
671+
{
672+
BNMetadata* value = BNDebuggerGetAdapterProperty(m_object, name.c_str());
673+
if (!value)
674+
return nullptr;
675+
return new Metadata(value);
676+
}
677+
678+
679+
bool DebuggerController::SetAdapterProperty(const std::string& name, const BinaryNinja::Ref<Metadata>& value)
680+
{
681+
return BNDebuggerSetAdapterProperty(m_object, name.c_str(), value->m_object);
682+
}

api/ffi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern "C"
5151
struct BNBinaryView;
5252
struct BNArchitecture;
5353
struct BNDataBuffer;
54+
struct BNMetadata;
5455
enum BNFunctionGraphType;
5556

5657
struct BNDebugThread
@@ -399,6 +400,10 @@ extern "C"
399400
void* ctx);
400401
DEBUGGER_FFI_API void BNDebuggerRemoveEventCallback(BNDebuggerController* controller, size_t index);
401402

403+
DEBUGGER_FFI_API BNMetadata* BNDebuggerGetAdapterProperty(BNDebuggerController* controller, const char* name);
404+
DEBUGGER_FFI_API bool BNDebuggerSetAdapterProperty(BNDebuggerController* controller, const char* name,
405+
BNMetadata* value);
406+
402407
#ifdef __cplusplus
403408
}
404409
#endif

core/debugadapter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,15 @@ bool DebugAdapter::DisconnectDebugServer()
112112
{
113113
return true;
114114
}
115+
116+
117+
Ref<Metadata> DebugAdapter::GetProperty(const std::string &name)
118+
{
119+
return nullptr;
120+
}
121+
122+
123+
bool DebugAdapter::SetProperty(const std::string &name, const BinaryNinja::Ref<BinaryNinja::Metadata>& value)
124+
{
125+
return false;
126+
}

core/debugadapter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,9 @@ namespace BinaryNinjaDebugger
272272
void PostDebuggerEvent(const DebuggerEvent &event);
273273

274274
virtual void WriteStdin(const std::string& msg);
275+
276+
BinaryNinja::Ref<BinaryNinja::Metadata> GetProperty(const std::string& name);
277+
278+
bool SetProperty(const std::string& name, const BinaryNinja::Ref<BinaryNinja::Metadata>& value);
275279
};
276280
};

core/debuggercontroller.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,3 +1477,18 @@ DebugStopReason DebuggerController::WaitForAdapterStop()
14771477
RemoveEventCallback(callback);
14781478
return reason;
14791479
}
1480+
1481+
1482+
Ref<Metadata> DebuggerController::GetAdapterProperty(const std::string& name)
1483+
{
1484+
if (!m_adapter)
1485+
return nullptr;
1486+
1487+
return m_adapter->GetProperty(name);
1488+
}
1489+
1490+
1491+
bool DebuggerController::SetAdapterProperty(const std::string& name, const BinaryNinja::Ref<BinaryNinja::Metadata>& value)
1492+
{
1493+
return true;
1494+
}

core/debuggercontroller.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,8 @@ namespace BinaryNinjaDebugger
226226

227227
DebugStopReason WaitForTargetStop();
228228
DebugStopReason WaitForAdapterStop();
229+
230+
BinaryNinja::Ref<BinaryNinja::Metadata> GetAdapterProperty(const std::string& name);
231+
bool SetAdapterProperty(const std::string& name, const BinaryNinja::Ref<BinaryNinja::Metadata>& value);
229232
};
230233
};

core/ffi.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,3 +819,16 @@ DEBUGGER_FFI_API DebugStopReason BNDebuggerGetStopReason(BNDebuggerController* c
819819
{
820820
return controller->object->StopReason();
821821
}
822+
823+
824+
DEBUGGER_FFI_API BNMetadata* BNDebuggerGetAdapterProperty(BNDebuggerController* controller, const char* name)
825+
{
826+
return API_OBJECT_REF(controller->object->GetAdapterProperty(name));
827+
}
828+
829+
830+
DEBUGGER_FFI_API bool BNDebuggerSetAdapterProperty(BNDebuggerController* controller, const char* name,
831+
BNMetadata* value)
832+
{
833+
return controller->object->SetAdapterProperty(name, new Metadata(BNNewMetadataReference(value)));
834+
}

ui/debugserversetting.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ limitations under the License.
2828
#include "fontsettings.h"
2929
#include "debuggerapi.h"
3030

31-
using namespace BinaryNinjaDebuggerAPI;
32-
3331
class DebugServerSettingsDialog: public QDialog
3432
{
3533
Q_OBJECT
3634

3735
private:
38-
DebuggerController* m_controller;
36+
BinaryNinjaDebuggerAPI::DebuggerController* m_controller;
3937
QLineEdit* m_addressEntry;
4038
QLineEdit* m_portEntry;
4139

4240
public:
43-
DebugServerSettingsDialog(QWidget* parent, DebuggerController* controller);
41+
DebugServerSettingsDialog(QWidget* parent, BinaryNinjaDebuggerAPI::DebuggerController* controller);
4442

4543
private Q_SLOTS:
4644
void apply();

0 commit comments

Comments
 (0)