about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-11-22 16:48:08 +0100
committerChristian Krinitsin <mail@krinitsin.com>2025-11-22 16:48:08 +0100
commit5f19fd9999dbe61d60d74c09bc8e96b40f0ec193 (patch)
treee25bc7b55bddcd612910a5e5224c999b9e2e1a54
parente66bf82d5efeba26cf86fccafac20dee32fc95b9 (diff)
downloadfocaccia-5f19fd9999dbe61d60d74c09bc8e96b40f0ec193.tar.gz
focaccia-5f19fd9999dbe61d60d74c09bc8e96b40f0ec193.zip
Revert benchmark additions in scripts
-rw-r--r--src/focaccia/qemu/_qemu_tool.py100
-rwxr-xr-xsrc/focaccia/tools/capture_transforms.py11
-rwxr-xr-xsrc/focaccia/tools/validate_qemu.py10
3 files changed, 22 insertions, 99 deletions
diff --git a/src/focaccia/qemu/_qemu_tool.py b/src/focaccia/qemu/_qemu_tool.py
index 88ce02a..7ca556b 100644
--- a/src/focaccia/qemu/_qemu_tool.py
+++ b/src/focaccia/qemu/_qemu_tool.py
@@ -10,11 +10,8 @@ import re
 import gdb
 import logging
 import traceback
-import subprocess
-import time
 from typing import Iterable, Optional
 
-from focaccia.benchmark import Timer
 import focaccia.parser as parser
 from focaccia.arch import supported_architectures, Arch
 from focaccia.compare import compare_symbolic, Error, ErrorTypes
@@ -541,54 +538,10 @@ def main():
         raise NotImplementedError(f'Deterministic log {args.deterministic_log} specified but '
                                    'Focaccia built without deterministic log support')
 
-    # Benchmark native QEMU execution
-    if args.benchmark_execution_continue:
-        try:
-            timer = Timer("Emulator execution", paused=True, iterations=10)
-            for i in range(timer.iterations):
-                qemu_process = subprocess.Popen(
-                    [f"qemu-{args.guest_arch}", "-singlestep", "-g", args.remote.split(':')[1], args.executable],
-                    stdout=subprocess.DEVNULL,
-                    stderr=subprocess.DEVNULL
-                )
-                time.sleep(0.5)
-                timer.unpause()
-                gdb_server = GDBServerStateIterator(args.remote, detlog)
-                gdb.execute("continue")
-                qemu_process.wait()
-                timer.pause()
-            timer.log_time()
-            exit(0)
-        except Exception as e:
-            raise Exception(f'Unable to benchmark QEMU: {e}')
-    if args.benchmark_execution_stepping:
-        try:
-            timer = Timer("Emulator execution", paused=True, iterations=10)
-            for i in range(timer.iterations):
-                try:
-                    qemu_process = subprocess.Popen(
-                            [f"qemu-{args.guest_arch}", "-g", args.remote.split(':')[1], args.executable],
-                        stdout=subprocess.DEVNULL,
-                        stderr=subprocess.DEVNULL
-                    )
-                    time.sleep(0.5)
-                    timer.unpause()
-                    gdb_server = GDBServerStateIterator(args.remote, detlog)
-                    state_iter = iter(gdb_server)
-                    while True:
-                        cur_state = next(state_iter)
-                except StopIteration:
-                    timer.pause()
-            timer.log_time()
-            exit(0)
-        except Exception as e:
-            raise Exception(f'Unable to benchmark QEMU: {e}')
-
-    if not args.benchmark_trace_test:
-        try:
-            gdb_server = GDBServerStateIterator(args.remote, detlog)
-        except Exception as e:
-            raise Exception(f'Unable to perform basic GDB setup: {e}')
+    try:
+        gdb_server = GDBServerStateIterator(args.remote, detlog)
+    except Exception as e:
+        raise Exception(f'Unable to perform basic GDB setup: {e}')
 
     try:
         executable: str | None = None
@@ -612,43 +565,26 @@ def main():
 
     # Use symbolic trace to collect concrete trace from QEMU
     try:
-        timer = Timer("Emulator tracing", iterations=10, paused=True, enabled=args.benchmark_trace_test)
-        for i in range(timer.iterations):
-            if timer.enabled:
-                qemu_process = subprocess.Popen(
-                        [f"qemu-{args.guest_arch}", "-g", args.remote.split(':')[1], executable],
-                    stdout=subprocess.DEVNULL,
-                    stderr=subprocess.DEVNULL
-                )
-                time.sleep(0.5)
-                timer.unpause()
-                gdb_server = GDBServerStateIterator(args.remote, detlog)
-
-            conc_states, matched_transforms = collect_conc_trace(
-                gdb_server,
-                symb_transforms.states,
-                symb_transforms.env.start_address,
-                symb_transforms.env.stop_address)
-            timer.pause()
-        timer.log_time()
+        conc_states, matched_transforms = collect_conc_trace(
+            gdb_server,
+            symb_transforms.states,
+            symb_transforms.env.start_address,
+            symb_transforms.env.stop_address)
     except Exception as e:
         raise Exception(f'Failed to collect concolic trace from QEMU: {e}')
 
     # Verify and print result
     if not args.quiet:
         try:
-            timer = Timer("Emulator testing", iterations=10, enabled=args.benchmark_trace_test)
-            for i in range(timer.iterations):
-                res = compare_symbolic(conc_states, matched_transforms)
-                if qemu_crash["crashed"]:
-                    res.append({
-                        'pc': qemu_crash["pc"],
-                        'txl': None,
-                        'ref': qemu_crash["ref"],
-                        'errors': qemu_crash["errors"],
-                        'snap': qemu_crash["snap"],
-                    })
-            timer.log_time()
+            res = compare_symbolic(conc_states, matched_transforms)
+            if qemu_crash["crashed"]:
+                res.append({
+                    'pc': qemu_crash["pc"],
+                    'txl': None,
+                    'ref': qemu_crash["ref"],
+                    'errors': qemu_crash["errors"],
+                    'snap': qemu_crash["snap"],
+                })
             print_result(res, verbosity[args.error_level])
         except Exception as e:
             raise Exception('Error occured when comparing with symbolic equations: {e}')
diff --git a/src/focaccia/tools/capture_transforms.py b/src/focaccia/tools/capture_transforms.py
index 6a8a38a..268af36 100755
--- a/src/focaccia/tools/capture_transforms.py
+++ b/src/focaccia/tools/capture_transforms.py
@@ -4,7 +4,7 @@ import sys
 import argparse
 import logging
 
-from focaccia import parser, utils, benchmark
+from focaccia import parser, utils
 from focaccia.trace import TraceEnvironment
 from focaccia.native.tracer import SymbolicTracer
 from focaccia.deterministic import DeterministicLog
@@ -51,10 +51,6 @@ def main():
                       type=utils.to_num,
                       help='Set a time limit for executing an instruction symbolically, skip'
                            'instruction when limit is exceeded')
-    prog.add_argument('--benchmark',
-                      default=False,
-                      action='store_true',
-                      help='Benchmark the trace function')
     args = prog.parse_args()
 
     if args.debug:
@@ -79,10 +75,7 @@ def main():
     tracer = SymbolicTracer(env, remote=args.remote, cross_validate=args.debug,
                             force=args.force)
 
-    timer = benchmark.Timer("Native tracing", iterations=10, enabled=args.benchmark)
-    for i in range(timer.iterations):
-        trace = tracer.trace(time_limit=args.insn_time_limit)
-    timer.log_time()
+    trace = tracer.trace(time_limit=args.insn_time_limit)
 
     with open(args.output, 'w') as file:
         parser.serialize_transformations(trace, file)
diff --git a/src/focaccia/tools/validate_qemu.py b/src/focaccia/tools/validate_qemu.py
index f1823b9..4b5160f 100755
--- a/src/focaccia/tools/validate_qemu.py
+++ b/src/focaccia/tools/validate_qemu.py
@@ -76,7 +76,7 @@ memory, and stepping forward by single instructions.
                       type=str,
                       choices=supported_architectures.keys(),
                       help='Architecture of the emulated guest'
-                           '(Only required when using --use-socket or --benchmark-executioe)')
+                           '(Only required when using --use-socket)')
     prog.add_argument('--remote',
                       type=str,
                       help='The hostname:port pair at which to find a QEMU GDB server.')
@@ -86,12 +86,6 @@ memory, and stepping forward by single instructions.
                       help='GDB binary to invoke.')
     prog.add_argument('--deterministic-log', default=None,
                       help='The directory containing rr traces')
-    prog.add_argument('--benchmark-execution-continue', default=False, action='store_true',
-                      help="Benchmark QEMU's execution of binary without tracing (continue mode) (overrides other flags)")
-    prog.add_argument('--benchmark-execution-stepping', default=False, action='store_true',
-                      help="Benchmark QEMU's execution of binary without tracing (stepping mode) (overrides other flags)")
-    prog.add_argument('--benchmark-trace-test', default=False, action='store_true',
-                      help="Benchmark Focaccia's tracing and testing of QEMU")
     return prog
 
 def quoted(s: str) -> str:
@@ -111,7 +105,7 @@ def main():
     env = os.environ.copy()
 
     # Differentiate between the QEMU GDB server and QEMU plugin interfaces
-    if args.use_socket and not args.benchmark_execution:
+    if args.use_socket:
         if not args.guest_arch:
             argparser.error('--guest-arch is required when --use-socket is specified')