(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:tracing)
          op: Equal
          rhs: {(/sys/kernel/debug/tracing)}
          spids: [175]
        )
      ]
      spids: [175]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:flock)
          op: Equal
          rhs: {(/var/tmp/.ftrace-lock)}
          spids: [178]
        )
      ]
      spids: [178]
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:opt_duration) op:Equal rhs:{(0)} spids:[181])]
          spids: [181]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:duration) op:Equal rhs:{(SQ )} spids:[185])]
          spids: [185]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:opt_pid) op:Equal rhs:{(0)} spids:[188])]
          spids: [188]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:pid) op:Equal rhs:{(SQ )} spids:[192])]
          spids: [192]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:opt_tid) op:Equal rhs:{(0)} spids:[195])]
          spids: [195]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:tid) op:Equal rhs:{(SQ )} spids:[199])]
          spids: [199]
        )
      terminator: <Op_Semi ";">
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:pidtext) op:Equal rhs:{(SQ )} spids:[202])]
      spids: [202]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:opt_headers) op:Equal rhs:{(0)} spids:[204])]
      spids: [204]
    )
    (C {(trap)} {(SQ <":">)} {(INT)} {(QUIT)} {(TERM)} {(PIPE)} {(HUP)})
    (FuncDef
      name: usage
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (HereDoc
                  op_id: Redir_DLessDash
                  fd: -1
                  body: 
                    {
                      (DQ ("USAGE: functrace [-hH] [-p PID] [-L TID] [-d secs] funcstring\n") 
                        ("                 -d seconds      # trace duration, and use buffers\n") ("                 -h              # this usage message\n") 
                        ("                 -H              # include column headers\n") ("                 -p PID          # trace when this pid is on-CPU\n") 
                        ("                 -L TID          # trace when this thread is on-CPU\n") ("  eg,\n") ("       functrace do_nanosleep    # trace the do_nanosleep() function\n") 
                        ("       functrace '*sleep'        # trace functions ending in ") (Right_DoubleQuote "\"") (sleep) (Right_DoubleQuote "\"") ("\n") 
                        ("       functrace -p 198 'vfs*'   # trace ") (Right_DoubleQuote "\"") ("vfs*") (Right_DoubleQuote "\"") (" funcs for PID 198\n") 
                        ("       functrace 'tcp*' > out    # trace all ") (Right_DoubleQuote "\"") ("tcp*") (Right_DoubleQuote "\"") (" funcs to out file\n") 
                        (
"       functrace -d 1 'tcp*' > out  # trace 1 sec, then write out file\n"
                        ) ("\n") ("See the man page and example file for more info.\n")
                      )
                    }
                  do_expansion: True
                  here_end: END
                  was_filled: True
                  spids: [236]
                )
                (Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[239])
              ]
            )
            (C {(exit)})
          ]
          spids: [231]
        )
      spids: [227 230]
    )
    (FuncDef
      name: warn
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: (Pipeline children:[(C {(eval)} {(DQ ($ VSub_At "$@"))})] negated:True)
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (SimpleCommand
                      words: [
                        {(echo)}
                        {
                          (DQ ("WARNING: command failed ") 
                            (EscapedLiteralPart
                              token: <Lit_EscapedChar "\\\"">
                            ) ($ VSub_At "$@") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">)
                          )
                        }
                      ]
                      redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[297])]
                    )
                  ]
                  spids: [-1 292]
                )
              ]
              spids: [-1 308]
            )
          ]
          spids: [278]
        )
      spids: [274 277]
    )
    (FuncDef
      name: end
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)}]
              redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[326])]
            )
            (SimpleCommand
              words: [{(echo)} {(DQ ("Ending tracing..."))}]
              redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[336])]
            )
            (C {(cd)} {($ VSub_Name "$tracing")})
            (C {(warn)} {(DQ ("echo nop > current_tracer"))})
            (AndOr
              children: [
                (DParen
                  child: 
                    (ArithBinary
                      op_id: Arith_DPipe
                      left: (ArithVarRef name:opt_pid)
                      right: (ArithVarRef name:opt_tid)
                    )
                )
                (C {(warn)} {(DQ ("echo > set_ftrace_pid"))})
              ]
              op_id: Op_DAmp
            )
            (C {(warn)} {(DQ ("echo > set_ftrace_filter"))})
            (C {(warn)} {(DQ ("echo > trace"))})
            (AndOr
              children: [
                (DParen child:(ArithVarRef name:wroteflock))
                (C {(warn)} {(DQ ("rm ") ($ VSub_Name "$flock"))})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [317]
        )
      spids: [313 316]
    )
    (FuncDef
      name: die
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At "$@"))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[414])]
            )
            (C {(exit)} {(1)})
          ]
          spids: [409]
        )
      spids: [405 408]
    )
    (FuncDef
      name: edie
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At "$@"))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[442])]
            )
            (SimpleCommand
              words: [{(exec)}]
              redirects: [
                (Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[452])
                (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[455])
              ]
            )
            (C {(end)})
            (C {(exit)} {(1)})
          ]
          spids: [433]
        )
      spids: [429 432]
    )
    (While
      cond: [(C {(getopts)} {(d) (Lit_Other ":") (hHp) (Lit_Other ":") (L) (Lit_Other ":")} {(opt)})]
      body: 
        (DoGroup
          children: [
            (Case
              to_match: {($ VSub_Name "$opt")}
              arms: [
                (case_arm
                  pat_list: [{(d)}]
                  action: [
                    (Sentence
                      child: 
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:opt_duration)
                              op: Equal
                              rhs: {(1)}
                              spids: [498]
                            )
                          ]
                          spids: [498]
                        )
                      terminator: <Op_Semi ";">
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:duration)
                          op: Equal
                          rhs: {($ VSub_Name "$OPTARG")}
                          spids: [502]
                        )
                      ]
                      spids: [502]
                    )
                  ]
                  spids: [495 496 505 -1]
                )
                (case_arm
                  pat_list: [{(p)}]
                  action: [
                    (Sentence
                      child: 
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:opt_pid)
                              op: Equal
                              rhs: {(1)}
                              spids: [511]
                            )
                          ]
                          spids: [511]
                        )
                      terminator: <Op_Semi ";">
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:pid)
                          op: Equal
                          rhs: {($ VSub_Name "$OPTARG")}
                          spids: [515]
                        )
                      ]
                      spids: [515]
                    )
                  ]
                  spids: [508 509 518 -1]
                )
                (case_arm
                  pat_list: [{(L)}]
                  action: [
                    (Sentence
                      child: 
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:opt_tid)
                              op: Equal
                              rhs: {(1)}
                              spids: [524]
                            )
                          ]
                          spids: [524]
                        )
                      terminator: <Op_Semi ";">
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:tid)
                          op: Equal
                          rhs: {($ VSub_Name "$OPTARG")}
                          spids: [528]
                        )
                      ]
                      spids: [528]
                    )
                  ]
                  spids: [521 522 531 -1]
                )
                (case_arm
                  pat_list: [{(H)}]
                  action: [
                    (Sentence
                      child: 
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:opt_headers)
                              op: Equal
                              rhs: {(1)}
                              spids: [537]
                            )
                          ]
                          spids: [537]
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  spids: [534 535 541 -1]
                )
                (case_arm
                  pat_list: [{(h)} {(Lit_Other "?")}]
                  action: [(C {(usage)})]
                  spids: [544 547 551 -1]
                )
              ]
              spids: [488 492 554]
            )
          ]
          spids: [485 556]
        )
    )
    (C {(shift)} 
      {
        (ArithSubPart
          anode: 
            (ArithBinary
              op_id: Arith_Minus
              left: (ArithWord w:{($ VSub_Name "$OPTIND")})
              right: (ArithWord w:{(Lit_Digits 1)})
            )
          spids: [560 569]
        )
      }
    )
    (AndOr
      children: [
        (DParen
          child: 
            (ArithBinary
              op_id: Arith_DEqual
              left: (ArithWord w:{($ VSub_Pound "$#")})
              right: (ArithWord w:{(Lit_Digits 0)})
            )
        )
        (C {(usage)})
      ]
      op_id: Op_DAmp
    )
    (AndOr
      children: [
        (DParen
          child: 
            (ArithBinary
              op_id: Arith_DAmp
              left: (ArithVarRef name:opt_pid)
              right: (ArithVarRef name:opt_tid)
            )
        )
        (C {(edie)} {(DQ ("ERROR: You can use -p or -L but not both."))})
      ]
      op_id: Op_DAmp
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:funcs)
          op: Equal
          rhs: {(DQ ($ VSub_Number "$1"))}
          spids: [609]
        )
      ]
      spids: [609]
    )
    (AndOr
      children: [
        (DParen child:(ArithVarRef name:opt_pid))
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:pidtext)
              op: Equal
              rhs: {(DQ (" for PID ") ($ VSub_Name "$pid"))}
              spids: [623]
            )
          ]
          spids: [623]
        )
      ]
      op_id: Op_DAmp
    )
    (AndOr
      children: [
        (DParen child:(ArithVarRef name:opt_tid))
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:pidtext)
              op: Equal
              rhs: {(DQ (" for TID ") ($ VSub_Name "$pid"))}
              spids: [638]
            )
          ]
          spids: [638]
        )
      ]
      op_id: Op_DAmp
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (DParen child:(ArithVarRef name:opt_duration))
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (C {(echo)} 
              {
                (DQ ("Tracing ") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) 
                  ($ VSub_Name "$funcs") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) ($ VSub_Name "$pidtext") (" for ") 
                  ($ VSub_Name "$duration") (" seconds...")
                )
              }
            )
          ]
          spids: [-1 654]
        )
      ]
      else_action: [
        (C {(echo)} 
          {
            (DQ ("Tracing ") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) ($ VSub_Name "$funcs") 
              (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) ($ VSub_Name "$pidtext") ("... Ctrl-C to end.")
            )
          }
        )
      ]
      spids: [670 684]
    )
    (AndOr
      children: [
        (C {(cd)} {($ VSub_Name "$tracing")})
        (C {(die)} 
          {
            (DQ ("ERROR: accessing tracing. Root user? Kernel has FTRACE?\n") 
              ("    debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)")
            )
          }
        )
      ]
      op_id: Op_DPipe
    )
    (AndOr
      children: [
        (DBracket expr:(BoolUnary op_id:BoolUnary_e child:{($ VSub_Name "$flock")}))
        (C {(die)} 
          {
            (DQ ("ERROR: ftrace may be in use by PID ") 
              (CommandSubPart
                command_list: (CommandList children:[(C {(cat)} {($ VSub_Name "$flock")})])
                left_token: <Left_CommandSub "$(">
                spids: [721 725]
              ) (" ") ($ VSub_Name "$flock")
            )
          }
        )
      ]
      op_id: Op_DAmp
    )
    (AndOr
      children: [
        (SimpleCommand
          words: [{(echo)} {($ VSub_Dollar "$$")}]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{($ VSub_Name "$flock")} spids:[734])]
        )
        (C {(die)} {(DQ ("ERROR: unable to write ") ($ VSub_Name "$flock") (.))})
      ]
      op_id: Op_DPipe
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:wroteflock) op:Equal rhs:{(1)} spids:[748])]
      spids: [748]
    )
    (C {(sysctl)} {(-q)} {(kernel.ftrace_enabled) (Lit_Other "=") (1)})
    (SimpleCommand
      words: [{(read)} {(mode)}]
      redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{(current_tracer)} spids:[770])]
    )
    (AndOr
      children: [
        (DBracket
          expr: 
            (BoolBinary
              op_id: BoolBinary_GlobNEqual
              left: {(DQ ($ VSub_Name "$mode"))}
              right: {(DQ (nop))}
            )
        )
        (C {(edie)} {(DQ ("ERROR: ftrace active (current_tracer=") ($ VSub_Name "$mode") (")"))})
      ]
      op_id: Op_DAmp
    )
    (If
      arms: [
        (if_arm
          cond: [(Sentence child:(DParen child:(ArithVarRef name:opt_pid)) terminator:<Op_Semi ";">)]
          action: [
            (SimpleCommand
              words: [{(echo)}]
              redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(set_ftrace_pid)} spids:[813])]
            )
            (ForEach
              iter_name: tid
              iter_words: [{(/proc/) ($ VSub_Name "$pid") (/task/) (Lit_Other "*")}]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (Pipeline
                                  children: [
                                    (SimpleCommand
                                      words: [
                                        {(echo)}
                                        {
                                          (BracedVarSub
                                            token: <VSub_Name tid>
                                            suffix_op: 
                                              (StringUnary
                                                op_id: VOp1_DPound
                                                arg_word: {("*") (Lit_Slash /)}
                                              )
                                            spids: [843 848]
                                          )
                                        }
                                      ]
                                      redirects: [
                                        (Redir
                                          op_id: Redir_DGreat
                                          fd: -1
                                          arg_word: {(set_ftrace_pid)}
                                          spids: [850]
                                        )
                                      ]
                                    )
                                  ]
                                  negated: True
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [
                            (C {(edie)} 
                              {
                                (DQ ("ERROR: setting -p ") ($ VSub_Name "$pid") 
                                  (" (PID exist?). Exiting.")
                                )
                              }
                            )
                          ]
                          spids: [-1 855]
                        )
                      ]
                      spids: [-1 867]
                    )
                  ]
                  spids: [834 870]
                )
              spids: [827 832]
            )
          ]
          spids: [-1 808]
        )
      ]
      spids: [-1 872]
    )
    (If
      arms: [
        (if_arm
          cond: [(Sentence child:(DParen child:(ArithVarRef name:opt_tid)) terminator:<Op_Semi ";">)]
          action: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (SimpleCommand
                              words: [{(echo)} {($ VSub_Name "$tid")}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: -1
                                  arg_word: {(set_ftrace_pid)}
                                  spids: [895]
                                )
                              ]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(edie)} 
                      {(DQ ("ERROR: setting -L ") ($ VSub_Name "$tid") (" (TID exist?). Exiting."))}
                    )
                  ]
                  spids: [-1 900]
                )
              ]
              spids: [-1 912]
            )
          ]
          spids: [-1 884]
        )
      ]
      spids: [-1 914]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (Pipeline
                  children: [
                    (SimpleCommand
                      words: [{(echo)} {(DQ ($ VSub_Name "$funcs"))}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(set_ftrace_filter)}
                          spids: [926]
                        )
                      ]
                    )
                  ]
                  negated: True
                )
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (C {(edie)} 
              {
                (DQ ("ERROR: enabling ") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) 
                  ($ VSub_Name "$funcs") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) (". Exiting.")
                )
              }
            )
          ]
          spids: [-1 931]
        )
      ]
      spids: [-1 944]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (Pipeline
                  children: [
                    (SimpleCommand
                      words: [{(echo)} {(KW_Function function)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(current_tracer)}
                          spids: [954]
                        )
                      ]
                    )
                  ]
                  negated: True
                )
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (C {(edie)} 
              {
                (DQ ("ERROR: setting current_tracer to ") 
                  (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) (function) (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) (". Exiting.")
                )
              }
            )
          ]
          spids: [-1 959]
        )
      ]
      spids: [-1 972]
    )
    (C {(warn)} {(DQ ("echo > trace"))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (DParen child:(ArithVarRef name:opt_duration))
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (C {(sleep)} {($ VSub_Name "$duration")})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: (DParen child:(ArithVarRef name:opt_headers))
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(cat)} {(trace)})]
                  spids: [-1 1012]
                )
              ]
              else_action: [(C {(grep)} {(-v)} {(SQ <"^#">)} {(trace)})]
              spids: [1020 1034]
            )
          ]
          spids: [-1 994]
        )
      ]
      else_action: [
        (AndOr
          children: [(DParen child:(ArithVarRef name:opt_headers)) (C {(cat)} {(trace)})]
          op_id: Op_DAmp
        )
        (C {(cat)} {(trace_pipe)})
      ]
      spids: [1036 1061]
    )
    (C {(end)})
  ]
)