2015-09-03 08:35:46 +08:00
|
|
|
//===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-09-03 08:35:46 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Expression/ExpressionVariable.h"
|
2016-03-22 06:23:38 +08:00
|
|
|
#include "lldb/Expression/IRExecutionUnit.h"
|
2018-05-01 07:59:17 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2015-09-03 08:35:46 +08:00
|
|
|
|
2015-09-05 04:49:51 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
ExpressionVariable::~ExpressionVariable() {}
|
|
|
|
|
|
|
|
uint8_t *ExpressionVariable::GetValueBytes() {
|
|
|
|
const size_t byte_size = m_frozen_sp->GetByteSize();
|
|
|
|
if (byte_size > 0) {
|
|
|
|
if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size) {
|
|
|
|
m_frozen_sp->GetValue().ResizeData(byte_size);
|
|
|
|
m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());
|
|
|
|
}
|
|
|
|
return const_cast<uint8_t *>(
|
|
|
|
m_frozen_sp->GetDataExtractor().GetDataStart());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2015-09-05 04:49:51 +08:00
|
|
|
}
|
2015-10-01 03:57:57 +08:00
|
|
|
|
|
|
|
PersistentExpressionState::~PersistentExpressionState() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {
|
2016-03-22 06:23:38 +08:00
|
|
|
SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
|
|
|
|
|
|
|
|
if (si != m_symbol_map.end())
|
|
|
|
return si->second;
|
|
|
|
else
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PersistentExpressionState::RegisterExecutionUnit(
|
|
|
|
lldb::IRExecutionUnitSP &execution_unit_sp) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
m_execution_units.insert(execution_unit_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "Registering JITted Functions:\n");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-22 06:23:38 +08:00
|
|
|
for (const IRExecutionUnit::JittedFunction &jitted_function :
|
|
|
|
execution_unit_sp->GetJittedFunctions()) {
|
|
|
|
if (jitted_function.m_external &&
|
|
|
|
jitted_function.m_name != execution_unit_sp->GetFunctionName() &&
|
|
|
|
jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
|
|
|
|
m_symbol_map[jitted_function.m_name.GetCString()] =
|
|
|
|
jitted_function.m_remote_addr;
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",
|
|
|
|
jitted_function.m_name.GetCString(),
|
|
|
|
jitted_function.m_remote_addr);
|
2016-03-22 06:23:38 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "Registering JIIted Symbols:\n");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-22 06:23:38 +08:00
|
|
|
for (const IRExecutionUnit::JittedGlobalVariable &global_var :
|
|
|
|
execution_unit_sp->GetJittedGlobalVariables()) {
|
|
|
|
if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) {
|
|
|
|
// Demangle the name before inserting it, so that lookups by the ConstStr
|
2018-05-01 00:49:04 +08:00
|
|
|
// of the demangled name will find the mangled one (needed for looking up
|
|
|
|
// metadata pointers.)
|
2016-03-22 06:23:38 +08:00
|
|
|
Mangled mangler(global_var.m_name);
|
|
|
|
mangler.GetDemangledName(lldb::eLanguageTypeUnknown);
|
|
|
|
m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
|
|
|
|
global_var.m_name.GetCString(), global_var.m_remote_addr);
|
2016-03-22 06:23:38 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-03-22 06:23:38 +08:00
|
|
|
}
|
2019-08-28 06:50:40 +08:00
|
|
|
|
|
|
|
ConstString PersistentExpressionState::GetNextPersistentVariableName(
|
|
|
|
Target &target, llvm::StringRef Prefix) {
|
|
|
|
llvm::SmallString<64> name;
|
|
|
|
{
|
|
|
|
llvm::raw_svector_ostream os(name);
|
|
|
|
os << Prefix << target.GetNextPersistentVariableIndex();
|
|
|
|
}
|
|
|
|
return ConstString(name);
|
|
|
|
}
|