# -*- shell-script -*- # This program needs to be SOURCE'd and is not called as an executable # Copyright (C) 2006, 2007, 2008 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. # # Enter the debugger at the calling stack frame. This is useful to # hard-code a breakpoint at a given point in a program, even if the code # is not otherwise being debugged. # Leaving this the debugger terminates the program. # Any parameters after the first one are exec'd. In this way you can # force specific options to get set. proc _Dbg_debugger { set -o functrace if (( $# > 0 )) { global step_ignore := $1 shift } else { typeset step_ignore=$(_Dbg_step_ignore:-'') } while (( $# > 0 )) { eval $1 shift } if [[ -z $_Dbg_set_trace_init ]] { global _Dbg_set_trace_init := '1' global _Dbg_step_ignore := $(step_ignore:-0) _Dbg_write_journal "_Dbg_step_ignore=0" } else { global _Dbg_step_ignore := $(1:-1) } trap '_Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG } (CommandList children: [ (FuncDef name: _Dbg_debugger body: (BraceGroup children: [ (C {(set)} {(-o)} {(functrace)}) (If arms: [ (if_arm cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_Great left: (ArithWord w:{($ VSub_Pound "$#")}) right: (ArithWord w:{(Lit_Digits 0)}) ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:step_ignore) op: Equal rhs: {($ VSub_Number "$1")} spids: [106] ) ] spids: [106] ) (C {(shift)}) ] spids: [-1 103] ) ] else_action: [ (C {(typeset)} {(Lit_VarLike "step_ignore=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [119 124] ) } ) ] spids: [113 127] ) (While cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_Great left: (ArithWord w:{($ VSub_Pound "$#")}) right: (ArithWord w:{(Lit_Digits 0)}) ) ) terminator: ) ] body: (DoGroup children: [(C {(eval)} {($ VSub_Number "$1")}) (C {(shift)})] spids: [146 157] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_z child: {($ VSub_Name "$_Dbg_set_trace_init")} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_set_trace_init) op: Equal rhs: {(1)} spids: [176] ) ] spids: [176] ) (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:{(0)}) spids: [181 185] ) } spids: [180] ) ] spids: [180] ) (C {(_Dbg_write_journal)} {(DQ ("_Dbg_step_ignore=0"))}) ] spids: [-1 173] ) ] else_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: [199 203] ) } spids: [198] ) ] spids: [198] ) ] spids: [195 206] ) (C {(trap)} {(SQ <"_Dbg_debug_trap_handler 0 \"$BASH_COMMAND\" \"$@\"">)} {(DEBUG)}) ] spids: [78] ) spids: [74 77] ) ] )