Path: blob/main/contrib/llvm-project/lldb/source/Expression/ExpressionVariable.cpp
39587 views
//===-- ExpressionVariable.cpp --------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Expression/ExpressionVariable.h"9#include "lldb/Expression/IRExecutionUnit.h"10#include "lldb/Target/Target.h"11#include "lldb/Utility/LLDBLog.h"12#include "lldb/Utility/Log.h"13#include <optional>1415using namespace lldb_private;1617char ExpressionVariable::ID;1819ExpressionVariable::ExpressionVariable() : m_flags(0) {}2021uint8_t *ExpressionVariable::GetValueBytes() {22std::optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();23if (byte_size && *byte_size) {24if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {25m_frozen_sp->GetValue().ResizeData(*byte_size);26m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());27}28return const_cast<uint8_t *>(29m_frozen_sp->GetDataExtractor().GetDataStart());30}31return nullptr;32}3334char PersistentExpressionState::ID;3536PersistentExpressionState::PersistentExpressionState() = default;3738PersistentExpressionState::~PersistentExpressionState() = default;3940lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {41SymbolMap::iterator si = m_symbol_map.find(name.GetCString());4243if (si != m_symbol_map.end())44return si->second;45else46return LLDB_INVALID_ADDRESS;47}4849void PersistentExpressionState::RegisterExecutionUnit(50lldb::IRExecutionUnitSP &execution_unit_sp) {51Log *log = GetLog(LLDBLog::Expressions);5253m_execution_units.insert(execution_unit_sp);5455LLDB_LOGF(log, "Registering JITted Functions:\n");5657for (const IRExecutionUnit::JittedFunction &jitted_function :58execution_unit_sp->GetJittedFunctions()) {59if (jitted_function.m_external &&60jitted_function.m_name != execution_unit_sp->GetFunctionName() &&61jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {62m_symbol_map[jitted_function.m_name.GetCString()] =63jitted_function.m_remote_addr;64LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",65jitted_function.m_name.GetCString(),66jitted_function.m_remote_addr);67}68}6970LLDB_LOGF(log, "Registering JIIted Symbols:\n");7172for (const IRExecutionUnit::JittedGlobalVariable &global_var :73execution_unit_sp->GetJittedGlobalVariables()) {74if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {75// Demangle the name before inserting it, so that lookups by the ConstStr76// of the demangled name will find the mangled one (needed for looking up77// metadata pointers.)78Mangled mangler(global_var.m_name);79mangler.GetDemangledName();80m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;81LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",82global_var.m_name.GetCString(), global_var.m_remote_addr);83}84}85}868788