1 //===-- RegisterUtilities.cpp ---------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "Plugins/Process/elf-core/RegisterUtilities.h"
10 #include "llvm/ADT/STLExtras.h"
13 using namespace lldb_private
;
15 static std::optional
<uint32_t>
16 getNoteType(const llvm::Triple
&Triple
,
17 llvm::ArrayRef
<RegsetDesc
> RegsetDescs
) {
18 for (const auto &Entry
: RegsetDescs
) {
19 if (Entry
.OS
!= Triple
.getOS())
21 if (Entry
.Arch
!= llvm::Triple::UnknownArch
&&
22 Entry
.Arch
!= Triple
.getArch())
29 DataExtractor
lldb_private::getRegset(llvm::ArrayRef
<CoreNote
> Notes
,
30 const llvm::Triple
&Triple
,
31 llvm::ArrayRef
<RegsetDesc
> RegsetDescs
) {
32 auto TypeOr
= getNoteType(Triple
, RegsetDescs
);
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
);