You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/input-commands.md
+300-9Lines changed: 300 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,6 +322,216 @@ i a <addr> # Short form
322
322
323
323
---
324
324
325
+
## 🗂️ Source Path Commands
326
+
327
+
Commands for managing source code path mappings when DWARF debug information contains compilation-time paths that differ from runtime paths.
328
+
329
+
### srcpath - Show Path Mappings
330
+
331
+
**Syntax:**
332
+
```
333
+
srcpath
334
+
```
335
+
336
+
**Description:**
337
+
Display current path substitution rules and search directories. Shows both runtime-added rules and config file rules.
338
+
339
+
### srcpath add - Add Search Directory
340
+
341
+
**Syntax:**
342
+
```
343
+
srcpath add <directory>
344
+
```
345
+
346
+
**Parameters:**
347
+
-`<directory>`: Directory path to search for source files
348
+
349
+
**Examples:**
350
+
```
351
+
srcpath add /usr/local/src # Add search directory
352
+
srcpath add /home/user/sources # Add user sources directory
353
+
```
354
+
355
+
**Description:**
356
+
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`.
357
+
358
+
### srcpath map - Map Compilation Path to Runtime Path
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.
378
+
379
+
### srcpath remove - Remove Mapping or Directory
380
+
381
+
**Syntax:**
382
+
```
383
+
srcpath remove <path>
384
+
```
385
+
386
+
**Parameters:**
387
+
-`<path>`: Path prefix of a mapping or search directory to remove
388
+
389
+
**Examples:**
390
+
```
391
+
srcpath remove /build/project # Remove mapping with this 'from' prefix
#### Auxiliary: Use `srcpath add` for Search Directories
464
+
465
+
Only use when `map` cannot solve the problem (e.g., header files scattered across multiple locations):
466
+
467
+
```bash
468
+
# Add additional search directories
469
+
srcpath add /usr/local/include
470
+
srcpath add /opt/vendor/include
471
+
```
472
+
473
+
**Note**: `add` searches by **filename** (basename) only in directory root (non-recursive), cannot handle subdirectories, and may not find the correct file when names conflict.
474
+
475
+
### Configuration File Support
476
+
477
+
Path mappings can be persisted in `config.toml` to avoid manual configuration each time:
478
+
479
+
```toml
480
+
[source]
481
+
# Recommended: DWARF directory mappings
482
+
substitutions = [
483
+
{ from = "/home/build/myproject", to = "/home/user/work/myproject" },
484
+
{ from = "/usr/src/linux-5.15", to = "/home/user/kernel/linux-5.15" },
485
+
]
486
+
487
+
# Auxiliary: Additional search directories (searches by filename)
488
+
search_dirs = [
489
+
"/usr/local/include",
490
+
"/opt/local/src",
491
+
]
492
+
```
493
+
494
+
Runtime rules (via commands) take priority over config file rules.
495
+
496
+
### Common Use Cases
497
+
498
+
**Scenario 1: Source compiled on CI server** ⭐ Recommended
3.**Preserve directory structure**: Keep same relative path structure as during compilation
530
+
4.**Save to config**: Save common mappings to `config.toml` to avoid repeated configuration
531
+
5.**Use `add` cautiously**: Only use when `map` cannot 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
532
+
533
+
---
534
+
325
535
## ⚙️ Control Commands
326
536
327
537
General control and utility commands.
@@ -376,16 +586,98 @@ Exit GhostScope. You can also use `Ctrl+C` twice to quit.
376
586
|`info address`|`i a`| View address info |
377
587
|`save traces`|`s t`| Save trace points |
378
588
|`source`|`s`| Load script (except "s t") |
589
+
|`srcpath`| - | Manage source path mappings |
379
590
380
591
---
381
592
382
-
## Command Completion
593
+
## Command Completion & History
594
+
595
+
### Command Completion
596
+
597
+
GhostScope provides a multi-layered intelligent completion system:
598
+
599
+
#### 1. Tab Command Completion
600
+
601
+
Press `Tab` to trigger command and parameter completion:
0 commit comments