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 { 527c575b3bSJohnny Chen return arraysize(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 bool success; 762837b766SJim Ingham int32_t result; 772837b766SJim Ingham result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); 782837b766SJim Ingham if (!success) 792837b766SJim Ingham error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); 802837b766SJim Ingham else 812837b766SJim Ingham use_dynamic = (lldb::DynamicValueType) result; 822837b766SJim Ingham } 832837b766SJim Ingham break; 8468ebae61SGreg Clayton case 'T': show_types = true; break; 8584c39663SGreg Clayton case 'L': show_location= true; break; 8684c39663SGreg Clayton case 'F': flat_output = true; break; 8768ebae61SGreg Clayton case 'O': use_objc = true; break; 88ce68b02cSEnrico Granata case 'R': be_raw = true; break; 8922c55d18SEnrico Granata case 'A': ignore_cap = true; break; 90ce68b02cSEnrico Granata 9168ebae61SGreg Clayton case 'D': 9284c39663SGreg Clayton max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 9384c39663SGreg Clayton if (!success) 9484c39663SGreg Clayton error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); 9584c39663SGreg Clayton break; 9684c39663SGreg Clayton 9768ebae61SGreg Clayton case 'P': 9884c39663SGreg Clayton ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 9984c39663SGreg Clayton if (!success) 10084c39663SGreg Clayton error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 10184c39663SGreg Clayton break; 10284c39663SGreg Clayton 1030c5ef693SEnrico Granata case 'Y': 1040c5ef693SEnrico Granata if (option_arg) 1050c5ef693SEnrico Granata { 1060c5ef693SEnrico Granata no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 1070c5ef693SEnrico Granata if (!success) 1080c5ef693SEnrico Granata error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 1090c5ef693SEnrico Granata } 1100c5ef693SEnrico Granata else 1110c5ef693SEnrico Granata no_summary_depth = 1; 1120c5ef693SEnrico Granata break; 1130c5ef693SEnrico Granata 114d55546b2SEnrico Granata case 'S': 115d55546b2SEnrico Granata use_synth = Args::StringToBoolean(option_arg, true, &success); 116d55546b2SEnrico Granata if (!success) 117d55546b2SEnrico Granata error.SetErrorStringWithFormat("Invalid synthetic-type '%s'.\n", option_arg); 118d55546b2SEnrico Granata break; 11984c39663SGreg Clayton default: 12084c39663SGreg Clayton error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); 12184c39663SGreg Clayton break; 12284c39663SGreg Clayton } 12384c39663SGreg Clayton 12484c39663SGreg Clayton return error; 12584c39663SGreg Clayton } 12684c39663SGreg Clayton 12784c39663SGreg Clayton void 12884c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 12984c39663SGreg Clayton { 13084c39663SGreg Clayton show_types = false; 1310c5ef693SEnrico Granata no_summary_depth = 0; 13284c39663SGreg Clayton show_location = false; 13384c39663SGreg Clayton flat_output = false; 13484c39663SGreg Clayton use_objc = false; 13584c39663SGreg Clayton max_depth = UINT32_MAX; 13684c39663SGreg Clayton ptr_depth = 0; 137d55546b2SEnrico Granata use_synth = true; 138ce68b02cSEnrico Granata be_raw = false; 13922c55d18SEnrico Granata ignore_cap = false; 14084c39663SGreg Clayton 141*c14ee32dSGreg Clayton Target *target = interpreter.GetExecutionContext().GetTargetPtr(); 1422837b766SJim Ingham if (target != NULL) 1432837b766SJim Ingham use_dynamic = target->GetPreferDynamicValue(); 1442837b766SJim Ingham else 1452837b766SJim Ingham { 1462837b766SJim Ingham // If we don't have any targets, then dynamic values won't do us much good. 1472837b766SJim Ingham use_dynamic = lldb::eNoDynamicValues; 1482837b766SJim Ingham } 1492837b766SJim Ingham } 150