16#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/StringExtras.h"
19#include "llvm/DebugInfo/CodeView/CodeView.h"
20#include "llvm/DebugInfo/CodeView/EnumTables.h"
21#include "llvm/Support/ScopedPrinter.h"
29 llvm::codeview::CPUType cpu_type;
31 case llvm::Triple::ArchType::aarch64:
32 cpu_type = llvm::codeview::CPUType::ARM64;
36 cpu_type = llvm::codeview::CPUType::X64;
40 llvm::ArrayRef<llvm::EnumEntry<uint16_t>> register_names =
41 llvm::codeview::getRegisterNames(cpu_type);
42 auto it = llvm::find_if(
44 [®_name](
const llvm::EnumEntry<uint16_t> ®ister_entry) {
45 return reg_name.compare_insensitive(register_entry.Name) == 0;
48 if (it == register_names.end())
51 auto reg_id =
static_cast<llvm::codeview::RegisterId
>(it->Value);
56 llvm::StringRef register_name,
57 llvm::Triple::ArchType arch_type,
58 llvm::BumpPtrAllocator &alloc) {
59 std::vector<std::pair<llvm::StringRef, Node *>> parsed =
62 for (
auto it = parsed.begin(), end = parsed.end(); it != end; ++it) {
67 for (const auto &pair : llvm::make_range(parsed.begin(), it)) {
68 if (pair.first == symbol.GetName())
78 return MakeNode<RegisterNode>(alloc, reg_num);
83 if (it->first == register_name) {
93 llvm::StringRef program, llvm::StringRef register_name,
94 llvm::Triple::ArchType arch_type,
Stream &stream) {
95 llvm::BumpPtrAllocator node_alloc;
96 Node *target_program =
98 if (target_program ==
nullptr) {
102 ToDWARF(*target_program, stream);
static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, llvm::Triple::ArchType arch_type)
static Node * ResolveFPOProgram(llvm::StringRef program, llvm::StringRef register_name, llvm::Triple::ArchType arch_type, llvm::BumpPtrAllocator &alloc)
A stream class that can stream formatted output to a file.
The base class for all nodes in the parsed postfix tree.
A node representing a symbolic reference to a named entity.
llvm::StringRef GetName() const
#define LLDB_INVALID_REGNUM
bool TranslateFPOProgramToDWARFExpression(llvm::StringRef program, llvm::StringRef register_name, llvm::Triple::ArchType arch_type, lldb_private::Stream &stream)
uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type, llvm::codeview::RegisterId register_id)
void ToDWARF(Node &node, Stream &stream)
Serialize the given expression tree as DWARF.
bool ResolveSymbols(Node *&node, llvm::function_ref< Node *(SymbolNode &symbol)> replacer)
A utility function for "resolving" SymbolNodes.
std::vector< std::pair< llvm::StringRef, Node * > > ParseFPOProgram(llvm::StringRef prog, llvm::BumpPtrAllocator &alloc)
A class that represents a running process on the host machine.