Skip to content

Commit

Permalink
Add root command to print callgraph's root node
Browse files Browse the repository at this point in the history
  • Loading branch information
picatz committed Jan 3, 2024
1 parent e5fe887 commit fbeb379
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/taint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,22 @@ var builtinCommandCG = &command{
},
}

var builtinCommandRoot = &command{
name: "root",
desc: "print the callgraph's root",
fn: func(ctx context.Context, bt *bufio.Writer, args []string, flags map[string]string) error {
if cg == nil {
bt.WriteString("no callgraph is loaded\n")
bt.Flush()
return nil
}

bt.WriteString(cg.Root.String() + "\n")
bt.Flush()
return nil
},
}

var builtinCommandNodes = &command{
name: "nodes",
desc: "print the callgraph nodes",
Expand Down Expand Up @@ -598,6 +614,7 @@ var builtinCommands = commands{
builtinCommandLoad,
builtinCommandPkgs,
builtinCommandCG,
builtinCommandRoot,
builtinCommandNodes,
builtinCommandsCallpath,
builtinCommandCheck,
Expand Down

0 comments on commit fbeb379

Please sign in to comment.