summaryrefslogtreecommitdiff
path: root/design/mock/list.c
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 14:12:42 -0300
committerGabriel Schneider <[email protected]>2026-11-10 14:35:56 -0300
commitf8740f6996eefc235af066a6686f52847c158a6b (patch)
tree1536ce2825e337e2dac75046093b583d04a96d9b /design/mock/list.c
parente2fa716dcda7de877908de006adc34f0c3593693 (diff)
downloadcomputeranim-f8740f6996eefc235af066a6686f52847c158a6b.tar.gz
computeranim-f8740f6996eefc235af066a6686f52847c158a6b.zip
design, revision 2: the whole context in every frame, a lens beside it
The user's premise: show what pwndbg shows, hide nothing; the semantic views stay as a lens on the machine. So every frame holds the registers (all, each followed as a pointer), the stack telescope and the backtrace in a column that never changes, and the source, the disassembly and the scene's lens in the other. A value's ink says where it points (stack, heap, code, data; rwx underlined), its paper says what happened to it. JetBrains Mono NL for everything mono; the floor is mono 20, which a phone does not read: what narration depends on is also in the caption. Mocks 9 to 11 are drawn from a real recording of targets/list.
Diffstat (limited to 'design/mock/list.c')
-rw-r--r--design/mock/list.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/design/mock/list.c b/design/mock/list.c
new file mode 100644
index 0000000..e09d301
--- /dev/null
+++ b/design/mock/list.c
@@ -0,0 +1,42 @@
+// A linked list on the heap: built, reversed, summed. `list_done` gets the
+// finished list, the place for a tracer to look at it.
+#include <stdio.h>
+#include <stdlib.h>
+
+struct node {
+ long value;
+ struct node *next;
+};
+
+__attribute__((noinline)) static struct node *push(struct node *head, long value) {
+ struct node *n = malloc(sizeof *n);
+ n->value = value;
+ n->next = head;
+ return n;
+}
+
+__attribute__((noinline)) static struct node *reverse(struct node *head) {
+ struct node *prev = NULL;
+ while (head) {
+ struct node *next = head->next;
+ head->next = prev;
+ prev = head;
+ head = next;
+ }
+ return prev;
+}
+
+__attribute__((noinline)) long list_done(struct node *head) {
+ long sum = 0;
+ for (; head; head = head->next) sum += head->value;
+ return sum;
+}
+
+int main(int argc, char **argv) {
+ int n = argc > 1 ? atoi(argv[1]) : 6;
+ struct node *head = NULL;
+ for (int i = n; i >= 1; i--) head = push(head, i * i);
+ head = reverse(head);
+ printf("sum = %ld\n", list_done(head));
+ return 0;
+}