# -*- shell-script -*- # step.sh - Debugger step ("step into") commmand. # # Copyright (C) 2006, 2008, 2009, 2010, 2015 Rocky Bernstein rocky@gnu.org # # bashdb 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. # # bashdb 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 bashdb; see the file COPYING. If not, write to the Free Software # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. # Sets whether or not to display command to be executed in debugger prompt. # If yes, always show. If auto, show only if the same line is to be run # but the command is different. # The default behavior of step_force. typeset -i _Dbg_set_different=0 _Dbg_help_add step \ "step [COUNT] Single step an statement. This is sometimes called 'step into'. If COUNT is given, stepping occurs that many times before stopping. Otherwise COUNT is one. COUNT an be an arithmetic expression. In contrast to \"next\", functions and source'd files are stepped into. See also \"skip\"." _Dbg_help_add 'step+' \ "step+ -- Single step a statement ensuring a different line after the step. In contrast to \"step\", we ensure that the file and line position is different from the last one just stopped at. See also \"step-\" and \"set force\"." _Dbg_help_add 'step-' \ "step- -- Single step a statement without the \`step force' setting. Set step force may have been set on. step- ensures we turn that off for this command. See also \"step\" and \"set force\"." # Step command # $1 is command step+, step-, or step # $2 is an optional additional count. proc _Dbg_do_step { _Dbg_not_running && return 3 global _Dbg_last_cmd := $_Dbg_cmd global _Dbg_last_next_step_cmd := $_Dbg_cmd global _Dbg_last_next_step_args := @Argv typeset count=$(1:-1) typeset suffix global suffix := $(_Dbg_last_next_step_cmd:${#_Dbg_last_step_next_cmd}-1:1) matchstr "suffix" { '+' { global _Dbg_step_force := '1' } '-' { global _Dbg_step_force := '0' } * { global _Dbg_step_force := $_Dbg_set_different } } if [[ $count == [0-9]* ]] { global _Dbg_step_ignore := $(count:-1) } else { _Dbg_errmsg "Argument ($count) should be a number or nothing." global _Dbg_step_ignore := '-1' return 2 } global _Dbg_old_set_opts := ""$_Dbg_old_set_opts -o functrace"" _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore" _Dbg_write_journal "_Dbg_step_force=$_Dbg_step_force" _Dbg_write_journal "_Dbg_old_set_opts='$_Dbg_old_set_opts'" global _Dbg_inside_skip := '0' global _Dbg_continue_rc := '0' return 0 } _Dbg_alias_add 's' 'step' _Dbg_alias_add 's+' 'step+' _Dbg_alias_add 's-' 'step-' (CommandList children: [ (C {(typeset)} {(-i)} {(Lit_VarLike "_Dbg_set_different=") (0)}) (C {(_Dbg_help_add)} {(step)} { (DQ ("step [COUNT]\n") ("\n") ("Single step an statement. This is sometimes called 'step into'.\n") ("\n") ("\n") ("If COUNT is given, stepping occurs that many times before\n") ("stopping. Otherwise COUNT is one. COUNT an be an arithmetic\n") ("expression.\n") ("\n") ("In contrast to ") (EscapedLiteralPart token:) (next) (EscapedLiteralPart token:) (", functions and source'd files are stepped\n") ("into. See also ") (EscapedLiteralPart token:) (skip) (EscapedLiteralPart token:) (.) ) } ) (C {(_Dbg_help_add)} {(SQ <"step+">)} { (DQ ("step+ -- Single step a statement ensuring a different line after the step.\n") ("\n") ("In contrast to ") (EscapedLiteralPart token:) (step) (EscapedLiteralPart token:) (", we ensure that the file and line position is\n") ("different from the last one just stopped at.\n") ("\n") ("See also ") (EscapedLiteralPart token:) (step-) (EscapedLiteralPart token:) (" and ") (EscapedLiteralPart token:) ("set force") (EscapedLiteralPart token:) (.) ) } ) (C {(_Dbg_help_add)} {(SQ )} { (DQ ("step- -- Single step a statement without the ") (EscapedLiteralPart token:) ("step force' setting.\n") ("\n") ("Set step force may have been set on. step- ensures we turn that off for\n") ("this command.\n") ("\n") ("See also ") (EscapedLiteralPart token:) (step) (EscapedLiteralPart token:) (" and ") (EscapedLiteralPart token:) ("set force") (EscapedLiteralPart token:) (.) ) } ) (FuncDef name: _Dbg_do_step body: (BraceGroup children: [ (AndOr children: [ (C {(_Dbg_not_running)}) (ControlFlow token: arg_word:{(3)}) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_last_cmd) op: Equal rhs: {(DQ ($ VSub_Name "$_Dbg_cmd"))} spids: [187] ) ] spids: [187] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_last_next_step_cmd) op: Equal rhs: {(DQ ($ VSub_Name "$_Dbg_cmd"))} spids: [193] ) ] spids: [193] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_last_next_step_args) op: Equal rhs: {(DQ ($ VSub_At "$@"))} spids: [199] ) ] spids: [199] ) (C {(typeset)} {(Lit_VarLike "count=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(1)}) spids: [209 213] ) } ) (C {(typeset)} {(suffix)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:suffix) op: Equal rhs: { (BracedVarSub token: suffix_op: (Slice begin: (ArithBinary op_id: Arith_Minus left: (ArithWord w: { (BracedVarSub token: prefix_op: VSub_Pound spids: [225 228] ) } ) right: (ArithWord w:{(Lit_Digits 1)}) ) length: (ArithWord w:{(Lit_Digits 1)}) ) spids: [222 233] ) } spids: [221] ) ] spids: [221] ) (Case to_match: {(DQ (suffix))} arms: [ (case_arm pat_list: [{(SQ <"+">)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_step_force) op: Equal rhs: {(1)} spids: [252] ) ] spids: [252] ) ] spids: [247 250 255 -1] ) (case_arm pat_list: [{(SQ <->)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_step_force) op: Equal rhs: {(0)} spids: [264] ) ] spids: [264] ) ] spids: [259 262 267 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_step_force) op: Equal rhs: {($ VSub_Name "$_Dbg_set_different")} spids: [274] ) ] spids: [274] ) ] spids: [270 272 277 -1] ) ] spids: [237 243 280] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$count")} right: {(Lit_Other "[") (0-9) (Lit_Other "]") (Lit_Other "*")} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_step_ignore) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(1)}) spids: [305 309] ) } spids: [304] ) ] spids: [304] ) ] spids: [-1 301] ) ] else_action: [ (C {(_Dbg_errmsg)} {(DQ ("Argument (") ($ VSub_Name "$count") (") should be a number or nothing."))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_step_ignore) op: Equal rhs: {(-1)} spids: [324] ) ] spids: [324] ) (ControlFlow token: arg_word:{(2)}) ] spids: [312 333] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_old_set_opts) op: Equal rhs: {(DQ ($ VSub_Name "$_Dbg_old_set_opts") (" -o functrace"))} spids: [336] ) ] spids: [336] ) (C {(_Dbg_write_journal)} {(DQ ("_Dbg_step_ignore=") ($ VSub_Name "$_Dbg_step_ignore"))}) (C {(_Dbg_write_journal)} {(DQ ("_Dbg_step_force=") ($ VSub_Name "$_Dbg_step_force"))}) (C {(_Dbg_write_journal)} {(DQ ("_Dbg_old_set_opts='") ($ VSub_Name "$_Dbg_old_set_opts") ("'"))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_inside_skip) op: Equal rhs: {(0)} spids: [369] ) ] spids: [369] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_continue_rc) op: Equal rhs: {(0)} spids: [373] ) ] spids: [373] ) (ControlFlow token: arg_word:{(0)}) ] spids: [173] ) spids: [169 172] ) (C {(_Dbg_alias_add)} {(SQ )} {(SQ )}) (C {(_Dbg_alias_add)} {(SQ <"s+">)} {(SQ <"step+">)}) (C {(_Dbg_alias_add)} {(SQ )} {(SQ )}) ] )