From 228f693f135c91ffc1afdab86d23a5a6a02595a0 Mon Sep 17 00:00:00 2001 From: bbracker Date: Sun, 6 Mar 2022 14:04:30 -0800 Subject: [PATCH] remove checkpoint trace generation since that requires qemu hacking and because we are able to generate the whole trace on VLSI --- ...n-on-logging-mid-execution-using-GDB.patch | 53 ------------------- .../createGenCheckpointScript.py | 21 ++------ linux/testvector-generation/genCheckpoint.sh | 23 +++----- 3 files changed, 10 insertions(+), 87 deletions(-) delete mode 100644 linux/testvector-generation/0001-bens-hack-to-turn-on-logging-mid-execution-using-GDB.patch diff --git a/linux/testvector-generation/0001-bens-hack-to-turn-on-logging-mid-execution-using-GDB.patch b/linux/testvector-generation/0001-bens-hack-to-turn-on-logging-mid-execution-using-GDB.patch deleted file mode 100644 index 1b0e1d4aa..000000000 --- a/linux/testvector-generation/0001-bens-hack-to-turn-on-logging-mid-execution-using-GDB.patch +++ /dev/null @@ -1,53 +0,0 @@ -From f9882bd274bde82d8c38a9c31692b6ee33d8cd9a Mon Sep 17 00:00:00 2001 -From: root -Date: Mon, 28 Feb 2022 22:48:29 +0000 -Subject: [PATCH] bens hack to turn on logging mid-execution using GDB - ---- - gdbstub.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/gdbstub.c b/gdbstub.c -index 141d7bc4ec..98ecce1b67 100644 ---- a/gdbstub.c -+++ b/gdbstub.c -@@ -2317,6 +2317,23 @@ static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) - } - put_packet("OK"); - } -+ -+static void handle_set_qemu_logging(GArray *params, void *user_ctx) -+{ -+ if (!params->len) { -+ put_packet("E22"); -+ return; -+ } -+ -+ int log_mask; -+ if (!get_param(params, 0)->val_ul) { -+ log_mask = 0; -+ } else { -+ log_mask = CPU_LOG_TB_IN_ASM | CPU_LOG_INT | CPU_LOG_TB_CPU | CPU_LOG_TB_NOCHAIN; -+ } -+ qemu_set_log(log_mask); -+ put_packet("OK"); -+} - #endif - - static const GdbCmdParseEntry gdb_gen_query_set_common_table[] = { -@@ -2430,6 +2447,12 @@ static const GdbCmdParseEntry gdb_gen_set_table[] = { - .cmd_startswith = 1, - .schema = "l0" - }, -+ { -+ .handler = handle_set_qemu_logging, -+ .cmd = "qemu.Logging:", -+ .cmd_startswith = 1, -+ .schema = "l0" -+ }, - #endif - }; - --- -2.27.0 - diff --git a/linux/testvector-generation/createGenCheckpointScript.py b/linux/testvector-generation/createGenCheckpointScript.py index 02d1bcc76..264a2ee6e 100755 --- a/linux/testvector-generation/createGenCheckpointScript.py +++ b/linux/testvector-generation/createGenCheckpointScript.py @@ -1,7 +1,7 @@ #! /usr/bin/python3 import sys -if len(sys.argv) != 9: +if len(sys.argv) != 8: sys.exit("""Error createGenCheckpointScript.py expects 7 args: @@ -9,8 +9,7 @@ if len(sys.argv) != 9: - - """) + """) tcpPort=sys.argv[1] vmlinux=sys.argv[2] @@ -19,7 +18,6 @@ statePath=sys.argv[4] ramPath=sys.argv[5] checkPC=sys.argv[6] checkPCoccurences=sys.argv[7] -genTrace=sys.argv[8] GDBscript = f""" # GDB config @@ -56,20 +54,7 @@ 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 -b *0x1000 -del 1 -c -""" -else: - GDBscript+=\ -""" + kill q """ diff --git a/linux/testvector-generation/genCheckpoint.sh b/linux/testvector-generation/genCheckpoint.sh index 834ef6bb6..87e295414 100755 --- a/linux/testvector-generation/genCheckpoint.sh +++ b/linux/testvector-generation/genCheckpoint.sh @@ -6,12 +6,11 @@ recordFile="$tvDir/all.qemu" traceFile="$tvDir/all.txt" # Parse Commandline Arg -if [ "$#" -ne 2 ]; then - echo "genCheckpoint requires 2 arguments: " >&2 +if [ "$#" -ne 1 ]; then + echo "genCheckpoint requires 1 argument: " >&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 @@ -25,14 +24,8 @@ rawStateFile="$checkPtDir/stateGDB.txt" rawRamFile="$checkPtDir/ramGDB.bin" ramFile="$checkPtDir/ram.bin" -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 +read -p "This scripts is going to create a checkpoint at $instrs instrs. +Is that what you wanted? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then @@ -63,7 +56,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 $genTrace + ./createGenCheckpointScript.py $tcpPort $imageDir/vmlinux $instrs $rawStateFile $rawRamFile $pc $occurences # GDB+QEMU echo "Starting QEMU in replay mode with attached GDB script at $(date +%H:%M:%S)" (qemu-system-riscv64 \ @@ -81,10 +74,8 @@ then echo "Changing Endianness at $(date +%H:%M:%S)" make fixBinMem ./fixBinMem "$rawRamFile" "$ramFile" - if [ $genTrace -ne "1" ]; then - echo "Copying over a truncated trace" - tail -n+$instrs $traceFile > $outTraceFile - fi + echo "Copying over a truncated trace" + tail -n+$instrs $traceFile > $outTraceFile read -p "Checkpoint completed at $(date +%H:%M:%S)" -n 1 -r # Cleanup