184c39663SGreg Clayton //===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===// 284c39663SGreg Clayton // 384c39663SGreg Clayton // The LLVM Compiler Infrastructure 484c39663SGreg Clayton // 584c39663SGreg Clayton // This file is distributed under the University of Illinois Open Source 684c39663SGreg Clayton // License. See LICENSE.TXT for details. 784c39663SGreg Clayton // 884c39663SGreg Clayton //===----------------------------------------------------------------------===// 984c39663SGreg Clayton 104bee32e5SJohnny Chen #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" 1184c39663SGreg Clayton 1284c39663SGreg Clayton // C Includes 1384c39663SGreg Clayton // C++ Includes 1484c39663SGreg Clayton // Other libraries and framework includes 1584c39663SGreg Clayton // Project includes 162837b766SJim Ingham #include "lldb/Target/Target.h" 172837b766SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h" 187c575b3bSJohnny Chen #include "lldb/Utility/Utils.h" 1984c39663SGreg Clayton 2084c39663SGreg Clayton using namespace lldb; 2184c39663SGreg Clayton using namespace lldb_private; 2284c39663SGreg Clayton 2384c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() 2484c39663SGreg Clayton { 2584c39663SGreg Clayton } 2684c39663SGreg Clayton 2784c39663SGreg Clayton OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () 2884c39663SGreg Clayton { 2984c39663SGreg Clayton } 3084c39663SGreg Clayton 3168ebae61SGreg Clayton static OptionDefinition 3284c39663SGreg Clayton g_option_table[] = 3384c39663SGreg Clayton { 34*67cc0636SGreg Clayton { 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."}, 35d55546b2SEnrico Granata { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, 3668ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, 3784c39663SGreg Clayton { 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."}, 3884c39663SGreg Clayton { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 3968ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 4068ebae61SGreg Clayton { 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)."}, 4168ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 42e58a507dSEnrico Granata { 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)."}, 43ce68b02cSEnrico Granata { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, 4422c55d18SEnrico Granata { 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."}, 4584c39663SGreg Clayton { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } 4684c39663SGreg Clayton }; 4784c39663SGreg Clayton 4884c39663SGreg Clayton uint32_t 4984c39663SGreg Clayton OptionGroupValueObjectDisplay::GetNumDefinitions () 5084c39663SGreg Clayton { 516ebc8c45SJohnny Chen return llvm::array_lengthof(g_option_table); 5284c39663SGreg Clayton } 5384c39663SGreg Clayton 5484c39663SGreg Clayton const OptionDefinition * 5584c39663SGreg Clayton OptionGroupValueObjectDisplay::GetDefinitions () 5684c39663SGreg Clayton { 5784c39663SGreg Clayton return g_option_table; 5884c39663SGreg Clayton } 5984c39663SGreg Clayton 6084c39663SGreg Clayton 6184c39663SGreg Clayton Error 6284c39663SGreg Clayton OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 6384c39663SGreg Clayton uint32_t option_idx, 6484c39663SGreg Clayton const char *option_arg) 6584c39663SGreg Clayton { 6684c39663SGreg Clayton Error error; 6784c39663SGreg Clayton char short_option = (char) g_option_table[option_idx].short_option; 6884c39663SGreg Clayton bool success = false; 6984c39663SGreg Clayton 7084c39663SGreg Clayton switch (short_option) 7184c39663SGreg Clayton { 722837b766SJim Ingham case 'd': 732837b766SJim Ingham { 742837b766SJim Ingham int32_t result; 75*67cc0636SGreg Clayton result = Args::StringToOptionEnum (option_arg, g_dynamic_value_types, 2, error); 76cf0e4f0dSGreg Clayton if (error.Success()) 772837b766SJim Ingham use_dynamic = (lldb::DynamicValueType) result; 782837b766SJim Ingham } 792837b766SJim Ingham break; 8068ebae61SGreg Clayton case 'T': show_types = true; break; 8184c39663SGreg Clayton case 'L': show_location= true; break; 8284c39663SGreg Clayton case 'F': flat_output = true; break; 8368ebae61SGreg Clayton case 'O': use_objc = true; break; 84ce68b02cSEnrico Granata case 'R': be_raw = true; break; 8522c55d18SEnrico Granata case 'A': ignore_cap = true; break; 86ce68b02cSEnrico Granata 8768ebae61SGreg Clayton case 'D': 8884c39663SGreg Clayton max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 8984c39663SGreg Clayton if (!success) 9086edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg); 9184c39663SGreg Clayton break; 9284c39663SGreg Clayton 9368ebae61SGreg Clayton case 'P': 9484c39663SGreg Clayton ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 9584c39663SGreg Clayton if (!success) 9686edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 9784c39663SGreg Clayton break; 9884c39663SGreg Clayton 990c5ef693SEnrico Granata case 'Y': 1000c5ef693SEnrico Granata if (option_arg) 1010c5ef693SEnrico Granata { 1020c5ef693SEnrico Granata no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 1030c5ef693SEnrico Granata if (!success) 10486edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 1050c5ef693SEnrico Granata } 1060c5ef693SEnrico Granata else 1070c5ef693SEnrico Granata no_summary_depth = 1; 1080c5ef693SEnrico Granata break; 1090c5ef693SEnrico Granata 110d55546b2SEnrico Granata case 'S': 111d55546b2SEnrico Granata use_synth = Args::StringToBoolean(option_arg, true, &success); 112d55546b2SEnrico Granata if (!success) 11386edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg); 114d55546b2SEnrico Granata break; 11584c39663SGreg Clayton default: 11686edbf41SGreg Clayton error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 11784c39663SGreg Clayton break; 11884c39663SGreg Clayton } 11984c39663SGreg Clayton 12084c39663SGreg Clayton return error; 12184c39663SGreg Clayton } 12284c39663SGreg Clayton 12384c39663SGreg Clayton void 12484c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 12584c39663SGreg Clayton { 12682f4cf46SGreg Clayton // If these defaults change, be sure to modify AnyOptionWasSet(). 12784c39663SGreg Clayton show_types = false; 1280c5ef693SEnrico Granata no_summary_depth = 0; 12984c39663SGreg Clayton show_location = false; 13084c39663SGreg Clayton flat_output = false; 13184c39663SGreg Clayton use_objc = false; 13284c39663SGreg Clayton max_depth = UINT32_MAX; 13384c39663SGreg Clayton ptr_depth = 0; 134d55546b2SEnrico Granata use_synth = true; 135ce68b02cSEnrico Granata be_raw = false; 13622c55d18SEnrico Granata ignore_cap = false; 13784c39663SGreg Clayton 138c14ee32dSGreg Clayton Target *target = interpreter.GetExecutionContext().GetTargetPtr(); 1392837b766SJim Ingham if (target != NULL) 1402837b766SJim Ingham use_dynamic = target->GetPreferDynamicValue(); 1412837b766SJim Ingham else 1422837b766SJim Ingham { 1432837b766SJim Ingham // If we don't have any targets, then dynamic values won't do us much good. 1442837b766SJim Ingham use_dynamic = lldb::eNoDynamicValues; 1452837b766SJim Ingham } 1462837b766SJim Ingham } 147