Skip to content

Commit 41d18ec

Browse files
xusheng6claude
andauthored
Update TTD documentation for new features (#989)
* Update TTD documentation for new features - Document improved automatic WinDbg/TTD installation process (#964) - Add documentation for "Attach and Record TTD Trace" feature (#980) - Document TTD code coverage time range filter and execution count display (#959) - Add instructions for enabling TTD Coverage render layer - Document get_instruction_execution_count() Python API method Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add placeholder screenshots and update section for WinDbg/TTD - Add placeholder screenshot for WinDbg/TTD installer - Add new section documenting the update process for WinDbg/TTD - Add placeholder screenshot for the update dialog - Add placeholder screenshot for TTD attach dialog Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Clarify TTD Coverage render layer is enabled by default Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update TTD Memory widget documentation - Add Time Range filter parameters (Start Time, End Time) - Update column table: replace Event Type, Time Start, Time End with Position - Update double-click interaction to reference Position column - Note that Value is truncated to access size Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add documentation validation workflow and screenshots - Add GitHub Actions workflow to validate markdown formatting on PR/push - Add check_markdown_list.py script (from binaryninja repo) to validate markdown list formatting (missing blank lines before lists) - Add screenshots for TTD install, update, and attach dialogs This uses the same validation that runs during the binaryninja build process, ensuring debugger docs won't cause build failures when integrated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add docs-validate build target Run with: ninja docs-validate Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove GitHub CI workflow (local validation only) * Update screenshots --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 75fc20f commit 41d18ec

10 files changed

Lines changed: 360 additions & 14 deletions

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ endif()
5454
if(WIN32)
5555
add_subdirectory(installer)
5656
endif()
57+
58+
# Documentation validation target
59+
add_custom_target(docs-validate
60+
COMMAND python ${CMAKE_SOURCE_DIR}/scripts/check_markdown_list.py ${CMAKE_SOURCE_DIR}/docs/
61+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
62+
COMMENT "Validating documentation formatting..."
63+
)

docs/guide/dbgeng-ttd.md

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,32 @@ The WinDbg installation only needs to be done once.
2020

2121
- Open Binary Ninja
2222
- Click `Debugger` -> `Install WinDbg/TTD` from the menu
23-
- Wait for the installation to finish
24-
- Behind the scenes, this runs a C++ installer that downloads and configures WinDbg
23+
- A dialog will appear showing the installation progress:
24+
- The installer automatically downloads the latest WinDbg from Microsoft
25+
- It extracts the necessary files (DbgEng DLLs and TTD components)
2526
- WinDbg will be installed to `%APPDATA%\Binary Ninja\windbg`
27+
- Progress and status are displayed in real-time
28+
- Wait for the installation to complete
2629
- Restart Binary Ninja
2730

31+
<img src="../../img/debugger/ttd_install_windbg.png" width="600px">
32+
33+
The automatic installer handles all the complexity of downloading and extracting the WinDbg MSIX bundle.
34+
35+
### Update WinDbg/TTD
36+
37+
If you already have WinDbg/TTD installed and want to check for updates:
38+
39+
- Click `Debugger` -> `Install WinDbg/TTD` from the menu
40+
- A dialog will appear showing:
41+
- The currently installed version
42+
- The latest available version from Microsoft
43+
- If a newer version is available, click "Update" to download and install it
44+
- If you are already on the latest version, the dialog will indicate that no update is needed
45+
- Restart Binary Ninja after updating
46+
47+
<img src="../../img/debugger/ttd_update_windbg.png" width="600px">
48+
2849
### Install WinDbg Manually
2950

3051
- Download https://aka.ms/windbg/download
@@ -43,9 +64,11 @@ The WinDbg installation only needs to be done once.
4364

4465
## Record a TTD Trace
4566

46-
Once we have installed and configured WinDbg, we can start recording a TTD trace. There are two ways to do it, we can either
47-
do it from within Binary Ninja, or do it from WinDbg. Doing it from Binary Ninja is more convenient, though it does not support
48-
all types of recording supported by WinDbg (e.g., attach to a running process and start recording).
67+
Once we have installed and configured WinDbg, we can start recording a TTD trace. There are multiple ways to do it:
68+
69+
1. **Launch and record**: Start a new process and record it from within Binary Ninja
70+
2. **Attach and record**: Attach to a running process and record it from within Binary Ninja
71+
3. **Record in WinDbg**: Use WinDbg directly for more advanced recording options
4972

5073
### Record a TTD Trace in Binary Ninja
5174

@@ -65,6 +88,33 @@ all types of recording supported by WinDbg (e.g., attach to a running process an
6588
- Click "Record". A UAC dialog will pop up because the TTD recording requires Administrator privilege
6689
- Accept the elevation. The program will be launched and recorded. Once it exits, find the trace file in the trace output directory
6790

91+
### Attach and Record TTD Trace
92+
93+
You can attach TTD to a running process to record its execution. This is useful when:
94+
95+
- The process is already running and you want to capture its behavior
96+
- The process has complex startup requirements that are difficult to replicate via launch
97+
- You want to record only a specific portion of the process's execution
98+
99+
To attach and record:
100+
101+
- Make sure you have WinDbg properly installed and configured
102+
- Click `Debugger` -> `TTD` -> `Attach and Record TTD Trace` from the menu
103+
104+
<img src="../../img/debugger/ttd_attach.png" width="600px">
105+
106+
- In the "TTD Attach" dialog:
107+
- A list of running processes is displayed with their PID, name, and command line
108+
- Use the filter box to search for a specific process by name or PID
109+
- Select the process you want to attach to
110+
- Trace Output Directory: the directory to write the trace (defaults to your Documents folder)
111+
- Trace Child Processes: if checked, includes child processes spawned by the target in the recording
112+
- Click "Attach". A UAC dialog will pop up because TTD recording requires Administrator privilege
113+
- Accept the elevation. TTD will attach to the process and begin recording
114+
- Interact with the application as needed to capture the behavior you want to analyze
115+
- When done, terminate the process or use the TTD controls to stop recording
116+
- Find the trace file in the trace output directory
117+
68118
### Record a TTD Trace in WinDbg
69119

70120
- Find `DbgX.Shell.exe` in the WinDbg installation, run it
@@ -236,11 +286,15 @@ The widget appears in the right sidebar by default.
236286

237287
**Query Parameters:**
238288

239-
- **Start Address**: Beginning address of the memory range to query (hexadecimal)
240-
- Auto-populated with the binary's start address by default
289+
- **Address Range**: The memory range to query
290+
- **Start Address**: Beginning address of the memory range (hexadecimal)
291+
- **End Address**: Ending address of the memory range (hexadecimal)
292+
- Auto-populated with the binary's address range by default
241293

242-
- **End Address**: Ending address of the memory range to query (hexadecimal)
243-
- Auto-populated with the binary's end address by default
294+
- **Time Range (Optional)**: Filter results to a specific time window in the trace
295+
- **Start Time**: Beginning TTD position (format: `sequence:step` in hexadecimal, e.g., `0:0`)
296+
- **End Time**: Ending TTD position (format: `sequence:step` in hexadecimal, e.g., `23f:a7`)
297+
- Leave blank to query the entire trace
244298

245299
- **Access Types**: Select which types of memory access to include:
246300
- **Read**: Memory read operations
@@ -255,20 +309,18 @@ The results table displays the following information for each memory access even
255309
| Column | Description |
256310
|--------|-------------|
257311
| Index | Sequential index of the result |
258-
| Event Type | Always "Memory" for TTD.Memory events |
259-
| Time Start | TTD position when the access began |
260-
| Time End | TTD position when the access completed |
312+
| Position | TTD position when the access occurred (format: sequence:step) |
261313
| Access Type | Type of access: R (Read), W (Write), E (Execute) |
262314
| Address | Memory address that was accessed |
263315
| Size | Number of bytes accessed |
264-
| Value | Data value that was read/written/executed |
316+
| Value | Data value that was read/written/executed (truncated to the access size) |
265317
| Thread ID | OS thread ID that performed the access |
266318
| Unique Thread ID | Unique thread identifier in the trace |
267319
| IP | Instruction pointer (address of instruction that caused the access) |
268320

269321
**Interacting with Results:**
270322

271-
- **Double-click Time Start/End**: Time-travels to that position in the trace and navigates to the instruction that caused the access
323+
- **Double-click Position**: Time-travels to that position in the trace and navigates to the instruction that caused the access
272324
- **Double-click Address/IP**: Navigates to that address in the disassembly view
273325
- **Right-click menu**:
274326
- Copy selected cell
@@ -418,12 +470,34 @@ Code coverage analysis identifies all instructions that were executed during the
418470

419471
<img src="../../img/debugger/ttd_code_coverage.png" width="600px">
420472

473+
**Time Range Filter:**
474+
475+
Code coverage analysis can be limited to a specific time range within the trace:
476+
477+
- Check "Specify time range for analysis" in the dialog
478+
- Enter the start and end TTD positions (format: sequence:step, e.g., `1A0:0` to `2B5:1F`)
479+
- This allows you to analyze coverage for specific portions of the trace, such as:
480+
- A specific function execution
481+
- A particular user interaction
482+
- The time between two breakpoints
483+
421484
**Analysis Results:**
422485

423486
- **Executed Instructions**: Highlighted with red background in the disassembly
487+
- **Execution Count**: Each executed instruction shows the number of times it was executed in brackets, e.g., `[42]`
424488
- **Result Count**: Number of unique instructions executed is shown in the dialog
425489
- **Coverage Overlay**: Visual indication of which code paths were taken
426490

491+
**TTD Coverage Render Layer:**
492+
493+
The TTD Coverage render layer is enabled by default. Once code coverage analysis completes, executed instructions will automatically be highlighted in red with their execution counts displayed in the disassembly view.
494+
495+
If the highlighting is not visible, you can manually enable the render layer:
496+
497+
1. Right-click in the disassembly view
498+
2. Select `Render Layers` from the context menu
499+
3. Check `TTD Coverage` to enable the render layer
500+
427501
**Caching:**
428502

429503
Code coverage analysis results can be cached for faster loading:

docs/guide/ttd-python-api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,27 @@ def get_executed_instruction_count(self) -> int:
561561
"""
562562
```
563563

564+
### get_instruction_execution_count()
565+
566+
```python
567+
def get_instruction_execution_count(self, address: int) -> int:
568+
"""
569+
Get the execution count for a specific instruction address.
570+
571+
This returns how many times a specific instruction was executed during
572+
the TTD trace, which is useful for identifying hot paths and frequently
573+
executed code.
574+
575+
Note: Requires code coverage analysis to have been run first.
576+
577+
Args:
578+
address: Instruction address to check
579+
580+
Returns:
581+
Number of times the instruction was executed (0 if not executed or analysis not run)
582+
"""
583+
```
584+
564585
### save_code_coverage_to_file()
565586

566587
```python
@@ -605,6 +626,17 @@ if dbg.is_ttd:
605626
if dbg.is_instruction_executed(0x401000):
606627
print("Instruction at 0x401000 was executed")
607628

629+
# Get execution count for hot path analysis
630+
exec_count = dbg.get_instruction_execution_count(0x401000)
631+
if exec_count > 0:
632+
print(f"Instruction at 0x401000 was executed {exec_count} times")
633+
634+
# Find hot spots by checking execution counts
635+
for addr in range(0x401000, 0x401100, 4):
636+
count = dbg.get_instruction_execution_count(addr)
637+
if count > 100:
638+
print(f"Hot instruction at {addr:#x}: executed {count} times")
639+
608640
# Save results for later
609641
dbg.save_code_coverage_to_file("/path/to/coverage.data")
610642
else:
4.62 KB
Loading

docs/img/debugger/ttd_attach.png

77.7 KB
Loading
1.67 KB
Loading
57 KB
Loading
-9.36 KB
Loading
25 KB
Loading

0 commit comments

Comments
 (0)