Skip to content

Commit 4c3a16f

Browse files
Copilotxusheng6
andcommitted
Implement TTD.Calls functionality - core implementation and UI
Co-authored-by: xusheng6 <[email protected]>
1 parent 0b54994 commit 4c3a16f

File tree

13 files changed

+1472
-0
lines changed

13 files changed

+1472
-0
lines changed

api/debuggerapi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,23 @@ namespace BinaryNinjaDebuggerAPI {
500500
TTDMemoryEvent() : threadId(0), uniqueThreadId(0), accessType(TTDMemoryRead), address(0), size(0), memoryAddress(0), instructionAddress(0), value(0) {}
501501
};
502502

503+
struct TTDCallEvent
504+
{
505+
std::string eventType; // Event type (always "Call" for TTD.Calls objects)
506+
uint32_t threadId; // OS thread ID of thread that made the call
507+
uint32_t uniqueThreadId; // Unique ID for the thread across the trace
508+
std::string function; // Symbolic name of the function
509+
uint64_t functionAddress; // Function's address in memory
510+
uint64_t returnAddress; // Instruction to return to after the call
511+
uint64_t returnValue; // Return value of the function (if not void)
512+
bool hasReturnValue; // Whether the function has a return value
513+
std::vector<std::string> parameters; // Array containing parameters passed to the function
514+
TTDPosition timeStart; // Position when call started
515+
TTDPosition timeEnd; // Position when call ended
516+
517+
TTDCallEvent() : threadId(0), uniqueThreadId(0), functionAddress(0), returnAddress(0), returnValue(0), hasReturnValue(false) {}
518+
};
519+
503520

504521
typedef BNDebugAdapterConnectionStatus DebugAdapterConnectionStatus;
505522
typedef BNDebugAdapterTargetStatus DebugAdapterTargetStatus;
@@ -665,6 +682,7 @@ namespace BinaryNinjaDebuggerAPI {
665682

666683
// TTD Memory Analysis Methods
667684
std::vector<TTDMemoryEvent> GetTTDMemoryAccessForAddress(uint64_t address, uint64_t size, TTDMemoryAccessType accessType = TTDMemoryRead);
685+
std::vector<TTDCallEvent> GetTTDCallsForSymbols(const std::vector<std::string>& symbols, uint64_t startReturnAddress = 0, uint64_t endReturnAddress = 0);
668686
TTDPosition GetCurrentTTDPosition();
669687
bool SetTTDPosition(const TTDPosition& position);
670688

api/ffi.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@ extern "C"
323323
BNDebuggerTTDMemoryAccessType accessType;
324324
} BNDebuggerTTDMemoryEvent;
325325

326+
typedef struct BNDebuggerTTDCallEvent
327+
{
328+
char* eventType; // Event type (always "Call" for TTD.Calls objects)
329+
uint32_t threadId; // OS thread ID of thread that made the call
330+
uint32_t uniqueThreadId; // Unique ID for the thread across the trace
331+
char* function; // Symbolic name of the function
332+
uint64_t functionAddress; // Function's address in memory
333+
uint64_t returnAddress; // Instruction to return to after the call
334+
uint64_t returnValue; // Return value of the function (if not void)
335+
bool hasReturnValue; // Whether the function has a return value
336+
char** parameters; // Array containing parameters passed to the function
337+
size_t parameterCount; // Number of parameters
338+
BNDebuggerTTDPosition timeStart; // Position when call started
339+
BNDebuggerTTDPosition timeEnd; // Position when call ended
340+
} BNDebuggerTTDCallEvent;
341+
326342

327343
// This should really be a union, but gcc complains...
328344
typedef struct BNDebuggerEventData
@@ -533,9 +549,12 @@ extern "C"
533549
// TTD Memory Analysis Functions
534550
DEBUGGER_FFI_API BNDebuggerTTDMemoryEvent* BNDebuggerGetTTDMemoryAccessForAddress(BNDebuggerController* controller,
535551
uint64_t address, uint64_t size, BNDebuggerTTDMemoryAccessType accessType, size_t* count);
552+
DEBUGGER_FFI_API BNDebuggerTTDCallEvent* BNDebuggerGetTTDCallsForSymbols(BNDebuggerController* controller,
553+
const char** symbols, size_t symbolCount, uint64_t startReturnAddress, uint64_t endReturnAddress, size_t* count);
536554
DEBUGGER_FFI_API BNDebuggerTTDPosition BNDebuggerGetCurrentTTDPosition(BNDebuggerController* controller);
537555
DEBUGGER_FFI_API bool BNDebuggerSetTTDPosition(BNDebuggerController* controller, BNDebuggerTTDPosition position);
538556
DEBUGGER_FFI_API void BNDebuggerFreeTTDMemoryEvents(BNDebuggerTTDMemoryEvent* events);
557+
DEBUGGER_FFI_API void BNDebuggerFreeTTDCallEvents(BNDebuggerTTDCallEvent* events);
539558

540559
DEBUGGER_FFI_API void BNDebuggerPostDebuggerEvent(BNDebuggerController* controller, BNDebuggerEvent* event);
541560

0 commit comments

Comments
 (0)