greatly improve trace-generating checkpoint process with QEMU hack

This commit is contained in:
bbracker 2022-02-28 23:00:00 +00:00
parent 8f2a533470
commit 8321c76d95
4 changed files with 60 additions and 11 deletions

1
.gitignore vendored
View file

@ -61,6 +61,7 @@ linux/testvector-generation/genCheckpoint.gdb
linux/testvector-generation/silencePipe
linux/testvector-generation/silencePipe.control
linux/testvector-generation/fixBinMem
linux/testvector-generation/qemu-serial
*.dtb
synthDC/WORK
synthDC/alib-52

View file

@ -0,0 +1,53 @@
From f9882bd274bde82d8c38a9c31692b6ee33d8cd9a Mon Sep 17 00:00:00 2001
From: root <root@tera.eng.hmc.edu>
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

View file

@ -35,9 +35,6 @@ maintenance packet Qqemu.PhyMemMode:1
# Symbol file
file {vmlinux}
# Silence Trace Generation
shell echo 1 > ./silencePipe.control
# Step over reset vector into actual code
stepi 100
# Proceed to checkpoint
@ -56,11 +53,11 @@ set logging off
# Log main memory to a file
print "GDB storing RAM to {ramPath}\\n"
#dump binary memory {ramPath} 0x80000000 0xffffffff
#dump binary memory {ramPath} 0x80000000 0x80ffffff
dump binary memory {ramPath} 0x80000000 0xffffffff
dump binary memory {ramPath} 0x80000000 0x80ffffff
# Generate Trace Until End
shell echo 0 > ./silencePipe.control
maintenance packet Qqemu.Logging:1
# Do this by setting an impossible breakpoint
b *0x1000
del 1

View file

@ -1,9 +1,9 @@
#!/bin/bash
tcpPort=1237
tcpPort=1238
imageDir=$RISCV/buildroot/output/images
tvDir=$RISCV/linux-testvectors
recordFile="$tvDir/all.qemu"
traceFile="$tvDir/all_up_to_498.txt"
traceFile="$tvDir/all.txt"
# Parse Commandline Arg
if [ "$#" -ne 1 ]; then
@ -30,7 +30,6 @@ echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Creating checkpoint at $instrs instructions!"
make silencePipe
# Create Output Directory
echo "Elevating permissions to create $checkPtDir and stuff inside it"
@ -66,9 +65,8 @@ then
-nographic \
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
-singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=replay,rrfile=$recordFile \
-d nochain,cpu,in_asm,int \
-gdb tcp::$tcpPort -S \
2>&1 >/dev/null | ./silencePipe | ./parseQEMUtoGDB/parseQEMUtoGDB_run.py | ./parseGDBtoTrace/parseGDBtoTrace_run.py $interruptsFile | ./remove_dup.awk > $outTraceFile) \
2>&1 1>./qemu-serial | ./parseQEMUtoGDB/parseQEMUtoGDB_run.py | ./parseGDBtoTrace/parseGDBtoTrace_run.py $interruptsFile | ./remove_dup.awk > $outTraceFile) \
& riscv64-unknown-elf-gdb --quiet -ex "source genCheckpoint.gdb"
echo "Completed GDB script at $(date +%H:%M:%S)"