[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
|
|
|
//===-- DumpValueObjectOptions.cpp ----------------------------------------===//
|
2015-10-19 22:04:25 +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
|
2015-10-19 22:04:25 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
|
|
|
|
|
|
2024-10-24 20:20:48 -07:00
|
|
|
#include "lldb/ValueObject/ValueObject.h"
|
2015-10-19 22:04:25 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions::DumpValueObjectOptions()
|
2024-12-02 16:23:26 -08:00
|
|
|
: m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
|
|
|
|
|
m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
|
2015-11-13 21:37:47 +00:00
|
|
|
m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
|
2025-08-15 08:37:26 -07:00
|
|
|
m_show_types(false), m_show_location(false), m_use_object_desc(false),
|
2023-03-23 21:43:32 -07:00
|
|
|
m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
|
|
|
|
|
m_hide_value(false), m_run_validator(false),
|
|
|
|
|
m_use_type_display_name(true), m_allow_oneliner_mode(true),
|
|
|
|
|
m_hide_pointer_value(false), m_reveal_empty_aggregates(true) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
|
2015-11-13 21:37:47 +00:00
|
|
|
: DumpValueObjectOptions() {
|
2015-10-19 22:04:25 +00:00
|
|
|
m_use_dynamic = valobj.GetDynamicValueType();
|
|
|
|
|
m_use_synthetic = valobj.IsSynthetic();
|
|
|
|
|
m_varformat_language = valobj.GetPreferredDisplayLanguage();
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
2024-12-02 16:23:26 -08:00
|
|
|
DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
|
|
|
|
|
m_max_ptr_depth = {depth};
|
2015-10-19 22:04:25 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
2022-04-26 16:34:10 -07:00
|
|
|
DumpValueObjectOptions::SetMaximumDepth(uint32_t depth, bool is_default) {
|
2015-10-19 22:04:25 +00:00
|
|
|
m_max_depth = depth;
|
2022-04-26 16:34:10 -07:00
|
|
|
m_max_depth_is_default = is_default;
|
2015-10-19 22:04:25 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
|
|
|
|
|
m_decl_printing_helper = helper;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
[lldb] Show register fields using bitfield struct types
This change uses the information from target.xml sent by
the GDB stub to produce C types that we can use to print
register fields.
lldb-server *does not* produce this information yet. This will
only work with GDB stubs that do. gdbserver or qemu
are 2 I know of. Testing is added that uses a mocked lldb-server.
```
(lldb) register read cpsr x0 fpcr fpsr x1
cpsr = 0x60001000
= (N = 0, Z = 1, C = 1, V = 0, TCO = 0, DIT = 0, UAO = 0, PAN = 0, SS = 0, IL = 0, SSBS = 1, BTYPE = 0, D = 0, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0)
```
Only "register read" will display fields, and only when
we are not printing a register block.
For example, cpsr is a 32 bit register. Using the target's scratch type
system we construct a type:
```
struct __attribute__((__packed__)) cpsr {
uint32_t N : 1;
uint32_t Z : 1;
...
uint32_t EL : 2;
uint32_t SP : 1;
};
```
If this register had unallocated bits in it, those would
have been filled in by RegisterFlags as anonymous fields.
A new option "SetChildPrintingDecider" is added so we
can disable printing those.
Important things about this type:
* It is packed so that sizeof(struct cpsr) == sizeof(the real register).
(this will hold for all flags types we create)
* Each field has the same storage type, which is the same as the type
of the raw register value. This prevents fields being spilt over
into more storage units, as is allowed by most ABIs.
* Each bitfield size matches that of its register field.
* The most significant field is first.
The last point is required because the most significant bit (MSB)
being on the left/top of a print out matches what you'd expect to
see in an architecture manual. In addition, having lldb print a
different field order on big/little endian hosts is not acceptable.
As a consequence, if the target is little endian we have to
reverse the order of the fields in the value. The value of each field
remains the same. For example 0b01 doesn't become 0b10, it just shifts
up or down.
This is needed because clang's type system assumes that for a struct
like the one above, the least significant bit (LSB) will be first
for a little endian target. We need the MSB to be first.
Finally, if lldb's host is a different endian to the target we have
to byte swap the host endian value to match the endian of the target's
typesystem.
| Host Endian | Target Endian | Field Order Swap | Byte Order Swap |
|-------------|---------------|------------------|-----------------|
| Little | Little | Yes | No |
| Big | Little | Yes | Yes |
| Little | Big | No | Yes |
| Big | Big | No | No |
Testing was done as follows:
* Little -> Little
* LE AArch64 native debug.
* Big -> Little
* s390x lldb running under QEMU, connected to LE AArch64 target.
* Little -> Big
* LE AArch64 lldb connected to QEMU's GDB stub, which is running
an s390x program.
* Big -> Big
* s390x lldb running under QEMU, connected to another QEMU's GDB
stub, which is running an s390x program.
As we are not allowed to link core code to plugins directly,
I have added a new plugin RegisterTypeBuilder. There is one implementation
of this, RegisterTypeBuilderClang, which uses TypeSystemClang to build
the CompilerType from the register fields.
Reviewed By: jasonmolenda
Differential Revision: https://reviews.llvm.org/D145580
2023-01-13 15:50:37 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetChildPrintingDecider(ChildPrintingDecider decider) {
|
|
|
|
|
m_child_printing_decider = decider;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
|
|
|
|
|
m_show_types = show;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
|
|
|
|
|
m_show_location = show;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-15 08:37:26 -07:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::DisableObjectDescription() {
|
|
|
|
|
// Reset these options to their default values.
|
|
|
|
|
SetUseObjectDescription(false);
|
|
|
|
|
SetHideRootType(false);
|
|
|
|
|
SetHideName(false);
|
|
|
|
|
SetHideValue(false);
|
|
|
|
|
SetShowSummary(true);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetUseObjectDescription(bool use) {
|
|
|
|
|
m_use_object_desc = use;
|
2015-10-19 22:04:25 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
|
2018-12-15 00:15:33 +00:00
|
|
|
if (!show)
|
2015-10-19 22:04:25 +00:00
|
|
|
SetOmitSummaryDepth(UINT32_MAX);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2015-10-19 22:04:25 +00:00
|
|
|
SetOmitSummaryDepth(0);
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
|
|
|
|
|
m_use_dynamic = dyn;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
|
|
|
|
|
m_use_synthetic = use_synthetic;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
|
|
|
|
|
m_scope_already_checked = check;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
|
|
|
|
|
m_flat_output = flat;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
|
|
|
|
|
m_omit_summary_depth = depth;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
|
|
|
|
|
m_ignore_cap = ignore;
|
|
|
|
|
return *this;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
|
|
|
|
|
SetUseSyntheticValue(false);
|
|
|
|
|
SetOmitSummaryDepth(UINT32_MAX);
|
|
|
|
|
SetIgnoreCap(true);
|
|
|
|
|
SetHideName(false);
|
|
|
|
|
SetHideValue(false);
|
|
|
|
|
SetUseTypeDisplayName(false);
|
|
|
|
|
SetAllowOnelinerMode(false);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
|
|
|
|
|
m_format = format;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
|
|
|
|
|
m_summary_sp = summary;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
|
|
|
|
|
if (name)
|
|
|
|
|
m_root_valobj_name.assign(name);
|
|
|
|
|
else
|
|
|
|
|
m_root_valobj_name.clear();
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
|
|
|
|
|
m_hide_root_type = hide_root_type;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 21:43:32 -07:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetHideRootName(bool hide_root_name) {
|
|
|
|
|
m_hide_root_name = hide_root_name;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 22:04:25 +00:00
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
|
|
|
|
|
m_hide_name = hide_name;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
|
|
|
|
|
m_hide_value = hide_value;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
|
|
|
|
|
m_hide_pointer_value = hide;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
|
|
|
|
|
lldb::LanguageType lang) {
|
|
|
|
|
m_varformat_language = lang;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
|
|
|
|
|
m_run_validator = run;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
|
|
|
|
|
m_use_type_display_name = dis;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
|
|
|
|
|
m_allow_oneliner_mode = oneliner;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2015-11-10 19:07:58 +00:00
|
|
|
|
|
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
|
|
|
|
|
m_reveal_empty_aggregates = reveal;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2016-04-25 00:52:47 +00:00
|
|
|
|
2025-03-15 08:57:51 -07:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetExpandPointerTypeFlags(unsigned flags) {
|
|
|
|
|
m_expand_ptr_type_flags = flags;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 00:52:47 +00:00
|
|
|
DumpValueObjectOptions &
|
|
|
|
|
DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
|
2016-11-04 18:15:39 +00:00
|
|
|
m_pointer_as_array = PointerAsArraySettings(element_count);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
|
|
|
|
|
const PointerAsArraySettings &ptr_array) {
|
|
|
|
|
m_pointer_as_array = ptr_array;
|
2016-04-25 00:52:47 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|