# -*- shell-script -*- # "set linetrace" debugger command # # Copyright (C) 2010, 2016 Rocky Bernstein rocky@gnu.org # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place, Suite 330, Boston, # MA 02111 USA. _Dbg_help_add_sub set linetrace \ 'set linetrace [on|off] Set shell-like \"set -x\" line tracing' 1 typeset -i _Dbg_linetrace_expand=0 # expand variables in linetrace output typeset -i _Dbg_linetrace_delay=0 # sleep after linetrace _Dbg_help_add_sub set linetrace \ '**set linetrace** [**on**|**off**] Set xtrace-style line tracing See also: --------- **show linetrace** ' proc _Dbg_do_set_linetrace { typeset onoff=$(1:-'off') matchstr $onoff { on | 1 { _Dbg_write_journal_eval "_Dbg_set_linetrace=1" } off | 0 { _Dbg_write_journal_eval "_Dbg_set_linetrace=0" } d | de | del | dela | delay { eval $_seteglob if [[ $2 != $int_pat ]] { _Dbg_msg "Bad int parameter: $2" eval $_resteglob return 1 } eval $_resteglob _Dbg_write_journal_eval "_Dbg_linetrace_delay=$2" } e | ex | exp | expa | expan | expand { typeset onoff=$(2:-'on') matchstr $onoff { on | 1 { _Dbg_write_journal_eval "_Dbg_linetrace_expand=1" } off | 0 { _Dbg_write_journal_eval "_Dbg_linetrace_expand=0" } * { _Dbg_errmsg "\"expand\", \"on\" or \"off\" expected." } } } * { _Dbg_errmsg "\"expand\", \"on\" or \"off\" expected." return 1 } } return 0 } (CommandList children: [ (C {(_Dbg_help_add_sub)} {(set)} {(linetrace)} {(SQ <"set linetrace [on|off]\n"> <"\n"> <"Set shell-like \\\"set -x\\\" line tracing">)} {(1)} ) (C {(typeset)} {(-i)} {(Lit_VarLike "_Dbg_linetrace_expand=") (0)}) (C {(typeset)} {(-i)} {(Lit_VarLike "_Dbg_linetrace_delay=") (0)}) (C {(_Dbg_help_add_sub)} {(set)} {(linetrace)} { (SQ <"**set linetrace** [**on**|**off**]\n"> <"\n"> <"Set xtrace-style line tracing\n"> <"\n"> <"See also:\n"> <"---------\n"> <"\n"> <"**show linetrace**\n"> ) } ) (FuncDef name: _Dbg_do_set_linetrace body: (BraceGroup children: [ (C {(typeset)} {(Lit_VarLike "onoff=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [124 130] ) } ) (Case to_match: {($ VSub_Name "$onoff")} arms: [ (case_arm pat_list: [{(on)} {(1)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_set_linetrace=1"))})] spids: [140 146 156 -1] ) (case_arm pat_list: [{(off)} {(0)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_set_linetrace=0"))})] spids: [159 165 175 -1] ) (case_arm pat_list: [{(d)} {(de)} {(del)} {(dela)} {(delay)}] action: [ (C {(eval)} {(DQ ($ VSub_Name "$_seteglob"))}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Number "$2")} right: {($ VSub_Name "$int_pat")} ) ) terminator: ) ] action: [ (C {(_Dbg_msg)} {(DQ ("Bad int parameter: ") ($ VSub_Number "$2"))}) (C {(eval)} {(DQ ($ VSub_Name "$_resteglob"))}) (ControlFlow token: arg_word: {(1)} ) ] spids: [-1 220] ) ] spids: [-1 243] ) (C {(eval)} {(DQ ($ VSub_Name "$_resteglob"))}) (C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_linetrace_delay=") ($ VSub_Number "$2"))}) ] spids: [178 196 261 -1] ) (case_arm pat_list: [{(e)} {(ex)} {(exp)} {(expa)} {(expan)} {(expand)}] action: [ (C {(typeset)} {(Lit_VarLike "onoff=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [292 298] ) } ) (Case to_match: {($ VSub_Name "$onoff")} arms: [ (case_arm pat_list: [{(on)} {(1)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_linetrace_expand=1"))})] spids: [308 314 324 -1] ) (case_arm pat_list: [{(off)} {(0)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_linetrace_expand=0"))})] spids: [327 333 343 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(_Dbg_errmsg)} { (DQ (EscapedLiteralPart token:) (expand) (EscapedLiteralPart token: ) (", ") (EscapedLiteralPart token:) (on) (EscapedLiteralPart token: ) (" or ") (EscapedLiteralPart token:) (off) (EscapedLiteralPart token: ) (" expected.") ) } ) ] spids: [346 348 369 -1] ) ] spids: [301 305 372] ) ] spids: [264 286 375 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(_Dbg_errmsg)} { (DQ (EscapedLiteralPart token:) (expand) (EscapedLiteralPart token: ) (", ") (EscapedLiteralPart token:) (on) (EscapedLiteralPart token: ) (" or ") (EscapedLiteralPart token:) (off) (EscapedLiteralPart token: ) (" expected.") ) } ) (ControlFlow token: arg_word:{(1)}) ] spids: [379 381 -1 407] ) ] spids: [133 137 407] ) (ControlFlow token: arg_word:{(0)}) ] spids: [118] ) spids: [114 117] ) ] )