From f5bcc8dc6eb21df90aeb443032779df3e73c53a1 Mon Sep 17 00:00:00 2001 From: Ethan Graham Date: Wed, 16 Jul 2025 12:46:20 +0000 Subject: pkg/csource: add call argument annotations to generated C-source files The structure of arguments passed into syscalls is often hard to parse since it is memcpy'd into mmap'd regions. Structural relations are often lost in translation, resulting in reproducers that take longer for a developer to understand. This patch adds functionality for parsing syscall arguments semantically and emitting a structured and human-readable comment which is inserted before each syscall in the resulting C-source. --- pkg/csource/testdata/0 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkg/csource/testdata/0 (limited to 'pkg/csource/testdata/0') diff --git a/pkg/csource/testdata/0 b/pkg/csource/testdata/0 new file mode 100644 index 000000000..1f8c0f959 --- /dev/null +++ b/pkg/csource/testdata/0 @@ -0,0 +1,25 @@ +r0 = socket$netlink(0x10, 0x3, 0x2) +bind$netlink(r0, &(0x7f0000514ff4)={0x10, 0x0, 0x0, 0x2ffffffff}, 0xc) + +// socket$netlink arguments: [ +// domain: const = 0x10 (8 bytes) +// type: const = 0x3 (8 bytes) +// proto: netlink_proto = 0x2 (4 bytes) +// ] +// returns sock_netlink +syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=NETLINK_USERSOCK*/2) +// bind$netlink arguments: [ +// fd: sock_netlink (resource) +// addr: ptr[in, sockaddr_nl_t[AF_NETLINK, netlink_port_id, +// flags[netlink_group_bitmap, int32]]] { +// sockaddr_nl_t[AF_NETLINK, netlink_port_id, flags[netlink_group_bitmap, +// int32]] { +// nl_family: const = 0x10 (2 bytes) +// nl_pad: const = 0x0 (2 bytes) +// nl_pid: int32 = 0x0 (4 bytes) +// nl_groups: netlink_group_bitmap = 0x2ffffffff (4 bytes) +// } +// } +// addrlen: len = 0xc (8 bytes) +// ] +syscall(__NR_bind, /*fd=*/r[0], /*addr=*/0x200000514ff4ul, /*addrlen=*/0xcul) \ No newline at end of file -- cgit mrf-deployment