<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
//===-- ValueObjectPrinter.cpp -------------------------------------*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/DataFormatters/ValueObjectPrinter.h"
|
|
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
|
// C++ Includes
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
// Project includes
|
|
|
|
|
#include "lldb/Core/Debugger.h"
|
2013-10-04 23:14:13 +00:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2015-06-03 20:43:54 +00:00
|
|
|
DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
|
|
|
|
|
DumpValueObjectOptions()
|
|
|
|
|
{
|
|
|
|
|
m_use_dynamic = valobj.GetDynamicValueType();
|
|
|
|
|
m_use_synthetic = valobj.IsSynthetic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
|
|
|
|
|
Stream* s)
|
|
|
|
|
{
|
|
|
|
|
if (valobj)
|
|
|
|
|
{
|
|
|
|
|
DumpValueObjectOptions options(*valobj);
|
|
|
|
|
Init (valobj,s,options,options.m_max_ptr_depth,0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DumpValueObjectOptions options;
|
|
|
|
|
Init (valobj,s,options,options.m_max_ptr_depth,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
|
|
|
|
|
Stream* s,
|
2013-10-05 00:20:27 +00:00
|
|
|
const DumpValueObjectOptions& options)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
2013-10-05 00:20:27 +00:00
|
|
|
Init(valobj,s,options,options.m_max_ptr_depth,0);
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
|
|
|
|
|
Stream* s,
|
|
|
|
|
const DumpValueObjectOptions& options,
|
2015-07-27 18:34:14 +00:00
|
|
|
const DumpValueObjectOptions::PointerDepth& ptr_depth,
|
2013-10-05 00:20:27 +00:00
|
|
|
uint32_t curr_depth)
|
|
|
|
|
{
|
|
|
|
|
Init(valobj,s,options,ptr_depth,curr_depth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::Init (ValueObject* valobj,
|
|
|
|
|
Stream* s,
|
|
|
|
|
const DumpValueObjectOptions& options,
|
2015-07-27 18:34:14 +00:00
|
|
|
const DumpValueObjectOptions::PointerDepth& ptr_depth,
|
2013-10-05 00:20:27 +00:00
|
|
|
uint32_t curr_depth)
|
|
|
|
|
{
|
|
|
|
|
m_orig_valobj = valobj;
|
|
|
|
|
m_valobj = nullptr;
|
|
|
|
|
m_stream = s;
|
|
|
|
|
this->options = options;
|
|
|
|
|
m_ptr_depth = ptr_depth;
|
|
|
|
|
m_curr_depth = curr_depth;
|
|
|
|
|
assert (m_orig_valobj && "cannot print a NULL ValueObject");
|
|
|
|
|
assert (m_stream && "cannot print to a NULL Stream");
|
|
|
|
|
m_should_print = eLazyBoolCalculate;
|
|
|
|
|
m_is_nil = eLazyBoolCalculate;
|
|
|
|
|
m_is_ptr = eLazyBoolCalculate;
|
|
|
|
|
m_is_ref = eLazyBoolCalculate;
|
|
|
|
|
m_is_aggregate = eLazyBoolCalculate;
|
|
|
|
|
m_summary_formatter = {nullptr,false};
|
|
|
|
|
m_value.assign("");
|
|
|
|
|
m_summary.assign("");
|
|
|
|
|
m_error.assign("");
|
|
|
|
|
}
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintValueObject ()
|
|
|
|
|
{
|
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-08 18:27:36 +00:00
|
|
|
if (!GetMostSpecializedValue () || m_valobj == nullptr)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
{
|
2014-09-06 02:20:19 +00:00
|
|
|
PrintValidationMarkerIfNeeded();
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
PrintLocationIfNeeded();
|
|
|
|
|
m_stream->Indent();
|
|
|
|
|
|
|
|
|
|
bool show_type = PrintTypeIfNeeded();
|
|
|
|
|
|
|
|
|
|
PrintNameIfNeeded(show_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool value_printed = false;
|
|
|
|
|
bool summary_printed = false;
|
|
|
|
|
|
|
|
|
|
bool val_summary_ok = PrintValueAndSummaryIfNeeded (value_printed,summary_printed);
|
|
|
|
|
|
|
|
|
|
if (val_summary_ok)
|
|
|
|
|
PrintChildrenIfNeeded (value_printed, summary_printed);
|
2013-10-03 02:06:02 +00:00
|
|
|
else
|
|
|
|
|
m_stream->EOL();
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
|
2014-09-06 02:20:19 +00:00
|
|
|
PrintValidationErrorIfNeeded();
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
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-08 18:27:36 +00:00
|
|
|
ValueObjectPrinter::GetMostSpecializedValue ()
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
2013-10-04 23:14:13 +00:00
|
|
|
if (m_valobj)
|
|
|
|
|
return true;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
bool update_success = m_orig_valobj->UpdateValueIfNeeded (true);
|
|
|
|
|
if (!update_success)
|
|
|
|
|
{
|
2013-10-22 22:42:14 +00:00
|
|
|
m_valobj = m_orig_valobj;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
else
|
2013-10-22 22:42:14 +00:00
|
|
|
{
|
|
|
|
|
if (m_orig_valobj->IsDynamic())
|
|
|
|
|
{
|
|
|
|
|
if (options.m_use_dynamic == eNoDynamicValues)
|
|
|
|
|
{
|
|
|
|
|
ValueObject *static_value = m_orig_valobj->GetStaticValue().get();
|
|
|
|
|
if (static_value)
|
|
|
|
|
m_valobj = static_value;
|
|
|
|
|
else
|
|
|
|
|
m_valobj = m_orig_valobj;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_valobj = m_orig_valobj;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (options.m_use_dynamic != eNoDynamicValues)
|
|
|
|
|
{
|
|
|
|
|
ValueObject *dynamic_value = m_orig_valobj->GetDynamicValue(options.m_use_dynamic).get();
|
|
|
|
|
if (dynamic_value)
|
|
|
|
|
m_valobj = dynamic_value;
|
|
|
|
|
else
|
|
|
|
|
m_valobj = m_orig_valobj;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_valobj = m_orig_valobj;
|
|
|
|
|
}
|
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-08 18:27:36 +00:00
|
|
|
|
|
|
|
|
if (m_valobj->IsSynthetic())
|
|
|
|
|
{
|
|
|
|
|
if (options.m_use_synthetic == false)
|
|
|
|
|
{
|
|
|
|
|
ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get();
|
|
|
|
|
if (non_synthetic)
|
|
|
|
|
m_valobj = non_synthetic;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (options.m_use_synthetic == true)
|
|
|
|
|
{
|
|
|
|
|
ValueObject *synthetic = m_valobj->GetSyntheticValue().get();
|
|
|
|
|
if (synthetic)
|
|
|
|
|
m_valobj = synthetic;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-22 22:42:14 +00:00
|
|
|
}
|
2015-08-24 23:46:31 +00:00
|
|
|
m_clang_type = m_valobj->GetCompilerType();
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
m_type_flags = m_clang_type.GetTypeInfo ();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
|
ValueObjectPrinter::GetDescriptionForDisplay ()
|
|
|
|
|
{
|
|
|
|
|
const char* str = m_valobj->GetObjectDescription();
|
|
|
|
|
if (!str)
|
|
|
|
|
str = m_valobj->GetSummaryAsCString();
|
|
|
|
|
if (!str)
|
|
|
|
|
str = m_valobj->GetValueAsCString();
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
|
ValueObjectPrinter::GetRootNameForDisplay (const char* if_fail)
|
|
|
|
|
{
|
|
|
|
|
const char *root_valobj_name = options.m_root_valobj_name.empty() ?
|
|
|
|
|
m_valobj->GetName().AsCString() :
|
|
|
|
|
options.m_root_valobj_name.c_str();
|
|
|
|
|
return root_valobj_name ? root_valobj_name : if_fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::ShouldPrintValueObject ()
|
|
|
|
|
{
|
|
|
|
|
if (m_should_print == eLazyBoolCalculate)
|
2014-10-21 20:52:14 +00:00
|
|
|
m_should_print = (options.m_flat_output == false || m_type_flags.Test (eTypeHasValue)) ? eLazyBoolYes : eLazyBoolNo;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return m_should_print == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::IsNil ()
|
|
|
|
|
{
|
|
|
|
|
if (m_is_nil == eLazyBoolCalculate)
|
|
|
|
|
m_is_nil = m_valobj->IsObjCNil() ? eLazyBoolYes : eLazyBoolNo;
|
|
|
|
|
return m_is_nil == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::IsPtr ()
|
|
|
|
|
{
|
|
|
|
|
if (m_is_ptr == eLazyBoolCalculate)
|
2014-10-21 20:52:14 +00:00
|
|
|
m_is_ptr = m_type_flags.Test (eTypeIsPointer) ? eLazyBoolYes : eLazyBoolNo;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return m_is_ptr == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::IsRef ()
|
|
|
|
|
{
|
|
|
|
|
if (m_is_ref == eLazyBoolCalculate)
|
2014-10-21 20:52:14 +00:00
|
|
|
m_is_ref = m_type_flags.Test (eTypeIsReference) ? eLazyBoolYes : eLazyBoolNo;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return m_is_ref == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::IsAggregate ()
|
|
|
|
|
{
|
|
|
|
|
if (m_is_aggregate == eLazyBoolCalculate)
|
2014-10-21 20:52:14 +00:00
|
|
|
m_is_aggregate = m_type_flags.Test (eTypeHasChildren) ? eLazyBoolYes : eLazyBoolNo;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
return m_is_aggregate == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintLocationIfNeeded ()
|
|
|
|
|
{
|
|
|
|
|
if (options.m_show_location)
|
|
|
|
|
{
|
|
|
|
|
m_stream->Printf("%s: ", m_valobj->GetLocationAsCString());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintTypeIfNeeded ()
|
|
|
|
|
{
|
|
|
|
|
bool show_type = true;
|
|
|
|
|
// if we are at the root-level and been asked to hide the root's type, then hide it
|
|
|
|
|
if (m_curr_depth == 0 && options.m_hide_root_type)
|
|
|
|
|
show_type = false;
|
|
|
|
|
else
|
|
|
|
|
// otherwise decide according to the usual rules (asked to show types - always at the root level)
|
|
|
|
|
show_type = options.m_show_types || (m_curr_depth == 0 && !options.m_flat_output);
|
|
|
|
|
|
|
|
|
|
if (show_type)
|
|
|
|
|
{
|
|
|
|
|
// Some ValueObjects don't have types (like registers sets). Only print
|
|
|
|
|
// the type if there is one to print
|
2014-11-21 18:47:26 +00:00
|
|
|
ConstString type_name;
|
|
|
|
|
if (options.m_use_type_display_name)
|
|
|
|
|
type_name = m_valobj->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-17 19:14:17 +00:00
|
|
|
else
|
2014-11-21 18:47:26 +00:00
|
|
|
type_name = m_valobj->GetQualifiedTypeName();
|
|
|
|
|
if (type_name)
|
|
|
|
|
m_stream->Printf("(%s) ", type_name.GetCString());
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
else
|
|
|
|
|
show_type = false;
|
|
|
|
|
}
|
|
|
|
|
return show_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintNameIfNeeded (bool show_type)
|
|
|
|
|
{
|
|
|
|
|
if (options.m_flat_output)
|
|
|
|
|
{
|
|
|
|
|
// If we are showing types, also qualify the C++ base classes
|
|
|
|
|
const bool qualify_cxx_base_classes = show_type;
|
|
|
|
|
if (!options.m_hide_name)
|
|
|
|
|
{
|
|
|
|
|
m_valobj->GetExpressionPath(*m_stream, qualify_cxx_base_classes);
|
|
|
|
|
m_stream->PutCString(" =");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!options.m_hide_name)
|
|
|
|
|
{
|
|
|
|
|
const char *name_cstr = GetRootNameForDisplay("");
|
|
|
|
|
m_stream->Printf ("%s =", name_cstr);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::CheckScopeIfNeeded ()
|
|
|
|
|
{
|
|
|
|
|
if (options.m_scope_already_checked)
|
|
|
|
|
return true;
|
|
|
|
|
return m_valobj->IsInScope();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TypeSummaryImpl*
|
|
|
|
|
ValueObjectPrinter::GetSummaryFormatter ()
|
|
|
|
|
{
|
|
|
|
|
if (m_summary_formatter.second == false)
|
|
|
|
|
{
|
|
|
|
|
TypeSummaryImpl* entry = options.m_summary_sp ? options.m_summary_sp.get() : m_valobj->GetSummaryFormat().get();
|
|
|
|
|
|
|
|
|
|
if (options.m_omit_summary_depth > 0)
|
|
|
|
|
entry = NULL;
|
|
|
|
|
m_summary_formatter.first = entry;
|
|
|
|
|
m_summary_formatter.second = true;
|
|
|
|
|
}
|
|
|
|
|
return m_summary_formatter.first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::GetValueSummaryError (std::string& value,
|
|
|
|
|
std::string& summary,
|
|
|
|
|
std::string& error)
|
|
|
|
|
{
|
2014-02-15 01:24:44 +00:00
|
|
|
if (options.m_format != eFormatDefault && options.m_format != m_valobj->GetFormat())
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
2014-02-15 01:24:44 +00:00
|
|
|
m_valobj->GetValueAsCString(options.m_format,
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char* val_cstr = m_valobj->GetValueAsCString();
|
|
|
|
|
if (val_cstr)
|
|
|
|
|
value.assign(val_cstr);
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
const char* err_cstr = m_valobj->GetError().AsCString();
|
|
|
|
|
if (err_cstr)
|
|
|
|
|
error.assign(err_cstr);
|
|
|
|
|
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
{
|
|
|
|
|
if (IsNil())
|
|
|
|
|
summary.assign("nil");
|
|
|
|
|
else if (options.m_omit_summary_depth == 0)
|
|
|
|
|
{
|
|
|
|
|
TypeSummaryImpl* entry = GetSummaryFormatter();
|
|
|
|
|
if (entry)
|
|
|
|
|
m_valobj->GetSummaryAsCString(entry, summary);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char* sum_cstr = m_valobj->GetSummaryAsCString();
|
|
|
|
|
if (sum_cstr)
|
|
|
|
|
summary.assign(sum_cstr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintValueAndSummaryIfNeeded (bool& value_printed,
|
|
|
|
|
bool& summary_printed)
|
|
|
|
|
{
|
|
|
|
|
bool error_printed = false;
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
{
|
|
|
|
|
if (!CheckScopeIfNeeded())
|
|
|
|
|
m_error.assign("out of scope");
|
|
|
|
|
if (m_error.empty())
|
|
|
|
|
{
|
|
|
|
|
GetValueSummaryError(m_value, m_summary, m_error);
|
|
|
|
|
}
|
|
|
|
|
if (m_error.size())
|
|
|
|
|
{
|
|
|
|
|
error_printed = true;
|
|
|
|
|
m_stream->Printf (" <%s>\n", m_error.c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Make sure we have a value and make sure the summary didn't
|
|
|
|
|
// specify that the value should not be printed - and do not print
|
|
|
|
|
// the value if this thing is nil
|
|
|
|
|
// (but show the value if the user passes a format explicitly)
|
|
|
|
|
TypeSummaryImpl* entry = GetSummaryFormatter();
|
2014-04-23 23:16:25 +00:00
|
|
|
if (!IsNil() && !m_value.empty() && (entry == NULL || (entry->DoesPrintValue(m_valobj) || options.m_format != eFormatDefault) || m_summary.empty()) && !options.m_hide_value)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
|
|
|
|
m_stream->Printf(" %s", m_value.c_str());
|
|
|
|
|
value_printed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_summary.size())
|
|
|
|
|
{
|
|
|
|
|
m_stream->Printf(" %s", m_summary.c_str());
|
|
|
|
|
summary_printed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return !error_printed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintObjectDescriptionIfNeeded (bool value_printed,
|
|
|
|
|
bool summary_printed)
|
|
|
|
|
{
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
{
|
|
|
|
|
// let's avoid the overly verbose no description error for a nil thing
|
|
|
|
|
if (options.m_use_objc && !IsNil())
|
|
|
|
|
{
|
|
|
|
|
if (!options.m_hide_value || !options.m_hide_name)
|
|
|
|
|
m_stream->Printf(" ");
|
|
|
|
|
const char *object_desc = nullptr;
|
|
|
|
|
if (value_printed || summary_printed)
|
|
|
|
|
object_desc = m_valobj->GetObjectDescription();
|
|
|
|
|
else
|
|
|
|
|
object_desc = GetDescriptionForDisplay();
|
|
|
|
|
if (object_desc && *object_desc)
|
|
|
|
|
{
|
|
|
|
|
m_stream->Printf("%s\n", object_desc);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (value_printed == false && summary_printed == false)
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 18:34:14 +00:00
|
|
|
bool
|
|
|
|
|
DumpValueObjectOptions::PointerDepth::CanAllowExpansion (bool is_root,
|
|
|
|
|
TypeSummaryImpl* entry,
|
|
|
|
|
ValueObject *valobj,
|
|
|
|
|
const std::string& summary)
|
|
|
|
|
{
|
|
|
|
|
switch (m_mode)
|
|
|
|
|
{
|
|
|
|
|
case Mode::Always:
|
|
|
|
|
return (m_count > 0);
|
|
|
|
|
case Mode::Never:
|
|
|
|
|
return false;
|
|
|
|
|
case Mode::Default:
|
|
|
|
|
if (is_root)
|
|
|
|
|
m_count = std::min<decltype(m_count)>(m_count,1);
|
|
|
|
|
return m_count > 0;
|
|
|
|
|
case Mode::Formatters:
|
|
|
|
|
if (!entry || entry->DoesPrintChildren(valobj) || summary.empty())
|
|
|
|
|
return m_count > 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-09-09 17:25:43 +00:00
|
|
|
return false;
|
2015-07-27 18:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
DumpValueObjectOptions::PointerDepth::CanAllowExpansion () const
|
|
|
|
|
{
|
|
|
|
|
switch (m_mode)
|
|
|
|
|
{
|
|
|
|
|
case Mode::Always:
|
|
|
|
|
case Mode::Default:
|
|
|
|
|
case Mode::Formatters:
|
|
|
|
|
return (m_count > 0);
|
|
|
|
|
case Mode::Never:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-09-09 17:25:43 +00:00
|
|
|
return false;
|
2015-07-27 18:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description,
|
2015-07-27 18:34:14 +00:00
|
|
|
DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
|
|
|
|
const bool is_ref = IsRef ();
|
|
|
|
|
const bool is_ptr = IsPtr ();
|
|
|
|
|
|
2015-07-27 18:34:14 +00:00
|
|
|
TypeSummaryImpl* entry = GetSummaryFormatter();
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
if (is_failed_description || m_curr_depth < options.m_max_depth)
|
|
|
|
|
{
|
|
|
|
|
// We will show children for all concrete types. We won't show
|
|
|
|
|
// pointer contents unless a pointer depth has been specified.
|
|
|
|
|
// We won't reference contents unless the reference is the
|
|
|
|
|
// root object (depth of zero).
|
|
|
|
|
|
|
|
|
|
// Use a new temporary pointer depth in case we override the
|
|
|
|
|
// current pointer depth below...
|
|
|
|
|
|
|
|
|
|
if (is_ptr || is_ref)
|
|
|
|
|
{
|
|
|
|
|
// We have a pointer or reference whose value is an address.
|
|
|
|
|
// Make sure that address is not NULL
|
|
|
|
|
AddressType ptr_address_type;
|
|
|
|
|
if (m_valobj->GetPointerValue (&ptr_address_type) == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
2015-07-27 18:34:14 +00:00
|
|
|
const bool is_root_level = m_curr_depth == 0;
|
|
|
|
|
|
|
|
|
|
if (is_ref &&
|
|
|
|
|
is_root_level)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
|
|
|
|
// If this is the root object (depth is zero) that we are showing
|
|
|
|
|
// and it is a reference, and no pointer depth has been supplied
|
|
|
|
|
// print out what it references. Don't do this at deeper depths
|
|
|
|
|
// otherwise we can end up with infinite recursion...
|
2015-07-27 18:34:14 +00:00
|
|
|
return true;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-27 18:34:14 +00:00
|
|
|
return curr_ptr_depth.CanAllowExpansion(false, entry, m_valobj, m_summary);
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-23 23:16:25 +00:00
|
|
|
return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-24 21:30:58 +00:00
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::ShouldExpandEmptyAggregates ()
|
|
|
|
|
{
|
|
|
|
|
TypeSummaryImpl* entry = GetSummaryFormatter();
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return entry->DoesPrintEmptyAggregates();
|
|
|
|
|
}
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
ValueObject*
|
|
|
|
|
ValueObjectPrinter::GetValueObjectForChildrenGeneration ()
|
|
|
|
|
{
|
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-08 18:27:36 +00:00
|
|
|
return m_valobj;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::PrintChildrenPreamble ()
|
|
|
|
|
{
|
|
|
|
|
if (options.m_flat_output)
|
|
|
|
|
{
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
m_stream->EOL();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
m_stream->PutCString(IsRef () ? ": {\n" : " {\n");
|
|
|
|
|
m_stream->IndentMore();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::PrintChild (ValueObjectSP child_sp,
|
2015-07-27 18:34:14 +00:00
|
|
|
const DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
|
|
|
|
DumpValueObjectOptions child_options(options);
|
2015-06-17 02:11:48 +00:00
|
|
|
child_options.SetFormat(options.m_format).SetSummary().SetRootValueObjectName();
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
child_options.SetScopeChecked(true).SetHideName(options.m_hide_name).SetHideValue(options.m_hide_value)
|
|
|
|
|
.SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0);
|
|
|
|
|
if (child_sp.get())
|
|
|
|
|
{
|
|
|
|
|
ValueObjectPrinter child_printer(child_sp.get(),
|
|
|
|
|
m_stream,
|
|
|
|
|
child_options,
|
2015-07-27 18:34:14 +00:00
|
|
|
(IsPtr() || IsRef()) ? --curr_ptr_depth : curr_ptr_depth,
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
m_curr_depth + 1);
|
|
|
|
|
child_printer.PrintValueObject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
|
ValueObjectPrinter::GetMaxNumChildrenToPrint (bool& print_dotdotdot)
|
|
|
|
|
{
|
|
|
|
|
ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
|
|
|
|
|
|
|
|
|
|
size_t num_children = synth_m_valobj->GetNumChildren();
|
|
|
|
|
print_dotdotdot = false;
|
|
|
|
|
if (num_children)
|
|
|
|
|
{
|
|
|
|
|
const size_t max_num_children = m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
|
|
|
|
|
|
|
|
|
|
if (num_children > max_num_children && !options.m_ignore_cap)
|
|
|
|
|
{
|
|
|
|
|
print_dotdotdot = true;
|
|
|
|
|
return max_num_children;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return num_children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::PrintChildrenPostamble (bool print_dotdotdot)
|
|
|
|
|
{
|
|
|
|
|
if (!options.m_flat_output)
|
|
|
|
|
{
|
|
|
|
|
if (print_dotdotdot)
|
|
|
|
|
{
|
|
|
|
|
m_valobj->GetTargetSP()->GetDebugger().GetCommandInterpreter().ChildrenTruncated();
|
|
|
|
|
m_stream->Indent("...\n");
|
|
|
|
|
}
|
|
|
|
|
m_stream->IndentLess();
|
|
|
|
|
m_stream->Indent("}\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2015-07-27 18:34:14 +00:00
|
|
|
ValueObjectPrinter::PrintChildren (bool value_printed,
|
|
|
|
|
bool summary_printed,
|
|
|
|
|
const DumpValueObjectOptions::PointerDepth& curr_ptr_depth)
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
{
|
|
|
|
|
ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
|
|
|
|
|
|
|
|
|
|
bool print_dotdotdot = false;
|
|
|
|
|
size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
|
|
|
|
|
if (num_children)
|
|
|
|
|
{
|
|
|
|
|
PrintChildrenPreamble ();
|
|
|
|
|
|
|
|
|
|
for (size_t idx=0; idx<num_children; ++idx)
|
|
|
|
|
{
|
|
|
|
|
ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
|
|
|
|
|
PrintChild (child_sp, curr_ptr_depth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrintChildrenPostamble (print_dotdotdot);
|
|
|
|
|
}
|
|
|
|
|
else if (IsAggregate())
|
|
|
|
|
{
|
|
|
|
|
// Aggregate, no children...
|
|
|
|
|
if (ShouldPrintValueObject())
|
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-08 18:27:36 +00:00
|
|
|
{
|
|
|
|
|
// if it has a synthetic value, then don't print {}, the synthetic children are probably only being used to vend a value
|
2015-07-24 21:30:58 +00:00
|
|
|
if (m_valobj->DoesProvideSyntheticValue() || !ShouldExpandEmptyAggregates())
|
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-08 18:27:36 +00:00
|
|
|
m_stream->PutCString( "\n");
|
|
|
|
|
else
|
|
|
|
|
m_stream->PutCString(" {}\n");
|
|
|
|
|
}
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ShouldPrintValueObject())
|
|
|
|
|
m_stream->EOL();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-04 23:14:13 +00:00
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintChildrenOneLiner (bool hide_names)
|
|
|
|
|
{
|
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-08 18:27:36 +00:00
|
|
|
if (!GetMostSpecializedValue () || m_valobj == nullptr)
|
2013-10-04 23:14:13 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
|
|
|
|
|
|
|
|
|
|
bool print_dotdotdot = false;
|
|
|
|
|
size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
|
|
|
|
|
|
|
|
|
|
if (num_children)
|
|
|
|
|
{
|
|
|
|
|
m_stream->PutChar('(');
|
|
|
|
|
|
|
|
|
|
for (uint32_t idx=0; idx<num_children; ++idx)
|
|
|
|
|
{
|
|
|
|
|
lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
|
2014-10-09 18:47:36 +00:00
|
|
|
if (child_sp)
|
|
|
|
|
child_sp = child_sp->GetQualifiedRepresentationIfAvailable(options.m_use_dynamic, options.m_use_synthetic);
|
2013-10-04 23:14:13 +00:00
|
|
|
if (child_sp)
|
|
|
|
|
{
|
|
|
|
|
if (idx)
|
|
|
|
|
m_stream->PutCString(", ");
|
|
|
|
|
if (!hide_names)
|
|
|
|
|
{
|
|
|
|
|
const char* name = child_sp.get()->GetName().AsCString();
|
|
|
|
|
if (name && *name)
|
|
|
|
|
{
|
|
|
|
|
m_stream->PutCString(name);
|
|
|
|
|
m_stream->PutCString(" = ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
child_sp->DumpPrintableRepresentation(*m_stream,
|
|
|
|
|
ValueObject::eValueObjectRepresentationStyleSummary,
|
2015-06-17 02:11:48 +00:00
|
|
|
lldb::eFormatInvalid,
|
2013-10-04 23:14:13 +00:00
|
|
|
ValueObject::ePrintableRepresentationSpecialCasesDisable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (print_dotdotdot)
|
|
|
|
|
m_stream->PutCString(", ...)");
|
|
|
|
|
else
|
|
|
|
|
m_stream->PutChar(')');
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
void
|
|
|
|
|
ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
|
|
|
|
|
bool summary_printed)
|
|
|
|
|
{
|
|
|
|
|
// this flag controls whether we tried to display a description for this object and failed
|
|
|
|
|
// if that happens, we want to display the children, if any
|
|
|
|
|
bool is_failed_description = !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
|
|
|
|
|
|
2015-07-27 18:34:14 +00:00
|
|
|
auto curr_ptr_depth = m_ptr_depth;
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
bool print_children = ShouldPrintChildren (is_failed_description,curr_ptr_depth);
|
2015-07-27 18:34:14 +00:00
|
|
|
bool print_oneline = (curr_ptr_depth.CanAllowExpansion() ||
|
2015-03-12 22:16:20 +00:00
|
|
|
options.m_show_types ||
|
|
|
|
|
!options.m_allow_oneliner_mode ||
|
|
|
|
|
options.m_flat_output ||
|
|
|
|
|
options.m_show_location) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
|
|
|
|
|
if (print_children)
|
|
|
|
|
{
|
2013-10-04 23:14:13 +00:00
|
|
|
if (print_oneline)
|
|
|
|
|
{
|
|
|
|
|
m_stream->PutChar(' ');
|
|
|
|
|
PrintChildrenOneLiner (false);
|
|
|
|
|
m_stream->EOL();
|
|
|
|
|
}
|
|
|
|
|
else
|
2015-07-27 18:34:14 +00:00
|
|
|
PrintChildren (value_printed, summary_printed, curr_ptr_depth);
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
|
|
|
|
else if (m_curr_depth >= options.m_max_depth && IsAggregate() && ShouldPrintValueObject())
|
|
|
|
|
{
|
|
|
|
|
m_stream->PutCString("{...}\n");
|
|
|
|
|
}
|
2013-10-03 18:11:24 +00:00
|
|
|
else
|
|
|
|
|
m_stream->EOL();
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
}
|
2014-09-06 02:20:19 +00:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::ShouldPrintValidation ()
|
|
|
|
|
{
|
|
|
|
|
return options.m_run_validator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintValidationMarkerIfNeeded ()
|
|
|
|
|
{
|
|
|
|
|
if (!ShouldPrintValidation())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
m_validation = m_valobj->GetValidationStatus();
|
|
|
|
|
|
|
|
|
|
if (TypeValidatorResult::Failure == m_validation.first)
|
|
|
|
|
{
|
|
|
|
|
m_stream->Printf("! ");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ValueObjectPrinter::PrintValidationErrorIfNeeded ()
|
|
|
|
|
{
|
|
|
|
|
if (!ShouldPrintValidation())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (TypeValidatorResult::Success == m_validation.first)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (m_validation.second.empty())
|
|
|
|
|
m_validation.second.assign("unknown error");
|
|
|
|
|
|
|
|
|
|
m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());
|
|
|
|
|
m_stream->EOL();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|