sql-cli 1.69.2

SQL query tool for CSV/JSON with both interactive TUI and non-interactive CLI modes - perfect for exploration and automation
Documentation
# Debugging sql-cli with LLDB

## Quick Start

```bash
# Build with debug symbols
cargo build

# Run with rust-lldb (RECOMMENDED - includes Rust formatters)
rust-lldb target/debug/sql-cli

# Or use plain lldb (our .lldbinit will try to load formatters)
lldb target/debug/sql-cli

# Debug a test
cargo test --no-run
rust-lldb target/debug/deps/sql_cli-<hash>
```

## Why rust-lldb?

`rust-lldb` is a wrapper that automatically loads Python formatters for Rust types:
- Pretty prints String, Vec, HashMap, Option, Result
- Shows string contents instead of pointers
- Displays Vec length and contents
- Unwraps Option/Result values

## Essential LLDB Commands

### Breakpoints
```lldb
# Set breakpoint at function
b sql_cli::ui::enhanced_tui::EnhancedTuiApp::export_to_csv

# Set breakpoint at line
b enhanced_tui.rs:4551

# List breakpoints
bl

# Delete breakpoint
bd 1
```

### Running
```lldb
# Run with arguments
r test_data.csv -e "select * from data"

# Continue after breakpoint
c

# Step over (next line)
n

# Step into function
s

# Step out of function
f
```

### Inspecting Variables
```lldb
# Print variable
p provider

# Print with formatting
pp self.buffer()

# Print all locals
info-locals

# Print backtrace
bt
```

## Key Breakpoint Locations for DataProvider Migration

### Export Flow
1. **TUI initiates export**: `enhanced_tui.rs:4548` (export_to_csv)
2. **Get DataProvider**: `enhanced_tui.rs:232` (get_data_provider)
3. **Create BufferAdapter**: `enhanced_tui.rs:237`
4. **DataExporter works with trait**: `data_exporter.rs:14` (export_provider_to_csv)
5. **BufferAdapter provides data**: `buffer_adapter.rs` (get_row, get_column_names)

### Setting Multiple Breakpoints
```lldb
# Set all export flow breakpoints
b enhanced_tui.rs:4551
b enhanced_tui.rs:237
b data_exporter.rs:15
b buffer_adapter.rs:39
```

## Debugging Tips

### 1. Follow the Trait
When debugging trait-based code, use `p` to see the concrete type:
```lldb
p provider
# Shows: Box<BufferAdapter> as Box<dyn DataProvider>
```

### 2. Check Rust Types
```lldb
# See String content
p some_string

# See Vec content
p some_vec

# See Option
p some_option
```

### 3. Conditional Breakpoints
```lldb
# Break only when row index is 10
b buffer_adapter.rs:39
br mod -c "index == 10"
```

## VSCode Integration

If using VSCode with CodeLLDB:

```json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug sql-cli",
            "cargo": {
                "args": [
                    "build",
                    "--bin=sql-cli",
                    "--package=sql-cli"
                ],
                "filter": {
                    "name": "sql-cli",
                    "kind": "bin"
                }
            },
            "args": ["test_data.csv", "-e", "select * from data"],
            "cwd": "${workspaceFolder}/sql-cli"
        }
    ]
}
```

## RustRover / IntelliJ IDEA

1. Click on line number to set breakpoint
2. Right-click on `main.rs` → Debug 'sql-cli'
3. Use Debug panel to step through code

## Common Issues

### Can't see variable values
- Make sure you built with `cargo build` (debug mode)
- NOT `cargo build --release`

### Breakpoint not hit
- Check the function name matches exactly
- Use `bl` to list and verify breakpoints
- Make sure the code path actually reaches that point

### Too much output
- Use `pp` instead of `p` for pretty printing
- Use `frame variable <name>` for specific variables