summaryrefslogtreecommitdiff
path: root/targets/libc.c
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:58:00 -0300
committerGabriel Schneider <[email protected]>2026-11-10 11:58:53 -0300
commit8beab959b633e6641d07aba053a55e6e8e61eb00 (patch)
tree0e5a91c0a00e121fe4094a333438ee90ccc5fdda /targets/libc.c
parent3fdb67c479dcc1ad0f1e51832bc086622692249c (diff)
downloadcomputeranim-8beab959b633e6641d07aba053a55e6e8e61eb00.tar.gz
computeranim-8beab959b633e6641d07aba053a55e6e8e61eb00.zip
targets, test-debugger, bench-debugger
A linked list, a graph search in Zig, the same C under glibc and musl, two threads. The tests drive the debugger over them: breakpoint counts, the lines a step walks (as gdb), a list snapshotted by a hook, a watch's words, the syscalls that tell glibc from musl, threads, attach, and scripted dbg and record sessions. The bench measures steps, stops and memory access from bare ptrace up to a recording. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'targets/libc.c')
-rw-r--r--targets/libc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/targets/libc.c b/targets/libc.c
new file mode 100644
index 0000000..2dad81b
--- /dev/null
+++ b/targets/libc.c
@@ -0,0 +1,19 @@
+// The same C under two C libraries (glibc linked dynamically, musl
+// statically): what startup, malloc and stdio turn into, seen as syscalls.
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Volatile, or the compiler proves the allocations away.
+static char *volatile small, *volatile big;
+
+int main(void) {
+ small = malloc(64);
+ big = malloc(1 << 20);
+ strcpy(small, "small");
+ memset(big, 'b', 1 << 20);
+ printf("%s %c\n", small, big[4096]);
+ free(big);
+ free(small);
+ return 0;
+}