Skip to content
Merged
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
2 changes: 1 addition & 1 deletion bins/dwarf-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::warn;

#[derive(Parser)]
#[command(name = "dwarf-tool")]
#[command(version = "0.1.0")]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(about = "DWARF debug information analysis tool with multiple analysis modes")]
#[command(author = "swananan")]
#[command(
Expand Down
34 changes: 33 additions & 1 deletion docs/input-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,39 @@ t process_data # Use short form
```

**Description:**
After executing trace command, you enter Script Mode to write trace scripts. Press `Ctrl+S` to save and execute, `Ctrl+C` to cancel.
After executing trace command, you enter Script Mode to write trace scripts. Press `Ctrl+S` to save and execute, `Ctrl+C` or `Esc` to cancel.

**Script Mode Workflow:**
1. Execute `trace <target>` → Enter Script Mode with syntax highlighting
2. Write trace script (see [Script Language Reference](scripting.md) for syntax)
3. Submit and compile:
- `Ctrl+S`: Submit script and compile to eBPF
- `Ctrl+C` or `Esc`: Cancel and return to Input Mode
4. View compilation results in command panel
5. Check real-time trace output in eBPF Output Panel

**Script Caching:**
- Scripts are automatically cached per target
- Re-entering same target (e.g., `trace sample.c:42` again) restores previous script
- Cache persists until you exit GhostScope
- Useful for iterative debugging: modify → test → modify

**Quick Start Example:**
```bash
# 1. Enter script mode for a function
trace main

# 2. In Script Mode, write:
print "Entering main, argc={}", argc;

# 3. Press Ctrl+S to submit
# 4. See output: ✅ Trace Results: 1 successful, 0 failed

# 5. Later, modify the same trace:
trace main # Your previous script is restored!

# 6. Edit and press Ctrl+S again
```

### enable - Enable Traces

Expand Down
10 changes: 8 additions & 2 deletions docs/tui-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,13 @@ Browse and navigate command history with Vim-style navigation.

### Mode: Script Mode

Edit trace scripts after executing `trace` command.
Edit trace scripts with syntax highlighting after executing `trace` command.

**Features:**
- Real-time syntax highlighting for GhostScope script language
- Line numbers with current line emphasis
- Multi-line editing support
- Automatic script caching per target (restored on re-entry)

#### Text Editing

Expand Down Expand Up @@ -279,7 +285,7 @@ Edit trace scripts after executing `trace` command.
| Shortcut | Function |
|----------|----------|
| `Ctrl+S` | Submit script (compile and load) |
| `Ctrl+C` | Cancel script edit |
| `Ctrl+C` or `Esc` | Cancel script edit and return to Input Mode |

---

Expand Down
34 changes: 33 additions & 1 deletion docs/zh/input-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,39 @@ t process_data # 使用缩写形式
```

**说明:**
执行 trace 命令后会进入脚本编辑模式,编写追踪脚本。按 `Ctrl+S` 保存并执行,`Ctrl+C` 取消。
执行 trace 命令后会进入脚本编辑模式,编写追踪脚本。按 `Ctrl+S` 保存并执行,`Ctrl+C` 或 `Esc` 取消。

**脚本模式工作流:**
1. 执行 `trace <target>` → 进入带语法高亮的脚本模式
2. 编写追踪脚本(脚本语法见[脚本语言参考](scripting.md))
3. 提交和编译:
- `Ctrl+S`:提交脚本并编译为 eBPF
- `Ctrl+C` 或 `Esc`:取消并返回输入模式
4. 在命令面板查看编译结果
5. 在 eBPF 输出面板查看实时追踪输出

**脚本缓存:**
- 脚本会按目标自动缓存
- 重新进入相同目标(如再次 `trace sample.c:42`)会恢复之前的脚本
- 缓存会持续到退出 GhostScope
- 适合迭代调试:修改 → 测试 → 修改

**快速入门示例:**
```bash
# 1. 进入函数的脚本模式
trace main

# 2. 在脚本模式中编写:
print "进入 main,argc={}", argc;

# 3. 按 Ctrl+S 提交
# 4. 看到输出:✅ Trace Results: 1 successful, 0 failed

# 5. 稍后修改同一个追踪:
trace main # 你之前的脚本会被恢复!

# 6. 编辑后再次按 Ctrl+S
```

### enable - 启用追踪

Expand Down
10 changes: 8 additions & 2 deletions docs/zh/tui-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,13 @@ GhostScope TUI 界面由三个面板组成,每个面板具有不同的功能

### 模式:脚本模式

在执行 `trace` 命令后编辑追踪脚本。
在执行 `trace` 命令后编辑追踪脚本,支持语法高亮。

**特性:**
- GhostScope 脚本语言的实时语法高亮
- 行号显示,当前行高亮
- 多行编辑支持
- 按目标自动缓存脚本(重新进入时恢复)

#### 文本编辑

Expand Down Expand Up @@ -279,7 +285,7 @@ GhostScope TUI 界面由三个面板组成,每个面板具有不同的功能
| 快捷键 | 功能 |
|--------|------|
| `Ctrl+S` | 提交脚本(编译和加载)|
| `Ctrl+C` | 取消脚本编辑 |
| `Ctrl+C` 或 `Esc` | 取消脚本编辑并返回输入模式 |

---

Expand Down
4 changes: 2 additions & 2 deletions ghostscope-ui/src/components/command_panel/script_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ impl ScriptEditor {
state.mode = InteractionMode::ScriptEditor;

let message = if restored_from_cache {
format!("📝 Script editor opened for '{target}' (restored from cache)\nPress Ctrl+S to submit, ESC to cancel, F3 to clear")
format!("📝 Script editor opened for '{target}' (restored from cache)\nPress Ctrl+S to submit, ESC to cancel")
} else {
format!("📝 Script editor opened for '{target}'\nPress Ctrl+S to submit, ESC to cancel, F3 to clear")
format!("📝 Script editor opened for '{target}'\nPress Ctrl+S to submit, ESC to cancel")
};

let styled = vec![
Expand Down
4 changes: 2 additions & 2 deletions ghostscope-ui/src/components/loading/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl LoadingUI {
let header_text = Text::from(vec![Line::from(vec![
Span::styled("🔍 ", Style::default().fg(Color::Yellow)),
Span::styled(
"Ghostscope v0.1.0 - A DWARF-aware eBPF tracer with cgdb-like TUI - explore live processes at runtime",
format!("Ghostscope v{} - A DWARF-aware eBPF tracer with cgdb-like TUI - explore live processes at runtime", env!("CARGO_PKG_VERSION")),
Style::default()
.fg(Color::White)
.add_modifier(Modifier::BOLD),
Expand Down Expand Up @@ -201,7 +201,7 @@ impl LoadingUI {

let mut lines = vec![
Line::from(Span::styled(
"🔍 Ghostscope v0.1.0",
format!("🔍 Ghostscope v{}", env!("CARGO_PKG_VERSION")),
Style::default()
.fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
Expand Down
2 changes: 1 addition & 1 deletion ghostscope/src/config/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum LayoutMode {
#[command(
about = "A DWARF-aware eBPF tracer with cgdb-like TUI - explore live processes at runtime"
)]
#[command(version = "0.1.0")]
#[command(version = env!("CARGO_PKG_VERSION"))]
pub struct Args {
/// Binary file to debug (path or name)
pub binary: Option<String>,
Expand Down