From 3f1d25c3e62f91f2555f0649c7c71f3b730717be Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 5 Feb 2023 17:35:44 +0000 Subject: deploy: 724d077860e103631605f09a7de35e3ad8796f56 --- tools/qemu.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tools/qemu.html') diff --git a/tools/qemu.html b/tools/qemu.html index daf3e1a..b53cb23 100644 --- a/tools/qemu.html +++ b/tools/qemu.html @@ -353,6 +353,34 @@ launched with the same parameters.

...

Instructions to build a minimal Kernel and initrd.

+

Appendix: Cheap instruction tracer

+
test: test.s
+	as -o test.o test.s
+	ld -o test test.o testc.o
+
+trace: test
+	qemu-x86_64 -singlestep -d nochain,cpu ./test 2>&1 | awk '/RIP/ { print $$1; }'
+
+clean:
+	$(RM) test test-bin test.o
+
+
.section .text, "ax"
+
+.global _start
+_start:
+    xor %rax, %rax
+    mov $0x8, %rax
+1:
+    cmp $0, %rax
+    je 2f
+    dec %rax
+    jmp 1b
+2:
+    # x86-64 exit(2) syscall
+    mov $0, %rdi
+    mov $60, %rax
+    syscall
+

References