aboutsummaryrefslogtreecommitdiffstats
path: root/source/Expression/Materializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Expression/Materializer.cpp')
-rw-r--r--source/Expression/Materializer.cpp140
1 files changed, 68 insertions, 72 deletions
diff --git a/source/Expression/Materializer.cpp b/source/Expression/Materializer.cpp
index 0f871fcbefbc..cd332484debb 100644
--- a/source/Expression/Materializer.cpp
+++ b/source/Expression/Materializer.cpp
@@ -11,7 +11,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
@@ -46,20 +45,6 @@ uint32_t Materializer::AddStructMember(Entity &entity) {
return ret;
}
-void Materializer::Entity::SetSizeAndAlignmentFromType(CompilerType &type) {
- if (llvm::Optional<uint64_t> size = type.GetByteSize(nullptr))
- m_size = *size;
-
- uint32_t bit_alignment = type.GetTypeBitAlign();
-
- if (bit_alignment % 8) {
- bit_alignment += 8;
- bit_alignment &= ~((uint32_t)0x111u);
- }
-
- m_alignment = bit_alignment / 8;
-}
-
class EntityPersistentVariable : public Materializer::Entity {
public:
EntityPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp,
@@ -94,9 +79,8 @@ public:
return;
}
- if (log)
- log->Printf("Allocated %s (0x%" PRIx64 ") successfully",
- m_persistent_variable_sp->GetName().GetCString(), mem);
+ LLDB_LOGF(log, "Allocated %s (0x%" PRIx64 ") successfully",
+ m_persistent_variable_sp->GetName().GetCString(), mem);
// Put the location of the spare memory into the live data of the
// ValueObject.
@@ -158,11 +142,12 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityPersistentVariable::Materialize [address = 0x%" PRIx64
- ", m_name = %s, m_flags = 0x%hx]",
- (uint64_t)load_addr,
- m_persistent_variable_sp->GetName().AsCString(),
- m_persistent_variable_sp->m_flags);
+ LLDB_LOGF(log,
+ "EntityPersistentVariable::Materialize [address = 0x%" PRIx64
+ ", m_name = %s, m_flags = 0x%hx]",
+ (uint64_t)load_addr,
+ m_persistent_variable_sp->GetName().AsCString(),
+ m_persistent_variable_sp->m_flags);
}
if (m_persistent_variable_sp->m_flags &
@@ -209,12 +194,12 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf(
- "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64
- ", m_name = %s, m_flags = 0x%hx]",
- (uint64_t)process_address + m_offset,
- m_persistent_variable_sp->GetName().AsCString(),
- m_persistent_variable_sp->m_flags);
+ LLDB_LOGF(log,
+ "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64
+ ", m_name = %s, m_flags = 0x%hx]",
+ (uint64_t)process_address + m_offset,
+ m_persistent_variable_sp->GetName().AsCString(),
+ m_persistent_variable_sp->m_flags);
}
if (m_delegate) {
@@ -291,11 +276,10 @@ public:
ExpressionVariable::EVNeedsFreezeDry ||
m_persistent_variable_sp->m_flags &
ExpressionVariable::EVKeepInTarget) {
- if (log)
- log->Printf(
- "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
- m_persistent_variable_sp->GetName().GetCString(), (uint64_t)mem,
- (unsigned long long)m_persistent_variable_sp->GetByteSize());
+ LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
+ m_persistent_variable_sp->GetName().GetCString(),
+ (uint64_t)mem,
+ (unsigned long long)m_persistent_variable_sp->GetByteSize());
// Read the contents of the spare memory area
@@ -441,9 +425,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityVariable::Materialize [address = 0x%" PRIx64
- ", m_variable_sp = %s]",
- (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntityVariable::Materialize [address = 0x%" PRIx64
+ ", m_variable_sp = %s]",
+ (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
}
ExecutionContextScope *scope = frame_sp.get();
@@ -545,12 +530,15 @@ public:
return;
}
- size_t bit_align =
- m_variable_sp->GetType()->GetLayoutCompilerType().GetTypeBitAlign();
- size_t byte_align = (bit_align + 7) / 8;
+ llvm::Optional<size_t> opt_bit_align =
+ m_variable_sp->GetType()->GetLayoutCompilerType().GetTypeBitAlign(scope);
+ if (!opt_bit_align) {
+ err.SetErrorStringWithFormat("can't get the type alignment for %s",
+ m_variable_sp->GetName().AsCString());
+ return;
+ }
- if (!byte_align)
- byte_align = 1;
+ size_t byte_align = (*opt_bit_align + 7) / 8;
Status alloc_error;
const bool zero_memory = false;
@@ -606,9 +594,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityVariable::Dematerialize [address = 0x%" PRIx64
- ", m_variable_sp = %s]",
- (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntityVariable::Dematerialize [address = 0x%" PRIx64
+ ", m_variable_sp = %s]",
+ (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
}
if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
@@ -802,11 +791,14 @@ public:
err.SetErrorString("can't get size of type");
return;
}
- size_t bit_align = m_type.GetTypeBitAlign();
- size_t byte_align = (bit_align + 7) / 8;
- if (!byte_align)
- byte_align = 1;
+ llvm::Optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
+ if (!opt_bit_align) {
+ err.SetErrorStringWithFormat("can't get the type alignment");
+ return;
+ }
+
+ size_t byte_align = (*opt_bit_align + 7) / 8;
Status alloc_error;
const bool zero_memory = true;
@@ -869,20 +861,18 @@ public:
return;
}
- Status type_system_error;
- TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(
- &type_system_error, m_type.GetMinimumLanguage());
+ auto type_system_or_err =
+ target_sp->GetScratchTypeSystemForLanguage(m_type.GetMinimumLanguage());
- if (!type_system) {
+ if (auto error = type_system_or_err.takeError()) {
err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: "
"couldn't get the corresponding type "
"system: %s",
- type_system_error.AsCString());
+ llvm::toString(std::move(error)).c_str());
return;
}
-
PersistentExpressionState *persistent_state =
- type_system->GetPersistentExpressionState();
+ type_system_or_err->GetPersistentExpressionState();
if (!persistent_state) {
err.SetErrorString("Couldn't dematerialize a result variable: "
@@ -1064,9 +1054,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntitySymbol::Materialize [address = 0x%" PRIx64
- ", m_symbol = %s]",
- (uint64_t)load_addr, m_symbol.GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntitySymbol::Materialize [address = 0x%" PRIx64
+ ", m_symbol = %s]",
+ (uint64_t)load_addr, m_symbol.GetName().AsCString());
}
const Address sym_address = m_symbol.GetAddress();
@@ -1110,9 +1101,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntitySymbol::Dematerialize [address = 0x%" PRIx64
- ", m_symbol = %s]",
- (uint64_t)load_addr, m_symbol.GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntitySymbol::Dematerialize [address = 0x%" PRIx64
+ ", m_symbol = %s]",
+ (uint64_t)load_addr, m_symbol.GetName().AsCString());
}
// no work needs to be done
@@ -1179,9 +1171,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityRegister::Materialize [address = 0x%" PRIx64
- ", m_register_info = %s]",
- (uint64_t)load_addr, m_register_info.name);
+ LLDB_LOGF(log,
+ "EntityRegister::Materialize [address = 0x%" PRIx64
+ ", m_register_info = %s]",
+ (uint64_t)load_addr, m_register_info.name);
}
RegisterValue reg_value;
@@ -1241,9 +1234,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityRegister::Dematerialize [address = 0x%" PRIx64
- ", m_register_info = %s]",
- (uint64_t)load_addr, m_register_info.name);
+ LLDB_LOGF(log,
+ "EntityRegister::Dematerialize [address = 0x%" PRIx64
+ ", m_register_info = %s]",
+ (uint64_t)load_addr, m_register_info.name);
}
Status extract_error;
@@ -1380,7 +1374,8 @@ Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"Materializer::Materialize (frame_sp = %p, process_address = 0x%" PRIx64
") materialized:",
static_cast<void *>(frame_sp.get()), process_address);
@@ -1415,9 +1410,10 @@ void Materializer::Dematerializer::Dematerialize(Status &error,
} else {
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf("Materializer::Dematerialize (frame_sp = %p, process_address "
- "= 0x%" PRIx64 ") about to dematerialize:",
- static_cast<void *>(frame_sp.get()), m_process_address);
+ LLDB_LOGF(log,
+ "Materializer::Dematerialize (frame_sp = %p, process_address "
+ "= 0x%" PRIx64 ") about to dematerialize:",
+ static_cast<void *>(frame_sp.get()), m_process_address);
for (EntityUP &entity_up : m_materializer->m_entities)
entity_up->DumpToLog(*m_map, m_process_address, log);
}