This document details all commands available in GhostScope's Command Interaction Panel Input Mode.
Type help in Input Mode to see available commands with their shortcuts.
Commands for setting and managing trace points in your application.
Syntax:
trace <target> [index]
t <target> [index] # Short form
Parameters:
<target>: Can be:- Function name:
function_name - File and line:
file:linewhere file can be:- Full path:
/path/to/file.c:42 - Relative path:
src/file.c:42 - Filename (fuzzy match):
file.c:42or even partial name
- Full path:
- Address:
0xADDRormodule_suffix:0xADDR0xADDR: Module-relative virtual address (DWARF PC). Default module depends on startup mode:-t <binary>: defaults to<binary>(including.so)-p <pid>: defaults to the process’s main executable
module_suffix:0xADDR: Address in a specific module. The module part supports full path or unique suffix matching; ambiguous suffixes will be reported with candidates.
- Function name:
Examples:
trace main # Trace main function
trace main 2 # Trace only the 2nd address of 'main' (see 'info function main')
trace calculate_something # Trace specific function
trace /home/user/src/sample.c:42 # Full path
trace /home/user/src/sample.c:42 1 # Trace only the 1st address for that line
trace src/sample.c:42 # Relative path
trace sample.c:42 # Filename only (fuzzy match)
trace sample:42 # Partial filename (fuzzy match)
t 0x401234 # Address in default module (depends on -t/-p)
t libc.so.6:0x1234 # Address in a shared library by suffix
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 or Esc to cancel.
Script Mode Workflow:
- Execute
trace <target>→ Enter Script Mode with syntax highlighting - Write trace script (see Script Language Reference for syntax)
- Submit and compile:
Ctrl+S: Submit script and compile to eBPFCtrl+CorEsc: Cancel and return to Input Mode
- View compilation results in command panel
- 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:42again) restores previous script - Cache persists until you exit GhostScope
- Useful for iterative debugging: modify → test → modify
Quick Start Example:
# 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- When tracing, compilation results now annotate each target with its code origin:
inline: The target address is inside an inlined function instance (DW_TAG_inlined_subroutine).call: The target address is in a non-inlined context (regular function body/entry).
- The command panel shows these as:
— inline|call @ file:linenext to each address. - This helps distinguish whether your probe lands in an inlined body or a normal function location.
-
Function target (
trace <function_name> { ... }):- Non-inline: selects the first executable instruction after the function prologue (prologue-skip).
- Inline: selects the inline instance start (low_pc semantics of the inline DIE); this is an entry-like point and may not align to a statement boundary. Use a line target if you need precise statement alignment.
- Multiple inline instances: if a function is inlined at multiple call sites, you’ll see one address per instance (plus one for the non-inline definition, if present).
-
Source line target (
trace <file:line> { ... }):- Resolves to the statement boundary on that line for each occurrence (one per inline instance across callers), i.e., statement-level semantics.
- Typically yields one address per instance where that source line is active.
- You can restrict to a single address with
trace <file:line> [index].
Syntax:
enable <id|all>
en <id|all> # Short form
Parameters:
<id>: Trace point ID numberall: Enable all trace points
Examples:
enable 1 # Enable trace with ID 1
enable all # Enable all traces
en 3 # Short form for ID 3
Syntax:
disable <id|all>
dis <id|all> # Short form
Parameters:
<id>: Trace point ID numberall: Disable all trace points
Examples:
disable 2 # Disable trace with ID 2
disable all # Disable all traces
dis 1 # Short form for ID 1
Syntax:
delete <id|all>
del <id|all> # Short form
Parameters:
<id>: Trace point ID numberall: Delete all trace points
Examples:
delete 3 # Delete trace with ID 3
delete all # Delete all traces
del 2 # Short form for ID 2
Syntax:
save traces [file]
save traces enabled [file]
save traces disabled [file]
s t [file] # Short form
Parameters:
[file]: Optional filename (uses default if not provided)enabled: Save only enabled tracesdisabled: Save only disabled traces
Behavior:
- Saves each trace as a
trace <target> { ... }block with metadata. - If a trace was created with
trace <target> [index], the selected address index is preserved in the save file and restored on load.
Examples:
save traces # Save all to default file
save traces my_traces.gs # Save to specific file
save traces enabled active.gs # Save only enabled traces
save traces disabled backup.gs # Save only disabled traces
s t session.gs # Short form
Syntax:
save output [file]
s o [file] # Short form
Parameters:
[file]: Optional filename (uses timestamped default if not provided)
Behavior:
- Starts realtime logging of eBPF trace events to file
- All subsequent trace events are immediately written to file
- File is created if it doesn't exist, or appended if it exists
- Each event is flushed immediately for realtime capture
- Use
stop outputto stop logging
Examples:
save output # Start logging to ebpf_output_TIMESTAMP.log
save output debug.log # Start logging to debug.log
s o trace_events.log # Short form
Syntax:
save session [file]
s s [file] # Short form
Parameters:
[file]: Optional filename (uses timestamped default if not provided)
Behavior:
- Starts realtime logging of command session (commands + responses)
- All subsequent commands and their responses are immediately written to file
- File is created if it doesn't exist, or appended if it exists
- Commands are marked with
>>>, responses are indented - Use
stop sessionto stop logging
Examples:
save session # Start logging to command_session_TIMESTAMP.log
save session debug_session.log # Start logging to debug_session.log
s s my_session.log # Short form
Syntax:
stop output
Behavior:
- Stops realtime eBPF output logging
- Flushes and closes the log file
- Returns error if no logging is active
Syntax:
stop session
Behavior:
- Stops realtime session logging
- Flushes and closes the log file
- Returns error if no logging is active
Syntax:
source <file>
s <file> # Short form (but not "s t")
Parameters:
<file>: Script file to load
Behavior:
- Loads all
trace <target> { ... }blocks in the file. - If a block includes an address index (saved from a prior session), only that indexed address is reattached for the target.
Examples:
source traces.gs # Load trace script
source /path/to/script.gs # Load from path
s my_script.gs # Short form
Commands for viewing debug information and trace status.
Syntax:
info # Show available info subcommands
i # Short form
Description: Displays list of available info subcommands.
Syntax:
info trace [id]
i t [id] # Short form
Parameters:
[id]: Optional trace ID (shows all if omitted)
Examples:
info trace # Show all trace statuses
info trace 1 # Show details for trace ID 1
i t # Short form for all
i t 2 # Short form for ID 2
Syntax:
info source
i s # Short form
Description: Display all loaded source files with debug information.
Syntax:
info file
i file # Short form
i f # Shortest form (no args)
Description: Display executable file information including:
- File path and type (ELF 64-bit/32-bit)
- Entry point address
- Symbol table status
- Debug information status (includes .gnu_debuglink detection)
- Section addresses (.text, .data)
- Launch mode (PID mode or static analysis mode)
Output:
- ELF virtual addresses: For
-tmode (static analysis) - Runtime loaded addresses: For
-pmode (attached to process) - Debug link: Shows separate debug file path if using .gnu_debuglink
Examples:
info file # Show executable info
i file # Short form
i f # Shortest form
Syntax:
info share # Show libraries WITH debug info (default)
info share all # Show ALL loaded shared libraries
i sh # Short form for `info share`
i sh all # Short form for `info share all`
Description: Display loaded shared libraries (dynamic libraries) with:
- Memory address ranges (from/to)
- Symbol table status
- Debug information status
- Library file paths
- Separate debug files (if using .gnu_debuglink)
By default, info share only lists libraries that have debug information available.
Use info share all to list every loaded library regardless of debug info.
Output Format:
📚 Shared Libraries (N):
From To Syms Debug Shared Object
──────────────────────────────────────────────────────────────────────
0x00007f... 0x00007f... ✓ ✓ /lib/libc.so.6
Debug files (.gnu_debuglink):
/lib/libc.so.6 → /usr/lib/debug/.build-id/ab/cdef.debug
Syntax:
info function <name> [verbose|v]
i f <name> [v] # Short form
Parameters:
<name>: Function name[verbose|v]: Optional. Show DWARF location expressions (hidden by default)
Examples:
info function main # Show debug info (without DWARF expressions)
info function main v # Show with DWARF expressions
i f calculate verbose # Short form with verbose
i f test v # Shortest form with verbose
Syntax:
info line <file:line> [verbose|v]
i l <file:line> [v] # Short form
Parameters:
<file:line>: File name and line number[verbose|v]: Optional. Show DWARF location expressions (hidden by default)
Examples:
info line main.c:42 # Debug info for line 42 (without DWARF expressions)
info line main.c:42 v # Show with DWARF expressions
i l test.c:100 verbose # Short form with verbose
i l test.c:100 v # Shortest form with verbose
Syntax:
info address <0xADDR | module_suffix:0xADDR> [verbose|v]
i a <0xADDR | module_suffix:0xADDR> [v] # Short form
Parameters:
<0xADDR>: Module-relative virtual address (DWARF/symbol PC) in hex. If no module is specified, the default module applies (see below).module_suffix:0xADDR: Address in a specific module. The module part supports full path or unique suffix matching; ambiguity will be reported with candidates.[verbose|v]: Optional. Show DWARF location expressions (hidden by default).
Defaults and modes:
- Launched with
-t <binary>(target mode): the default module is<binary>. - Launched with
-p <pid>(PID mode): the default module is the main executable of the process. For library addresses, specify the module via suffix or use-twith that.so.
Description: Shows per-module debug info for a given address: resolves function name (if any), source file:line (if available), and variables/parameters visible at that PC. Also displays the underlying module to attach and performs module suffix matching.
Examples:
info address 0x401234 # Use default module (depends on -t/-p)
info address libc.so.6:0x1234 # Suffix match shared library + address
info address /usr/bin/nginx:0xdeadbeef v # Full path + verbose
- For
info function,info line, andinfo address, each address line includes:— inlineif the PC falls in an inlined subroutine instance, otherwise— call.@ file:linewith the resolved source location when available.
- Same source line may appear multiple times (one per inline instance across different callers).
Commands for managing source code path mappings when DWARF debug information contains compilation-time paths that differ from runtime paths.
Syntax:
srcpath
Description: Display current path substitution rules and search directories. Shows both runtime-added rules and config file rules.
Syntax:
srcpath add <directory>
Parameters:
<directory>: Directory path to search for source files
Examples:
srcpath add /usr/local/src # Add search directory
srcpath add /home/user/sources # Add user sources directory
Description:
When a source file cannot be found via exact path or substitution, GhostScope will search in the root of these directories by filename (basename matching, non-recursive). For example, after adding /usr/local/src, it can find /usr/local/src/foo.c but not /usr/local/src/subdir/bar.c.
Syntax:
srcpath map <from> <to>
Parameters:
<from>: Compilation-time path prefix (from DWARF debug info)<to>: Runtime path prefix (actual location on this machine)
Examples:
srcpath map /build/project /home/user/project # CI build path to local
srcpath map /usr/src/linux-5.15 /home/user/kernel # Kernel sources moved
srcpath map /buildroot/arm /local/embedded # Cross-compilation paths
Description:
Replaces path prefixes from compilation time with runtime paths. If you run the same mapping twice with different <to> paths, the second one will update the existing mapping.
Syntax:
srcpath remove <path>
Parameters:
<path>: Path prefix of a mapping or search directory to remove
Examples:
srcpath remove /build/project # Remove mapping with this 'from' prefix
srcpath remove /usr/local/src # Remove search directory
Description: Removes a runtime-added rule (mapping or search directory). Config file rules cannot be removed via this command.
Syntax:
srcpath clear
Description: Clears all runtime-added rules (both mappings and search directories). Config file rules are preserved.
Syntax:
srcpath reset
Description:
Removes all runtime-added rules and resets to config file rules only. Same as srcpath clear.
GhostScope uses a relative path + directory prefix approach to locate source files:
-
DWARF Information Contains:
- Compilation directory (comp_dir): e.g.,
/home/build/nginx-1.27.1 - Source file relative path: e.g.,
src/core/nginx.c
- Compilation directory (comp_dir): e.g.,
-
Path Composition:
- Full path = Compilation directory + Relative path
- Example:
/home/build/nginx-1.27.1/src/core/nginx.c
-
Resolution Order:
- First: Try original full path
- Then: Apply
mapsubstitution rules (recommended) - Last: Search in
adddirectories by filename
Map the compilation directory from DWARF to your local source directory. This makes all relative path files automatically resolve:
# Check file loading error message for DWARF directory
# Error displays:
# DWARF Directory: /home/build/nginx-1.27.1
# Relative Path: src/core/nginx.c
# Map DWARF directory to local path
srcpath map /home/build/nginx-1.27.1 /home/user/nginx-1.27.1
# Now all files can be found:
# /home/build/nginx-1.27.1/src/core/nginx.c → /home/user/nginx-1.27.1/src/core/nginx.c
# /home/build/nginx-1.27.1/src/http/ngx_http.c → /home/user/nginx-1.27.1/src/http/ngx_http.cAdvantages:
- ✅ One-time setup, works for all files
- ✅ Preserves directory structure, easy to understand
- ✅ Supports multi-level directories and complex projects
- ✅ File search (
okey) automatically updates paths
Only use when map cannot solve the problem (e.g., header files scattered across multiple locations):
# Add additional search directories
srcpath add /usr/local/include
srcpath add /opt/vendor/includeNote: add searches by filename (basename) only in directory root (non-recursive), cannot handle subdirectories, and may not find the correct file when names conflict.
Path mappings can be persisted in config.toml to avoid manual configuration each time:
[source]
# Recommended: DWARF directory mappings
substitutions = [
{ from = "/home/build/myproject", to = "/home/user/work/myproject" },
{ from = "/usr/src/linux-5.15", to = "/home/user/kernel/linux-5.15" },
]
# Auxiliary: Additional search directories (searches by filename)
search_dirs = [
"/usr/local/include",
"/opt/local/src",
]Runtime rules (via commands) take priority over config file rules.
Scenario 1: Source compiled on CI server ⭐ Recommended
# Check DWARF Directory in error message
# Then map it to your local source root
srcpath map /home/jenkins/workspace/myproject /home/user/myprojectScenario 2: Compiled in container, debugging locally ⭐ Recommended
# Docker container compilation directory: /build/app
# Local source at: /home/user/app
srcpath map /build/app /home/user/appScenario 3: Multiple independent header directories
# System headers and third-party library headers
srcpath add /usr/local/include
srcpath add /opt/project/vendorScenario 4: Correcting a wrong mapping
srcpath map /build /wrong/path # First attempt (wrong)
srcpath map /build /correct/path # Second attempt (updates existing mapping)- Prefer
map: Map DWARF compilation directory, not individual files - Check error messages: File loading failures display DWARF Directory, map it directly
- Preserve directory structure: Keep same relative path structure as during compilation
- Save to config: Save common mappings to
config.tomlto avoid repeated configuration - Use
addcautiously: Only use whenmapcannot solve the problem, as it only searches by filename in directory root (non-recursive), cannot handle subdirectories, and may find wrong files with same names
General control and utility commands.
Syntax:
help
Description: Display comprehensive help with all available commands and keyboard shortcuts.
Syntax:
clear
Description: Clear command history (removes all previous commands from history display).
Syntax:
quit
exit
Description:
Exit GhostScope. You can also use Ctrl+C twice to quit.
| Full Command | Short Form | Description |
|---|---|---|
trace |
t |
Set trace point |
enable |
en |
Enable trace |
disable |
dis |
Disable trace |
delete |
del |
Delete trace |
info |
i |
View information |
info file |
i f, i file |
View executable file info |
info trace |
i t |
View trace status |
info source |
i s |
View source files |
info share |
i sh |
View libraries WITH debug info |
info share all |
i sh all |
View all shared libraries |
info function |
i f <name> |
View function info |
info line |
i l |
View line info |
info address |
i a |
View address info |
save traces |
s t |
Save trace points |
source |
s |
Load script (except "s t") |
srcpath |
- | Manage source path mappings |
GhostScope provides a multi-layered intelligent completion system:
Press Tab to trigger command and parameter completion:
- Command Completion: Auto-complete GhostScope commands (trace, enable, info, etc.)
- File Path Completion: Auto-complete file paths for source command
- Parameter Completion: Context-aware parameter suggestions
Examples:
gs > t<Tab> → trace
gs > info s<Tab> → info source
gs > source /pa<Tab> → source /path/to/script.gs
As you type, GhostScope displays gray suggestion text based on command history:
- Trigger Condition: After typing 3+ characters
- Source: Matches prefix from command history
- Accept Suggestion: Press
→(Right arrow) orCtrl+E - Ignore Suggestion: Continue typing or move cursor
Example:
gs > trace main<typing>
trace main -s "print(a, b, c)" ← Gray suggestion
Press → to accept the entire suggestion
For commands requiring file paths, Tab completion supports:
- Relative Paths: From current directory
- Absolute Paths: From root directory
- Multi-level Navigation: Navigate through directory hierarchies
- Smart Filtering: Only show relevant file types (.gs script files)
GhostScope automatically saves command history for quick reuse and search:
| Shortcut | Function |
|---|---|
↑ or Ctrl+P |
Previous history command |
↓ or Ctrl+N |
Next history command |
- Auto-save: Commands automatically saved to
.ghostscope_historyfile - Cross-session: History shared across different GhostScope sessions
- Deduplication: Consecutive duplicate commands not recorded
- Capacity Limit: Stores up to 1000 recent commands by default
Use clear command to clear history:
gs > clear # Clear command historyNote: Clearing history deletes all records in .ghostscope_history file.
History and completion behavior can be adjusted in config file (see Configuration):
[history]
enabled = true # Enable history recording
max_entries = 1000 # Maximum history entries
[auto_suggestion]
enabled = true # Enable auto-suggestion
min_chars = 3 # Minimum chars to trigger suggestion- Use Shortcuts: Master command shortcuts (
t,en,dis) for faster workflow - Tab Completion: Use
Tabextensively for completion and command discovery - History Navigation: Use
Ctrl+P/Ctrl+Nor↑/↓to quickly reuse commands - Batch Operations: Use
allparameter to operate on all traces at once - Save Sessions: Regularly save your trace configuration with
save traces - Script Reuse: Save common trace patterns in files and load with
source
Common error messages and their meanings:
"Unknown command": Command not recognized. Check spelling or usehelp"Usage: <command> <args>": Invalid arguments. Check command syntax"Trace ID not found": The specified trace ID doesn't exist"File not found": Script file doesn't exist at specified path
- TUI Reference Guide - Complete keyboard shortcuts and panel operations
- Script Language Reference - Trace script syntax
- Quick Tutorial - Getting started guide
Commands to adjust UI during runtime.
Syntax:
ui source <on|off>
Description:
ui source off: Hide the Source panel and keep only eBPF Output + Command panels. Useful when source code is unavailable on the machine.ui source on: Show the Source panel again. When turned on, GhostScope will request source code immediately.
Tip: You can also control this via CLI or config:
- CLI:
--no-source-panel(hide) /--source-panel(show) - Config:
[ui].show_source_panel=false
Layout Ratio:
- When the Source panel is hidden, the two remaining panels follow
[ui].two_panel_ratiosif set; otherwise they fall back to the last two values of[ui].panel_ratios(example:4:3:3→3:3).