LLDB  mainline
RegisterUtilities.cpp
Go to the documentation of this file.
1 //===-- RegisterUtilities.cpp ---------------------------------------------===//
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 
10 #include "llvm/ADT/STLExtras.h"
11 
12 using namespace lldb_private;
13 
14 static llvm::Optional<uint32_t>
15 getNoteType(const llvm::Triple &Triple,
16  llvm::ArrayRef<RegsetDesc> RegsetDescs) {
17  for (const auto &Entry : RegsetDescs) {
18  if (Entry.OS != Triple.getOS())
19  continue;
20  if (Entry.Arch != llvm::Triple::UnknownArch &&
21  Entry.Arch != Triple.getArch())
22  continue;
23  return Entry.Note;
24  }
25  return llvm::None;
26 }
27 
28 DataExtractor lldb_private::getRegset(llvm::ArrayRef<CoreNote> Notes,
29  const llvm::Triple &Triple,
30  llvm::ArrayRef<RegsetDesc> RegsetDescs) {
31  auto TypeOr = getNoteType(Triple, RegsetDescs);
32  if (!TypeOr)
33  return DataExtractor();
34  uint32_t Type = *TypeOr;
35  auto Iter = llvm::find_if(
36  Notes, [Type](const CoreNote &Note) { return Note.info.n_type == Type; });
37  return Iter == Notes.end() ? DataExtractor() : DataExtractor(Iter->data);
38 }
getNoteType
static llvm::Optional< uint32_t > getNoteType(const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:15
RegisterUtilities.h
ELFNote::n_type
elf::elf_word n_type
Definition: ObjectFileELF.h:27
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::CoreNote::info
ELFNote info
Definition: RegisterUtilities.h:74
lldb_private::getRegset
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:28
uint32_t
lldb_private::Type
Definition: Type.h:66
lldb_private::FormatEntity::Entry
Definition: FormatEntity.h:40
lldb_private::CoreNote
Definition: RegisterUtilities.h:73
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16