LLDB mainline
ExpressionVariable.cpp
Go to the documentation of this file.
1//===-- ExpressionVariable.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
11#include "lldb/Target/Target.h"
13#include "lldb/Utility/Log.h"
14#include <optional>
15
16using namespace lldb_private;
17
19
21
23 std::optional<uint64_t> byte_size =
24 llvm::expectedToOptional(m_frozen_sp->GetByteSize());
25 if (byte_size && *byte_size) {
26 if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {
27 m_frozen_sp->GetValue().ResizeData(*byte_size);
28 m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());
29 }
30 return const_cast<uint8_t *>(
31 m_frozen_sp->GetDataExtractor().GetDataStart());
32 }
33 return nullptr;
34}
35
37
39
41
43 SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
44
45 if (si != m_symbol_map.end())
46 return si->second;
47 else
49}
50
52 lldb::IRExecutionUnitSP &execution_unit_sp) {
54
55 m_execution_units.insert(execution_unit_sp);
56
57 LLDB_LOGF(log, "Registering JITted Functions:\n");
58
59 for (const IRExecutionUnit::JittedFunction &jitted_function :
60 execution_unit_sp->GetJittedFunctions()) {
61 if (jitted_function.m_external &&
62 jitted_function.m_name != execution_unit_sp->GetFunctionName() &&
63 jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
64 m_symbol_map[jitted_function.m_name.GetCString()] =
65 jitted_function.m_remote_addr;
66 LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",
67 jitted_function.m_name.GetCString(),
68 jitted_function.m_remote_addr);
69 }
70 }
71
72 LLDB_LOGF(log, "Registering JIIted Symbols:\n");
73
74 for (const IRExecutionUnit::JittedGlobalVariable &global_var :
75 execution_unit_sp->GetJittedGlobalVariables()) {
76 if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {
77 // Demangle the name before inserting it, so that lookups by the ConstStr
78 // of the demangled name will find the mangled one (needed for looking up
79 // metadata pointers.)
80 Mangled mangler(global_var.m_name);
81 mangler.GetDemangledName();
82 m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
83 LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
84 global_var.m_name.GetCString(), global_var.m_remote_addr);
85 }
86 }
87}
#define LLDB_LOGF(log,...)
Definition Log.h:376
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
lldb::ValueObjectSP m_frozen_sp
These members should be private.
static char ID
LLVM RTTI support.
A class that handles mangled names.
Definition Mangled.h:34
ConstString GetDemangledName() const
Demangled name get accessor.
Definition Mangled.cpp:284
void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp)
ExecutionUnitSet m_execution_units
The execution units that contain valuable symbols.
SymbolMap m_symbol_map
The addresses of the symbols in m_execution_units.
virtual lldb::addr_t LookupSymbol(ConstString name)
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
std::shared_ptr< lldb_private::IRExecutionUnit > IRExecutionUnitSP
uint64_t addr_t
Definition lldb-types.h:80
"lldb/Expression/IRExecutionUnit.h" Encapsulates a single function that has been generated by the JIT...