Class |
Description |
|---|---|
DebugBreakpoint represents a breakpoint in the target. It has the following fields: |
|
DebugBreakpoints represents all breakpoints of the target. |
|
DebugFrame represents a frame in the stack trace. It has the following fields: |
|
DebugModule represents a module in the target. It has the following fields: |
|
DebugModules represents all modules of the target. |
|
DebugProcess represents a process in the target. It has the following fields: |
|
DebugRegister represents a register in the target. It has the following fields: |
|
DebugRegisters represents all registers of the target. |
|
DebugThread represents a thread in the target. It has the following fields: |
|
DebugThreads represents all threads of the target. |
|
The |
|
DebuggerEvent is the event object that a debugger event callback receives |
|
DebuggerEventData is the collection of all possible data associated with the debugger events |
|
|
|
ErrorEventData is the data associated with a ErrorEvent |
|
ModuleNameAndOffset represents an address that is relative to the start of module. |
|
|
StdOutMessageEventData is the data associated with a StdOutMessageEvent |
TTDBookmark represents a saved position in a TTD trace with an optional note and view address. |
|
TTDCallEvent represents a function call event in a TTD trace. It has the following fields: |
|
TTDEvent represents important events that happened during a TTD trace. |
|
TTD Event Type enumeration for different types of events in TTD traces. These are bitfield flags… |
|
TTDException represents information about exceptions that occurred during a TTD trace. |
|
TTD Exception Type enumeration for different types of exceptions. |
|
TTDMemoryEvent represents a memory access event in a TTD trace. It has the following fields: |
|
TTDModule represents information about modules that were loaded/unloaded during a TTD trace. |
|
TTDPosition represents a position in a time travel debugging trace. |
|
|
TTDPositionRangeIndexedMemoryEvent represents a memory access event in a TTD trace with position… |
TTDThread represents information about threads and their lifetime during a TTD trace. |
|
|
TargetExitedEventData is the data associated with a TargetExitedEvent |
|
TargetStoppedEventData is the data associated with a TargetStoppedEvent |
Function |
Description |
|---|---|
|
Parse TTD memory access type from string specification. |
Bases: object
DebugBreakpoint represents a breakpoint in the target. It has the following fields:
module: the name of the module for which the breakpoint is in
offset: the offset of the breakpoint to the start of the module
address: the absolute address of the breakpoint
enabled: whether the breakpoint is enabled (read-only)
condition: the condition expression for the breakpoint (empty if no condition)
type: the type of breakpoint (Software, HardwareExecute, HardwareRead, HardwareWrite, HardwareAccess)
size: the size in bytes for hardware breakpoints/watchpoints (1, 2, 4, or 8)
Bases: object
DebugBreakpoints represents all breakpoints of the target.
breakpoints (List[DebugBreakpoint]) –
Bases: object
DebugFrame represents a frame in the stack trace. It has the following fields:
index: the index of the frame
pc: the program counter of the frame
sp: the stack pointer of the frame
fp: the frame pointer of the frame
func_name: the function name which the pc is in
func_start: the start of the function
module: the module of the pc
Bases: object
DebugModules represents all modules of the target.
modules (List[DebugModule]) –
Bases: object
DebugRegister represents a register in the target. It has the following fields:
name: the name of the register
value: the value of the register
width: the width of the register, in bits. E.g., rax register is 64-bits wide
index: the index of the register. This is reported by the DebugAdapter and should remain unchanged
hint: a string that shows the content of the memory pointed to by the register. It is empty if the register value do not point to a valid (mapped) memory region
Bases: object
DebugThread represents a thread in the target. It has the following fields:
tid: the ID of the thread. On different systems, this may be either the system thread ID, or a sequential index starting from zero.
rip: the current address (instruction pointer) of the thread
In the future, we should provide both the internal thread ID and the system thread ID.
Bases: object
DebugThreads represents all threads of the target.
threads (List[DebugThread]) –
Bases: object
The DebuggerController object is the core of the debugger. Most debugger operations can be performed on it.
It takes in a BinaryView and creates a debugger for it. If a debugger is already existing for the very same
BinaryView object, the debugger is returned.
Most operations of the debugger are performed on this class. For example, we can launch the debugger as follows:
>>> bv = load("test/binaries/helloworld")
>>> dbg = DebuggerController(bv)
>>> dbg.launch_and_wait()
<DebugStopReason.Breakpoint: 6>
When the launch_and_wait() returns DebugStopReason.Breakpoint, it means the debugger has launched the target
successfully, and the target stopped at the entry point of the binary. Now we can perform other control operations
on it, e.g., resume the target by calling step_into_and_wait().
>>> dbg.step_into_and_wait()
<DebugStopReason.SingleStep: 4>
For all the API functions that resume the target, e.g., launch go, step into, etc, there are two variants of them.
One of them resumes the target and waits for it to stop again synchronously, step_into_and_wait will do a step
into, and it only returns AFTER the target stops again. This is more frequently used, and is suitable for automating
a sequence of actions. However, after calling such a synchronous API, if for any reason the target does not stop as
expected, Binary Ninja might be confused or hang.
The second set of API works asynchronously. For example, step into will only do a step into, but does NOT wait
for the target to stop again. Usually the asynchronous API is used with register_event_callback to listen for
the relevant events (e.g., target resumed, stopped, etc). The asynchronous API is harder to use and is only
recommended when the synchronous version does not suit your need. The Binary Ninja debugger UI uses the
asynchronous API.
To retrieve all the registers, run regs:
>>> dbg.regs
{'x0': <DebugRegister: x0, 0x1>, ...}
More often we only need get the value of one regisgter:
>>> dbg.regs['x1']
<DebugRegister: x1, 0x16fdffa70, &"/Users/xxxx//debugger/test/binaries/Darwin-arm64-signed/helloworld">
The result contains the register value as well as a string that can be dereferenced at its value.
ip returns the current intrudction pointer, and stack_pointer` returns the stack pointer:
>>> dbg.stack_pointer
6171916256
>>> dbg.ip
4294983364
To read/write memory value, use read_memory/write_memory. Or you can directly read/write the binary view
object returned by dbg.data.
>>> dbg.read_memory(dbg.ip, 0x10)
<binaryninja.databuffer.DataBuffer object at 0x32ffa2f90>
>>> dbg.data.read(dbg.ip, 0x10)
b'ý{©ýÿø ¸'
>>> dbg.write_memory(dbg.stack_pointer, b'a' * 0x10)
True
>>> dbg.data.write(dbg.stack_pointer, b'a' * 0x10)
16
modules returns the list of modules, threads returns the list of threads.
Breakpoints can be added via add_breakpoint:
>>> dbg.add_breakpoint(0x100003ed0)
And it will be hit after we resume the target with go_and_wait:
>>> dbg.go_and_wait()
<DebugStopReason.Breakpoint: 6>
We can resume it again:
>>> dbg.go_and_wait()
<DebugStopReason.ProcessExited: 2>
Since there are no other breakpoints in the target, the process executes and then exits.
For more examples of using the debugger Python API, feel free to get some inspirations from our [unit tests](https://github.com/Vector35/debugger/blob/dev/test/debugger_test.py)
bv (BinaryView) –
Add a breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to add
Add a hardware breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to add
bp_type (DebugBreakpointType) – the type of hardware breakpoint (DebugBreakpointType.BNHardwareExecuteBreakpoint, BNHardwareReadBreakpoint, BNHardwareWriteBreakpoint, or BNHardwareAccessBreakpoint)
size (int) – the size in bytes for the watchpoint (1, 2, 4, or 8)
True if successful, False otherwise
Add a TTD bookmark. If a bookmark with the same position already exists, it is updated.
position – TTDPosition object or string in format “sequence:step”
note – optional note for the bookmark
view_address – optional view address to navigate to when the bookmark is activated
True if the bookmark was added/updated successfully
Attach to a running process
The PID of the target process must be set via DebuggerState.pid_attach
Attach to a running process and wait until all debugger events are processed
The PID of the target process must be set via DebuggerState.pid_attach
DebugStopReason
Connect to a remote target (process)
The host and port of the remote target must first be specified by setting remote_host and remote_port
Connect to a remote target (process) and wait for all debugger events to be processed
The host and port of the remote target must first be specified by setting remote_host and remote_port
DebugStopReason
Connect to a debug server.
The host and port of the debug server must first be specified by setting remote_host and remote_port
Delete a breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to delete
Delete a hardware breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to delete
bp_type (DebugBreakpointType) – the type of hardware breakpoint (DebugBreakpointType.BNHardwareExecuteBreakpoint, BNHardwareReadBreakpoint, BNHardwareWriteBreakpoint, or BNHardwareAccessBreakpoint)
size (int) – the size in bytes for the watchpoint (1, 2, 4, or 8)
True if successful, False otherwise
Delete the DebuggerController object. Intended for internal use. Ordinary users do not need to call it.
Disable a breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to disable
Enable a breakpoint
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to enable
Execute a backend command and get the output
For LLDB adapter, any LLDB commands can be executed. The returned string is what gets printed if one executes the command in the LLDB prompt.
For DbgEnd adapter, any WinDbg commands can be executed. The returned string is what gets printed if one executes the command in WinDbg.
Get the stack frames of the thread specified by tid
tid (int) – thread id
list of stack frames
Get all TTD events from the trace.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
list of all TTDEvent objects in the trace
List[TTDEvent]
Get the condition for a breakpoint
address – the address of the breakpoint (int or ModuleNameAndOffset)
the condition expression, or empty string if no condition
Get the count of executed instructions from the last code coverage analysis.
This method requires that run_code_coverage_analysis() has been called first.
number of unique executed instructions
Get the execution count for a specific instruction address.
This method requires that run_code_coverage_analysis() has been called first.
Get the detected remote base address of the target module.
This returns the base address that the debugger detected for the input binary in the remote process. Returns None if not connected or detection failed.
The remote base address, or None if unavailable
int | None
Get TTD call events for specific symbols/functions.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
list of TTDCallEvent objects
May raise an exception if TTD is not available
Get TTD events for specific event types using bitfield filtering.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
Get TTD memory access events for a specific address range.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
address (int) – starting memory address to query
end_address (int) – ending memory address to query
access_type – type of memory access to query - can be: - DebuggerTTDMemoryAccessType enum values - String specification like “r”, “w”, “e”, “rw”, “rwe”, etc. - Integer values (for backward compatibility)
list of TTDMemoryEvent objects
May raise an exception if TTD is not available
Get TTD memory access events for a specific address range and time range.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
start_address (int) – starting memory address to query
end_address (int) – ending memory address to query
access_type – type of memory access to query - can be: - DebuggerTTDMemoryAccessType enum values - String specification like “r”, “w”, “e”, “rw”, “rwe”, etc. - Integer values (for backward compatibility)
start_time (TTDPosition | None) – starting TTD position (default: start of trace)
end_time (TTDPosition | None) – ending TTD position (default: end of trace)
list of TTDPositionRangeIndexedMemoryEvent objects
May raise an exception if TTD is not available
Get the next memory access to a specific address from the current TTD position.
This is more efficient than pulling all accesses and searching, as it uses the TTD NextMemoryAccess API directly.
Get the previous memory access to a specific address from the current TTD position.
This is more efficient than pulling all accesses and searching, as it uses the TTD PrevMemoryAccess API directly.
Resume the target.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Resume the target.
The call is blocking and only returns when the target stops.
the reason for the stop
DebugStopReason
Resume the target in reverse.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Resume the target in reverse.
The call is blocking and only returns when the target stops.
the reason for the stop
DebugStopReason
Checks whether a breakpoint exists at the specified address
The input can be either an absolute address, or a ModuleNameAndOffset, which specifies a relative address to the start of a module. The latter is useful for ASLR.
address – the address of breakpoint to query
Check if an instruction at a specific address was executed during code coverage analysis.
This method requires that run_code_coverage_analysis() has been called first.
Launch the target and wait for all debugger events to be processed
DebugStopReason
Launch or connect to the target. Intended for internal use. Ordinary users do not need to call it.
None
Convenience method to navigate to a timestamp string.
timestamp_str: String in format “sequence:step” (hex or decimal)
bool: True if navigation succeeded, False otherwise
Pause a running target.
The call is blocking and only returns when the target stops.
None
Terminate the target, and wait for all callback to be called
None
Read memory from the target.
One can also get the data BinaryView of the DebuggerController, and use ordinary read methods to read
its content.
always returns a DataBuffer. When the operation fails, the size of the DataBuffer is 0x0
Rebase the input binary view to the specified base address.
This allows manual rebasing to a user-specified address, which is useful when the auto-detected remote base is incorrect.
Note: In UI mode, this returns True immediately and the rebase completes asynchronously.
Rebase the input binary view to match the remote base address.
This is useful when auto-rebase is disabled (via the debugger.autoRebase setting)
and you want to manually trigger a rebase after the target has been launched.
Note: In UI mode, this returns True immediately and the rebase completes asynchronously.
True if the rebase was initiated successfully, False otherwise
Register a debugger event callback to receive notification when various events happen.
The callback receives DebuggerEvent object that contains the type of the event and associated data.
callback (Callable[[DebuggerEvent], None]) – the callback to register
an integer handle to the registered event callback
Remove the debugger event callback from the DebuggerController
index (int) –
Remove a TTD bookmark by position.
position – TTDPosition object or string in format “sequence:step”
True if the bookmark was found and removed
Restart a running target.
The call is blocking and only returns when the target stops again after the restart.
None
Run code coverage analysis on a specific address range and time range.
This method is only available when debugging with TTD (Time Travel Debugging). Use the is_ttd property to check if TTD is available before calling this method.
The code coverage analysis identifies which instructions within the specified address range were executed during the specified time range. Results can be queried using the is_instruction_executed() method.
start_address (int) – starting address of the range to analyze
end_address (int) – ending address of the range to analyze
start_time (TTDPosition | None) – starting TTD position (default: start of trace)
end_time (TTDPosition | None) – ending TTD position (default: end of trace)
True if analysis succeeded, False otherwise
May raise an exception if TTD is not available
Resume the target, and wait for it to break at the given address(es).
The address parameter can be either an integer, or a list of integers.
Internally, the debugger places breakpoints on these addresses, resume the target, and wait for the target to break. Then the debugger removes the added breakpoints.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Resume the target, and wait for it to break at the given address(es).
The address parameter can be either an integer, or a list of integers.
Internally, the debugger places breakpoints on these addresses, resume the target, and wait for the target to break. Then the debugger removes the added breakpoints.
The call is blocking and only returns when the target stops.
the reason for the stop
DebugStopReason
Resume the target in reverse, and wait for it to break at the given address(es).
The address parameter can be either an integer, or a list of integers.
Internally, the debugger places breakpoints on these addresses, resumes the target in reverse, and waits for the target to break. Then the debugger removes the added breakpoints.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Resume the target in reverse, and wait for it to break at the given address(es).
The address parameter can be either an integer, or a list of integers.
Internally, the debugger places breakpoints on these addresses, resumes the target in reverse, and waits for the target to break. Then the debugger removes the added breakpoints.
The call is blocking and only returns when the target stops.
the reason for the stop
DebugStopReason
Save code coverage results to a file.
This method requires that run_code_coverage_analysis() has been called first.
Set a condition for a breakpoint
The condition is an expression that will be evaluated using Binary Ninja’s expression parser when the breakpoint is hit. If the condition evaluates to non-zero (true), the debugger stops. If it evaluates to zero (false), the debugger silently continues execution.
Example conditions:
"rax == 0x1234" - break when RAX equals 0x1234
"rsp + 0x20" - break when the expression is non-zero
Pass an empty string to clear the condition.
Navigate to a specific position in the TTD trace.
position: TTDPosition object or string in format “sequence:step”
bool: True if navigation succeeded, False otherwise
Perform a step into on the target.
When the next instruction is not a call, execute the next instruction. When the next instruction is a call, follow the call the get into the first instruction of the call.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or follow into the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping into on IL.
The call is asynchronous and returns before the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
whether the operation is successfully requested
Perform a step into on the target in reverse.
When the next instruction is not a call, execute the next instruction. When the next instruction is a call, follow the call the get into the first instruction of the call.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or follow into the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping into on IL.
The call is blocking and only returns when the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
the reason for the stop
DebugStopReason
Perform a step into on the target in reverse.
When the previous instruction is not a call, step backwards. When the previous instruction is a call, follow the call into the last instruction of the function.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or follow into the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping into on IL.
The call is asynchronous and returns before the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
whether the operation is successfully requested
Perform a reverse step into on the target.
When the previous instruction is not a call, reverse the program to the previous state. When the previous instruction is a call, follow the call to get into the last instruction of the call.
The operation can be performed on an IL level specified by the il parameter, which then either reverses the current IL instruction, or follow into the previous IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping into on IL.
The call is blocking and only returns when the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
the reason for the stop
DebugStopReason
Perform a step over on the target.
When the next instruction is not a call, execute the next instruction. When the next instruction is a call, complete the execution of the function and break at next instruction.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or completes the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping over on IL.
The call is asynchronous and returns before the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
whether the operation is successfully requested
Perform a step over on the target.
When the next instruction is not a call, execute the next instruction. When the next instruction is a call, complete the execution of the function and break at next instruction.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or completes the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping over on IL.
The call is blocking and only returns when the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
the reason for the stop
DebugStopReason
Perform a step over on the target in reverse.
When the previous instruction is not a call, step backwards. When the previous instruction is a call, step back over the call.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or completes the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping over on IL.
The call is asynchronous and returns before the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
whether the operation is successfully requested
Perform a step over on the target in reverse.
When the next instruction is not a call, execute the next instruction. When the next instruction is a call, complete the execution of the function and break at next instruction.
The operation can be performed on an IL level specified by the il parameter, which then either executes the
next IL instruction, or completes the IL function. Note, the underlying operation is still performed at the
disassembly level because that is the only thing a debugger understands. The high-level operations are simulated
on top of the disassembly and analysis.
Some limitations are known with stepping over on IL.
The call is blocking and only returns when the target stops.
il (FunctionGraphType) – optional IL level to perform the operation at
the reason for the stop
DebugStopReason
Perform a step return on the target.
Step return completes the execution of the current function and returns to its caller. This operation relies heavily on stack frame analysis, which is done by the DebugAdapters.
If a DebugAdapter does not support (i.e., overload) this function, a fallback handling is provided by the DebuggerController. It checks the MLIL function and put breakpoints on all returning instructions and then resume the target. By the time it breaks, the target is about to return from the current function.
This fallback behavior is slightly different from that offered by the LLDB and DbgEng adapter, which returns from the current function and break afterwards.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Perform a step return on the target.
Step return completes the execution of the current function and returns to its caller. This operation relies heavily on stack frame analysis, which is done by the DebugAdapters.
If a DebugAdapter does not support (i.e., overload) this function, a fallback handling is provided by the DebuggerController. It checks the MLIL function and put breakpoints on all returning instructions and then resume the target. By the time it breaks, the target is about to return from the current function.
This fallback behavior is slightly different from that offered by the LLDB and DbgEng adapter, which returns from the current function and break afterwards.
The call is blocking and only returns when the target stops.
the reason for the stop
DebugStopReason
Perform a step return on the target in reverse.
Step return reverses the execution of the current function and returns to its caller. This operation relies heavily on stack frame analysis, which is done by the DebugAdapters.
If a DebugAdapter does not support (i.e., overload) this function, a fallback handling is provided by the DebuggerController. It checks the MLIL function and put breakpoints on all returning instructions and then resume the target. By the time it breaks, the target is about to return from the current function.
This fallback behavior is slightly different from that offered by the LLDB and DbgEng adapter, which returns from the current function and break afterwards.
The call is asynchronous and returns before the target stops.
whether the operation is successfully requested
Navigate to the previous TTD timestamp in the position history.
bool: True if navigation succeeded, False if there is no previous position
Navigate to the next TTD timestamp in the position history.
bool: True if navigation succeeded, False if there is no next position
Update an existing TTD bookmark’s note and view address.
position – TTDPosition object or string in format “sequence:step”
note – new note for the bookmark
view_address – new view address for the bookmark
True if the bookmark was found and updated
Write memory of the target.
One can also get the data BinaryView of the DebuggerController, and use ordinary write methods to write
its content.
Write to the stdin of the target. Only works on Linux and macOS.
The PID of the process currently being debugged. (read-only)
This returns the PID of the currently attached or running process.
the PID of the active process, or 0 if no process is active or the PID is unavailable
The active thread of the target. (read/write)
returns the active thread of the target
sets the active thread of the target
The name for the current DebugAdapter. (read/write)
returns the name of the current DebugAdapter
sets the DebugAdapter to use
The list of breakpoints
a DebugBreakpoints wrapper containing all breakpoints
Check if there is a previous TTD position to navigate to.
bool: True if back navigation is possible
Check if there is a next TTD position to navigate to.
bool: True if forward navigation is possible
The command line arguments of the target. (read/write)
This can be set before launching the target to specify the command line arguments. The arguments are supplied as a single string. The string is NOT shell expanded, which means the user must properly escape it if needed.
returns the command line arguments
sets the command line arguments
Get the connection status of the debugger
Get the current position in the TTD trace.
TTDPosition: Current position, or None if not in TTD mode
Get the (rebased) BinaryView of the debugger
The path of the executable. (read/write)
This can be set before launching the target. Be default, it is the path of the FileMetadata
(bv.file.filename)
returns the executable path
sets the executable path
The exit code of the target (read-only)
This is only meaningful after the target has executed and exited.
The input file used to create the database
This should be set before launching the target. Be default, it is the path of the FileMetadata
(bv.file.filename)
returns the input file path
sets the input file path
The IP (instruction pointer) of the target
For x86_64, it returns the value of rip register.
For x86, it returns the value of eip register.
For armv7/aarch64, or any other architecture that is not native to BN, it returns the value of pc register.
Get the live BinaryView of the debugger
Deprecated since version 4.1.5542: Debugger no longer uses the live view, Use data instead
The modules of the target
a DebugModules wrapper containing all modules
The PID to attach to. (read/write)
pid_attach is only useful for connecting to a running process using PID.
returns the PID to attach to
sets the PID to attach to
The processes of the target.
All registers of the target
a list of DebugRegister
Get the architecture of the running target (read-only). This could be different from the architecture of the original binary.
The remote host to connect to. (read/write)
remote_host and remote_port are only useful for remote debugging.
returns the remote host
sets the remote host
The remote port to connect to. (read/write)
remote_host and remote_port are only useful for remote debugging.
returns the remote port
sets the remote port
Whether to run the target in a separate terminal. (read/write)
The default value is false.
This can be set before launching the target to configure whether the target should be executed in a separate terminal. On Linux and macOS, when set, the target runs in its own terminal and the DebuggerController cannot receive notification of stdout output, or write to its stdin. All input/output must be performed in the target’s console. On Windows, this option has no effect and the target always runs in its own terminal.
returns whether to run the target in a separate terminal
sets whether to run the target in a separate terminal
The reason for the target to stop
This is the same value to the return value of the function that resumed the target, e.g., go()
Get the status of the target
The threads of the target.
Get all TTD bookmarks.
list of TTDBookmark objects
The path of the target. (read/write)
This can be set before launching the target to configure a working directory. Be default, it is the path of the binaryninja executable. In the future, we will change the default working directory to the folder that the executable is in.
returns the working directory
sets the working directory
Bases: object
DebuggerEvent is the event object that a debugger event callback receives
type: a DebuggerEventType that specifies the event type
data: a DebuggerEventData that specifies the event data
type (DebuggerEventType) –
data (DebuggerEventData) –
Bases: object
DebuggerEventData is the collection of all possible data associated with the debugger events
target_stopped_data: the data associated with a TargetStoppedEvent
error_data: the data associated with an ErrorEvent
absolute_address: an integer address, which is used when an absolute breakpoint is added/removed
relative_address: a ModuleNameAndOffset, which is used when a relative breakpoint is added/removed
exit_data: the data associated with a TargetExitedEvent
message_data: message data, used by both StdOutMessageEvent and BackendMessageEvent
target_stopped_data (TargetStoppedEventData) –
error_data (ErrorEventData) –
absolute_address (int) –
relative_address (ModuleNameAndOffset) –
exit_data (TargetExitedEventData) –
message_data (StdOutMessageEventData) –
Bases: object
controller (DebuggerController) –
callback (Callable[[DebuggerEvent], None]) –
controller (DebuggerController) –
index (int) –
None
Bases: object
TTDBookmark represents a saved position in a TTD trace with an optional note and view address.
position: the TTD position (TTDPosition object)
view_address: the address the user was viewing when the bookmark was created
note: an optional note describing the bookmark
position (TTDPosition) –
note (str) –
view_address (int) –
Bases: object
TTDCallEvent represents a function call event in a TTD trace. It has the following fields:
event_type: type of the event (always “Call” for TTD.Calls objects)
thread_id: OS thread ID that made the call
unique_thread_id: unique thread ID across the trace
function: symbolic name of the function
function_address: function’s address in memory
return_address: instruction to return to after the call
return_value: return value of the function (if not void)
has_return_value: whether the function has a return value
parameters: list of parameters passed to the function
time_start: TTD position when call started
time_end: TTD position when call ended
Bases: object
TTDEvent represents important events that happened during a TTD trace.
type (int): type of event (TTDEventType enum value) position (TTDPosition): position where event occurred module (TTDModule or None): module information for ModuleLoaded/ModuleUnloaded events thread (TTDThread or None): thread information for ThreadCreated/ThreadTerminated events exception (TTDException or None): exception information for Exception events
type (int) –
position (TTDPosition) –
Bases: object
TTDException represents information about exceptions that occurred during a TTD trace.
type (int): type of exception (TTDExceptionType.Software or TTDExceptionType.Hardware) program_counter (int): instruction where exception was thrown code (int): exception code flags (int): exception flags record_address (int): where in memory the exception record is found position (TTDPosition): position where exception occurred
Bases: object
TTDMemoryEvent represents a memory access event in a TTD trace. It has the following fields:
event_type: type of the event (e.g., “Memory”)
thread_id: OS thread ID that performed the memory access
unique_thread_id: unique thread ID across the trace
time_start: TTD position when the memory access started
time_end: TTD position when the memory access ended
address: memory address that was accessed
size: size of the memory access
memory_address: actual memory address (may differ from address field)
instruction_address: address of the instruction that performed the access
value: value that was read/written/executed
access_type: type of access (read/write/execute)
Bases: object
TTDModule represents information about modules that were loaded/unloaded during a TTD trace.
name (str): name and path of the module address (int): address where the module was loaded size (int): size of the module in bytes checksum (int): checksum of the module timestamp (int): timestamp of the module
Bases: object
TTDPositionRangeIndexedMemoryEvent represents a memory access event in a TTD trace with position information. This is used for memory queries filtered by both address range and time range.
position: TTD position when the memory access occurred
thread_id: OS thread ID that performed the memory access
unique_thread_id: unique thread ID across the trace
address: memory address that was accessed
instruction_address: address of the instruction that performed the access
size: size of the memory access in bytes
access_type: type of access (read/write/execute)
value: value that was read/written/executed (truncated to size)
data: the next 8 bytes of data at the memory address (as a bytes object)
Bases: object
TTDThread represents information about threads and their lifetime during a TTD trace.
unique_id (int): unique ID for the thread across the trace id (int): TID of the thread lifetime_start (TTDPosition): lifetime start position lifetime_end (TTDPosition): lifetime end position active_time_start (TTDPosition): active time start position active_time_end (TTDPosition): active time end position
unique_id (int) –
id (int) –
lifetime_start (TTDPosition) –
lifetime_end (TTDPosition) –
active_time_start (TTDPosition) –
active_time_end (TTDPosition) –
Parse TTD memory access type from string specification.
Can be combinations of ‘r’ (read), ‘w’ (write), ‘e’ (execute) e.g., “r”, “rw”, “rwe”, “we”, etc.
DebuggerTTDMemoryAccessType enum value