(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:tracing spids:[175]) op: Equal rhs: {(/sys/kernel/debug/tracing)} spids: [175] ) ] spids: [175] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:flock spids:[178]) op: Equal rhs: {(/var/tmp/.ftrace-lock)} spids: [178] ) ] spids: [178] ) (command.CommandList children: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_duration spids:[181]) op: Equal rhs: {(0)} spids: [181] ) ] spids: [181] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:duration spids:[185]) op: Equal rhs: (word.EmptyWord) spids: [185] ) ] spids: [185] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_pid spids:[188]) op: Equal rhs: {(0)} spids: [188] ) ] spids: [188] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pid spids:[192]) op: Equal rhs: (word.EmptyWord) spids: [192] ) ] spids: [192] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_tid spids:[195]) op: Equal rhs: {(0)} spids: [195] ) ] spids: [195] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:tid spids:[199]) op: Equal rhs: (word.EmptyWord) spids: [199] ) ] spids: [199] ) terminator: <Op_Semi ';'> ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pidtext spids:[202]) op: Equal rhs: (word.EmptyWord) spids: [202] ) ] spids: [202] ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_headers spids:[204]) op: Equal rhs: {(0)} spids: [204] ) ] spids: [204] ) (C {(trap)} {(SQ <':'>)} {(INT)} {(QUIT)} {(TERM)} {(PIPE)} {(HUP)}) (command.FuncDef name: usage body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.HereDoc op: <Redir_DLessDash '<<-'> fd: 16777215 here_begin: {(END)} here_end_span_id: 269 stdin_parts: [ ('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') ] ) (redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)}) ] ) (command.ControlFlow token:<ControlFlow_Exit exit>) ] spids: [231] ) spids: [227 230] ) (command.FuncDef name: warn body: (command.BraceGroup children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [(C {(eval)} {(DQ ($ VSub_At '$@'))})] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (command.SimpleCommand words: [ {(echo)} { (DQ ('WARNING: command failed ') (word_part.EscapedLiteralPart token: <Lit_EscapedChar '\\"'> ) ($ VSub_At '$@') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})] ) ] spids: [16777215 294] ) ] spids: [16777215 310] ) ] spids: [280] ) spids: [276 279] ) (command.FuncDef name: end body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(echo)}] redirects: [(redir.Redir op:<Redir_Great '2>'> fd:2 arg_word:{(/dev/null)})] ) (command.SimpleCommand words: [{(echo)} {(DQ ('Ending tracing...'))}] redirects: [(redir.Redir op:<Redir_Great '2>'> fd:2 arg_word:{(/dev/null)})] ) (C {(cd)} {($ VSub_DollarName '$tracing')}) (C {(warn)} {(DQ ('echo nop > current_tracer'))}) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithBinary op_id: Arith_DPipe left: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_pid>) right: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_tid>) ) spids: [354 363] ) (C {(warn)} {(DQ ('echo > set_ftrace_pid'))}) ] ) (C {(warn)} {(DQ ('echo > set_ftrace_filter'))}) (C {(warn)} {(DQ ('echo > trace'))}) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike wroteflock>) spids: [388 393] ) (C {(warn)} {(DQ ('rm ') ($ VSub_DollarName '$flock'))}) ] ) ] spids: [319] ) spids: [315 318] ) (command.FuncDef name: die body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(echo)} {(DQ ($ VSub_At '$@'))}] redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})] ) (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) ] spids: [411] ) spids: [407 410] ) (command.FuncDef name: edie body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(echo)} {(DQ ($ VSub_At '$@'))}] redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})] ) (command.SimpleCommand words: [{(exec)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)}) (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)}) ] ) (C {(end)}) (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) ] spids: [435] ) spids: [431 434] ) (command.WhileUntil keyword: <KW_While while> cond: [(C {(getopts)} {(d) (Lit_Other ':') (hHp) (Lit_Other ':') (L) (Lit_Other ':')} {(opt)})] body: (command.DoGroup children: [ (command.Case to_match: {($ VSub_DollarName '$opt')} arms: [ (case_arm pat_list: [{(d)}] action: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_duration spids:[500]) op: Equal rhs: {(1)} spids: [500] ) ] spids: [500] ) terminator: <Op_Semi ';'> ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:duration spids:[504]) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} spids: [504] ) ] spids: [504] ) ] spids: [497 498 507 16777215] ) (case_arm pat_list: [{(p)}] action: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_pid spids:[513]) op: Equal rhs: {(1)} spids: [513] ) ] spids: [513] ) terminator: <Op_Semi ';'> ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pid spids:[517]) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} spids: [517] ) ] spids: [517] ) ] spids: [510 511 520 16777215] ) (case_arm pat_list: [{(L)}] action: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_tid spids:[526]) op: Equal rhs: {(1)} spids: [526] ) ] spids: [526] ) terminator: <Op_Semi ';'> ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:tid spids:[530]) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} spids: [530] ) ] spids: [530] ) ] spids: [523 524 533 16777215] ) (case_arm pat_list: [{(H)}] action: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:opt_headers spids:[539]) op: Equal rhs: {(1)} spids: [539] ) ] spids: [539] ) terminator: <Op_Semi ';'> ) ] spids: [536 537 543 16777215] ) (case_arm pat_list: [{(h)} {(Lit_Other '?')}] action: [(C {(usage)})] spids: [546 549 553 16777215] ) ] spids: [490 494 556] ) ] spids: [487 558] ) ) (C {(shift)} { (word_part.ArithSubPart anode: (arith_expr.ArithBinary op_id: Arith_Minus left: (arith_expr.ArithWord w:{($ VSub_DollarName '$OPTIND')}) right: (arith_expr.ArithWord w:{(Lit_Digits 1)}) ) spids: [562 571] ) } ) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithBinary op_id: Arith_DEqual left: (arith_expr.ArithWord w:{($ VSub_Pound '$#')}) right: (arith_expr.ArithWord w:{(Lit_Digits 0)}) ) spids: [577 586] ) (C {(usage)}) ] ) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithBinary op_id: Arith_DAmp left: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_pid>) right: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_tid>) ) spids: [592 601] ) (C {(edie)} {(DQ ('ERROR: You can use -p or -L but not both.'))}) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:funcs spids:[611]) op: Equal rhs: {(DQ ($ VSub_Number '$1'))} spids: [611] ) ] spids: [611] ) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_pid>) spids: [616 621] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pidtext spids:[625]) op: Equal rhs: {(DQ (' for PID ') ($ VSub_DollarName '$pid'))} spids: [625] ) ] spids: [625] ) ] ) (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_tid>) spids: [631 636] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:pidtext spids:[640]) op: Equal rhs: {(DQ (' for TID ') ($ VSub_DollarName '$pid'))} spids: [640] ) ] spids: [640] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_duration>) spids: [648 653] ) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} { (DQ ('Tracing ') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_DollarName '$funcs') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_DollarName '$pidtext') (' for ') ($ VSub_DollarName '$duration') (' seconds...') ) } ) ] spids: [16777215 656] ) ] else_action: [ (C {(echo)} { (DQ ('Tracing ') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_DollarName '$funcs') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_DollarName '$pidtext') ('... Ctrl-C to end.') ) } ) ] spids: [672 686] ) (command.AndOr ops: [Op_DPipe] children: [ (C {(cd)} {($ VSub_DollarName '$tracing')}) (C {(die)} { (DQ ('ERROR: accessing tracing. Root user? Kernel has FTRACE?\n') (' debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)') ) } ) ] ) (command.AndOr ops: [Op_DAmp] children: [ (command.DBracket expr: (bool_expr.BoolUnary op_id:BoolUnary_e child:{($ VSub_DollarName '$flock')}) ) (C {(die)} { (DQ ('ERROR: ftrace may be in use by PID ') (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(cat)} {($ VSub_DollarName '$flock')})] ) left_token: <Left_CommandSub '$('> spids: [723 727] ) (' ') ($ VSub_DollarName '$flock') ) } ) ] ) (command.AndOr ops: [Op_DPipe] children: [ (command.SimpleCommand words: [{(echo)} {($ VSub_Dollar '$$')}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {($ VSub_DollarName '$flock')} ) ] ) (C {(die)} {(DQ ('ERROR: unable to write ') ($ VSub_DollarName '$flock') (.))}) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:wroteflock spids:[750]) op: Equal rhs: {(1)} spids: [750] ) ] spids: [750] ) (C {(sysctl)} {(-q)} {(kernel.ftrace_enabled) (Lit_Other '=') (1)}) (command.SimpleCommand words: [{(read)} {(mode)}] redirects: [(redir.Redir op:<Redir_Less '<'> fd:16777215 arg_word:{(current_tracer)})] ) (command.AndOr ops: [Op_DAmp] children: [ (command.DBracket expr: (bool_expr.BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_DollarName '$mode'))} right: {(DQ (nop))} ) ) (C {(edie)} {(DQ ('ERROR: ftrace active (current_tracer=') ($ VSub_DollarName '$mode') (')'))}) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_pid>) spids: [802 807] ) terminator: <Op_Semi ';'> ) ] action: [ (command.SimpleCommand words: [{(echo)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(set_ftrace_pid)})] ) (command.ForEach iter_name: tid iter_words: [{(/proc/) ($ VSub_DollarName '$pid') (/task/) (Lit_Other '*')}] do_arg_iter: F body: (command.DoGroup children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.SimpleCommand words: [ {(echo)} { (word_part.BracedVarSub token: <VSub_Name tid> suffix_op: (suffix_op.StringUnary op_id: VOp1_DPound arg_word: {('*') (Lit_Slash /)} ) spids: [845 850] ) } ] redirects: [ (redir.Redir op: <Redir_DGreat '>>'> fd: 16777215 arg_word: {(set_ftrace_pid)} ) ] ) ] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting -p ') ($ VSub_DollarName '$pid') (' (PID exist?). Exiting.') ) } ) ] spids: [16777215 857] ) ] spids: [16777215 869] ) ] spids: [836 872] ) spids: [829 834] ) ] spids: [16777215 810] ) ] spids: [16777215 874] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_tid>) spids: [878 883] ) terminator: <Op_Semi ';'> ) ] action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.SimpleCommand words: [{(echo)} {($ VSub_DollarName '$tid')}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(set_ftrace_pid)} ) ] ) ] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting -L ') ($ VSub_DollarName '$tid') (' (TID exist?). Exiting.') ) } ) ] spids: [16777215 902] ) ] spids: [16777215 914] ) ] spids: [16777215 886] ) ] spids: [16777215 916] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.SimpleCommand words: [{(echo)} {(DQ ($ VSub_DollarName '$funcs'))}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(set_ftrace_filter)} ) ] ) ] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (C {(edie)} { (DQ ('ERROR: enabling ') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_DollarName '$funcs') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ('. Exiting.') ) } ) ] spids: [16777215 933] ) ] spids: [16777215 946] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.SimpleCommand words: [{(echo)} {(KW_Function function)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(current_tracer)} ) ] ) ] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting current_tracer to ') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (function) (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ('. Exiting.') ) } ) ] spids: [16777215 961] ) ] spids: [16777215 974] ) (C {(warn)} {(DQ ('echo > trace'))}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_duration>) spids: [988 993] ) terminator: <Op_Semi ';'> ) ] action: [ (C {(sleep)} {($ VSub_DollarName '$duration')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_headers>) spids: [1006 1011] ) terminator: <Op_Semi ';'> ) ] action: [(C {(cat)} {(trace)})] spids: [16777215 1014] ) ] else_action: [(C {(grep)} {(-v)} {(SQ <'^#'>)} {(trace)})] spids: [1022 1036] ) ] spids: [16777215 996] ) ] else_action: [ (command.AndOr ops: [Op_DAmp] children: [ (command.DParen child: (arith_expr.ArithVarRef token:<Lit_ArithVarLike opt_headers>) spids: [1045 1050] ) (C {(cat)} {(trace)}) ] ) (C {(cat)} {(trace_pipe)}) ] spids: [1038 1063] ) (C {(end)}) ] )