Debian Codegraph @

tapset/bpf/syscall_table.stp

raw
1 # This is syscall_table tapset providing namely syscall_name() and syscall_num()
2 # functions. It uses architecture specific data contained in other arch
3 # specific tapsets. Helper scripts/dump-syscalls.sh is used to generate those.
4
5 function syscall_name(num) {
6 //%( CONFIG_COMPAT == "y" %?
7 // if (@__compat_task)
8 // return __syscall_32_num2name[num]
9 //%)
10 %( CONFIG_64BIT == "y" %?
11 return __syscall_64_num2name[num]
12 %:
13 return __syscall_32_num2name[num]
14 %)
15 }
16
17 # Systemtap is benevolent when an associative array is being queried for an
18 # unexisting key. If we call e.g. __syscall_64_name2num["unexisting_syscall"],
19 # the result is zero. But at the same time zero is a valid syscall number, so
20 # we really need to return some other value in this case to indicate that
21 # syscall with given name doesn't exist. Let's use following
22 # @return_sanitized macro.
23 #
24 # The other way round, when evaluating e.g. __syscall_64_num2name[-123], stap
25 # is benevolent too - we'll get an empty string. But that is sufficiently
26 # unique, so we are good at this front.
27
28 @define return_sanitized(indexable, key)
29 %(
30 if (@key in @indexable)
31 return @indexable[@key]
32 else
33 return -1
34 %)
35
36 function syscall_num(name) {
37 %( CONFIG_COMPAT == "y" %?
38 if (@__compat_task)
39 @return_sanitized(__syscall_32_name2num, name)
40 %)
41 %( CONFIG_64BIT == "y" %?
42 @return_sanitized(__syscall_64_name2num, name)
43 %:
44 @return_sanitized(__syscall_32_name2num, name)
45 %)
46 }
47