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 = m_frozen_sp->GetByteSize();
24 if (byte_size && *byte_size) {
25 if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {
26 m_frozen_sp->GetValue().ResizeData(*byte_size);
27 m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());
28 }
29 return const_cast<uint8_t *>(
30 m_frozen_sp->GetDataExtractor().GetDataStart());
31 }
32 return nullptr;
33}
34
36
38
40
42 SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
43
44 if (si != m_symbol_map.end())
45 return si->second;
46 else
48}
49
51 lldb::IRExecutionUnitSP &execution_unit_sp) {
53
54 m_execution_units.insert(execution_unit_sp);
55
56 LLDB_LOGF(log, "Registering JITted Functions:\n");
57
58 for (const IRExecutionUnit::JittedFunction &jitted_function :
59 execution_unit_sp->GetJittedFunctions()) {
60 if (jitted_function.m_external &&
61 jitted_function.m_name != execution_unit_sp->GetFunctionName() &&
62 jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
63 m_symbol_map[jitted_function.m_name.GetCString()] =
64 jitted_function.m_remote_addr;
65 LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",
66 jitted_function.m_name.GetCString(),
67 jitted_function.m_remote_addr);
68 }
69 }
70
71 LLDB_LOGF(log, "Registering JIIted Symbols:\n");
72
73 for (const IRExecutionUnit::JittedGlobalVariable &global_var :
74 execution_unit_sp->GetJittedGlobalVariables()) {
75 if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {
76 // Demangle the name before inserting it, so that lookups by the ConstStr
77 // of the demangled name will find the mangled one (needed for looking up
78 // metadata pointers.)
79 Mangled mangler(global_var.m_name);
80 mangler.GetDemangledName();
81 m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
82 LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
83 global_var.m_name.GetCString(), global_var.m_remote_addr);
84 }
85 }
86}
#define LLDB_LOGF(log,...)
Definition: Log.h:366
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
static char ID
LLVM RTTI support.
A class that handles mangled names.
Definition: Mangled.h:33
ConstString GetDemangledName() const
Demangled name get accessor.
Definition: Mangled.cpp:270
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
Definition: lldb-defines.h:82
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:331
std::shared_ptr< lldb_private::IRExecutionUnit > IRExecutionUnitSP
Definition: lldb-forward.h:361
uint64_t addr_t
Definition: lldb-types.h:80
"lldb/Expression/IRExecutionUnit.h" Encapsulates a single function that has been generated by the JIT...