[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- ValueObjectDynamicValue.cpp ---------------------------------------===//
|
2011-04-16 08:01:13 +08:00
|
|
|
//
|
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
|
2011-04-16 08:01:13 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/ValueObjectDynamicValue.h"
|
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
#include "lldb/Core/ValueObject.h"
|
2015-08-12 06:53:00 +08:00
|
|
|
#include "lldb/Symbol/CompilerType.h"
|
2011-04-16 08:01:13 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Utility/DataExtractor.h"
|
2022-02-03 20:26:10 +08:00
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Utility/Scalar.h"
|
|
|
|
#include "lldb/Utility/Status.h"
|
|
|
|
#include "lldb/lldb-types.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
|
2021-05-26 18:19:37 +08:00
|
|
|
#include <cstring>
|
2017-04-07 05:28:29 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
class Declaration;
|
|
|
|
}
|
2011-04-16 08:01:13 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2011-05-04 11:43:18 +08:00
|
|
|
ValueObjectDynamicValue::ValueObjectDynamicValue(
|
|
|
|
ValueObject &parent, lldb::DynamicValueType use_dynamic)
|
2013-01-23 09:17:27 +08:00
|
|
|
: ValueObject(parent), m_address(), m_dynamic_type_info(),
|
2011-05-04 11:43:18 +08:00
|
|
|
m_use_dynamic(use_dynamic) {
|
2011-07-30 03:53:35 +08:00
|
|
|
SetName(parent.GetName());
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2015-08-25 07:46:31 +08:00
|
|
|
CompilerType ValueObjectDynamicValue::GetCompilerTypeImpl() {
|
2013-10-29 08:28:35 +08:00
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
|
|
|
if (success) {
|
|
|
|
if (m_dynamic_type_info.HasType())
|
2015-08-25 07:46:31 +08:00
|
|
|
return m_value.GetCompilerType();
|
2013-10-29 08:28:35 +08:00
|
|
|
else
|
2015-08-25 07:46:31 +08:00
|
|
|
return m_parent->GetCompilerType();
|
2013-10-29 08:28:35 +08:00
|
|
|
}
|
2015-08-25 07:46:31 +08:00
|
|
|
return m_parent->GetCompilerType();
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ConstString ValueObjectDynamicValue::GetTypeName() {
|
2011-08-03 01:27:39 +08:00
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
2013-01-23 09:17:27 +08:00
|
|
|
if (success) {
|
|
|
|
if (m_dynamic_type_info.HasName())
|
|
|
|
return m_dynamic_type_info.GetName();
|
|
|
|
}
|
|
|
|
return m_parent->GetTypeName();
|
|
|
|
}
|
|
|
|
|
2013-10-29 08:28:35 +08:00
|
|
|
TypeImpl ValueObjectDynamicValue::GetTypeImpl() {
|
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
2013-10-30 01:42:02 +08:00
|
|
|
if (success && m_type_impl.IsValid()) {
|
2013-10-29 08:28:35 +08:00
|
|
|
return m_type_impl;
|
|
|
|
}
|
|
|
|
return m_parent->GetTypeImpl();
|
|
|
|
}
|
|
|
|
|
2013-01-23 09:17:27 +08:00
|
|
|
ConstString ValueObjectDynamicValue::GetQualifiedTypeName() {
|
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
|
|
|
if (success) {
|
|
|
|
if (m_dynamic_type_info.HasName())
|
|
|
|
return m_dynamic_type_info.GetName();
|
Introduce the concept of a "display name" for types
Rationale:
Pretty simply, the idea is that sometimes type names are way too long and contain way too many details for the average developer to care about. For instance, a plain ol' vector of int might be shown as
std::__1::vector<int, std::__1::allocator<....
rather than the much simpler std::vector<int> form, which is what most developers would actually type in their code
Proposed solution:
Introduce a notion of "display name" and a corresponding API GetDisplayTypeName() to return such a crafted for visual representation type name
Obviously, the display name and the fully qualified (or "true") name are not necessarily the same - that's the whole point
LLDB could choose to pick the "display name" as its one true notion of a type name, and if somebody really needs the fully qualified version of it, let them deal with the problem
Or, LLDB could rename what it currently calls the "type name" to be the "display name", and add new APIs for the fully qualified name, making the display name the default choice
The choice that I am making here is that the type name will keep meaning the same, and people who want a type name suited for display will explicitly ask for one
It is the less risky/disruptive choice - and it should eventually make it fairly obvious when someone is asking for the wrong type
Caveats:
- for now, GetDisplayTypeName() == GetTypeName(), there is no logic to produce customized display type names yet.
- while the fully-qualified type name is still the main key to the kingdom of data formatters, if we start showing custom names to people, those should match formatters
llvm-svn: 209072
2014-05-18 03:14:17 +08:00
|
|
|
}
|
|
|
|
return m_parent->GetQualifiedTypeName();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString ValueObjectDynamicValue::GetDisplayTypeName() {
|
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
|
|
|
if (success) {
|
2013-11-01 06:42:00 +08:00
|
|
|
if (m_dynamic_type_info.HasType())
|
2015-08-25 07:46:31 +08:00
|
|
|
return GetCompilerType().GetDisplayTypeName();
|
Introduce the concept of a "display name" for types
Rationale:
Pretty simply, the idea is that sometimes type names are way too long and contain way too many details for the average developer to care about. For instance, a plain ol' vector of int might be shown as
std::__1::vector<int, std::__1::allocator<....
rather than the much simpler std::vector<int> form, which is what most developers would actually type in their code
Proposed solution:
Introduce a notion of "display name" and a corresponding API GetDisplayTypeName() to return such a crafted for visual representation type name
Obviously, the display name and the fully qualified (or "true") name are not necessarily the same - that's the whole point
LLDB could choose to pick the "display name" as its one true notion of a type name, and if somebody really needs the fully qualified version of it, let them deal with the problem
Or, LLDB could rename what it currently calls the "type name" to be the "display name", and add new APIs for the fully qualified name, making the display name the default choice
The choice that I am making here is that the type name will keep meaning the same, and people who want a type name suited for display will explicitly ask for one
It is the less risky/disruptive choice - and it should eventually make it fairly obvious when someone is asking for the wrong type
Caveats:
- for now, GetDisplayTypeName() == GetTypeName(), there is no logic to produce customized display type names yet.
- while the fully-qualified type name is still the main key to the kingdom of data formatters, if we start showing custom names to people, those should match formatters
llvm-svn: 209072
2014-05-18 03:14:17 +08:00
|
|
|
if (m_dynamic_type_info.HasName())
|
|
|
|
return m_dynamic_type_info.GetName();
|
2013-01-23 09:17:27 +08:00
|
|
|
}
|
Introduce the concept of a "display name" for types
Rationale:
Pretty simply, the idea is that sometimes type names are way too long and contain way too many details for the average developer to care about. For instance, a plain ol' vector of int might be shown as
std::__1::vector<int, std::__1::allocator<....
rather than the much simpler std::vector<int> form, which is what most developers would actually type in their code
Proposed solution:
Introduce a notion of "display name" and a corresponding API GetDisplayTypeName() to return such a crafted for visual representation type name
Obviously, the display name and the fully qualified (or "true") name are not necessarily the same - that's the whole point
LLDB could choose to pick the "display name" as its one true notion of a type name, and if somebody really needs the fully qualified version of it, let them deal with the problem
Or, LLDB could rename what it currently calls the "type name" to be the "display name", and add new APIs for the fully qualified name, making the display name the default choice
The choice that I am making here is that the type name will keep meaning the same, and people who want a type name suited for display will explicitly ask for one
It is the less risky/disruptive choice - and it should eventually make it fairly obvious when someone is asking for the wrong type
Caveats:
- for now, GetDisplayTypeName() == GetTypeName(), there is no logic to produce customized display type names yet.
- while the fully-qualified type name is still the main key to the kingdom of data formatters, if we start showing custom names to people, those should match formatters
llvm-svn: 209072
2014-05-18 03:14:17 +08:00
|
|
|
return m_parent->GetDisplayTypeName();
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2015-10-22 03:28:08 +08:00
|
|
|
size_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
|
2011-08-03 01:27:39 +08:00
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
2013-10-29 08:28:35 +08:00
|
|
|
if (success && m_dynamic_type_info.HasType()) {
|
2018-11-06 04:49:07 +08:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
|
|
|
auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
|
2015-10-22 03:28:08 +08:00
|
|
|
return children_count <= max ? children_count : max;
|
2011-04-16 08:01:13 +08:00
|
|
|
} else
|
2015-10-22 03:28:08 +08:00
|
|
|
return m_parent->GetNumChildren(max);
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2020-07-25 23:27:21 +08:00
|
|
|
llvm::Optional<uint64_t> ValueObjectDynamicValue::GetByteSize() {
|
2011-08-03 01:27:39 +08:00
|
|
|
const bool success = UpdateValueIfNeeded(false);
|
2013-10-29 08:28:35 +08:00
|
|
|
if (success && m_dynamic_type_info.HasType()) {
|
2015-10-15 06:44:30 +08:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
|
|
|
return m_value.GetValueByteSize(nullptr, &exe_ctx);
|
2011-04-16 08:01:13 +08:00
|
|
|
} else
|
|
|
|
return m_parent->GetByteSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ValueType ValueObjectDynamicValue::GetValueType() const {
|
|
|
|
return m_parent->GetValueType();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ValueObjectDynamicValue::UpdateValue() {
|
|
|
|
SetValueIsValid(false);
|
|
|
|
m_error.Clear();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-08-03 01:27:39 +08:00
|
|
|
if (!m_parent->UpdateValueIfNeeded(false)) {
|
2011-05-30 08:49:24 +08:00
|
|
|
// The dynamic value failed to get an error, pass the error along
|
|
|
|
if (m_error.Success() && m_parent->GetError().Fail())
|
|
|
|
m_error = m_parent->GetError();
|
2011-04-16 08:01:13 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Setting our type_sp to NULL will route everything back through our parent
|
|
|
|
// which is equivalent to not using dynamic values.
|
2011-05-04 11:43:18 +08:00
|
|
|
if (m_use_dynamic == lldb::eNoDynamicValues) {
|
2013-01-23 09:17:27 +08:00
|
|
|
m_dynamic_type_info.Clear();
|
2011-05-04 11:43:18 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-02-17 15:49:44 +08:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (target) {
|
|
|
|
m_data.SetByteOrder(target->GetArchitecture().GetByteOrder());
|
|
|
|
m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
|
2011-05-04 11:43:18 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
// First make sure our Type and/or Address haven't changed:
|
2012-02-17 15:49:44 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2011-04-16 08:01:13 +08:00
|
|
|
if (!process)
|
|
|
|
return false;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
TypeAndOrName class_type_or_name;
|
|
|
|
Address dynamic_address;
|
|
|
|
bool found_dynamic_type = false;
|
|
|
|
Value::ValueType value_type;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2015-09-23 03:45:52 +08:00
|
|
|
LanguageRuntime *runtime = nullptr;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage();
|
|
|
|
if (known_type != lldb::eLanguageTypeUnknown &&
|
|
|
|
known_type != lldb::eLanguageTypeC) {
|
|
|
|
runtime = process->GetLanguageRuntime(known_type);
|
2015-09-23 03:45:52 +08:00
|
|
|
if (runtime)
|
|
|
|
found_dynamic_type = runtime->GetDynamicTypeAndAddress(
|
2013-10-30 01:42:02 +08:00
|
|
|
*m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
|
2015-09-23 03:45:52 +08:00
|
|
|
value_type);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2015-09-23 03:45:52 +08:00
|
|
|
runtime = process->GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus);
|
2011-04-16 08:01:13 +08:00
|
|
|
if (runtime)
|
2015-09-23 03:58:02 +08:00
|
|
|
found_dynamic_type = runtime->GetDynamicTypeAndAddress(
|
|
|
|
*m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
|
2016-05-06 05:10:28 +08:00
|
|
|
value_type);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
if (!found_dynamic_type) {
|
2015-09-23 03:58:02 +08:00
|
|
|
runtime = process->GetLanguageRuntime(lldb::eLanguageTypeObjC);
|
2011-04-16 08:01:13 +08:00
|
|
|
if (runtime)
|
2013-10-30 01:42:02 +08:00
|
|
|
found_dynamic_type = runtime->GetDynamicTypeAndAddress(
|
|
|
|
*m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
|
|
|
|
value_type);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
// Getting the dynamic value may have run the program a bit, and so marked us
|
2018-05-01 00:49:04 +08:00
|
|
|
// as needing updating, but we really don't...
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
m_update_point.SetUpdated();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-05-06 05:10:28 +08:00
|
|
|
if (runtime && found_dynamic_type) {
|
2013-01-23 09:17:27 +08:00
|
|
|
if (class_type_or_name.HasType()) {
|
2015-09-23 03:58:02 +08:00
|
|
|
m_type_impl =
|
2015-09-23 03:45:52 +08:00
|
|
|
TypeImpl(m_parent->GetCompilerType(),
|
2016-05-06 05:10:28 +08:00
|
|
|
runtime->FixUpDynamicType(class_type_or_name, *m_parent)
|
2015-08-25 07:46:31 +08:00
|
|
|
.GetCompilerType());
|
2013-10-30 01:42:02 +08:00
|
|
|
} else {
|
|
|
|
m_type_impl.Clear();
|
2013-10-29 08:28:35 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2016-05-06 05:10:28 +08:00
|
|
|
m_type_impl.Clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-05-06 05:10:28 +08:00
|
|
|
// If we don't have a dynamic type, then make ourselves just a echo of our
|
2018-05-01 00:49:04 +08:00
|
|
|
// parent. Or we could return false, and make ourselves an echo of our
|
|
|
|
// parent?
|
2011-04-16 08:01:13 +08:00
|
|
|
if (!found_dynamic_type) {
|
2016-05-06 05:10:28 +08:00
|
|
|
if (m_dynamic_type_info)
|
|
|
|
SetValueDidChange(true);
|
|
|
|
ClearDynamicTypeInformation();
|
|
|
|
m_dynamic_type_info.Clear();
|
|
|
|
m_value = m_parent->GetValue();
|
2019-08-09 03:22:32 +08:00
|
|
|
m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
|
2011-05-30 08:49:24 +08:00
|
|
|
return m_error.Success();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
Value old_value(m_value);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2022-03-16 22:38:05 +08:00
|
|
|
Log *log = GetLog(LLDBLog::Types);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-23 02:18:36 +08:00
|
|
|
bool has_changed_type = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-01-23 09:17:27 +08:00
|
|
|
if (!m_dynamic_type_info) {
|
|
|
|
m_dynamic_type_info = class_type_or_name;
|
2012-10-23 02:18:36 +08:00
|
|
|
has_changed_type = true;
|
2013-01-23 09:17:27 +08:00
|
|
|
} else if (class_type_or_name != m_dynamic_type_info) {
|
2011-04-16 08:01:13 +08:00
|
|
|
// We are another type, we need to tear down our children...
|
2013-01-23 09:17:27 +08:00
|
|
|
m_dynamic_type_info = class_type_or_name;
|
2011-04-16 08:01:13 +08:00
|
|
|
SetValueDidChange(true);
|
2012-10-23 02:18:36 +08:00
|
|
|
has_changed_type = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-10-23 02:18:36 +08:00
|
|
|
if (has_changed_type)
|
|
|
|
ClearDynamicTypeInformation();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
if (!m_address.IsValid() || m_address != dynamic_address) {
|
|
|
|
if (m_address.IsValid())
|
|
|
|
SetValueDidChange(true);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
// We've moved, so we should be fine...
|
|
|
|
m_address = dynamic_address;
|
2012-02-17 15:49:44 +08:00
|
|
|
lldb::TargetSP target_sp(GetTargetSP());
|
|
|
|
lldb::addr_t load_address = m_address.GetLoadAddress(target_sp.get());
|
2011-04-16 08:01:13 +08:00
|
|
|
m_value.GetScalar() = load_address;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-09-23 03:45:52 +08:00
|
|
|
if (runtime)
|
2013-01-23 09:17:27 +08:00
|
|
|
m_dynamic_type_info =
|
2015-09-23 03:58:02 +08:00
|
|
|
runtime->FixUpDynamicType(m_dynamic_type_info, *m_parent);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-08-25 07:46:31 +08:00
|
|
|
m_value.SetCompilerType(m_dynamic_type_info.GetCompilerType());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-18 06:56:38 +08:00
|
|
|
m_value.SetValueType(value_type);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-05-06 05:10:28 +08:00
|
|
|
if (has_changed_type && log)
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "[%s %p] has a new dynamic type %s", GetName().GetCString(),
|
|
|
|
static_cast<void *>(this), GetTypeName().GetCString());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-01-23 09:17:27 +08:00
|
|
|
if (m_address.IsValid() && m_dynamic_type_info) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// The variable value is in the Scalar value inside the m_value. We can
|
|
|
|
// point our m_data right to it.
|
2019-08-09 03:22:32 +08:00
|
|
|
m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
|
2011-04-16 08:01:13 +08:00
|
|
|
if (m_error.Success()) {
|
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value
The rationale for doing things this way is twofold:
- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature
Comes with a test case
llvm-svn: 219330
2014-10-09 02:27:36 +08:00
|
|
|
if (!CanProvideValue()) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// this value object represents an aggregate type whose children have
|
|
|
|
// values, but this object does not. So we say we are changed if our
|
|
|
|
// location has changed.
|
2011-04-16 08:01:13 +08:00
|
|
|
SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() ||
|
|
|
|
m_value.GetScalar() != old_value.GetScalar());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
SetValueIsValid(true);
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-23 02:18:36 +08:00
|
|
|
// We get here if we've failed above...
|
2011-04-16 08:01:13 +08:00
|
|
|
SetValueIsValid(false);
|
2012-10-23 02:18:36 +08:00
|
|
|
return false;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-23 02:18:36 +08:00
|
|
|
bool ValueObjectDynamicValue::IsInScope() { return m_parent->IsInScope(); }
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
bool ValueObjectDynamicValue::SetValueFromCString(const char *value_str,
|
2017-05-12 12:51:55 +08:00
|
|
|
Status &error) {
|
2011-04-16 08:01:13 +08:00
|
|
|
if (!UpdateValueIfNeeded(false)) {
|
|
|
|
error.SetErrorString("unable to read value");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-17 15:49:44 +08:00
|
|
|
uint64_t my_value = GetValueAsUnsigned(UINT64_MAX);
|
2011-04-16 08:01:13 +08:00
|
|
|
uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2015-09-23 03:58:02 +08:00
|
|
|
if (my_value == UINT64_MAX || parent_value == UINT64_MAX) {
|
2013-07-12 06:46:58 +08:00
|
|
|
error.SetErrorString("unable to read value");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// if we are at an offset from our parent, in order to set ourselves
|
|
|
|
// correctly we would need to change the new value so that it refers to the
|
|
|
|
// correct dynamic type. we choose not to deal with that - if anything more
|
|
|
|
// than a value overwrite is required, you should be using the expression
|
|
|
|
// parser instead of the value editing facility
|
2011-04-16 08:01:13 +08:00
|
|
|
if (my_value != parent_value) {
|
|
|
|
// but NULL'ing out a value should always be allowed
|
|
|
|
if (strcmp(value_str, "0")) {
|
|
|
|
error.SetErrorString(
|
|
|
|
"unable to modify dynamic value, use 'expression' command");
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
bool ret_val = m_parent->SetValueFromCString(value_str, error);
|
|
|
|
SetNeedsUpdate();
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
bool ValueObjectDynamicValue::SetData(DataExtractor &data, Status &error) {
|
2012-05-09 05:25:06 +08:00
|
|
|
if (!UpdateValueIfNeeded(false)) {
|
|
|
|
error.SetErrorString("unable to read value");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-04-16 08:01:13 +08:00
|
|
|
|
2012-05-09 05:25:06 +08:00
|
|
|
uint64_t my_value = GetValueAsUnsigned(UINT64_MAX);
|
|
|
|
uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX);
|
2011-04-16 08:01:13 +08:00
|
|
|
|
|
|
|
if (my_value == UINT64_MAX || parent_value == UINT64_MAX) {
|
2012-05-09 05:25:06 +08:00
|
|
|
error.SetErrorString("unable to read value");
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// if we are at an offset from our parent, in order to set ourselves
|
|
|
|
// correctly we would need to change the new value so that it refers to the
|
|
|
|
// correct dynamic type. we choose not to deal with that - if anything more
|
|
|
|
// than a value overwrite is required, you should be using the expression
|
|
|
|
// parser instead of the value editing facility
|
2012-05-09 05:25:06 +08:00
|
|
|
if (my_value != parent_value) {
|
|
|
|
// but NULL'ing out a value should always be allowed
|
2013-04-13 09:21:23 +08:00
|
|
|
lldb::offset_t offset = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-02-18 17:37:04 +08:00
|
|
|
if (data.GetAddress(&offset) != 0) {
|
2012-05-09 05:25:06 +08:00
|
|
|
error.SetErrorString(
|
|
|
|
"unable to modify dynamic value, use 'expression' command");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-04-13 09:21:23 +08:00
|
|
|
|
|
|
|
bool ret_val = m_parent->SetData(data, error);
|
|
|
|
SetNeedsUpdate();
|
|
|
|
return ret_val;
|
|
|
|
}
|
2015-08-19 01:56:06 +08:00
|
|
|
|
2015-10-07 10:36:35 +08:00
|
|
|
void ValueObjectDynamicValue::SetPreferredDisplayLanguage(
|
|
|
|
lldb::LanguageType lang) {
|
|
|
|
this->ValueObject::SetPreferredDisplayLanguage(lang);
|
|
|
|
if (m_parent)
|
|
|
|
m_parent->SetPreferredDisplayLanguage(lang);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::LanguageType ValueObjectDynamicValue::GetPreferredDisplayLanguage() {
|
|
|
|
if (m_preferred_display_language == lldb::eLanguageTypeUnknown) {
|
|
|
|
if (m_parent)
|
|
|
|
return m_parent->GetPreferredDisplayLanguage();
|
|
|
|
return lldb::eLanguageTypeUnknown;
|
|
|
|
} else
|
|
|
|
return m_preferred_display_language;
|
|
|
|
}
|
|
|
|
|
2016-07-09 02:39:36 +08:00
|
|
|
bool ValueObjectDynamicValue::IsSyntheticChildrenGenerated() {
|
|
|
|
if (m_parent)
|
|
|
|
return m_parent->IsSyntheticChildrenGenerated();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValueObjectDynamicValue::SetSyntheticChildrenGenerated(bool b) {
|
|
|
|
if (m_parent)
|
|
|
|
m_parent->SetSyntheticChildrenGenerated(b);
|
|
|
|
this->ValueObject::SetSyntheticChildrenGenerated(b);
|
|
|
|
}
|
|
|
|
|
2015-08-19 01:56:06 +08:00
|
|
|
bool ValueObjectDynamicValue::GetDeclaration(Declaration &decl) {
|
|
|
|
if (m_parent)
|
|
|
|
return m_parent->GetDeclaration(decl);
|
|
|
|
|
|
|
|
return ValueObject::GetDeclaration(decl);
|
|
|
|
}
|
2015-11-10 03:27:34 +08:00
|
|
|
|
|
|
|
uint64_t ValueObjectDynamicValue::GetLanguageFlags() {
|
|
|
|
if (m_parent)
|
|
|
|
return m_parent->GetLanguageFlags();
|
|
|
|
return this->ValueObject::GetLanguageFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValueObjectDynamicValue::SetLanguageFlags(uint64_t flags) {
|
|
|
|
if (m_parent)
|
|
|
|
m_parent->SetLanguageFlags(flags);
|
|
|
|
else
|
|
|
|
this->ValueObject::SetLanguageFlags(flags);
|
|
|
|
}
|