Skip to content

Commit

Permalink
Add --output-caller flag
Browse files Browse the repository at this point in the history
Signed-off-by: gray <[email protected]>
  • Loading branch information
jschwinger233 authored and brb committed Jun 11, 2024
1 parent 0c793e9 commit 8e35676
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Usage: pwru [options] [pcap-filter]
-h, --help display this message and exit
--kernel-btf string specify kernel BTF file
--kmods strings list of kernel modules names to attach to
--output-caller print caller function name
--output-file string write traces to file
--output-json output traces in JSON format
--output-limit-lines uint exit the program after the number of events has been received/printed
Expand Down
3 changes: 2 additions & 1 deletion bpf/kprobe_pwru.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ struct config {
u8 output_skb: 1;
u8 output_shinfo: 1;
u8 output_stack: 1;
u8 output_unused: 3;
u8 output_caller: 1;
u8 output_unused: 2;
u8 is_set: 1;
u8 track_skb: 1;
u8 track_skb_by_stackid: 1;
Expand Down
4 changes: 4 additions & 0 deletions internal/pwru/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
OutputSkbMask
OutputShinfoMask
OutputStackMask
OutputCallerMask
)

const (
Expand Down Expand Up @@ -61,6 +62,9 @@ func GetConfig(flags *Flags) (cfg FilterCfg, err error) {
if flags.OutputStack {
cfg.OutputFlags |= OutputStackMask
}
if flags.OutputCaller {
cfg.OutputFlags |= OutputCallerMask
}
if flags.FilterTrackSkb {
cfg.FilterFlags |= TrackSkbMask
}
Expand Down
2 changes: 2 additions & 0 deletions internal/pwru/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Flags struct {
OutputSkb bool
OutputShinfo bool
OutputStack bool
OutputCaller bool
OutputLimitLines uint64
OutputFile string
OutputJson bool
Expand Down Expand Up @@ -76,6 +77,7 @@ func (f *Flags) SetFlags() {
flag.BoolVar(&f.OutputSkb, "output-skb", false, "print skb")
flag.BoolVar(&f.OutputShinfo, "output-skb-shared-info", false, "print skb shared info")
flag.BoolVar(&f.OutputStack, "output-stack", false, "print stack")
flag.BoolVar(&f.OutputCaller, "output-caller", false, "print caller function name")
flag.Uint64Var(&f.OutputLimitLines, "output-limit-lines", 0, "exit the program after the number of events has been received/printed")

flag.StringVar(&f.OutputFile, "output-file", "", "write traces to file")
Expand Down

0 comments on commit 8e35676

Please sign in to comment.