(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tracing) op: assign_op.Equal rhs: {(/sys/kernel/debug/tracing)} spids: [175] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flock) op: assign_op.Equal rhs: {(/var/tmp/.ftrace-lock)} spids: [178] ) ] ) (command.CommandList children: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_duration) op: assign_op.Equal rhs: {(0)} spids: [181] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:183) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:duration) op: assign_op.Equal rhs: (word.Empty) spids: [185] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:186) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_pid) op: assign_op.Equal rhs: {(0)} spids: [188] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:190) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pid) op: assign_op.Equal rhs: (word.Empty) spids: [192] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:193) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_tid) op: assign_op.Equal rhs: {(0)} spids: [195] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:197) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tid) op: assign_op.Equal rhs: (word.Empty) spids: [199] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:200) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pidtext) op: assign_op.Equal rhs: (word.Empty) spids: [202] ) ] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_headers) op: assign_op.Equal rhs: {(0)} spids: [204] ) ] ) (C {(trap)} {(SQ (Token id:Id.Lit_Chars val:':' span_id:210))} {(INT)} {(QUIT)} {(TERM)} {(PIPE)} {(HUP)} ) (command.ShFunction name: usage body: (command.BraceGroup children: [ (command.Simple words: [{(cat)}] redirects: [ (redir.HereDoc op: (Token id:Id.Redir_DLessDash val:'<<-' span_id:236) fd: -1 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 ") (Id.Right_DoubleQuote '"') (sleep) (Id.Right_DoubleQuote '"') ('\n') (" functrace -p 198 'vfs*' # trace ") (Id.Right_DoubleQuote '"') ('vfs*') (Id.Right_DoubleQuote '"') (' funcs for PID 198\n') (" functrace 'tcp*' > out # trace all ") (Id.Right_DoubleQuote '"') ('tcp*') (Id.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: (Token id:Id.Redir_GreatAnd val:'>&' span_id:239) fd: -1 arg_word: {(2)} ) ] ) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:271) ) ] ) ) (command.ShFunction name: warn body: (command.BraceGroup children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [(C {(eval)} {(DQ ($ Id.VSub_At '$@'))})] negated: T ) terminator: (Token id:Id.Op_Semi val:';' span_id:292) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ('WARNING: command failed ') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:304) ) ($ Id.VSub_At '$@') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:306) ) ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:299) fd: -1 arg_word: {(2)} ) ] ) ] spids: [283 294] ) ] ) ] ) ) (command.ShFunction name: end body: (command.BraceGroup children: [ (command.Simple words: [{(echo)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:328) fd: 2 arg_word: {(/dev/null)} ) ] ) (command.Simple words: [{(echo)} {(DQ ('Ending tracing...'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:338) fd: 2 arg_word: {(/dev/null)} ) ] ) (C {(cd)} {($ Id.VSub_DollarName '$tracing')}) (C {(warn)} {(DQ ('echo nop > current_tracer'))}) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.Binary op_id: Id.Arith_DPipe left: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_pid span_id:356) ) right: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_tid span_id:360) ) ) ) (C {(warn)} {(DQ ('echo > set_ftrace_pid'))}) ] ) (C {(warn)} {(DQ ('echo > set_ftrace_filter'))}) (C {(warn)} {(DQ ('echo > trace'))}) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:wroteflock span_id:390) ) ) (C {(warn)} {(DQ ('rm ') ($ Id.VSub_DollarName '$flock'))}) ] ) ] ) ) (command.ShFunction name: die body: (command.BraceGroup children: [ (command.Simple words: [{(echo)} {(DQ ($ Id.VSub_At '$@'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:416) fd: -1 arg_word: {(2)} ) ] ) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:424) arg_word: {(1)} ) ] ) ) (command.ShFunction name: edie body: (command.BraceGroup children: [ (command.Simple words: [{(echo)} {(DQ ($ Id.VSub_At '$@'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:444) fd: -1 arg_word: {(2)} ) ] ) (command.Simple words: [{(exec)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:454) fd: -1 arg_word: {(/dev/null)} ) (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'2>&' span_id:457) fd: 2 arg_word: {(1)} ) ] ) (C {(end)}) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:464) arg_word: {(1)} ) ] ) ) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:474) cond: [ (C {(getopts)} {(d) (Id.Lit_Other ':') (hHp) (Id.Lit_Other ':') (L) (Id.Lit_Other ':')} {(opt)}) ] body: (command.DoGroup children: [ (command.Case to_match: {($ Id.VSub_DollarName '$opt')} arms: [ (case_arm pat_list: [{(d)}] action: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_duration) op: assign_op.Equal rhs: {(1)} spids: [500] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:502) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:duration) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [504] ) ] ) ] spids: [497 498 507 -1] ) (case_arm pat_list: [{(p)}] action: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_pid) op: assign_op.Equal rhs: {(1)} spids: [513] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:515) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pid) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [517] ) ] ) ] spids: [510 511 520 -1] ) (case_arm pat_list: [{(L)}] action: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_tid) op: assign_op.Equal rhs: {(1)} spids: [526] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:528) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tid) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [530] ) ] ) ] spids: [523 524 533 -1] ) (case_arm pat_list: [{(H)}] action: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:opt_headers) op: assign_op.Equal rhs: {(1)} spids: [539] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:541) ) ] spids: [536 537 543 -1] ) (case_arm pat_list: [{(h)} {(Id.Lit_QMark '?')}] action: [(C {(usage)})] spids: [546 549 553 -1] ) ] ) ] ) ) (C {(shift)} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Minus left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$OPTIND')}) right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)}) ) ) } ) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.Binary op_id: Id.Arith_DEqual left: (arith_expr.ArithWord w:{($ Id.VSub_Pound '$#')}) right: (arith_expr.ArithWord w:{(Id.Lit_Digits 0)}) ) ) (C {(usage)}) ] ) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.Binary op_id: Id.Arith_DAmp left: (arith_expr.VarRef token:(Token id:Id.Lit_ArithVarLike val:opt_pid span_id:594)) right: (arith_expr.VarRef token:(Token id:Id.Lit_ArithVarLike val:opt_tid span_id:598)) ) ) (C {(edie)} {(DQ ('ERROR: You can use -p or -L but not both.'))}) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:funcs) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$1'))} spids: [611] ) ] ) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.VarRef token:(Token id:Id.Lit_ArithVarLike val:opt_pid span_id:618)) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pidtext) op: assign_op.Equal rhs: {(DQ (' for PID ') ($ Id.VSub_DollarName '$pid'))} spids: [625] ) ] ) ] ) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.VarRef token:(Token id:Id.Lit_ArithVarLike val:opt_tid span_id:633)) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pidtext) op: assign_op.Equal rhs: {(DQ (' for TID ') ($ Id.VSub_DollarName '$pid'))} spids: [640] ) ] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_duration span_id:650) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:654) ) ] action: [ (C {(echo)} { (DQ ('Tracing ') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:663) ) ($ Id.VSub_DollarName '$funcs') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:665) ) ($ Id.VSub_DollarName '$pidtext') (' for ') ($ Id.VSub_DollarName '$duration') (' seconds...') ) } ) ] spids: [646 656] ) ] else_action: [ (C {(echo)} { (DQ ('Tracing ') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:679) ) ($ Id.VSub_DollarName '$funcs') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:681) ) ($ Id.VSub_DollarName '$pidtext') ('... Ctrl-C to end.') ) } ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {(cd)} {($ Id.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: [Id.Op_DAmp] children: [ (command.DBracket expr: (bool_expr.Unary op_id:Id.BoolUnary_e child:{($ Id.VSub_DollarName '$flock')}) ) (C {(die)} { (DQ ('ERROR: ftrace may be in use by PID ') (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:723) command_list: (command.CommandList children: [(C {(cat)} {($ Id.VSub_DollarName '$flock')})] ) ) (' ') ($ Id.VSub_DollarName '$flock') ) } ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (command.Simple words: [{(echo)} {($ Id.VSub_Dollar '$$')}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:736) fd: -1 arg_word: {($ Id.VSub_DollarName '$flock')} ) ] ) (C {(die)} {(DQ ('ERROR: unable to write ') ($ Id.VSub_DollarName '$flock') (.))}) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:wroteflock) op: assign_op.Equal rhs: {(1)} spids: [750] ) ] ) (C {(sysctl)} {(-q)} {(kernel.ftrace_enabled) (Id.Lit_Equals '=') (1)}) (command.Simple words: [{(read)} {(mode)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Less val:'<' span_id:772) fd: -1 arg_word: {(current_tracer)} ) ] ) (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobNEqual left: {(DQ ($ Id.VSub_DollarName '$mode'))} right: {(DQ (nop))} ) ) (C {(edie)} {(DQ ('ERROR: ftrace active (current_tracer=') ($ Id.VSub_DollarName '$mode') (')'))} ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_pid span_id:804) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:808) ) ] action: [ (command.Simple words: [{(echo)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:815) fd: -1 arg_word: {(set_ftrace_pid)} ) ] ) (command.ForEach iter_name: tid iter_words: [{(/proc/) ($ Id.VSub_DollarName '$pid') (/task/) (Id.Lit_Star '*')}] do_arg_iter: F body: (command.DoGroup children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [ {(echo)} { (braced_var_sub token: (Token id:Id.VSub_Name val:tid span_id:846) suffix_op: (suffix_op.Unary op_id: Id.VOp1_DPound arg_word: {('*') (Id.Lit_Slash /)} ) ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_DGreat val:'>>' span_id:852) fd: -1 arg_word: {(set_ftrace_pid)} ) ] ) ] negated: T ) terminator: (Token id:Id.Op_Semi val:';' span_id:855) ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting -p ') ($ Id.VSub_DollarName '$pid') (' (PID exist?). Exiting.') ) } ) ] spids: [839 857] ) ] ) ] ) ) ] spids: [800 810] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_tid span_id:880) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:884) ) ] action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [{(echo)} {($ Id.VSub_DollarName '$tid')}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:897) fd: -1 arg_word: {(set_ftrace_pid)} ) ] ) ] negated: T ) terminator: (Token id:Id.Op_Semi val:';' span_id:900) ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting -L ') ($ Id.VSub_DollarName '$tid') (' (TID exist?). Exiting.') ) } ) ] spids: [889 902] ) ] ) ] spids: [876 886] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [{(echo)} {(DQ ($ Id.VSub_DollarName '$funcs'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:928) fd: -1 arg_word: {(set_ftrace_filter)} ) ] ) ] negated: T ) terminator: (Token id:Id.Op_Semi val:';' span_id:931) ) ] action: [ (C {(edie)} { (DQ ('ERROR: enabling ') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:940) ) ($ Id.VSub_DollarName '$funcs') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:942) ) ('. Exiting.') ) } ) ] spids: [918 933] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [{(echo)} {(Id.KW_Function function)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:956) fd: -1 arg_word: {(current_tracer)} ) ] ) ] negated: T ) terminator: (Token id:Id.Op_Semi val:';' span_id:959) ) ] action: [ (C {(edie)} { (DQ ('ERROR: setting current_tracer to ') (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:968) ) (function) (word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\"' span_id:970)) ('. Exiting.') ) } ) ] spids: [948 961] ) ] ) (C {(warn)} {(DQ ('echo > trace'))}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_duration span_id:990) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:994) ) ] action: [ (C {(sleep)} {($ Id.VSub_DollarName '$duration')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_headers span_id:1008) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:1012) ) ] action: [(C {(cat)} {(trace)})] spids: [1004 1014] ) ] else_action: [ (C {(grep)} {(-v)} {(SQ (Token id:Id.Lit_Chars val:'^#' span_id:1030))} {(trace)}) ] ) ] spids: [986 996] ) ] else_action: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (command.DParen child: (arith_expr.VarRef token: (Token id:Id.Lit_ArithVarLike val:opt_headers span_id:1047) ) ) (C {(cat)} {(trace)}) ] ) (C {(cat)} {(trace_pipe)}) ] ) (C {(end)}) ] )