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