LLDB  mainline
ExpressionVariable.cpp
Go to the documentation of this file.
1 //===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===//
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  const size_t byte_size = m_frozen_sp->GetByteSize();
20  if (byte_size > 0) {
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 NULL;
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  if (log)
49  log->Printf("Registering JITted Functions:\n");
50 
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;
58  if (log)
59  log->Printf(" Function: %s at 0x%" PRIx64 ".",
60  jitted_function.m_name.GetCString(),
61  jitted_function.m_remote_addr);
62  }
63  }
64 
65  if (log)
66  log->Printf("Registering JIIted Symbols:\n");
67 
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 will find the mangled one (needed for looking up
73  // 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;
77  if (log)
78  log->Printf(" Symbol: %s at 0x%" PRIx64 ".",
79  global_var.m_name.GetCString(), global_var.m_remote_addr);
80  }
81  }
82 }
83 
85  Target &target, llvm::StringRef Prefix) {
86  llvm::SmallString<64> name;
87  {
88  llvm::raw_svector_ostream os(name);
89  os << Prefix << target.GetNextPersistentVariableIndex();
90  }
91  return ConstString(name);
92 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
unsigned GetNextPersistentVariableIndex()
Return the next available number for numbered persistent variables.
Definition: Target.h:1115
void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
"lldb/Expression/IRExecutionUnit.h" Encapsulates a single function that has been generated by the JIT...
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
ConstString GetNextPersistentVariableName(Target &target, llvm::StringRef prefix)
Return a new persistent variable name with the specified prefix.
uint64_t addr_t
Definition: lldb-types.h:83
A uniqued constant string class.
Definition: ConstString.h:38
Unknown or invalid language value.
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
virtual lldb::addr_t LookupSymbol(ConstString name)
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113