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 "llvm/Support/Error.h" 15 16 #include <vector> 17 18 #ifdef __ANDROID__ 19 #if defined(__arm64__) || defined(__aarch64__) 20 typedef unsigned long elf_greg_t; 21 typedef elf_greg_t 22 elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))]; 23 typedef struct user_fpsimd_state elf_fpregset_t; 24 #ifndef NT_FPREGSET 25 #define NT_FPREGSET NT_PRFPREG 26 #endif // NT_FPREGSET 27 #elif defined(__mips__) 28 #ifndef NT_FPREGSET 29 #define NT_FPREGSET NT_PRFPREG 30 #endif // NT_FPREGSET 31 #endif 32 #else // __ANDROID__ 33 #include <sys/procfs.h> 34 #endif // __ANDROID__ 35 36 namespace lldb_private { 37 namespace process_linux { 38 39 /// \return 40 /// The content of /proc/cpuinfo and cache it if errors didn't happen. 41 llvm::Expected<llvm::ArrayRef<uint8_t>> GetProcfsCpuInfo(); 42 43 /// \return 44 /// A list of available logical core ids given the contents of 45 /// /proc/cpuinfo. 46 llvm::Expected<std::vector<int>> 47 GetAvailableLogicalCoreIDs(llvm::StringRef cpuinfo); 48 49 /// \return 50 /// A list with all the logical cores available in the system and cache it 51 /// if errors didn't happen. 52 llvm::Expected<llvm::ArrayRef<int>> GetAvailableLogicalCoreIDs(); 53 54 } // namespace process_linux 55 } // namespace lldb_private 56