2011-04-28 06:04:39 +08:00
//===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
2012-12-05 08:20:57 +08:00
# include "lldb/lldb-python.h"
2011-05-14 04:21:08 +08:00
# include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
2011-04-28 06:04:39 +08:00
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
<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-10-01 03:11:51 +08:00
# include "lldb/DataFormatters/ValueObjectPrinter.h"
2011-05-04 11:43:18 +08:00
# include "lldb/Target/Target.h"
# include "lldb/Interpreter/CommandInterpreter.h"
2011-09-10 08:48:33 +08:00
# include "lldb/Utility/Utils.h"
2011-04-28 06:04:39 +08:00
using namespace lldb ;
using namespace lldb_private ;
OptionGroupValueObjectDisplay : : OptionGroupValueObjectDisplay ( )
{
}
OptionGroupValueObjectDisplay : : ~ OptionGroupValueObjectDisplay ( )
{
}
2011-04-29 04:55:26 +08:00
static OptionDefinition
2011-04-28 06:04:39 +08:00
g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_1 , false , " dynamic-type " , ' d ' , OptionParser : : eRequiredArgument , nullptr , g_dynamic_value_types , 0 , eArgTypeNone , " Show the object as its full dynamic type, not its static type, if available. " } ,
{ LLDB_OPT_SET_1 , false , " synthetic-type " , ' S ' , OptionParser : : eRequiredArgument , nullptr , nullptr , 0 , eArgTypeBoolean , " Show the object obeying its synthetic provider, if available. " } ,
{ LLDB_OPT_SET_1 , false , " depth " , ' D ' , OptionParser : : eRequiredArgument , nullptr , nullptr , 0 , eArgTypeCount , " Set the max recurse depth when dumping aggregate types (default is infinity). " } ,
{ LLDB_OPT_SET_1 , false , " flat " , ' F ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Display results in a flat format that uses expression paths for each variable or member. " } ,
{ LLDB_OPT_SET_1 , false , " location " , ' L ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Show variable location information. " } ,
{ LLDB_OPT_SET_1 , false , " object-description " , ' O ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Print as an Objective-C object. " } ,
{ LLDB_OPT_SET_1 , false , " ptr-depth " , ' P ' , OptionParser : : eRequiredArgument , nullptr , nullptr , 0 , eArgTypeCount , " The number of pointers to be traversed when dumping values (default is zero). " } ,
{ LLDB_OPT_SET_1 , false , " show-types " , ' T ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Show variable types when dumping values. " } ,
{ LLDB_OPT_SET_1 , false , " no-summary-depth " , ' Y ' , OptionParser : : eOptionalArgument , nullptr , nullptr , 0 , eArgTypeCount , " Set the depth at which omitting summary information stops (default is 1). " } ,
{ LLDB_OPT_SET_1 , false , " raw-output " , ' R ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Don't use formatting options. " } ,
{ LLDB_OPT_SET_1 , false , " show-all-children " , ' A ' , OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone , " Ignore the upper bound on the number of children to show. " } ,
2014-09-06 10:20:19 +08:00
{ LLDB_OPT_SET_1 , false , " validate " , ' V ' , OptionParser : : eRequiredArgument , nullptr , nullptr , 0 , eArgTypeBoolean , " Show results of type validators. " } ,
2014-07-10 00:31:49 +08:00
{ 0 , false , nullptr , 0 , 0 , nullptr , nullptr , 0 , eArgTypeNone , nullptr }
2011-04-28 06:04:39 +08:00
} ;
uint32_t
OptionGroupValueObjectDisplay : : GetNumDefinitions ( )
{
2012-05-16 07:21:36 +08:00
return llvm : : array_lengthof ( g_option_table ) ;
2011-04-28 06:04:39 +08:00
}
const OptionDefinition *
OptionGroupValueObjectDisplay : : GetDefinitions ( )
{
return g_option_table ;
}
Error
OptionGroupValueObjectDisplay : : SetOptionValue ( CommandInterpreter & interpreter ,
uint32_t option_idx ,
const char * option_arg )
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = g_option_table [ option_idx ] . short_option ;
2011-04-28 06:04:39 +08:00
bool success = false ;
switch ( short_option )
{
2011-05-04 11:43:18 +08:00
case ' d ' :
{
int32_t result ;
2012-08-23 01:17:09 +08:00
result = Args : : StringToOptionEnum ( option_arg , g_dynamic_value_types , 2 , error ) ;
2011-10-08 02:58:12 +08:00
if ( error . Success ( ) )
2011-05-04 11:43:18 +08:00
use_dynamic = ( lldb : : DynamicValueType ) result ;
}
break ;
2011-04-29 04:55:26 +08:00
case ' T ' : show_types = true ; break ;
2011-04-28 06:04:39 +08:00
case ' L ' : show_location = true ; break ;
case ' F ' : flat_output = true ; break ;
2011-08-10 07:50:01 +08:00
case ' O ' : use_objc = true ; break ;
case ' R ' : be_raw = true ; break ;
2011-08-12 10:00:06 +08:00
case ' A ' : ignore_cap = true ; break ;
2011-08-10 07:50:01 +08:00
2011-04-29 04:55:26 +08:00
case ' D ' :
2011-04-28 06:04:39 +08:00
max_depth = Args : : StringToUInt32 ( option_arg , UINT32_MAX , 0 , & success ) ;
if ( ! success )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid max depth '%s' " , option_arg ) ;
2011-04-28 06:04:39 +08:00
break ;
2011-04-29 04:55:26 +08:00
case ' P ' :
2011-04-28 06:04:39 +08:00
ptr_depth = Args : : StringToUInt32 ( option_arg , 0 , 0 , & success ) ;
if ( ! success )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid pointer depth '%s' " , option_arg ) ;
2011-04-28 06:04:39 +08:00
break ;
2011-07-16 09:22:04 +08:00
case ' Y ' :
if ( option_arg )
{
no_summary_depth = Args : : StringToUInt32 ( option_arg , 0 , 0 , & success ) ;
if ( ! success )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid pointer depth '%s' " , option_arg ) ;
2011-07-16 09:22:04 +08:00
}
else
no_summary_depth = 1 ;
break ;
2011-07-22 08:16:08 +08:00
case ' S ' :
use_synth = Args : : StringToBoolean ( option_arg , true , & success ) ;
if ( ! success )
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid synthetic-type '%s' " , option_arg ) ;
2011-07-22 08:16:08 +08:00
break ;
2014-09-06 10:20:19 +08:00
case ' V ' :
run_validator = Args : : StringToBoolean ( option_arg , true , & success ) ;
if ( ! success )
error . SetErrorStringWithFormat ( " invalid validate '%s' " , option_arg ) ;
break ;
2011-04-28 06:04:39 +08:00
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " unrecognized option '%c' " , short_option ) ;
2011-04-28 06:04:39 +08:00
break ;
}
return error ;
}
void
OptionGroupValueObjectDisplay : : OptionParsingStarting ( CommandInterpreter & interpreter )
{
2011-10-26 12:32:38 +08:00
// If these defaults change, be sure to modify AnyOptionWasSet().
2011-07-16 09:22:04 +08:00
show_types = false ;
no_summary_depth = 0 ;
show_location = false ;
flat_output = false ;
use_objc = false ;
max_depth = UINT32_MAX ;
ptr_depth = 0 ;
2011-07-22 08:16:08 +08:00
use_synth = true ;
2011-08-10 07:50:01 +08:00
be_raw = false ;
2011-08-12 10:00:06 +08:00
ignore_cap = false ;
2014-09-06 10:20:19 +08:00
run_validator = false ;
2011-05-04 11:43:18 +08:00
2011-09-22 12:58:26 +08:00
Target * target = interpreter . GetExecutionContext ( ) . GetTargetPtr ( ) ;
2014-04-20 08:31:37 +08:00
if ( target ! = nullptr )
2011-05-04 11:43:18 +08:00
use_dynamic = target - > GetPreferDynamicValue ( ) ;
else
{
// If we don't have any targets, then dynamic values won't do us much good.
use_dynamic = lldb : : eNoDynamicValues ;
}
2011-05-14 04:21:08 +08:00
}
2013-03-27 02:04:53 +08: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-10-01 03:11:51 +08:00
DumpValueObjectOptions
OptionGroupValueObjectDisplay : : GetAsDumpOptions ( LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity ,
2013-03-27 02:04:53 +08:00
lldb : : Format format ,
lldb : : TypeSummaryImplSP summary_sp )
{
<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-10-01 03:11:51 +08:00
DumpValueObjectOptions options ;
2013-03-27 02:04:53 +08:00
options . SetMaximumPointerDepth ( ptr_depth ) ;
if ( use_objc )
options . SetShowSummary ( false ) ;
else
options . SetOmitSummaryDepth ( no_summary_depth ) ;
options . SetMaximumDepth ( max_depth )
. SetShowTypes ( show_types )
. SetShowLocation ( show_location )
. SetUseObjectiveC ( use_objc )
. SetUseDynamicType ( use_dynamic )
. SetUseSyntheticValue ( use_synth )
. SetFlatOutput ( flat_output )
. SetIgnoreCap ( ignore_cap )
. SetFormat ( format )
. SetSummary ( summary_sp ) ;
<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-10-01 03:11:51 +08:00
if ( lang_descr_verbosity = = eLanguageRuntimeDescriptionDisplayVerbosityCompact )
2013-03-27 02:04:53 +08:00
options . SetHideRootType ( use_objc )
. SetHideName ( use_objc )
. SetHideValue ( use_objc ) ;
if ( be_raw )
2014-11-22 02:47:26 +08:00
options . SetRawDisplay ( ) ;
2014-09-06 10:20:19 +08:00
options . SetRunValidator ( run_validator ) ;
2013-03-27 02:04:53 +08:00
return options ;
}