1 //===-- Procfs.h ---------------------------------------------- -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // source/Plugins/Process/Linux/Procfs.h defines the symbols we need from
10 // sys/procfs.h on Android/Linux for all supported architectures.
11 
12 #include <sys/ptrace.h>
13 
14 #include "lldb/lldb-types.h"
15 
16 #include "llvm/Support/Error.h"
17 
18 #include <vector>
19 
20 #ifdef __ANDROID__
21 #if defined(__arm64__) || defined(__aarch64__)
22 typedef unsigned long elf_greg_t;
23 typedef elf_greg_t
24     elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
25 typedef struct user_fpsimd_state elf_fpregset_t;
26 #ifndef NT_FPREGSET
27 #define NT_FPREGSET NT_PRFPREG
28 #endif // NT_FPREGSET
29 #elif defined(__mips__)
30 #ifndef NT_FPREGSET
31 #define NT_FPREGSET NT_PRFPREG
32 #endif // NT_FPREGSET
33 #endif
34 #else // __ANDROID__
35 #include <sys/procfs.h>
36 #endif // __ANDROID__
37 
38 namespace lldb_private {
39 namespace process_linux {
40 
41 /// \return
42 ///     The content of /proc/cpuinfo and cache it if errors didn't happen.
43 llvm::Expected<llvm::ArrayRef<uint8_t>> GetProcfsCpuInfo();
44 
45 /// \return
46 ///     A list of available logical core ids given the contents of
47 ///     /proc/cpuinfo.
48 llvm::Expected<std::vector<lldb::cpu_id_t>>
49 GetAvailableLogicalCoreIDs(llvm::StringRef cpuinfo);
50 
51 /// \return
52 ///     A list with all the logical cores available in the system and cache it
53 ///     if errors didn't happen.
54 llvm::Expected<llvm::ArrayRef<lldb::cpu_id_t>> GetAvailableLogicalCoreIDs();
55 
56 } // namespace process_linux
57 } // namespace lldb_private
58