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#include <optional>
12
13using namespace lldb_private;
14
15static std::optional<uint32_t>
16getNoteType(const llvm::Triple &Triple,
17 llvm::ArrayRef<RegsetDesc> RegsetDescs) {
18 for (const auto &Entry : RegsetDescs) {
19 if (Entry.OS != Triple.getOS())
20 continue;
21 if (Entry.Arch != llvm::Triple::UnknownArch &&
22 Entry.Arch != Triple.getArch())
23 continue;
24 return Entry.Note;
25 }
26 return std::nullopt;
27}
28
29DataExtractor lldb_private::getRegset(llvm::ArrayRef<CoreNote> Notes,
30 const llvm::Triple &Triple,
31 llvm::ArrayRef<RegsetDesc> RegsetDescs) {
32 auto TypeOr = getNoteType(Triple, RegsetDescs);
33 if (!TypeOr)
34 return DataExtractor();
35 uint32_t Type = *TypeOr;
36 auto Iter = llvm::find_if(
37 Notes, [Type](const CoreNote &Note) { return Note.info.n_type == Type; });
38 return Iter == Notes.end() ? DataExtractor() : DataExtractor(Iter->data);
39}
static std::optional< uint32_t > getNoteType(const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
An data extractor class.
Definition: DataExtractor.h:48
A class that represents a running process on the host machine.
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
elf::elf_word n_type
Definition: ObjectFileELF.h:28