[Lldb-commits] [lldb] [lldb] DRAFT All ValueObjectSP instances are now valid (non-null) but have an error state (PR #74912)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 19 14:11:52 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c8418c4a19dac494069559918b3e4ea505ddf148 63b1cca8660e40d612e43496d3ff07c48bafa628 -- lldb/include/lldb/Breakpoint/Watchpoint.h lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectConstResult.h lldb/include/lldb/Core/ValueObjectConstResultCast.h lldb/include/lldb/Core/ValueObjectConstResultChild.h lldb/include/lldb/Core/ValueObjectConstResultImpl.h lldb/include/lldb/Core/ValueObjectList.h lldb/include/lldb/Core/ValueObjectRegister.h lldb/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/include/lldb/Core/ValueObjectUpdater.h lldb/include/lldb/DataFormatters/TypeSynthetic.h lldb/include/lldb/DataFormatters/ValueObjectPrinter.h lldb/include/lldb/DataFormatters/VectorIterator.h lldb/include/lldb/Expression/ExpressionVariable.h lldb/include/lldb/Expression/UserExpression.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/include/lldb/Target/LanguageRuntime.h lldb/include/lldb/Target/StackFrame.h lldb/include/lldb/Target/StackFrameRecognizer.h lldb/include/lldb/Target/Target.h lldb/include/lldb/Target/Thread.h lldb/include/lldb/Target/ThreadPlan.h lldb/include/lldb/Target/ThreadPlanCallFunction.h lldb/include/lldb/lldb-forward.h lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Breakpoint/Watchpoint.cpp lldb/source/Commands/CommandObjectDWIMPrint.cpp lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectThread.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Commands/CommandObjectWatchpoint.cpp lldb/source/Core/FormatEntity.cpp lldb/source/Core/IOHandlerCursesGUI.cpp lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectConstResult.cpp lldb/source/Core/ValueObjectConstResultCast.cpp lldb/source/Core/ValueObjectConstResultChild.cpp lldb/source/Core/ValueObjectConstResultImpl.cpp lldb/source/Core/ValueObjectList.cpp lldb/source/Core/ValueObjectRegister.cpp lldb/source/Core/ValueObjectSyntheticFilter.cpp lldb/source/Core/ValueObjectUpdater.cpp lldb/source/DataFormatters/FormatManager.cpp lldb/source/DataFormatters/TypeSynthetic.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/source/DataFormatters/VectorType.cpp lldb/source/Expression/ExpressionVariable.cpp lldb/source/Target/StackFrame.cpp lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h
index 237363d67a..42b7d64d6a 100644
--- a/lldb/include/lldb/Core/ValueObjectList.h
+++ b/lldb/include/lldb/Core/ValueObjectList.h
@@ -53,6 +53,7 @@ public:
const std::vector<std::optional<lldb::ValueObjectSP>> &GetObjects() const {
return m_value_objects;
}
+
protected:
typedef std::vector<std::optional<lldb::ValueObjectSP>> collection;
// Classes that inherit from ValueObjectList can see and modify these
diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
index fd8323728b..70175e347d 100644
--- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -101,7 +101,8 @@ protected:
void PrintChildrenPostamble(bool print_dotdotdot);
- std::optional<lldb::ValueObjectSP> GenerateChild(ValueObject *synth_valobj, size_t idx);
+ std::optional<lldb::ValueObjectSP> GenerateChild(ValueObject *synth_valobj,
+ size_t idx);
void PrintChild(lldb::ValueObjectSP child_sp,
const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h
index f81a52032e..83643878c4 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -33,24 +33,25 @@ public:
virtual ~ExpressionVariable() = default;
- std::optional<uint64_t> GetByteSize() {
- if (m_frozen_sp)
- return m_frozen_sp.value()->GetByteSize();
- else
- return {};
- }
+ std::optional<uint64_t> GetByteSize() {
+ if (m_frozen_sp)
+ return m_frozen_sp.value()->GetByteSize();
+ else
+ return {};
+ }
ConstString GetName() {
- return m_frozen_sp ? m_frozen_sp.value()->GetName() : ConstString(""); }
+ return m_frozen_sp ? m_frozen_sp.value()->GetName() : ConstString("");
+ }
std::optional<lldb::ValueObjectSP> GetValueObject() { return m_frozen_sp; }
uint8_t *GetValueBytes();
- void ValueUpdated() {
- if (m_frozen_sp)
- m_frozen_sp.value()->ValueUpdated();
- }
+ void ValueUpdated() {
+ if (m_frozen_sp)
+ m_frozen_sp.value()->ValueUpdated();
+ }
RegisterInfo *GetRegisterInfo() {
if (m_frozen_sp)
@@ -60,20 +61,24 @@ public:
void SetRegisterInfo(const RegisterInfo *reg_info) {
if (m_frozen_sp)
- return m_frozen_sp.value()->GetValue().SetContext(
- Value::ContextType::RegisterInfo, const_cast<RegisterInfo *>(reg_info));
+ return m_frozen_sp.value()->GetValue().SetContext(
+ Value::ContextType::RegisterInfo,
+ const_cast<RegisterInfo *>(reg_info));
}
- CompilerType GetCompilerType() { return m_frozen_sp.value()->GetCompilerType(); }
+ CompilerType GetCompilerType() {
+ return m_frozen_sp.value()->GetCompilerType();
+ }
void SetCompilerType(const CompilerType &compiler_type) {
if (m_frozen_sp)
- m_frozen_sp.value()->GetValue().SetCompilerType(compiler_type);
+ m_frozen_sp.value()->GetValue().SetCompilerType(compiler_type);
}
void SetName(ConstString name) {
if (m_frozen_sp)
- m_frozen_sp.value()->SetName(name); }
+ m_frozen_sp.value()->SetName(name);
+ }
// this function is used to copy the address-of m_live_sp into m_frozen_sp
// this is necessary because the results of certain cast and pointer-
@@ -89,7 +94,8 @@ public:
if (!m_frozen_sp)
return;
- if (force || (m_frozen_sp.value()->GetLiveAddress() == LLDB_INVALID_ADDRESS))
+ if (force ||
+ (m_frozen_sp.value()->GetLiveAddress() == LLDB_INVALID_ADDRESS))
m_frozen_sp.value()->SetLiveAddress(m_live_sp.value()->GetLiveAddress());
}
@@ -123,8 +129,8 @@ public:
FlagType m_flags; // takes elements of Flags
// these should be private
- std::optional<lldb::ValueObjectSP> m_frozen_sp;
- std::optional<lldb::ValueObjectSP> m_live_sp;
+ std::optional<lldb::ValueObjectSP> m_frozen_sp;
+ std::optional<lldb::ValueObjectSP> m_live_sp;
};
/// \class ExpressionVariableList ExpressionVariable.h
diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h
index 24c50f29ff..2f5ae9d103 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -307,7 +307,7 @@ public:
///
/// \return
/// A shared pointer to the ValueObject described by var_expr.
- std::optional<lldb::ValueObjectSP> GetValueForVariableExpressionPath(
+ std::optional<lldb::ValueObjectSP> GetValueForVariableExpressionPath(
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
uint32_t options, lldb::VariableSP &var_sp, Status &error);
@@ -439,7 +439,7 @@ public:
///
/// \return
/// A ValueObject for this variable.
- std::optional<lldb::ValueObjectSP>
+ std::optional<lldb::ValueObjectSP>
GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp,
lldb::DynamicValueType use_dynamic);
@@ -463,7 +463,7 @@ public:
///
/// \return
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
- std::optional<lldb::ValueObjectSP> GuessValueForAddress(lldb::addr_t addr);
+ std::optional<lldb::ValueObjectSP> GuessValueForAddress(lldb::addr_t addr);
/// Attempt to reconstruct the ValueObject for the address contained in a
/// given register plus an offset. The ExpressionPath should indicate how
@@ -477,8 +477,8 @@ public:
///
/// \return
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
- std::optional<lldb::ValueObjectSP> GuessValueForRegisterAndOffset(ConstString reg,
- int64_t offset);
+ std::optional<lldb::ValueObjectSP>
+ GuessValueForRegisterAndOffset(ConstString reg, int64_t offset);
/// Attempt to reconstruct the ValueObject for a variable with a given \a name
/// from within the current StackFrame, within the current block. The search
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 49749b4890..ae87411aeb 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -720,7 +720,8 @@ protected:
options.SetFormat(m_option_format.GetFormat());
options.SetVariableFormatDisplayLanguage(
rec_value_sp.value()->GetPreferredDisplayLanguage());
- options.SetRootValueObjectName(rec_value_sp.value()->GetName().AsCString());
+ options.SetRootValueObjectName(
+ rec_value_sp.value()->GetName().AsCString());
rec_value_sp.value()->Dump(result.GetOutputStream(), options);
}
}
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 659b804a2c..f1b888b59f 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2870,13 +2870,15 @@ protected:
std::string description(formatter_sp->GetDescription());
result.GetOutputStream()
<< m_formatter_name << " applied to ("
- << result_valobj_sp.value()->GetDisplayTypeName().AsCString("<unknown>")
+ << result_valobj_sp.value()->GetDisplayTypeName().AsCString(
+ "<unknown>")
<< ") " << command << " is: " << description << "\n";
result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
} else {
result.GetOutputStream()
<< "no " << m_formatter_name << " applies to ("
- << result_valobj_sp.value()->GetDisplayTypeName().AsCString("<unknown>")
+ << result_valobj_sp.value()->GetDisplayTypeName().AsCString(
+ "<unknown>")
<< ") " << command << "\n";
result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult);
}
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index a892be3b9c..680cb0d44d 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -608,8 +608,8 @@ static bool DumpRegister(Stream &s, StackFrame *frame, RegisterKind reg_kind,
return false;
}
-static std::optional<ValueObjectSP> ExpandIndexedExpression(ValueObject *valobj, size_t index,
- bool deref_pointer) {
+static std::optional<ValueObjectSP>
+ExpandIndexedExpression(ValueObject *valobj, size_t index, bool deref_pointer) {
Log *log = GetLog(LLDBLog::DataFormatters);
std::string name_to_deref = llvm::formatv("[{0}]", index);
LLDB_LOG(log, "[ExpandIndexedExpression] name to deref: {0}", name_to_deref);
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index de1b9616de..9cf91b0701 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -4496,8 +4496,7 @@ struct Row {
std::vector<Row> children;
Row(const ValueObjectSP &v, Row *p)
- : value(v), parent(p),
- might_have_children(v->MightHaveChildren()) {}
+ : value(v), parent(p), might_have_children(v->MightHaveChildren()) {}
size_t GetDepth() const {
if (parent)
@@ -5939,7 +5938,8 @@ public:
std::optional<ValueObjectSP> value_sp =
frame->GetValueObjectForFrameVariable(local_sp, use_dynamic);
if (value_sp) {
- std::optional<ValueObjectSP> synthetic_value_sp = value_sp.value()->GetSyntheticValue();
+ std::optional<ValueObjectSP> synthetic_value_sp =
+ value_sp.value()->GetSyntheticValue();
if (synthetic_value_sp)
local_values.Append(synthetic_value_sp.value());
else
diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp
index 7affea7bb0..05edacbfe3 100644
--- a/lldb/source/Core/ValueObjectConstResult.cpp
+++ b/lldb/source/Core/ValueObjectConstResult.cpp
@@ -248,9 +248,11 @@ lldb::ValueObjectSP ValueObjectConstResult::Dereference() {
return m_impl.Dereference();
}
-std::optional<lldb::ValueObjectSP> ValueObjectConstResult::GetSyntheticChildAtOffset(
- uint32_t offset, const CompilerType &type, bool can_create,
- ConstString name_const_str) {
+std::optional<lldb::ValueObjectSP>
+ValueObjectConstResult::GetSyntheticChildAtOffset(uint32_t offset,
+ const CompilerType &type,
+ bool can_create,
+ ConstString name_const_str) {
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create,
name_const_str);
}
diff --git a/lldb/source/Core/ValueObjectConstResultCast.cpp b/lldb/source/Core/ValueObjectConstResultCast.cpp
index 615df5bbaa..57c711b8b5 100644
--- a/lldb/source/Core/ValueObjectConstResultCast.cpp
+++ b/lldb/source/Core/ValueObjectConstResultCast.cpp
@@ -33,7 +33,8 @@ lldb::ValueObjectSP ValueObjectConstResultCast::Dereference() {
return m_impl.Dereference();
}
-std::optional<lldb::ValueObjectSP> ValueObjectConstResultCast::GetSyntheticChildAtOffset(
+std::optional<lldb::ValueObjectSP>
+ValueObjectConstResultCast::GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str) {
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create,
diff --git a/lldb/source/Core/ValueObjectConstResultChild.cpp b/lldb/source/Core/ValueObjectConstResultChild.cpp
index 5cebd034b1..a789702774 100644
--- a/lldb/source/Core/ValueObjectConstResultChild.cpp
+++ b/lldb/source/Core/ValueObjectConstResultChild.cpp
@@ -40,7 +40,8 @@ lldb::ValueObjectSP ValueObjectConstResultChild::Dereference() {
return m_impl.Dereference();
}
-std::optional<lldb::ValueObjectSP> ValueObjectConstResultChild::GetSyntheticChildAtOffset(
+std::optional<lldb::ValueObjectSP>
+ValueObjectConstResultChild::GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str) {
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create,
diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp
index 734395d19d..cd26f6873e 100644
--- a/lldb/source/Core/ValueObjectConstResultImpl.cpp
+++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp
@@ -40,7 +40,8 @@ ValueObjectConstResultImpl::ValueObjectConstResultImpl(
lldb::ValueObjectSP ValueObjectConstResultImpl::Dereference() {
if (m_impl_backend == nullptr) {
Status error;
- error.SetErrorString("Unable to dereference result because the implementation details backend is null.");
+ error.SetErrorString("Unable to dereference result because the "
+ "implementation details backend is null.");
return ValueObjectConstResult::Create(nullptr, error);
}
@@ -112,7 +113,8 @@ ValueObject *ValueObjectConstResultImpl::CreateChildAtIndex(
return valobj;
}
-std::optional<lldb::ValueObjectSP> ValueObjectConstResultImpl::GetSyntheticChildAtOffset(
+std::optional<lldb::ValueObjectSP>
+ValueObjectConstResultImpl::GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str) {
if (m_impl_backend == nullptr)
@@ -128,7 +130,8 @@ lldb::ValueObjectSP ValueObjectConstResultImpl::AddressOf() {
if (m_impl_backend == nullptr) {
Status error;
- error.SetErrorString("Unable to get address because the implementation details backend is null.");
+ error.SetErrorString("Unable to get address because the implementation "
+ "details backend is null.");
return ValueObjectConstResult::Create(nullptr, error);
}
@@ -146,7 +149,8 @@ lldb::ValueObjectSP ValueObjectConstResultImpl::AddressOf() {
ConstString(new_name.c_str()), buffer, endian::InlHostByteOrder(),
exe_ctx.GetAddressByteSize());
- m_address_of_backend.value()->GetValue().SetValueType(Value::ValueType::Scalar);
+ m_address_of_backend.value()->GetValue().SetValueType(
+ Value::ValueType::Scalar);
m_address_of_backend.value()->GetValue().GetScalar() = m_live_address;
return m_address_of_backend.value();
@@ -158,7 +162,8 @@ lldb::ValueObjectSP
ValueObjectConstResultImpl::Cast(const CompilerType &compiler_type) {
if (m_impl_backend == nullptr) {
Status error;
- error.SetErrorString("Unable to cast because the implementation details backend is null.");
+ error.SetErrorString(
+ "Unable to cast because the implementation details backend is null.");
return ValueObjectConstResult::Create(nullptr, error);
}
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index 29fc237260..b540c231d5 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -483,7 +483,8 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
// also ask the child's type if it has any opinion
CompilerType child_compiler_type(child_sp.value()->GetCompilerType());
if (child_compiler_type.IsValid()) {
- switch (child_compiler_type.ShouldPrintAsOneLiner(child_sp.value().get())) {
+ switch (
+ child_compiler_type.ShouldPrintAsOneLiner(child_sp.value().get())) {
case eLazyBoolYes:
// an opinion of yes is only binding for the child, so keep going
case eLazyBoolCalculate:
@@ -497,7 +498,8 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
// if we decided to define synthetic children for a type, we probably care
// enough to show them, but avoid nesting children in children
if (child_sp.value()->GetSyntheticChildren().get() != nullptr) {
- std::optional<ValueObjectSP> synth_sp(child_sp.value()->GetSyntheticValue());
+ std::optional<ValueObjectSP> synth_sp(
+ child_sp.value()->GetSyntheticValue());
// wait.. wat? just get out of here..
if (!synth_sp)
return false;
@@ -520,7 +522,8 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
// if a summary is there..
if (child_sp.value()->GetSummaryFormat()) {
// and it wants children, then bail out
- if (child_sp.value()->GetSummaryFormat()->DoesPrintChildren(child_sp->get()))
+ if (child_sp.value()->GetSummaryFormat()->DoesPrintChildren(
+ child_sp->get()))
return false;
}
@@ -531,7 +534,8 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
// bailed out anyway
// so this only makes us bail out if this has no summary and we would
// then print children)
- if (!child_sp.value()->GetSummaryFormat() && !is_synth_val) // but again only do
+ if (!child_sp.value()->GetSummaryFormat() &&
+ !is_synth_val) // but again only do
// that if not a
// synthetic valued
// child
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 76713dc58f..2e1722ca57 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -115,7 +115,8 @@ std::string CXXSyntheticChildren::GetDescription() {
return std::string(sstr.GetString());
}
-std::optional<lldb::ValueObjectSP> SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
+std::optional<lldb::ValueObjectSP>
+SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
llvm::StringRef name, llvm::StringRef expression,
const ExecutionContext &exe_ctx) {
std::optional<ValueObjectSP> valobj_sp(
@@ -125,7 +126,8 @@ std::optional<lldb::ValueObjectSP> SyntheticChildrenFrontEnd::CreateValueObjectF
return valobj_sp;
}
-std::optional<lldb::ValueObjectSP> SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
+std::optional<lldb::ValueObjectSP>
+SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
CompilerType type) {
std::optional<ValueObjectSP> valobj_sp(
@@ -211,7 +213,8 @@ size_t ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(
name.GetCString());
}
-std::optional<ValueObjectSP> ScriptedSyntheticChildren::FrontEnd::GetSyntheticValue() {
+std::optional<ValueObjectSP>
+ScriptedSyntheticChildren::FrontEnd::GetSyntheticValue() {
if (!m_wrapper_sp || m_interpreter == nullptr)
return {};
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index e7aaccaf30..ccb1053069 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -126,7 +126,7 @@ bool ValueObjectPrinter::GetMostSpecializedValue() {
} else {
if (m_options.m_use_dynamic != eNoDynamicValues) {
ValueObject *dynamic_value =
- m_orig_valobj->GetDynamicValue(m_options.m_use_dynamic)->get();
+ m_orig_valobj->GetDynamicValue(m_options.m_use_dynamic)->get();
if (dynamic_value)
m_valobj = dynamic_value;
else
@@ -679,8 +679,8 @@ static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride,
return base + logical * stride;
}
-std::optional<ValueObjectSP> ValueObjectPrinter::GenerateChild(ValueObject *synth_valobj,
- size_t idx) {
+std::optional<ValueObjectSP>
+ValueObjectPrinter::GenerateChild(ValueObject *synth_valobj, size_t idx) {
if (m_options.m_pointer_as_array) {
// if generating pointer-as-array children, use GetSyntheticArrayMember
return synth_valobj->GetSyntheticArrayMember(
@@ -705,7 +705,8 @@ void ValueObjectPrinter::PrintChildren(
bool any_children_printed = false;
for (size_t idx = 0; idx < num_children; ++idx) {
- if (std::optional<ValueObjectSP> child_sp = GenerateChild(synth_m_valobj, idx)) {
+ if (std::optional<ValueObjectSP> child_sp =
+ GenerateChild(synth_m_valobj, idx)) {
if (m_options.m_child_printing_decider &&
!m_options.m_child_printing_decider(child_sp.value()->GetName()))
continue;
@@ -759,7 +760,8 @@ bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names) {
bool did_print_children = false;
for (uint32_t idx = 0; idx < num_children; ++idx) {
- std::optional<ValueObjectSP> child_sp(synth_m_valobj->GetChildAtIndex(idx));
+ std::optional<ValueObjectSP> child_sp(
+ synth_m_valobj->GetChildAtIndex(idx));
if (child_sp)
child_sp = child_sp.value()->GetQualifiedRepresentationIfAvailable(
m_options.m_use_dynamic, m_options.m_use_synthetic);
diff --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp
index bd5b531d14..0ee3d8bcca 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -27,7 +27,8 @@ uint8_t *ExpressionVariable::GetValueBytes() {
if (byte_size && *byte_size) {
if (m_frozen_sp.value()->GetDataExtractor().GetByteSize() < *byte_size) {
m_frozen_sp.value()->GetValue().ResizeData(*byte_size);
- m_frozen_sp.value()->GetValue().GetData(m_frozen_sp.value()->GetDataExtractor());
+ m_frozen_sp.value()->GetValue().GetData(
+ m_frozen_sp.value()->GetDataExtractor());
}
return const_cast<uint8_t *>(
m_frozen_sp.value()->GetDataExtractor().GetDataStart());
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index d1861ff48e..013d6e8900 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -648,12 +648,15 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
// If we have a non pointer type with a sythetic value then lets check if
// we have an sythetic dereference specified.
- if (!valobj_sp.value()->IsPointerType() && valobj_sp.value()->HasSyntheticValue()) {
+ if (!valobj_sp.value()->IsPointerType() &&
+ valobj_sp.value()->HasSyntheticValue()) {
if (valobj_sp.value()->GetCompilerType().IsReferenceType()) {
- valobj_sp = valobj_sp.value()->GetSyntheticValue().value()->Dereference();
+ valobj_sp =
+ valobj_sp.value()->GetSyntheticValue().value()->Dereference();
if (valobj_sp.value()->GetError().Fail()) {
error.SetErrorStringWithFormatv(
- "Failed to dereference reference type: %s", valobj_sp.value()->GetError());
+ "Failed to dereference reference type: %s",
+ valobj_sp.value()->GetError());
return {};
}
}
@@ -661,7 +664,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
valobj_sp = valobj_sp.value()->Dereference();
if (valobj_sp.value()->GetError().Fail()) {
error.SetErrorStringWithFormatv(
- "Failed to dereference sythetic value: {0}", valobj_sp.value()->GetError());
+ "Failed to dereference sythetic value: {0}",
+ valobj_sp.value()->GetError());
return {};
}
// Some synthetic plug-ins fail to set the error in Dereference
@@ -790,7 +794,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
if (index_expr.empty()) {
// The entire index expression was a single integer.
- if (valobj_sp.value()->GetCompilerType().IsPointerToScalarType() && deref) {
+ if (valobj_sp.value()->GetCompilerType().IsPointerToScalarType() &&
+ deref) {
// what we have is *ptr[low]. the most similar C++ syntax is to deref
// ptr and extract bit low out of it. reading array item low would be
// done by saying ptr[low], without a deref * sign
@@ -811,7 +816,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
// arr[0] (an operation that is equivalent to deref-ing arr) and
// extract bit low out of it. reading array item low would be done by
// saying arr[low], without a deref * sign
- std::optional<ValueObjectSP> temp(valobj_sp.value()->GetChildAtIndex(0));
+ std::optional<ValueObjectSP> temp(
+ valobj_sp.value()->GetChildAtIndex(0));
if (!temp) {
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
@@ -845,7 +851,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
} else if (is_objc_pointer) {
// dereferencing ObjC variables is not valid.. so let's try and
// recur to synthetic children
- std::optional<ValueObjectSP> synthetic = valobj_sp.value()->GetSyntheticValue();
+ std::optional<ValueObjectSP> synthetic =
+ valobj_sp.value()->GetSyntheticValue();
if (!synthetic /* no synthetic */
|| synthetic == valobj_sp) /* synthetic is the same as
the original object */
@@ -856,9 +863,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
valobj_sp.value()->GetTypeName().AsCString("<invalid type>"),
var_expr_path_strm.GetData());
} else if (
- static_cast<uint32_t>(child_index) >=
- synthetic.value()
- ->GetNumChildren() /* synthetic does not have that many values */) {
+ static_cast<uint32_t>(child_index) >= synthetic.value()
+ ->GetNumChildren() /* synthetic does not have that many values */) {
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
@@ -870,7 +876,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
- valobj_sp.value()->GetTypeName().AsCString("<invalid type>"),
+ valobj_sp.value()->GetTypeName().AsCString(
+ "<invalid type>"),
var_expr_path_strm.GetData());
}
}
@@ -916,7 +923,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
var_expr_path_strm.GetData());
}
} else {
- std::optional<ValueObjectSP> synthetic = valobj_sp.value()->GetSyntheticValue();
+ std::optional<ValueObjectSP> synthetic =
+ valobj_sp.value()->GetSyntheticValue();
if (no_synth_child /* synthetic is forbidden */ ||
!synthetic /* no synthetic */
|| synthetic == valobj_sp) /* synthetic is the same as the
@@ -927,10 +935,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
"\"(%s) %s\" is not an array type",
valobj_sp.value()->GetTypeName().AsCString("<invalid type>"),
var_expr_path_strm.GetData());
- } else if (
- static_cast<uint32_t>(child_index) >=
- synthetic.value()
- ->GetNumChildren() /* synthetic does not have that many values */) {
+ } else if (static_cast<uint32_t>(
+ child_index) >= synthetic.value()->GetNumChildren() /* synthetic does not have that many values */) {
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
@@ -986,7 +992,8 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
final_index = temp;
}
- if (valobj_sp.value()->GetCompilerType().IsPointerToScalarType() && deref) {
+ if (valobj_sp.value()->GetCompilerType().IsPointerToScalarType() &&
+ deref) {
// what we have is *ptr[low-high]. the most similar C++ syntax is to
// deref ptr and extract bits low thru high out of it. reading array
// items low thru high would be done by saying ptr[low-high], without a
@@ -1002,12 +1009,14 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
}
valobj_sp = temp;
deref = false;
- } else if (valobj_sp.value()->GetCompilerType().IsArrayOfScalarType() && deref) {
+ } else if (valobj_sp.value()->GetCompilerType().IsArrayOfScalarType() &&
+ deref) {
// what we have is *arr[low-high]. the most similar C++ syntax is to
// get arr[0] (an operation that is equivalent to deref-ing arr) and
// extract bits low thru high out of it. reading array items low thru
// high would be done by saying arr[low-high], without a deref * sign
- std::optional<ValueObjectSP> temp(valobj_sp.value()->GetChildAtIndex(0));
+ std::optional<ValueObjectSP> temp(
+ valobj_sp.value()->GetChildAtIndex(0));
if (!temp) {
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
@@ -1020,13 +1029,14 @@ std::optional<ValueObjectSP> StackFrame::GetValueForVariableExpressionPath(
deref = false;
}
- child_valobj_sp =
- valobj_sp.value()->GetSyntheticBitFieldChild(child_index, final_index, true);
+ child_valobj_sp = valobj_sp.value()->GetSyntheticBitFieldChild(
+ child_index, final_index, true);
if (!child_valobj_sp) {
valobj_sp.value()->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index,
- final_index, valobj_sp.value()->GetTypeName().AsCString("<invalid type>"),
+ final_index,
+ valobj_sp.value()->GetTypeName().AsCString("<invalid type>"),
var_expr_path_strm.GetData());
}
@@ -1174,7 +1184,8 @@ StackFrame::GetValueObjectForFrameVariable(const VariableSP &variable_sp,
if (!valobj_sp) {
if (m_variable_list_value_objects.GetSize() < num_variables)
m_variable_list_value_objects.Resize(num_variables);
- ValueObjectSP variable = ValueObjectVariable::Create(this, variable_sp);
+ ValueObjectSP variable =
+ ValueObjectVariable::Create(this, variable_sp);
m_variable_list_value_objects.SetValueObjectAtIndex(var_idx,
variable);
valobj_sp = variable;
@@ -1183,7 +1194,8 @@ StackFrame::GetValueObjectForFrameVariable(const VariableSP &variable_sp,
}
} // End of StackFrame mutex scope.
if (use_dynamic != eNoDynamicValues && valobj_sp) {
- std::optional<ValueObjectSP> dynamic_sp = valobj_sp.value()->GetDynamicValue(use_dynamic);
+ std::optional<ValueObjectSP> dynamic_sp =
+ valobj_sp.value()->GetDynamicValue(use_dynamic);
if (dynamic_sp)
return dynamic_sp;
}
@@ -1307,7 +1319,8 @@ GetBaseExplainingDereference(const Instruction::Operand &operand,
}
}
-std::optional<ValueObjectSP> StackFrame::GuessValueForAddress(lldb::addr_t addr) {
+std::optional<ValueObjectSP>
+StackFrame::GuessValueForAddress(lldb::addr_t addr) {
TargetSP target_sp = CalculateTarget();
const ArchSpec &target_arch = target_sp->GetArchitecture();
@@ -1382,7 +1395,7 @@ std::optional<ValueObjectSP> StackFrame::GuessValueForAddress(lldb::addr_t addr)
base_and_offset.second);
}
default:
- return {};
+ return {};
}
}
@@ -1390,8 +1403,8 @@ std::optional<ValueObjectSP> StackFrame::GuessValueForAddress(lldb::addr_t addr)
}
namespace {
-std::optional<ValueObjectSP> GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,
- int64_t offset) {
+std::optional<ValueObjectSP>
+GetValueForOffset(StackFrame &frame, ValueObjectSP &parent, int64_t offset) {
if (offset < 0 || uint64_t(offset) >= parent->GetByteSize()) {
return {};
}
@@ -1422,9 +1435,9 @@ std::optional<ValueObjectSP> GetValueForOffset(StackFrame &frame, ValueObjectSP
}
}
- std::optional<ValueObjectSP> GetValueForDereferincingOffset(StackFrame &frame,
- ValueObjectSP &base,
- int64_t offset) {
+std::optional<ValueObjectSP> GetValueForDereferincingOffset(StackFrame &frame,
+ ValueObjectSP &base,
+ int64_t offset) {
// base is a pointer to something
// offset is the thing to add to the pointer We return the most sensible
// ValueObject for the result of *(base+offset)
@@ -1433,7 +1446,7 @@ std::optional<ValueObjectSP> GetValueForOffset(StackFrame &frame, ValueObjectSP
return {};
}
- std::optional<ValueObjectSP> pointee = base->Dereference();
+ std::optional<ValueObjectSP> pointee = base->Dereference();
if (!pointee || pointee.value()->GetError().Fail()) {
return {};
@@ -1477,9 +1490,11 @@ std::optional<ValueObjectSP> GetValueForOffset(StackFrame &frame, ValueObjectSP
/// A string describing the base for the ExpressionPath. This could be a
/// variable, a register value, an argument, or a function return value.
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
- std::optional<ValueObjectSP> DoGuessValueAt(StackFrame &frame, ConstString reg,
- int64_t offset, Disassembler &disassembler,
- VariableList &variables, const Address &pc) {
+std::optional<ValueObjectSP> DoGuessValueAt(StackFrame &frame, ConstString reg,
+ int64_t offset,
+ Disassembler &disassembler,
+ VariableList &variables,
+ const Address &pc) {
// Example of operation for Intel:
//
// +14: movq -0x8(%rbp), %rdi
@@ -1667,8 +1682,8 @@ std::optional<ValueObjectSP> GetValueForOffset(StackFrame &frame, ValueObjectSP
}
}
-std::optional<ValueObjectSP> StackFrame::GuessValueForRegisterAndOffset(ConstString reg,
- int64_t offset) {
+std::optional<ValueObjectSP>
+StackFrame::GuessValueForRegisterAndOffset(ConstString reg, int64_t offset) {
TargetSP target_sp = CalculateTarget();
const ArchSpec &target_arch = target_sp->GetArchitecture();
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index d45be3332c..73cbc23cbc 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1443,9 +1443,10 @@ Status Thread::ReturnFromFrameWithIndex(uint32_t frame_idx,
return ReturnFromFrame(frame_sp, return_value_sp, broadcast);
}
-Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
- std::optional<lldb::ValueObjectSP> return_value_sp,
- bool broadcast) {
+Status
+Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
+ std::optional<lldb::ValueObjectSP> return_value_sp,
+ bool broadcast) {
Status return_error;
if (!frame_sp) {
@@ -1480,7 +1481,8 @@ Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
if (return_type) {
StreamString s;
return_type.DumpTypeDescription(&s);
- ValueObjectSP cast_value_sp = return_value_sp.value()->Cast(return_type);
+ ValueObjectSP cast_value_sp =
+ return_value_sp.value()->Cast(return_type);
if (cast_value_sp->GetError().Success()) {
cast_value_sp->SetFormat(eFormatHex);
return_value_sp = cast_value_sp;
@@ -1489,7 +1491,8 @@ Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
}
}
- return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp.value());
+ return_error =
+ abi->SetReturnValueObject(older_frame_sp, return_value_sp.value());
if (!return_error.Success())
return return_error;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/74912
More information about the lldb-commits
mailing list