Skip to content

Commit 60a80d0

Browse files
authored
Merge pull request #90 from zz85/flags
simplify CLI: add -o (output) and -e (event) unified flags (#88, #25)
2 parents bec33ac + 732be75 commit 60a80d0

5 files changed

Lines changed: 422 additions & 167 deletions

File tree

README.md

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ Installs `probee` and `pbee` (short alias). No nightly Rust required — a prebu
5353
sudo probee --tui
5454

5555
# Profile a specific command
56-
sudo probee --tui --cmd "my-application"
56+
sudo probee --tui -- my-application
5757

5858
# Generate an SVG flamegraph
59-
sudo probee --svg flamegraph.svg --time 5000
59+
sudo probee -o flamegraph.svg -t 5000
6060

6161
# Profile a command with args
62-
sudo probee --svg output.svg -- ./my-binary arg1 arg2
62+
sudo probee -o output.svg -- ./my-binary arg1 arg2
6363

6464
# Real-time flamegraphs via web server
6565
sudo probee --serve --skip-idle
6666

6767
# Trace function calls with uprobe
68-
sudo probee --uprobe malloc --time 1000 --svg malloc.svg
68+
sudo probee -e uprobe:malloc -t 1000 -o malloc.svg
6969

7070
# Off-CPU profiling — find where threads block
7171
sudo probee --off-cpu --tui -- ./my-server
@@ -84,7 +84,7 @@ Run `probee` with no arguments or `probee --help` for the full list of options a
8484
- **Smart uprobes** — GDB-style symbol resolution with glob, regex, demangled name matching, and multi-attach
8585
- **kprobe & tracepoint** support — profile kernel functions and tracepoint events
8686
- **Real-time web server** (`--serve`) — live flamegraph updates over HTTP with interactive controls
87-
- **Automatic termination** — stops when `--pid` target or `--cmd` process exits
87+
- **Automatic termination** — stops when `-p` target or child process exits
8888
- **Rust & C++ demangling** — via gimli/blazesym
8989
- **BPF-based aggregation** — stack counting in kernel to reduce userspace data transfer
9090
- **Group by CPU / process** — per-core or per-PID flamegraph breakdown (`--group-by-cpu`, `--group-by-process`)
@@ -97,57 +97,61 @@ Run `probee` with no arguments or `probee --help` for the full list of options a
9797

9898
### Output Formats
9999

100+
Use `-o <file>` to specify output — the format is inferred from the file extension:
101+
100102
```bash
101103
# SVG flamegraph
102-
sudo probee --svg profile.svg --frequency 999 --time 5000
104+
sudo probee -o profile.svg -f 999 -t 5000
103105

104106
# HTML flamegraph
105-
sudo probee --time 5000 --html flamegraphs.html
107+
sudo probee -o flamegraphs.html -t 5000
106108

107109
# Stackcollapse format (compatible with speedscope, flamegraph.pl)
108-
sudo probee --collapse profile.txt --frequency 999 --time 10000
110+
sudo probee -o profile.folded -f 999 -t 10000
109111

110112
# pprof protobuf (compatible with go tool pprof, Grafana/Pyroscope, Speedscope)
111-
sudo probee --pprof profile.pb.gz --time 5000
113+
sudo probee -o profile.pb.gz -t 5000
112114

113115
# AWS CodeGuru Profiler JSON (uploadable via AWS CLI)
114-
sudo probee --codeguru profile.json --time 5000
116+
sudo probee -o profile.codeguru.json -t 5000
115117

116118
# All output formats at once
117-
sudo probee --time 5000 --html out.html --json out.json --collapse out.txt --svg out.svg --pprof out.pb.gz
119+
sudo probee -t 5000 -o out.html -o out.json -o out.folded -o out.svg -o out.pb.gz
118120

119121
# Grouped by CPU
120-
sudo probee --svg profile.svg --frequency 999 --time 2000 --group-by-cpu
122+
sudo probee -o profile.svg -f 999 -t 2000 --group-by-cpu
121123

122124
# Grouped by process (each PID gets its own flamegraph sub-tree)
123-
sudo probee --svg profile.svg --time 5000 --group-by-process
125+
sudo probee -o profile.svg -t 5000 --group-by-process
124126
```
125127

126128
### Targeting
127129

128130
```bash
129131
# Profile specific PID (auto-stops when process exits)
130-
sudo probee --pid <pid> --svg output.svg --time 10000
132+
sudo probee -p <pid> -o output.svg -t 10000
131133

132134
# Profile specific CPU core
133-
sudo probee --cpu 0 --svg output.svg --time 5000
135+
sudo probee --cpu 0 -o output.svg -t 5000
134136

135137
# Profile a command
136-
sudo probee --svg output.svg -- ./my-binary arg1 arg2
138+
sudo probee -o output.svg -- ./my-binary arg1 arg2
137139

138140
# Real-time flamegraphs via web server
139-
sudo probee --time 5000 --serve --skip-idle --stream-mode 1
141+
sudo probee -t 5000 --serve --skip-idle --stream-mode 1
140142
# Then open http://localhost:8000/ and click "realtime-updates"
141143
```
142144

143145
### Kprobe & Tracepoint
144146

147+
Use `-e` with a probe type prefix:
148+
145149
```bash
146150
# Profile kernel function calls
147-
sudo probee --kprobe vfs_write --time 200 --svg kprobe.svg
151+
sudo probee -e kprobe:vfs_write -t 200 -o kprobe.svg
148152

149153
# Profile tracepoint events
150-
sudo probee --tracepoint tcp:tcp_probe --time 200 --svg tracepoint.svg
154+
sudo probee -e tracepoint:tcp:tcp_probe -t 200 -o tracepoint.svg
151155
```
152156

153157
### Smart Uprobe Targeting
@@ -156,40 +160,40 @@ Profile-bee supports GDB-style symbol resolution for uprobes. Instead of manuall
156160

157161
```bash
158162
# Auto-discover library
159-
sudo probee --uprobe malloc --time 1000 --svg malloc.svg
163+
sudo probee -e uprobe:malloc -t 1000 -o malloc.svg
160164

161165
# Multiple probes at once
162-
sudo probee --uprobe malloc --uprobe 'ret:free' --time 1000 --svg alloc.svg
166+
sudo probee -e uprobe:malloc -e uretprobe:free -t 1000 -o alloc.svg
163167

164168
# Glob matching — trace all pthread functions
165-
sudo probee --uprobe 'pthread_*' --time 1000 --svg pthread.svg
169+
sudo probee -e 'uprobe:pthread_*' -t 1000 -o pthread.svg
166170

167171
# Regex matching
168-
sudo probee --uprobe '/^sql_.*query/' --pid 1234 --time 2000 --svg sql.svg
172+
sudo probee -e 'uprobe:/^sql_.*query/' -p 1234 -t 2000 -o sql.svg
169173

170174
# Demangled C++/Rust name matching
171-
sudo probee --uprobe 'std::vector::push_back' --pid 1234 --time 1000 --svg vec.svg
175+
sudo probee -e 'uprobe:std::vector::push_back' -p 1234 -t 1000 -o vec.svg
172176

173177
# Source file and line number (requires DWARF debug info)
174-
sudo probee --uprobe 'main.c:42' --pid 1234 --time 1000 --svg source.svg
178+
sudo probee -e 'uprobe:main.c:42' -p 1234 -t 1000 -o source.svg
175179

176180
# Explicit library prefix
177-
sudo probee --uprobe libc:malloc --time 1000 --svg malloc.svg
181+
sudo probee -e uprobe:libc:malloc -t 1000 -o malloc.svg
178182

179183
# Absolute path to binary
180-
sudo probee --uprobe '/usr/lib/libc.so.6:malloc' --time 1000 --svg malloc.svg
184+
sudo probee -e 'uprobe:/usr/lib/libc.so.6:malloc' -t 1000 -o malloc.svg
181185

182186
# Return probe (uretprobe)
183-
sudo probee --uprobe ret:malloc --time 1000 --svg malloc_ret.svg
187+
sudo probee -e uretprobe:malloc -t 1000 -o malloc_ret.svg
184188

185189
# Function with offset
186-
sudo probee --uprobe malloc+0x10 --time 1000 --svg malloc_offset.svg
190+
sudo probee -e uprobe:malloc+0x10 -t 1000 -o malloc_offset.svg
187191

188192
# Scope to a specific PID
189-
sudo probee --uprobe malloc --uprobe-pid 12345 --time 1000 --svg malloc_pid.svg
193+
sudo probee -e uprobe:malloc --uprobe-pid 12345 -t 1000 -o malloc_pid.svg
190194

191195
# Discovery mode — list matching symbols without attaching
192-
sudo probee --list-probes 'pthread_*' --pid 1234
196+
sudo probee --list-probes 'uprobe:pthread_*' -p 1234
193197
```
194198

195199
**Probe spec syntax:**
@@ -223,13 +227,13 @@ The interactive terminal flamegraph viewer is included by default (forked and ad
223227

224228
```bash
225229
# Interactive TUI with a command
226-
sudo probee --tui --cmd "your-command"
230+
sudo probee --tui -- your-command
227231

228232
# Live profiling of a running process
229-
sudo probee --tui --pid <pid> --time 30000
233+
sudo probee --tui -p <pid> -t 30000
230234

231235
# With DWARF unwinding for optimized binaries
232-
sudo probee --tui --dwarf --cmd "./optimized-binary"
236+
sudo probee --tui --dwarf -- ./optimized-binary
233237

234238
# Build without TUI support
235239
cargo build --release --no-default-features
@@ -259,7 +263,7 @@ cargo build --release --no-default-features
259263
| **Flamegraph** | Interactive flame chart (default) |
260264
| **Top** | Flat function list sorted by overhead. Press `t` for expandable call tree. |
261265
| **Processes** | Process list with CPU% breakdown. `Enter` to zoom into a process. Press `t` for tree. |
262-
| **Output** | Child process stdout/stderr (when using `--cmd` or `--`) |
266+
| **Output** | Child process stdout/stderr (when using `-- <command>`) |
263267

264268
---
265269

@@ -288,10 +292,10 @@ This is the same approach used by [parca-agent](https://github.com/parca-dev/par
288292

289293
```bash
290294
# Enable DWARF unwinding for a no-frame-pointer binary
291-
sudo probee --dwarf --svg output.svg --time 5000 -- ./my-optimized-binary
295+
sudo probee --dwarf -o output.svg -t 5000 -- ./my-optimized-binary
292296

293297
# Frame pointer unwinding (the default)
294-
sudo probee --svg output.svg --time 5000 -- ./my-fp-binary
298+
sudo probee -o output.svg -t 5000 -- ./my-fp-binary
295299
```
296300

297301
**Note**: For symbol resolution, you still need debug information:
@@ -317,19 +321,19 @@ aws codeguruprofiler create-profiling-group \
317321
--compute-platform Default
318322

319323
# Profile and upload directly (use sudo -E to preserve AWS credentials)
320-
sudo -E probee --codeguru-upload --profiling-group my-app --time 10000
324+
sudo -E probee --codeguru-upload --profiling-group my-app -t 10000
321325

322326
# Off-CPU profiling uploads as WAITING counter type (visible in Latency view)
323-
sudo -E probee --codeguru-upload --profiling-group my-app --off-cpu --time 10000
327+
sudo -E probee --codeguru-upload --profiling-group my-app --off-cpu -t 10000
324328

325329
# Save a local copy while uploading
326-
sudo -E probee --codeguru-upload --profiling-group my-app --codeguru local.json --time 10000
330+
sudo -E probee --codeguru-upload --profiling-group my-app -o local.codeguru.json -t 10000
327331

328332
# Or generate the JSON locally and upload separately via AWS CLI
329-
sudo probee --codeguru profile.json --time 10000
333+
sudo probee -o profile.codeguru.json -t 10000
330334
aws codeguruprofiler post-agent-profile \
331335
--profiling-group-name my-app \
332-
--agent-profile fileb://profile.json \
336+
--agent-profile fileb://profile.codeguru.json \
333337
--content-type application/json
334338
```
335339

@@ -339,10 +343,10 @@ On-CPU samples use `RUNNABLE` counter type (visible in CPU and Latency views). O
339343

340344
### pprof Format
341345

342-
The `--pprof` flag outputs gzip-compressed [pprof](https://github.com/google/pprof) protobuf, the standard interchange format for profiling data:
346+
The `-o profile.pb.gz` output produces gzip-compressed [pprof](https://github.com/google/pprof) protobuf, the standard interchange format for profiling data:
343347

344348
```bash
345-
sudo probee --pprof profile.pb.gz --time 5000
349+
sudo probee -o profile.pb.gz -t 5000
346350

347351
# View with go tool pprof
348352
go tool pprof -http :8080 profile.pb.gz

docs/codeguru_format.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ these to populate different visualization views:
131131
## Example: On-CPU Profile
132132

133133
```bash
134-
sudo probee --codeguru profile.json --time 10000
134+
sudo probee -o profile.codeguru.json -t 10000
135135
```
136136

137137
```json
@@ -165,7 +165,7 @@ sudo probee --codeguru profile.json --time 10000
165165
## Example: Off-CPU Profile
166166

167167
```bash
168-
sudo probee --codeguru offcpu.json --off-cpu --time 10000
168+
sudo probee -o offcpu.codeguru.json --off-cpu -t 10000
169169
```
170170

171171
```json

profile-bee-tui/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This crate is not meant to be used directly. Instead, use it through profile-bee
3939
cargo build --release --features tui
4040

4141
# Use the TUI viewer
42-
sudo ./target/release/profile-bee --tui --cmd "your-command"
42+
sudo ./target/release/profile-bee --tui -- your-command
4343
```
4444

4545
## Architecture

0 commit comments

Comments
 (0)