[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 08:23:27 +01:00
|
|
|
//===-- ValueObjectRegister.cpp -------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/Core/ValueObjectRegister.h"
|
|
|
|
|
|
|
|
|
|
#include "lldb/Core/Module.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Core/Value.h"
|
2015-08-11 22:53:00 +00:00
|
|
|
#include "lldb/Symbol/CompilerType.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Utility/DataExtractor.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2019-07-30 22:12:34 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "lldb/Utility/Scalar.h"
|
|
|
|
|
#include "lldb/Utility/Status.h"
|
|
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-04-06 21:28:29 +00:00
|
|
|
|
2018-11-11 23:16:43 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-04-06 21:28:29 +00:00
|
|
|
|
2021-05-26 12:19:37 +02:00
|
|
|
#include <cassert>
|
2018-11-11 23:16:43 +00:00
|
|
|
#include <memory>
|
2023-01-07 13:43:00 -08:00
|
|
|
#include <optional>
|
2017-04-06 21:28:29 +00:00
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
|
class ExecutionContextScope;
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
#pragma mark ValueObjectRegisterSet
|
|
|
|
|
|
2011-04-22 23:53:53 +00:00
|
|
|
ValueObjectSP
|
|
|
|
|
ValueObjectRegisterSet::Create(ExecutionContextScope *exe_scope,
|
|
|
|
|
lldb::RegisterContextSP ®_ctx_sp,
|
|
|
|
|
uint32_t set_idx) {
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
auto manager_sp = ValueObjectManager::Create();
|
|
|
|
|
return (new ValueObjectRegisterSet(exe_scope, *manager_sp, reg_ctx_sp,
|
|
|
|
|
set_idx))
|
|
|
|
|
->GetSP();
|
2011-04-22 23:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-31 00:19:25 +00:00
|
|
|
ValueObjectRegisterSet::ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
ValueObjectManager &manager,
|
2011-03-31 00:19:25 +00:00
|
|
|
lldb::RegisterContextSP ®_ctx,
|
|
|
|
|
uint32_t reg_set_idx)
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
: ValueObject(exe_scope, manager), m_reg_ctx_sp(reg_ctx),
|
|
|
|
|
m_reg_set(nullptr), m_reg_set_idx(reg_set_idx) {
|
2010-06-08 16:52:24 +00:00
|
|
|
assert(reg_ctx);
|
|
|
|
|
m_reg_set = reg_ctx->GetRegisterSet(m_reg_set_idx);
|
|
|
|
|
if (m_reg_set) {
|
|
|
|
|
m_name.SetCString(m_reg_set->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 11:27:37 -07:00
|
|
|
ValueObjectRegisterSet::~ValueObjectRegisterSet() = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2015-08-24 23:46:31 +00:00
|
|
|
CompilerType ValueObjectRegisterSet::GetCompilerTypeImpl() {
|
2015-08-11 22:53:00 +00:00
|
|
|
return CompilerType();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConstString ValueObjectRegisterSet::GetTypeName() { return ConstString(); }
|
|
|
|
|
|
2012-03-30 02:04:38 +00:00
|
|
|
ConstString ValueObjectRegisterSet::GetQualifiedTypeName() {
|
|
|
|
|
return ConstString();
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 19:28:08 +00:00
|
|
|
size_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
|
2011-03-31 00:19:25 +00:00
|
|
|
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
|
2010-06-08 16:52:24 +00:00
|
|
|
if (reg_set) {
|
2015-10-21 19:28:08 +00:00
|
|
|
auto reg_count = reg_set->num_registers;
|
|
|
|
|
return reg_count <= max ? reg_count : max;
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 14:18:35 -08:00
|
|
|
std::optional<uint64_t> ValueObjectRegisterSet::GetByteSize() { return 0; }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2011-03-31 00:19:25 +00:00
|
|
|
bool ValueObjectRegisterSet::UpdateValue() {
|
2010-06-08 16:52:24 +00:00
|
|
|
m_error.Clear();
|
|
|
|
|
SetValueDidChange(false);
|
2012-02-17 07:49:44 +00:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
2013-11-04 09:33:30 +00:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
[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 11:14:47 +00:00
|
|
|
if (frame == nullptr)
|
2011-03-31 00:19:25 +00:00
|
|
|
m_reg_ctx_sp.reset();
|
2016-09-06 20:57:50 +00:00
|
|
|
else {
|
2011-03-31 00:19:25 +00:00
|
|
|
m_reg_ctx_sp = frame->GetRegisterContext();
|
|
|
|
|
if (m_reg_ctx_sp) {
|
|
|
|
|
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
|
[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 11:14:47 +00:00
|
|
|
if (reg_set == nullptr)
|
2011-03-31 00:19:25 +00:00
|
|
|
m_reg_ctx_sp.reset();
|
2010-06-08 16:52:24 +00:00
|
|
|
else if (m_reg_set != reg_set) {
|
|
|
|
|
SetValueDidChange(true);
|
2013-01-25 18:06:21 +00:00
|
|
|
m_name.SetCString(reg_set->name);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-03-31 00:19:25 +00:00
|
|
|
if (m_reg_ctx_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
SetValueIsValid(true);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2010-06-08 16:52:24 +00:00
|
|
|
SetValueIsValid(false);
|
2011-03-31 00:19:25 +00:00
|
|
|
m_error.SetErrorToGenericError();
|
2012-03-09 03:09:58 +00:00
|
|
|
m_children.Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-03-31 00:19:25 +00:00
|
|
|
return m_error.Success();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-25 18:06:21 +00:00
|
|
|
ValueObject *ValueObjectRegisterSet::CreateChildAtIndex(
|
|
|
|
|
size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
|
[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 11:14:47 +00:00
|
|
|
ValueObject *valobj = nullptr;
|
2011-03-31 00:19:25 +00:00
|
|
|
if (m_reg_ctx_sp && m_reg_set) {
|
2013-01-25 18:06:21 +00:00
|
|
|
const size_t num_children = GetNumChildren();
|
2010-06-08 16:52:24 +00:00
|
|
|
if (idx < num_children)
|
2021-08-23 15:29:45 +02:00
|
|
|
valobj = new ValueObjectRegister(
|
|
|
|
|
*this, m_reg_ctx_sp,
|
|
|
|
|
m_reg_ctx_sp->GetRegisterInfoAtIndex(m_reg_set->registers[idx]));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-04-22 23:53:53 +00:00
|
|
|
return valobj;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-31 00:19:25 +00:00
|
|
|
lldb::ValueObjectSP
|
2023-05-26 21:19:10 -07:00
|
|
|
ValueObjectRegisterSet::GetChildMemberWithName(llvm::StringRef name,
|
2011-03-31 00:19:25 +00:00
|
|
|
bool can_create) {
|
[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 11:14:47 +00:00
|
|
|
ValueObject *valobj = nullptr;
|
2011-03-31 00:19:25 +00:00
|
|
|
if (m_reg_ctx_sp && m_reg_set) {
|
2023-05-26 21:19:10 -07:00
|
|
|
const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name);
|
[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 11:14:47 +00:00
|
|
|
if (reg_info != nullptr)
|
2021-08-23 15:29:45 +02:00
|
|
|
valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, reg_info);
|
2011-03-31 00:19:25 +00:00
|
|
|
}
|
2011-04-22 23:53:53 +00:00
|
|
|
if (valobj)
|
|
|
|
|
return valobj->GetSP();
|
|
|
|
|
else
|
|
|
|
|
return ValueObjectSP();
|
2011-03-31 00:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-28 15:52:06 -07:00
|
|
|
size_t ValueObjectRegisterSet::GetIndexOfChildWithName(llvm::StringRef name) {
|
2011-03-31 00:19:25 +00:00
|
|
|
if (m_reg_ctx_sp && m_reg_set) {
|
2023-05-28 15:52:06 -07:00
|
|
|
const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name);
|
[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 11:14:47 +00:00
|
|
|
if (reg_info != nullptr)
|
2011-03-31 00:19:25 +00:00
|
|
|
return reg_info->kinds[eRegisterKindLLDB];
|
|
|
|
|
}
|
|
|
|
|
return UINT32_MAX;
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark ValueObjectRegister
|
|
|
|
|
|
2021-08-23 15:29:45 +02:00
|
|
|
void ValueObjectRegister::ConstructObject(const RegisterInfo *reg_info) {
|
2011-05-09 20:18:18 +00:00
|
|
|
if (reg_info) {
|
|
|
|
|
m_reg_info = *reg_info;
|
|
|
|
|
if (reg_info->name)
|
|
|
|
|
m_name.SetCString(reg_info->name);
|
2011-04-22 23:53:53 +00:00
|
|
|
else if (reg_info->alt_name)
|
|
|
|
|
m_name.SetCString(reg_info->alt_name);
|
2011-03-31 00:19:25 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-24 23:46:31 +00:00
|
|
|
ValueObjectRegister::ValueObjectRegister(ValueObject &parent,
|
2012-02-18 05:35:26 +00:00
|
|
|
lldb::RegisterContextSP ®_ctx_sp,
|
2021-08-23 15:29:45 +02:00
|
|
|
const RegisterInfo *reg_info)
|
2015-09-24 03:54:50 +00:00
|
|
|
: ValueObject(parent), m_reg_ctx_sp(reg_ctx_sp), m_reg_info(),
|
|
|
|
|
m_reg_value(), m_type_name(), m_compiler_type() {
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-17 22:23:34 +00:00
|
|
|
assert(reg_ctx_sp.get());
|
2021-08-23 15:29:45 +02:00
|
|
|
ConstructObject(reg_info);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectSP ValueObjectRegister::Create(ExecutionContextScope *exe_scope,
|
|
|
|
|
lldb::RegisterContextSP ®_ctx_sp,
|
2021-08-23 15:29:45 +02:00
|
|
|
const RegisterInfo *reg_info) {
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
auto manager_sp = ValueObjectManager::Create();
|
2021-08-23 15:29:45 +02:00
|
|
|
return (new ValueObjectRegister(exe_scope, *manager_sp, reg_ctx_sp, reg_info))
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
->GetSP();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 19:28:08 +00:00
|
|
|
ValueObjectRegister::ValueObjectRegister(ExecutionContextScope *exe_scope,
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
ValueObjectManager &manager,
|
2015-10-21 19:28:08 +00:00
|
|
|
lldb::RegisterContextSP ®_ctx,
|
2021-08-23 15:29:45 +02:00
|
|
|
const RegisterInfo *reg_info)
|
[lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.
This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.
Reviewers: teemperor, JDevlieghere, jingham
Subscribers: mgorny, jfb, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74153
2020-02-03 18:05:21 -08:00
|
|
|
: ValueObject(exe_scope, manager), m_reg_ctx_sp(reg_ctx), m_reg_info(),
|
2015-10-21 19:28:08 +00:00
|
|
|
m_reg_value(), m_type_name(), m_compiler_type() {
|
|
|
|
|
assert(reg_ctx);
|
2021-08-23 15:29:45 +02:00
|
|
|
ConstructObject(reg_info);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-02 11:27:37 -07:00
|
|
|
ValueObjectRegister::~ValueObjectRegister() = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2011-03-31 00:19:25 +00:00
|
|
|
CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!m_compiler_type.IsValid()) {
|
2012-02-17 07:49:44 +00:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
2019-07-30 22:12:34 +00:00
|
|
|
if (auto *target = exe_ctx.GetTargetPtr()) {
|
|
|
|
|
if (auto *exe_module = target->GetExecutableModulePointer()) {
|
|
|
|
|
auto type_system_or_err =
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-17 22:23:34 +00:00
|
|
|
exe_module->GetTypeSystemForLanguage(eLanguageTypeC);
|
2019-07-30 22:12:34 +00:00
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
2022-03-16 15:38:05 +01:00
|
|
|
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), std::move(err),
|
2022-01-31 15:57:48 +01:00
|
|
|
"Unable to get CompilerType from TypeSystem");
|
2019-07-30 22:12:34 +00:00
|
|
|
} else {
|
2022-11-14 16:24:36 -08:00
|
|
|
if (auto ts = *type_system_or_err)
|
|
|
|
|
m_compiler_type = ts->GetBuiltinTypeForEncodingAndBitSize(
|
|
|
|
|
m_reg_info.encoding, m_reg_info.byte_size * 8);
|
2019-07-30 22:12:34 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-09-24 03:54:50 +00:00
|
|
|
return m_compiler_type;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-08 21:25:06 +00:00
|
|
|
ConstString ValueObjectRegister::GetTypeName() {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (m_type_name.IsEmpty())
|
2020-02-12 09:35:19 +01:00
|
|
|
m_type_name = GetCompilerType().GetTypeName();
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_type_name;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-25 18:06:21 +00:00
|
|
|
size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
|
2018-11-05 20:49:07 +00:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
|
|
|
|
auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
|
2015-10-21 19:28:08 +00:00
|
|
|
return children_count <= max ? children_count : max;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2023-01-07 14:18:35 -08:00
|
|
|
std::optional<uint64_t> ValueObjectRegister::GetByteSize() {
|
2020-07-25 08:27:21 -07:00
|
|
|
return m_reg_info.byte_size;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-24 18:21:05 +00:00
|
|
|
bool ValueObjectRegister::UpdateValue() {
|
2010-06-08 16:52:24 +00:00
|
|
|
m_error.Clear();
|
2012-02-17 07:49:44 +00:00
|
|
|
ExecutionContext exe_ctx(GetExecutionContextRef());
|
2013-11-04 09:33:30 +00:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
[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 11:14:47 +00:00
|
|
|
if (frame == nullptr) {
|
2011-03-31 00:19:25 +00:00
|
|
|
m_reg_ctx_sp.reset();
|
2011-05-09 20:18:18 +00:00
|
|
|
m_reg_value.Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-09 20:18:18 +00:00
|
|
|
if (m_reg_ctx_sp) {
|
2016-09-01 18:31:40 +00:00
|
|
|
RegisterValue m_old_reg_value(m_reg_value);
|
2011-05-09 20:18:18 +00:00
|
|
|
if (m_reg_ctx_sp->ReadRegister(&m_reg_info, m_reg_value)) {
|
|
|
|
|
if (m_reg_value.GetData(m_data)) {
|
2012-02-21 00:09:25 +00:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
|
if (process)
|
|
|
|
|
m_data.SetAddressByteSize(process->GetAddressByteSize());
|
2021-02-11 12:57:04 -08:00
|
|
|
m_value.SetContext(Value::ContextType::RegisterInfo,
|
2011-05-09 20:18:18 +00:00
|
|
|
(void *)&m_reg_info);
|
2021-02-11 12:57:04 -08:00
|
|
|
m_value.SetValueType(Value::ValueType::HostAddress);
|
2011-05-09 20:18:18 +00:00
|
|
|
m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
|
|
|
|
|
SetValueIsValid(true);
|
2016-09-01 18:31:40 +00:00
|
|
|
SetValueDidChange(!(m_old_reg_value == m_reg_value));
|
2011-05-09 20:18:18 +00:00
|
|
|
return true;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
SetValueIsValid(false);
|
2011-03-31 00:19:25 +00:00
|
|
|
m_error.SetErrorToGenericError();
|
|
|
|
|
return false;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-31 00:19:25 +00:00
|
|
|
bool ValueObjectRegister::SetValueFromCString(const char *value_str,
|
2017-05-12 04:51:55 +00:00
|
|
|
Status &error) {
|
2011-08-12 23:34:31 +00:00
|
|
|
// The new value will be in the m_data. Copy that into our register value.
|
2016-11-17 23:47:31 +00:00
|
|
|
error =
|
|
|
|
|
m_reg_value.SetValueFromString(&m_reg_info, llvm::StringRef(value_str));
|
2022-02-28 14:27:32 +08:00
|
|
|
if (!error.Success())
|
2011-03-31 00:19:25 +00:00
|
|
|
return false;
|
2022-02-28 14:27:32 +08:00
|
|
|
|
|
|
|
|
if (!m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
|
|
|
|
|
error.SetErrorString("unable to write back to register");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetNeedsUpdate();
|
|
|
|
|
return true;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
bool ValueObjectRegister::SetData(DataExtractor &data, Status &error) {
|
2022-09-28 14:44:17 +00:00
|
|
|
error = m_reg_value.SetValueFromData(m_reg_info, data, 0, false);
|
2022-02-28 14:27:32 +08:00
|
|
|
if (!error.Success())
|
2011-08-16 03:49:01 +00:00
|
|
|
return false;
|
2022-02-28 14:27:32 +08:00
|
|
|
|
|
|
|
|
if (!m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
|
|
|
|
|
error.SetErrorString("unable to write back to register");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetNeedsUpdate();
|
|
|
|
|
return true;
|
2011-08-16 03:49:01 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-24 18:21:05 +00:00
|
|
|
bool ValueObjectRegister::ResolveValue(Scalar &scalar) {
|
|
|
|
|
if (UpdateValueIfNeeded(
|
|
|
|
|
false)) // make sure that you are up to date before returning anything
|
|
|
|
|
return m_reg_value.GetScalarValue(scalar);
|
2011-03-31 00:19:25 +00:00
|
|
|
return false;
|
2012-08-24 18:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-25 18:06:21 +00:00
|
|
|
void ValueObjectRegister::GetExpressionPath(Stream &s,
|
2012-08-24 18:21:05 +00:00
|
|
|
GetExpressionPathFormat epformat) {
|
|
|
|
|
s.Printf("$%s", m_reg_info.name);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|