Skip to content

Commit 34b905b

Browse files
giordanoZentrik
authored andcommitted
Define SYS_perf_event_open and SYS_prctl in a single place
1 parent 4701046 commit 34b905b

File tree

1 file changed

+13
-35
lines changed

1 file changed

+13
-35
lines changed

src/LinuxPerf.jl

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -157,28 +157,29 @@ function Base.show(io::IO, e::EventType)
157157
end
158158
end
159159

160-
# To support a new architecture, look for the code corresponding to the `perf_event_open`
161-
# syscall in https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html
162-
const SYS_perf_event_open = if Sys.ARCH === :x86_64
160+
# To support a new architecture, look for the codes corresponding to the
161+
# `perf_event_open` and `prctl` syscalls in
162+
# https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html
163+
const SYS_perf_event_open, SYS_prctl = if Sys.ARCH === :x86_64
163164
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/x86/entry/syscalls/syscall_64.tbl
164-
Clong(298)
165+
Clong(298), Clong(157)
165166
elseif Sys.ARCH === :i686
166167
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/x86/entry/syscalls/syscall_32.tbl
167-
Clong(336)
168+
Clong(336), Clong(172)
168169
elseif Sys.ARCH === :aarch64
169-
# See also https://arm64.syscall.sh/
170-
Clong(241)
170+
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/scripts/syscall.tbl
171+
Clong(241), Clong(167)
171172
elseif Sys.ARCH === :arm
172173
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/arm/tools/syscall.tbl
173-
Clong(364)
174+
Clong(364), Clong(172)
174175
elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
175176
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/powerpc/kernel/syscalls/syscall.tbl
176-
Clong(319)
177+
Clong(319), Clong(171)
177178
elseif Sys.ARCH === :riscv64 || Sys.ARCH === :rv64
178-
# See also https://jborza.com/post/2021-05-11-riscv-linux-syscalls/
179-
Clong(241)
179+
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/scripts/syscall.tbl
180+
Clong(241), Clong(167)
180181
else
181-
Clong(-1) # sentinel for unknown syscall ID
182+
Clong(-1), Clong(-1) # sentinel for unknown syscall ID
182183
end
183184

184185
"""
@@ -350,29 +351,6 @@ function Base.show(io::IO, g::EventGroup)
350351
print(io, "\t", g.event_types[end], ")")
351352
end
352353

353-
# To support a new architecture, look for the code corresponding to the `prctl` syscall in
354-
# https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html
355-
const SYS_prctl = if Sys.ARCH === :x86_64
356-
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/x86/entry/syscalls/syscall_64.tbl
357-
Clong(157)
358-
elseif Sys.ARCH === :i686
359-
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/x86/entry/syscalls/syscall_32.tbl
360-
Clong(172)
361-
elseif Sys.ARCH === :aarch64
362-
# See also https://arm64.syscall.sh/
363-
Clong(167)
364-
elseif Sys.ARCH === :arm
365-
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/arm/tools/syscall.tbl
366-
Clong(172)
367-
elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
368-
# See also https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/powerpc/kernel/syscalls/syscall.tbl
369-
Clong(171)
370-
elseif Sys.ARCH === :riscv64 || Sys.ARCH === :rv64
371-
# See also https://jborza.com/post/2021-05-11-riscv-linux-syscalls/
372-
Clong(167)
373-
else
374-
Clong(-1) # sentinel for unknown syscall ID
375-
end
376354
const PR_TASK_PERF_EVENTS_DISABLE = Cint(31)
377355
const PR_TASK_PERF_EVENTS_ENABLE = Cint(32)
378356

0 commit comments

Comments
 (0)