Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions BOOKMARK_FEATURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Debugger Bookmark Feature

This feature adds timestamp bookmarking capability to the Binary Ninja debugger, particularly useful for Time Travel Debugging (TTD) scenarios.

## Features

### Bookmark Management
- **Create bookmarks** at current debugger position with custom descriptions
- **Navigate to bookmarks** with double-click (attempts TTD position navigation + address navigation)
- **Persistent storage** - bookmarks are saved with the binary view
- **Time tracking** - each bookmark stores when it was created

### UI Components

#### Bookmarks Tab
A new "Bookmarks" tab is added to the debugger sidebar with the following columns:
- **Description**: User-provided description of the bookmark
- **TTD Position**: Time Travel Debugging position (if available)
- **Address**: Memory address where bookmark was created
- **Timestamp**: When the bookmark was created

#### Context Menu Actions
- **Add Bookmark...**: Create a new bookmark at current position
- **Jump To Bookmark**: Navigate to selected bookmark
- **Remove Bookmark**: Delete selected bookmark(s)

#### Global Action
- **Debugger > Add Bookmark** (Ctrl+M): Quick bookmark creation from anywhere in the UI

## Usage

### Creating Bookmarks

1. **Via Bookmarks Tab**:
- Navigate to desired debugger position
- Open Debugger sidebar > Bookmarks tab
- Right-click > "Add Bookmark..." or use the Add button
- Enter a description

2. **Via Global Action**:
- Navigate to desired debugger position
- Press Ctrl+M or use Debugger menu > Add Bookmark
- Enter a description

### Navigating to Bookmarks

1. **Double-click** any bookmark in the Bookmarks tab
2. Or right-click > "Jump To Bookmark"

The navigation system will:
1. First attempt TTD position navigation (if TTD is available)
2. Fall back to address navigation
3. Provide feedback on success/failure

### TTD Integration

For Time Travel Debugging sessions, the bookmark system:
- Automatically detects TTD capability
- Attempts to capture current TTD position using `!tt` command
- On navigation, tries multiple TTD position commands (`!tt <position>`, `!position <position>`)
- Falls back gracefully to address navigation if TTD positioning fails

## Implementation Notes

### Data Storage
Bookmarks are stored in Binary Ninja metadata under the key "debugger.bookmarks" as an array of objects containing:
```json
{
"description": "User description",
"ttdPosition": "12A:B4",
"address": 4194304,
"timestamp": "2024-01-01 12:00:00"
}
```

### TTD Command Compatibility
The system attempts multiple TTD command formats for maximum compatibility:
- `!tt <position>` (WinDbg TTD)
- `!position <position>` (alternate format)

### Error Handling
- Graceful fallback when TTD commands fail
- User-friendly error messages
- Automatic refresh of bookmark list
- Input validation and sanitization

## Development Notes

The bookmark feature follows existing debugger UI patterns:
- Uses same model/view/delegate pattern as breakpoints widget
- Integrates with existing action/menu system
- Follows Binary Ninja theming and font management
- Uses established metadata persistence patterns

Files added:
- `ui/bookmarkswidget.h` - Header with BookmarkItem, model, delegate, and widget classes
- `ui/bookmarkswidget.cpp` - Implementation with TTD integration
- Modified `ui/debuggerwidget.h/cpp` - Integration into main debugger UI
- Modified `ui/ui.cpp` - Global action registration
122 changes: 122 additions & 0 deletions UI_MOCKUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Binary Ninja Debugger UI Mockup - Bookmark Feature

## Main Debugger Sidebar Layout

```
┌─────────────────────────────────────────────────────────────┐
│ Debugger [×] │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─ Debug Controls ─────────────────────────────────────────┐ │
│ │ [▶] [⏸] [⏹] [📄] [🔄] [Launch] [Attach] [Connect] │ │
│ │ Play Pause Stop Step Restart │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─ Tab Controls ──────────────────────────────────────────┐ │
│ │ [Registers] [Breakpoints] [Bookmarks] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─ Bookmarks Tab ─────────────────────────────────────────┐ │
│ │ Description │ TTD Position │ Address │ Time │ │
│ │ ────────────────────────────────────────────────────── │ │
│ │ Main entry point │ 12A:B4 │ 0x401000 │ 14:30 │ │
│ │ Critical section │ 15C:A2 │ 0x402500 │ 14:35 │ │
│ │ Before API call │ 18F:DC │ 0x403100 │ 14:42 │ │
│ │ Exception handler │ 1A2:3F │ 0x404800 │ 14:48 │ │
│ │ Loop iteration 5 │ 1C8:91 │ 0x402200 │ 14:52 │ │
│ │ │ │ │ │ │
│ │ [Add Bookmark...] [Remove] [Jump To] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
```

## Context Menu (Right-click on bookmark)

```
┌────────────────────────┐
│ ▶ Jump To Bookmark │
│ ───────────────────── │
│ ✎ Edit Description... │
│ 🗑 Remove Bookmark │
│ ───────────────────── │
│ 📋 Copy Address │
│ 📋 Copy TTD Position │
└────────────────────────┘
```

## Add Bookmark Dialog (Ctrl+M or menu action)

```
┌────────────────────────────────────────────┐
│ Add Bookmark [×] │
├────────────────────────────────────────────┤
│ │
│ Current Position: │
│ Address: 0x401000 │
│ TTD Position: 12A:B4 │
│ │
│ Description: │
│ ┌────────────────────────────────────────┐ │
│ │ Main function entry point │ │
│ └────────────────────────────────────────┘ │
│ │
│ [Cancel] [Add Bookmark] │
└────────────────────────────────────────────┘
```

## Main Menu Integration

```
Debugger Menu:
├─ Debug Adapter Settings...
├─ ──────────────────────────
├─ Launch F6
├─ Attach To Process...
├─ Connect to Debug Server
├─ ──────────────────────────
├─ Pause F5
├─ Resume F9
├─ Go Backwards Shift+F9
├─ ──────────────────────────
├─ Toggle Breakpoint F2
├─ Add Bookmark Ctrl+M ← NEW!
├─ ──────────────────────────
└─ Settings...
```

## Key Features Demonstrated:

1. **Integrated Tab Layout**: Bookmarks appear as a natural third tab alongside Registers and Breakpoints

2. **Comprehensive Information**: Each bookmark shows:
- User-friendly description
- TTD position for time-travel navigation
- Memory address for fallback navigation
- Timestamp for organization

3. **Multiple Access Methods**:
- Direct tab access for bookmark management
- Global Ctrl+M shortcut for quick bookmark creation
- Context menu for bookmark operations

4. **Visual Consistency**: Follows existing Binary Ninja debugger UI patterns:
- Same table layout as breakpoints
- Consistent button styling and placement
- Standard dialog patterns

5. **User-Friendly Workflow**:
- One-click bookmark creation
- Double-click navigation
- Clear visual feedback and organization

## Navigation Behavior:

When double-clicking a bookmark or using "Jump To Bookmark":

1. **TTD Navigation**: Attempts `!tt 12A:B4` command to set TTD position
2. **Fallback Navigation**: If TTD fails, navigates to memory address
3. **Visual Feedback**: Updates main view to show bookmarked location
4. **Error Handling**: Shows informative messages if navigation fails

This provides a complete time-travel bookmark system that integrates seamlessly with the existing Binary Ninja debugger interface.
Loading