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