Skip to content

Commit

Permalink
Add a debugger info sidebar widget to display relevant info during de…
Browse files Browse the repository at this point in the history
…bugging
  • Loading branch information
xusheng6 committed Oct 21, 2024
1 parent 8c9c129 commit 721e5ec
Show file tree
Hide file tree
Showing 9 changed files with 2,347 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/debuggerapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,14 @@ namespace BinaryNinjaDebuggerAPI {
bool ReAddDebuggerMemoryRegion();

uint64_t GetViewFileSegmentsStart();

bool ComputeExprValue(const Ref<LowLevelILFunction>& func, const LowLevelILInstruction& expr,
uint64_t & value);
bool ComputeExprValue(const Ref<MediumLevelILFunction>& func, const MediumLevelILInstruction& expr,
uint64_t & value);
bool ComputeExprValue(const Ref<HighLevelILFunction>& func, const HighLevelILInstruction& expr,
uint64_t & value);
bool GetVariableValue(Variable& var, uint64_t address, size_t size, uint64_t& value);
};


Expand Down
31 changes: 31 additions & 0 deletions api/debuggercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ limitations under the License.
*/

#include "debuggerapi.h"
#include "lowlevelilinstruction.h"
#include "mediumlevelilinstruction.h"
#include "highlevelilinstruction.h"

using namespace BinaryNinja;
using namespace BinaryNinjaDebuggerAPI;
Expand Down Expand Up @@ -927,3 +930,31 @@ uint64_t DebuggerController::GetViewFileSegmentsStart()
{
return BNDebuggerGetViewFileSegmentsStart(m_object);
}


bool DebuggerController::ComputeExprValue(const Ref<LowLevelILFunction>& func,
const BinaryNinja::LowLevelILInstruction &expr, uint64_t &value)
{
return BNDebuggerComputeLLILExprValue(m_object, func->GetObject(), expr.exprIndex, value);
}


bool DebuggerController::ComputeExprValue(const Ref<MediumLevelILFunction>& func,
const BinaryNinja::MediumLevelILInstruction &expr, uint64_t &value)
{
return BNDebuggerComputeMLILExprValue(m_object, func->GetObject(), expr.exprIndex, value);
}


bool DebuggerController::ComputeExprValue(const Ref<HighLevelILFunction>& func,
const BinaryNinja::HighLevelILInstruction &expr, uint64_t &value)
{
return BNDebuggerComputeHLILExprValue(m_object, func->GetObject(), expr.exprIndex, value);
}


bool DebuggerController::GetVariableValue(BinaryNinja::Variable &var, uint64_t address, size_t size,
uint64_t &value)
{
return BNDebuggerGetVariableValue(m_object, &var, address, size, value);
}
14 changes: 14 additions & 0 deletions api/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ extern "C"
typedef struct BNArchitecture BNArchitecture;
typedef struct BNDataBuffer BNDataBuffer;
typedef struct BNMetadata BNMetadata;
typedef struct BNLowLevelILFunction BNLowLevelILFunction;
typedef struct BNMediumLevelILFunction BNMediumLevelILFunction;
typedef struct BNHighLevelILFunction BNHighLevelILFunction;
typedef struct BNVariable BNVariable;

// When `ffi.h` gets parsed by clang type parser, the binaryninjacore.h is NOT included so this enum will become not
// defined. As a workaround, I duplicate its definition here. When the code gets compiled, the `BN_TYPE_PARSER` is
Expand Down Expand Up @@ -516,6 +520,16 @@ extern "C"
DEBUGGER_FFI_API bool BNDebuggerSetAdapterProperty(
BNDebuggerController* controller, const char* name, BNMetadata* value);

// Compute expression values
DEBUGGER_FFI_API bool BNDebuggerComputeLLILExprValue(BNDebuggerController* controller,
BNLowLevelILFunction* function, size_t expr, uint64_t& value);
DEBUGGER_FFI_API bool BNDebuggerComputeMLILExprValue(BNDebuggerController* controller,
BNMediumLevelILFunction* function, size_t expr, uint64_t& value);
DEBUGGER_FFI_API bool BNDebuggerComputeHLILExprValue(BNDebuggerController* controller,
BNHighLevelILFunction* function, size_t expr, uint64_t& value);
DEBUGGER_FFI_API bool BNDebuggerGetVariableValue(BNDebuggerController* controller,
BNVariable* variable, uint64_t address, size_t size, uint64_t& value);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 721e5ec

Please sign in to comment.