From 810241190102eaf849f5744ca7eeb68ad34f01d7 Mon Sep 17 00:00:00 2001 From: Florent Revest Date: Tue, 4 Jul 2023 17:59:04 +0200 Subject: pkg/csource: annotate syscall() args with their pretty-printed values This factorizes const arguments into the shortest flags OR bitmask possible so they are easy to read. E.g: /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul --- pkg/csource/csource_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index eb85fd77b..957d2ebc9 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -223,6 +223,24 @@ syscall(SYS_csource6, /*buf=*/0x%xul); target.DataOffset+0x100, target.DataOffset+0x100, target.DataOffset+0x140, target.DataOffset+0x140), }, + { + input: ` +csource7(0x0) +csource7(0x1) +csource7(0x2) +csource7(0x3) +csource7(0x4) +csource7(0x5) +`, + output: ` +syscall(SYS_csource7, /*flag=*/0ul); +syscall(SYS_csource7, /*flag=BIT_0*/1ul); +syscall(SYS_csource7, /*flag=BIT_1*/2ul); +syscall(SYS_csource7, /*flag=BIT_0_AND_1*/3ul); +syscall(SYS_csource7, /*flag=*/4ul); +syscall(SYS_csource7, /*flag=BIT_0|0x4*/5ul); +`, + }, } for i, test := range tests { t.Run(fmt.Sprint(i), func(t *testing.T) { @@ -231,6 +249,7 @@ syscall(SYS_csource6, /*buf=*/0x%xul); t.Fatal(err) } ctx := &context{ + p: p, target: target, sysTarget: targets.Get(target.OS, target.Arch), } -- cgit mrf-deployment