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"
12 #include "lldb/Utility/Log.h"
13 
14 using namespace lldb_private;
15 
17 
19  llvm::Optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();
20  if (byte_size && *byte_size) {
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());
24  }
25  return const_cast<uint8_t *>(
26  m_frozen_sp->GetDataExtractor().GetDataStart());
27  }
28  return nullptr;
29 }
30 
32 
34  SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
35 
36  if (si != m_symbol_map.end())
37  return si->second;
38  else
39  return LLDB_INVALID_ADDRESS;
40 }
41 
43  lldb::IRExecutionUnitSP &execution_unit_sp) {
45 
46  m_execution_units.insert(execution_unit_sp);
47 
48  LLDB_LOGF(log, "Registering JITted Functions:\n");
49 
50  for (const IRExecutionUnit::JittedFunction &jitted_function :
51  execution_unit_sp->GetJittedFunctions()) {
52  if (jitted_function.m_external &&
53  jitted_function.m_name != execution_unit_sp->GetFunctionName() &&
54  jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
55  m_symbol_map[jitted_function.m_name.GetCString()] =
56  jitted_function.m_remote_addr;
57  LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",
58  jitted_function.m_name.GetCString(),
59  jitted_function.m_remote_addr);
60  }
61  }
62 
63  LLDB_LOGF(log, "Registering JIIted Symbols:\n");
64 
65  for (const IRExecutionUnit::JittedGlobalVariable &global_var :
66  execution_unit_sp->GetJittedGlobalVariables()) {
67  if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {
68  // Demangle the name before inserting it, so that lookups by the ConstStr
69  // of the demangled name will find the mangled one (needed for looking up
70  // metadata pointers.)
71  Mangled mangler(global_var.m_name);
72  mangler.GetDemangledName();
73  m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
74  LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
75  global_var.m_name.GetCString(), global_var.m_remote_addr);
76  }
77  }
78 }
lldb_private::PersistentExpressionState::~PersistentExpressionState
virtual ~PersistentExpressionState()
ExpressionVariable.h
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::IRExecutionUnit::JittedGlobalVariable
Definition: IRExecutionUnit.h:149
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ExpressionVariable::GetValueBytes
uint8_t * GetValueBytes()
Definition: ExpressionVariable.cpp:18
Target.h
LIBLLDB_LOG_EXPRESSIONS
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
lldb_private::ExpressionVariable::m_frozen_sp
lldb::ValueObjectSP m_frozen_sp
Definition: ExpressionVariable.h:110
Log.h
lldb_private::PersistentExpressionState::LookupSymbol
virtual lldb::addr_t LookupSymbol(ConstString name)
Definition: ExpressionVariable.cpp:33
lldb_private::IRExecutionUnit::JittedFunction
Definition: IRExecutionUnit.h:141
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
IRExecutionUnit.h
lldb_private::PersistentExpressionState::RegisterExecutionUnit
void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp)
Definition: ExpressionVariable.cpp:42
lldb_private::ExpressionVariable::~ExpressionVariable
virtual ~ExpressionVariable()
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Log
Definition: Log.h:49
lldb_private::PersistentExpressionState::m_execution_units
ExecutionUnitSet m_execution_units
The execution units that contain valuable symbols.
Definition: ExpressionVariable.h:245
lldb_private::PersistentExpressionState::m_symbol_map
SymbolMap m_symbol_map
The addresses of the symbols in m_execution_units.
Definition: ExpressionVariable.h:249