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 { 342837b766SJim Ingham { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, 352837b766SJim Ingham 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, 36d55546b2SEnrico Granata { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, 3768ebae61SGreg 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)."}, 3884c39663SGreg 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."}, 3984c39663SGreg Clayton { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 4068ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 4168ebae61SGreg 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)."}, 4268ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 430c5ef693SEnrico Granata { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."}, 44ce68b02cSEnrico Granata { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, 4522c55d18SEnrico 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."}, 4684c39663SGreg Clayton { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } 4784c39663SGreg Clayton }; 4884c39663SGreg Clayton 4984c39663SGreg Clayton uint32_t 5084c39663SGreg Clayton OptionGroupValueObjectDisplay::GetNumDefinitions () 5184c39663SGreg Clayton { 52*6ebc8c45SJohnny Chen return llvm::array_lengthof(g_option_table); 5384c39663SGreg Clayton } 5484c39663SGreg Clayton 5584c39663SGreg Clayton const OptionDefinition * 5684c39663SGreg Clayton OptionGroupValueObjectDisplay::GetDefinitions () 5784c39663SGreg Clayton { 5884c39663SGreg Clayton return g_option_table; 5984c39663SGreg Clayton } 6084c39663SGreg Clayton 6184c39663SGreg Clayton 6284c39663SGreg Clayton Error 6384c39663SGreg Clayton OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 6484c39663SGreg Clayton uint32_t option_idx, 6584c39663SGreg Clayton const char *option_arg) 6684c39663SGreg Clayton { 6784c39663SGreg Clayton Error error; 6884c39663SGreg Clayton char short_option = (char) g_option_table[option_idx].short_option; 6984c39663SGreg Clayton bool success = false; 7084c39663SGreg Clayton 7184c39663SGreg Clayton switch (short_option) 7284c39663SGreg Clayton { 732837b766SJim Ingham case 'd': 742837b766SJim Ingham { 752837b766SJim Ingham int32_t result; 76cf0e4f0dSGreg Clayton result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, error); 77cf0e4f0dSGreg Clayton if (error.Success()) 782837b766SJim Ingham use_dynamic = (lldb::DynamicValueType) result; 792837b766SJim Ingham } 802837b766SJim Ingham break; 8168ebae61SGreg Clayton case 'T': show_types = true; break; 8284c39663SGreg Clayton case 'L': show_location= true; break; 8384c39663SGreg Clayton case 'F': flat_output = true; break; 8468ebae61SGreg Clayton case 'O': use_objc = true; break; 85ce68b02cSEnrico Granata case 'R': be_raw = true; break; 8622c55d18SEnrico Granata case 'A': ignore_cap = true; break; 87ce68b02cSEnrico Granata 8868ebae61SGreg Clayton case 'D': 8984c39663SGreg Clayton max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 9084c39663SGreg Clayton if (!success) 9186edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg); 9284c39663SGreg Clayton break; 9384c39663SGreg Clayton 9468ebae61SGreg Clayton case 'P': 9584c39663SGreg Clayton ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 9684c39663SGreg Clayton if (!success) 9786edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 9884c39663SGreg Clayton break; 9984c39663SGreg Clayton 1000c5ef693SEnrico Granata case 'Y': 1010c5ef693SEnrico Granata if (option_arg) 1020c5ef693SEnrico Granata { 1030c5ef693SEnrico Granata no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 1040c5ef693SEnrico Granata if (!success) 10586edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 1060c5ef693SEnrico Granata } 1070c5ef693SEnrico Granata else 1080c5ef693SEnrico Granata no_summary_depth = 1; 1090c5ef693SEnrico Granata break; 1100c5ef693SEnrico Granata 111d55546b2SEnrico Granata case 'S': 112d55546b2SEnrico Granata use_synth = Args::StringToBoolean(option_arg, true, &success); 113d55546b2SEnrico Granata if (!success) 11486edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg); 115d55546b2SEnrico Granata break; 11684c39663SGreg Clayton default: 11786edbf41SGreg Clayton error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 11884c39663SGreg Clayton break; 11984c39663SGreg Clayton } 12084c39663SGreg Clayton 12184c39663SGreg Clayton return error; 12284c39663SGreg Clayton } 12384c39663SGreg Clayton 12484c39663SGreg Clayton void 12584c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 12684c39663SGreg Clayton { 12782f4cf46SGreg Clayton // If these defaults change, be sure to modify AnyOptionWasSet(). 12884c39663SGreg Clayton show_types = false; 1290c5ef693SEnrico Granata no_summary_depth = 0; 13084c39663SGreg Clayton show_location = false; 13184c39663SGreg Clayton flat_output = false; 13284c39663SGreg Clayton use_objc = false; 13384c39663SGreg Clayton max_depth = UINT32_MAX; 13484c39663SGreg Clayton ptr_depth = 0; 135d55546b2SEnrico Granata use_synth = true; 136ce68b02cSEnrico Granata be_raw = false; 13722c55d18SEnrico Granata ignore_cap = false; 13884c39663SGreg Clayton 139c14ee32dSGreg Clayton Target *target = interpreter.GetExecutionContext().GetTargetPtr(); 1402837b766SJim Ingham if (target != NULL) 1412837b766SJim Ingham use_dynamic = target->GetPreferDynamicValue(); 1422837b766SJim Ingham else 1432837b766SJim Ingham { 1442837b766SJim Ingham // If we don't have any targets, then dynamic values won't do us much good. 1452837b766SJim Ingham use_dynamic = lldb::eNoDynamicValues; 1462837b766SJim Ingham } 1472837b766SJim Ingham } 148