1 //===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Expression/ExpressionVariable.h"
11 #include "lldb/Expression/IRExecutionUnit.h"
12 #include "lldb/Utility/Log.h"
14 using namespace lldb_private;
16 ExpressionVariable::~ExpressionVariable() {}
18 uint8_t *ExpressionVariable::GetValueBytes() {
19 const size_t byte_size = m_frozen_sp->GetByteSize();
21 if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size) {
22 m_frozen_sp->GetValue().ResizeData(byte_size);
23 m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());
25 return const_cast<uint8_t *>(
26 m_frozen_sp->GetDataExtractor().GetDataStart());
31 PersistentExpressionState::~PersistentExpressionState() {}
33 lldb::addr_t PersistentExpressionState::LookupSymbol(const ConstString &name) {
34 SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
36 if (si != m_symbol_map.end())
39 return LLDB_INVALID_ADDRESS;
42 void PersistentExpressionState::RegisterExecutionUnit(
43 lldb::IRExecutionUnitSP &execution_unit_sp) {
44 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
46 m_execution_units.insert(execution_unit_sp);
49 log->Printf("Registering JITted Functions:\n");
51 for (const IRExecutionUnit::JittedFunction &jitted_function :
52 execution_unit_sp->GetJittedFunctions()) {
53 if (jitted_function.m_external &&
54 jitted_function.m_name != execution_unit_sp->GetFunctionName() &&
55 jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
56 m_symbol_map[jitted_function.m_name.GetCString()] =
57 jitted_function.m_remote_addr;
59 log->Printf(" Function: %s at 0x%" PRIx64 ".",
60 jitted_function.m_name.GetCString(),
61 jitted_function.m_remote_addr);
66 log->Printf("Registering JIIted Symbols:\n");
68 for (const IRExecutionUnit::JittedGlobalVariable &global_var :
69 execution_unit_sp->GetJittedGlobalVariables()) {
70 if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {
71 // Demangle the name before inserting it, so that lookups by the ConstStr
72 // of the demangled name
73 // will find the mangled one (needed for looking up metadata pointers.)
74 Mangled mangler(global_var.m_name);
75 mangler.GetDemangledName(lldb::eLanguageTypeUnknown);
76 m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
78 log->Printf(" Symbol: %s at 0x%" PRIx64 ".",
79 global_var.m_name.GetCString(), global_var.m_remote_addr);