Disassembly on request, and it is a debugging aid rather than evidence
SPIKE_DISASM=1 objdumps the exact buffers that ran. Kept behind a flag and kept out of the pass/fail path: a disassembly that reads correctly beside a function answering the wrong number is the normal outcome of hand-encoding.
This commit is contained in:
parent
ec5062a0ed
commit
c73f05b052
@ -96,12 +96,19 @@ let run src =
|
||||
Hashtbl.iter (fun n c -> Printf.printf " %-20s %4d bytes at %nx\n"
|
||||
n (String.length c) (Hashtbl.find addrs n)) bytes;
|
||||
|
||||
(* Dumped so oracle.sh can disassemble exactly the bytes that ran. *)
|
||||
(try
|
||||
let oc = open_out_bin (Filename.concat (Filename.dirname Sys.argv.(0)) "spike-add.bin") in
|
||||
output_string oc (Hashtbl.find bytes "spike-add");
|
||||
close_out oc
|
||||
with Not_found -> ());
|
||||
(* The bytes that actually ran, dumped where run.sh can objdump them.
|
||||
A debugging aid and not the evidence: a disassembly that reads correctly
|
||||
next to a function that answers 656 when it should answer 650 is the
|
||||
normal outcome of hand-encoding, which is why the checks below compare
|
||||
numbers. *)
|
||||
(match Sys.getenv_opt "SPIKE_DUMP" with
|
||||
| None -> ()
|
||||
| Some dir ->
|
||||
Hashtbl.iter
|
||||
(fun n c ->
|
||||
let oc = open_out_bin (Filename.concat dir (n ^ ".bin")) in
|
||||
output_string oc c; close_out oc)
|
||||
bytes);
|
||||
|
||||
(* ── The SysV boundary ──────────────────────────────────────────────
|
||||
Three synthetic functions, built as Tast by hand rather than written in
|
||||
|
||||
@ -32,7 +32,17 @@ ocamlfind ocamlopt -thread -package unix,threads.posix -linkpkg \
|
||||
|
||||
test -x "$out/spike" || { echo "build failed"; exit 1; }
|
||||
|
||||
"$out/spike" "$here/probe.flan"
|
||||
SPIKE_DUMP=$out "$out/spike" "$here/probe.flan"
|
||||
rc=$?
|
||||
|
||||
# Disassembly on request. objdump over the raw buffer, which is what to reach
|
||||
# for when a function answers the wrong number -- not what proves it answers
|
||||
# the right one.
|
||||
if [ "${SPIKE_DISASM:-}" = 1 ]; then
|
||||
for f in "$out"/*.bin; do
|
||||
echo; echo "== $(basename "$f" .bin)"
|
||||
objdump -D -b binary -m i386:x86-64 -M intel "$f" | tail -n +7
|
||||
done
|
||||
fi
|
||||
echo "exit: $rc"
|
||||
exit $rc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user