forked from Github_Repos/cvw
add option to not generate a trace when making checkpoints
This commit is contained in:
parent
a8e8cfb838
commit
da4d7de2bd
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/python3
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 8:
|
||||
if len(sys.argv) != 9:
|
||||
sys.exit("""Error createGenCheckpointScript.py expects 7 args:
|
||||
<TCP port number>
|
||||
<path to vmlinux>
|
||||
@ -9,7 +9,8 @@ if len(sys.argv) != 8:
|
||||
<path to GDB checkpoint state dump>
|
||||
<path to GDB ram dump>
|
||||
<checkpoint pc address>
|
||||
<number of times pc has already been hit before checkpoint>""")
|
||||
<number of times pc has already been hit before checkpoint>
|
||||
<whether to generate a trace after hitting checkpoint>""")
|
||||
|
||||
tcpPort=sys.argv[1]
|
||||
vmlinux=sys.argv[2]
|
||||
@ -18,6 +19,7 @@ statePath=sys.argv[4]
|
||||
ramPath=sys.argv[5]
|
||||
checkPC=sys.argv[6]
|
||||
checkPCoccurences=sys.argv[7]
|
||||
genTrace=sys.argv[8]
|
||||
|
||||
GDBscript = f"""
|
||||
# GDB config
|
||||
@ -54,7 +56,10 @@ set logging off
|
||||
# Log main memory to a file
|
||||
print "GDB storing RAM to {ramPath}\\n"
|
||||
dump binary memory {ramPath} 0x80000000 0xffffffff
|
||||
|
||||
"""
|
||||
if (genTrace=="1"):
|
||||
GDBscript+=\
|
||||
"""
|
||||
# Generate Trace Until End
|
||||
maintenance packet Qqemu.Logging:1
|
||||
# Do this by setting an impossible breakpoint
|
||||
@ -62,6 +67,12 @@ b *0x1000
|
||||
del 1
|
||||
c
|
||||
"""
|
||||
else:
|
||||
GDBscript+=\
|
||||
"""
|
||||
kill
|
||||
q
|
||||
"""
|
||||
GDBscriptFile = open("genCheckpoint.gdb",'w')
|
||||
GDBscriptFile.write(GDBscript)
|
||||
GDBscriptFile.close()
|
||||
|
@ -6,11 +6,12 @@ recordFile="$tvDir/all.qemu"
|
||||
traceFile="$tvDir/all.txt"
|
||||
|
||||
# Parse Commandline Arg
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "genCheckpoint requires 1 argument: <num instrs>" >&2
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "genCheckpoint requires 2 arguments: <num instrs> <whether to genTrace>" >&2
|
||||
exit 1
|
||||
fi
|
||||
instrs=$1
|
||||
genTrace=$2
|
||||
if ! [ "$instrs" -eq "$instrs" ] 2> /dev/null
|
||||
then
|
||||
echo "Error expected integer number of instructions, got $instrs" >&2
|
||||
@ -24,8 +25,14 @@ rawStateFile="$checkPtDir/stateGDB.txt"
|
||||
rawRamFile="$checkPtDir/ramGDB.bin"
|
||||
ramFile="$checkPtDir/ram.bin"
|
||||
|
||||
read -p "This scripts is going to create a checkpoint at $instrs instrs.
|
||||
Is that what you wanted? (y/n) " -n 1 -r
|
||||
if [ $genTrace -eq "1" ]; then
|
||||
read -p "This scripts is going to create a checkpoint at $instrs instrs.
|
||||
AND it's going to start generating a trace at that checkpoint.
|
||||
Is that what you wanted? (y/n) " -n 1 -r
|
||||
else
|
||||
read -p "This scripts is going to create a checkpoint at $instrs instrs.
|
||||
Is that what you wanted? (y/n) " -n 1 -r
|
||||
fi
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
@ -36,8 +43,10 @@ then
|
||||
sudo mkdir -p $checkPtDir
|
||||
sudo chown -R cad:users $checkPtDir
|
||||
sudo chmod -R a+rw $checkPtDir
|
||||
sudo touch $outTraceFile
|
||||
sudo chmod a+rw $outTraceFile
|
||||
if [ $genTrace -eq "1" ]; then
|
||||
sudo touch $outTraceFile
|
||||
sudo chmod a+rw $outTraceFile
|
||||
fi
|
||||
sudo touch $interruptsFile
|
||||
sudo chmod a+rw $interruptsFile
|
||||
sudo touch $rawStateFile
|
||||
@ -56,8 +65,7 @@ then
|
||||
echo "It occurs ${occurences} times before the ${instrs}th instr."
|
||||
|
||||
# Create GDB script because GDB is terrible at handling arguments / variables
|
||||
./createGenCheckpointScript.py $tcpPort $imageDir/vmlinux $instrs $rawStateFile $rawRamFile $pc $occurences
|
||||
|
||||
./createGenCheckpointScript.py $tcpPort $imageDir/vmlinux $instrs $rawStateFile $rawRamFile $pc $occurences $genTrace
|
||||
# GDB+QEMU
|
||||
echo "Starting QEMU in replay mode with attached GDB script at $(date +%H:%M:%S)"
|
||||
(qemu-system-riscv64 \
|
||||
@ -77,7 +85,7 @@ then
|
||||
./fixBinMem "$rawRamFile" "$ramFile"
|
||||
#echo "Creating truncated trace at $(date +%H:%M:%S)"
|
||||
#tail -n+$instrs "$tvDir/$traceFile" > "$checkPtDir/$traceFile"
|
||||
echo "Checkpoint completed at $(date +%H:%M:%S)"
|
||||
read -p "Checkpoint completed at $(date +%H:%M:%S)" -n 1 -r
|
||||
|
||||
# Cleanup
|
||||
echo "Elevating permissions to restrict write access to $checkPtDir"
|
||||
|
Loading…
Reference in New Issue
Block a user