(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:[298])]
                    )
                  ]
                  spids: [-1 293]
                )
              ]
              spids: [-1 309]
            )
          ]
          spids: [279]
        )
      spids: [275 278]
    )
    (FuncDef
      name: end
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)}]
              redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[327])]
            )
            (SimpleCommand
              words: [{(echo)} {(DQ ('Ending tracing...'))}]
              redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[337])]
            )
            (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: [318]
        )
      spids: [314 317]
    )
    (FuncDef
      name: die
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At '$@'))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[415])]
            )
            (C {(exit)} {(1)})
          ]
          spids: [410]
        )
      spids: [406 409]
    )
    (FuncDef
      name: edie
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At '$@'))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[443])]
            )
            (SimpleCommand
              words: [{(exec)}]
              redirects: [
                (Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[453])
                (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[456])
              ]
            )
            (C {(end)})
            (C {(exit)} {(1)})
          ]
          spids: [434]
        )
      spids: [430 433]
    )
    (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: [499]
                            )
                          ]
                          spids: [499]
                        )
                      terminator: <Op_Semi ';'>
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:duration)
                          op: Equal
                          rhs: {($ VSub_Name '$OPTARG')}
                          spids: [503]
                        )
                      ]
                      spids: [503]
                    )
                  ]
                  spids: [496 497 506 -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: [512]
                            )
                          ]
                          spids: [512]
                        )
                      terminator: <Op_Semi ';'>
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:pid)
                          op: Equal
                          rhs: {($ VSub_Name '$OPTARG')}
                          spids: [516]
                        )
                      ]
                      spids: [516]
                    )
                  ]
                  spids: [509 510 519 -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: [525]
                            )
                          ]
                          spids: [525]
                        )
                      terminator: <Op_Semi ';'>
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:tid)
                          op: Equal
                          rhs: {($ VSub_Name '$OPTARG')}
                          spids: [529]
                        )
                      ]
                      spids: [529]
                    )
                  ]
                  spids: [522 523 532 -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: [538]
                            )
                          ]
                          spids: [538]
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  spids: [535 536 542 -1]
                )
                (case_arm
                  pat_list: [{(h)} {(Lit_Other '?')}]
                  action: [(C {(usage)})]
                  spids: [545 548 552 -1]
                )
              ]
              spids: [489 493 555]
            )
          ]
          spids: [486 557]
        )
    )
    (C {(shift)} 
      {
        (ArithSubPart
          anode: 
            (ArithBinary
              op_id: Arith_Minus
              left: (ArithWord w:{($ VSub_Name '$OPTIND')})
              right: (ArithWord w:{(Lit_Digits 1)})
            )
          spids: [561 570]
        )
      }
    )
    (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: [610]
        )
      ]
      spids: [610]
    )
    (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: [624]
            )
          ]
          spids: [624]
        )
      ]
      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: [639]
            )
          ]
          spids: [639]
        )
      ]
      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 655]
        )
      ]
      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: [671 685]
    )
    (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: [722 726]
              ) (' ') ($ 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:[735])]
        )
        (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:[749])]
      spids: [749]
    )
    (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:[771])]
    )
    (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:[814])]
            )
            (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: [844 849]
                                          )
                                        }
                                      ]
                                      redirects: [
                                        (Redir
                                          op_id: Redir_DGreat
                                          fd: -1
                                          arg_word: {(set_ftrace_pid)}
                                          spids: [851]
                                        )
                                      ]
                                    )
                                  ]
                                  negated: True
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (C {(edie)} 
                              {
                                (DQ ('ERROR: setting -p ') ($ VSub_Name '$pid') 
                                  (' (PID exist?). Exiting.')
                                )
                              }
                            )
                          ]
                          spids: [-1 856]
                        )
                      ]
                      spids: [-1 868]
                    )
                  ]
                  spids: [835 871]
                )
              spids: [828 833]
            )
          ]
          spids: [-1 809]
        )
      ]
      spids: [-1 873]
    )
    (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: [896]
                                )
                              ]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(edie)} 
                      {(DQ ('ERROR: setting -L ') ($ VSub_Name '$tid') (' (TID exist?). Exiting.'))}
                    )
                  ]
                  spids: [-1 901]
                )
              ]
              spids: [-1 913]
            )
          ]
          spids: [-1 885]
        )
      ]
      spids: [-1 915]
    )
    (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: [927]
                        )
                      ]
                    )
                  ]
                  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 932]
        )
      ]
      spids: [-1 945]
    )
    (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: [955]
                        )
                      ]
                    )
                  ]
                  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 960]
        )
      ]
      spids: [-1 973]
    )
    (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 1013]
                )
              ]
              else_action: [(C {(grep)} {(-v)} {(SQ <'^#'>)} {(trace)})]
              spids: [1021 1035]
            )
          ]
          spids: [-1 995]
        )
      ]
      else_action: [
        (AndOr
          children: [(DParen child:(ArithVarRef name:opt_headers)) (C {(cat)} {(trace)})]
          op_id: Op_DAmp
        )
        (C {(cat)} {(trace_pipe)})
      ]
      spids: [1037 1062]
    )
    (C {(end)})
  ]
)