Add real-time output for funccount execution trace mode#54
Merged
Conversation
Modify funccount's -e option to print events immediately as they occur instead of only displaying results at the end of tracing. Changes: - BPF: Send full exectrace_event (40 bytes) via perf buffer for exec mode - BPF: Keep sending PID (4 bytes) for stack mode (backward compatible) - Userspace: Rewrite perf buffer callback to handle both event types - Userspace: Add real-time symbol resolution and immediate printing - Userspace: Support count limit (-c) with early exit - Userspace: Skip post-processing for exec mode - Fix: Use flexible size check (>= 40) to handle struct padding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements real-time output for
funccount's-e(execution trace) option. Previously, the-eoption would only display results at the end of tracing. Now, function call events are printed immediately as they occur.Changes
BPF Layer (
funccount/bpf/funccount.bpf.c)exectrace_eventstruct (40 bytes) through perf buffer for exec modeUserspace Layer (
funccount/funccount.rs)-cflag) with early exitSymbolAnalyzerearly for real-time symbol resolutionBug Fix
>= 40instead of== 40) to handle struct padding from kernel-userspace boundaryFeatures
✅ Real-time output - events print as they occur
✅ Count limit support - honors
-cflag to stop after N events✅ Symbol resolution - resolves kernel and userspace symbols before printing
✅ Relative timestamps - works with
-rflag✅ Backward compatible - stack trace mode unchanged
✅ Multi-CPU safe - uses atomic operations for thread safety
Test Plan
Tested with:
sudo funccount -e k:vfs_read- Basic real-time tracesudo funccount -e -c 10 k:vfs_read- Count limitsudo funccount -e -r k:vfs_read- Relative timestampssudo funccount k:vfs_read- Stack mode (backward compatibility verified)🤖 Generated with Claude Code