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/Target/Target.h"
19 #include "lldb/Interpreter/CommandInterpreter.h"
20 #include "lldb/Utility/Utils.h"
23 using namespace lldb_private;
25 OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay()
29 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
33 static OptionDefinition
36 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
37 { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
38 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
39 { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
40 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."},
41 { LLDB_OPT_SET_1, false, "object-description", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."},
42 { LLDB_OPT_SET_1, false, "ptr-depth", 'P', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."},
43 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."},
44 { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set the depth at which omitting summary information stops (default is 1)."},
45 { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."},
46 { LLDB_OPT_SET_1, false, "show-all-children", 'A', no_argument, NULL, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."},
47 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
51 OptionGroupValueObjectDisplay::GetNumDefinitions ()
53 return llvm::array_lengthof(g_option_table);
56 const OptionDefinition *
57 OptionGroupValueObjectDisplay::GetDefinitions ()
59 return g_option_table;
64 OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
66 const char *option_arg)
69 const int short_option = g_option_table[option_idx].short_option;
77 result = Args::StringToOptionEnum (option_arg, g_dynamic_value_types, 2, error);
79 use_dynamic = (lldb::DynamicValueType) result;
82 case 'T': show_types = true; break;
83 case 'L': show_location= true; break;
84 case 'F': flat_output = true; break;
85 case 'O': use_objc = true; break;
86 case 'R': be_raw = true; break;
87 case 'A': ignore_cap = true; break;
90 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
92 error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg);
96 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
98 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
104 no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
106 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
109 no_summary_depth = 1;
113 use_synth = Args::StringToBoolean(option_arg, true, &success);
115 error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg);
118 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
126 OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter)
128 // If these defaults change, be sure to modify AnyOptionWasSet().
130 no_summary_depth = 0;
131 show_location = false;
134 max_depth = UINT32_MAX;
140 Target *target = interpreter.GetExecutionContext().GetTargetPtr();
142 use_dynamic = target->GetPreferDynamicValue();
145 // If we don't have any targets, then dynamic values won't do us much good.
146 use_dynamic = lldb::eNoDynamicValues;
150 ValueObject::DumpValueObjectOptions
151 OptionGroupValueObjectDisplay::GetAsDumpOptions (bool objc_is_compact,
153 lldb::TypeSummaryImplSP summary_sp)
155 ValueObject::DumpValueObjectOptions options;
156 options.SetMaximumPointerDepth(ptr_depth);
158 options.SetShowSummary(false);
160 options.SetOmitSummaryDepth(no_summary_depth);
161 options.SetMaximumDepth(max_depth)
162 .SetShowTypes(show_types)
163 .SetShowLocation(show_location)
164 .SetUseObjectiveC(use_objc)
165 .SetUseDynamicType(use_dynamic)
166 .SetUseSyntheticValue(use_synth)
167 .SetFlatOutput(flat_output)
168 .SetIgnoreCap(ignore_cap)
170 .SetSummary(summary_sp);
173 options.SetHideRootType(use_objc)
174 .SetHideName(use_objc)
175 .SetHideValue(use_objc);
178 options.SetRawDisplay(true);