#####################################################################
#
# ppw-gdb-commands
#
# This is a gdb version 6.X command file used to provide canned sequences
# of gdb commands for running EUROPA under the control of gdb.
#
# NOTE:For gdb version 5.0 use the ppw-gdb5.0-commands command file instead
#      These command sequences do not work with gdb versions 5.2 and 5.3 
#
# usage: gdb -x ppw-gdb-commands executable
#
# This file currently provides two commands:
#   1) init-run          - run once to initialize EUROPA debug session
#   2) write-step N      - run to enable PPW writing of one step
#                             where: N is the step number to write
#   3) write-next N      - write next N steps, 
#                             where: N is number of steps
#
#####################################################################

define init-run
tbreak EUROPA::CBPlanner::stepBreakpoint
run
set EUROPA::PlanWriter::PartialPlanWriter::noFullWrite=1
set EUROPA::PlanWriter::PartialPlanWriter::writeStep=1
printf "Ready to enable writing of a step with write-step N\n"
printf "At step %d\n", m_step
end

define write-step 
tbreak EUROPA::CBPlanner::stepBreakpoint if m_step == $arg0
cont
printf "Setting PartialPlanWriter to enable writing step %d\n", m_step
set EUROPA::PlanWriter::PartialPlanWriter::noFullWrite=0
tbreak EUROPA::CBPlanner::stepBreakpoint
cont
printf "Finished writing step %d\n", m_step-1
printf "At step %d\n", m_step
set EUROPA::PlanWriter::PartialPlanWriter::noFullWrite=1
end

define write-next 
set $start = m_step
break EUROPA::CBPlanner::stepBreakpoint if m_step == $start + $arg0
printf "PartialPlanWriter writing steps %d - %d\n", m_step, m_step + $arg0 - 1
set EUROPA::PlanWriter::PartialPlanWriter::noFullWrite=0
cont 
printf "Finished writing steps %d - %d\n", $start, m_step-1
printf "At step %d\n", m_step
set EUROPA::PlanWriter::PartialPlanWriter::noFullWrite=1
clear EUROPA::CBPlanner::stepBreakpoint
end
