1 //===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
16 // Other libraries and framework includes
18 #include "lldb/DataFormatters/ValueObjectPrinter.h"
19 #include "lldb/Target/Target.h"
20 #include "lldb/Interpreter/CommandInterpreter.h"
21 #include "lldb/Utility/Utils.h"
24 using namespace lldb_private;
26 OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay()
30 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
34 static OptionDefinition
37 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', OptionParser::eRequiredArgument, g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
38 { LLDB_OPT_SET_1, false, "synthetic-type", 'S', OptionParser::eRequiredArgument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
39 { LLDB_OPT_SET_1, false, "depth", 'D', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
40 { LLDB_OPT_SET_1, false, "flat", 'F', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
41 { LLDB_OPT_SET_1, false, "location", 'L', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable location information."},
42 { LLDB_OPT_SET_1, false, "object-description", 'O', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."},
43 { LLDB_OPT_SET_1, false, "ptr-depth", 'P', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."},
44 { LLDB_OPT_SET_1, false, "show-types", 'T', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."},
45 { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', OptionParser::eOptionalArgument, NULL, 0, eArgTypeCount, "Set the depth at which omitting summary information stops (default is 1)."},
46 { LLDB_OPT_SET_1, false, "raw-output", 'R', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Don't use formatting options."},
47 { LLDB_OPT_SET_1, false, "show-all-children", 'A', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."},
48 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
52 OptionGroupValueObjectDisplay::GetNumDefinitions ()
54 return llvm::array_lengthof(g_option_table);
57 const OptionDefinition *
58 OptionGroupValueObjectDisplay::GetDefinitions ()
60 return g_option_table;
65 OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
67 const char *option_arg)
70 const int short_option = g_option_table[option_idx].short_option;
78 result = Args::StringToOptionEnum (option_arg, g_dynamic_value_types, 2, error);
80 use_dynamic = (lldb::DynamicValueType) result;
83 case 'T': show_types = true; break;
84 case 'L': show_location= true; break;
85 case 'F': flat_output = true; break;
86 case 'O': use_objc = true; break;
87 case 'R': be_raw = true; break;
88 case 'A': ignore_cap = true; break;
91 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
93 error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg);
97 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
99 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
105 no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
107 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
110 no_summary_depth = 1;
114 use_synth = Args::StringToBoolean(option_arg, true, &success);
116 error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg);
119 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
127 OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter)
129 // If these defaults change, be sure to modify AnyOptionWasSet().
131 no_summary_depth = 0;
132 show_location = false;
135 max_depth = UINT32_MAX;
141 Target *target = interpreter.GetExecutionContext().GetTargetPtr();
143 use_dynamic = target->GetPreferDynamicValue();
146 // If we don't have any targets, then dynamic values won't do us much good.
147 use_dynamic = lldb::eNoDynamicValues;
151 DumpValueObjectOptions
152 OptionGroupValueObjectDisplay::GetAsDumpOptions (LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
154 lldb::TypeSummaryImplSP summary_sp)
156 DumpValueObjectOptions options;
157 options.SetMaximumPointerDepth(ptr_depth);
159 options.SetShowSummary(false);
161 options.SetOmitSummaryDepth(no_summary_depth);
162 options.SetMaximumDepth(max_depth)
163 .SetShowTypes(show_types)
164 .SetShowLocation(show_location)
165 .SetUseObjectiveC(use_objc)
166 .SetUseDynamicType(use_dynamic)
167 .SetUseSyntheticValue(use_synth)
168 .SetFlatOutput(flat_output)
169 .SetIgnoreCap(ignore_cap)
171 .SetSummary(summary_sp);
173 if (lang_descr_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
174 options.SetHideRootType(use_objc)
175 .SetHideName(use_objc)
176 .SetHideValue(use_objc);
179 options.SetRawDisplay(true);