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 10*93a64300SDaniel Malea #include "lldb/lldb-python.h" 11*93a64300SDaniel Malea 124bee32e5SJohnny Chen #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" 1384c39663SGreg Clayton 1484c39663SGreg Clayton // C Includes 1584c39663SGreg Clayton // C++ Includes 1684c39663SGreg Clayton // Other libraries and framework includes 1784c39663SGreg Clayton // Project includes 182837b766SJim Ingham #include "lldb/Target/Target.h" 192837b766SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h" 207c575b3bSJohnny Chen #include "lldb/Utility/Utils.h" 2184c39663SGreg Clayton 2284c39663SGreg Clayton using namespace lldb; 2384c39663SGreg Clayton using namespace lldb_private; 2484c39663SGreg Clayton 2584c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() 2684c39663SGreg Clayton { 2784c39663SGreg Clayton } 2884c39663SGreg Clayton 2984c39663SGreg Clayton OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () 3084c39663SGreg Clayton { 3184c39663SGreg Clayton } 3284c39663SGreg Clayton 3368ebae61SGreg Clayton static OptionDefinition 3484c39663SGreg Clayton g_option_table[] = 3584c39663SGreg Clayton { 3667cc0636SGreg 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."}, 37d55546b2SEnrico Granata { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, 3868ebae61SGreg 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)."}, 3984c39663SGreg 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."}, 4084c39663SGreg Clayton { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 4168ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 4268ebae61SGreg 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)."}, 4368ebae61SGreg Clayton { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 44e58a507dSEnrico 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)."}, 45ce68b02cSEnrico Granata { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, 4622c55d18SEnrico 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."}, 47b4cb0be3SFilipe Cabecinhas { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } 4884c39663SGreg Clayton }; 4984c39663SGreg Clayton 5084c39663SGreg Clayton uint32_t 5184c39663SGreg Clayton OptionGroupValueObjectDisplay::GetNumDefinitions () 5284c39663SGreg Clayton { 536ebc8c45SJohnny Chen return llvm::array_lengthof(g_option_table); 5484c39663SGreg Clayton } 5584c39663SGreg Clayton 5684c39663SGreg Clayton const OptionDefinition * 5784c39663SGreg Clayton OptionGroupValueObjectDisplay::GetDefinitions () 5884c39663SGreg Clayton { 5984c39663SGreg Clayton return g_option_table; 6084c39663SGreg Clayton } 6184c39663SGreg Clayton 6284c39663SGreg Clayton 6384c39663SGreg Clayton Error 6484c39663SGreg Clayton OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 6584c39663SGreg Clayton uint32_t option_idx, 6684c39663SGreg Clayton const char *option_arg) 6784c39663SGreg Clayton { 6884c39663SGreg Clayton Error error; 693bcdfc0eSGreg Clayton const int short_option = g_option_table[option_idx].short_option; 7084c39663SGreg Clayton bool success = false; 7184c39663SGreg Clayton 7284c39663SGreg Clayton switch (short_option) 7384c39663SGreg Clayton { 742837b766SJim Ingham case 'd': 752837b766SJim Ingham { 762837b766SJim Ingham int32_t result; 7767cc0636SGreg Clayton result = Args::StringToOptionEnum (option_arg, g_dynamic_value_types, 2, error); 78cf0e4f0dSGreg Clayton if (error.Success()) 792837b766SJim Ingham use_dynamic = (lldb::DynamicValueType) result; 802837b766SJim Ingham } 812837b766SJim Ingham break; 8268ebae61SGreg Clayton case 'T': show_types = true; break; 8384c39663SGreg Clayton case 'L': show_location= true; break; 8484c39663SGreg Clayton case 'F': flat_output = true; break; 8568ebae61SGreg Clayton case 'O': use_objc = true; break; 86ce68b02cSEnrico Granata case 'R': be_raw = true; break; 8722c55d18SEnrico Granata case 'A': ignore_cap = true; break; 88ce68b02cSEnrico Granata 8968ebae61SGreg Clayton case 'D': 9084c39663SGreg Clayton max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 9184c39663SGreg Clayton if (!success) 9286edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg); 9384c39663SGreg Clayton break; 9484c39663SGreg Clayton 9568ebae61SGreg Clayton case 'P': 9684c39663SGreg Clayton ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 9784c39663SGreg Clayton if (!success) 9886edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 9984c39663SGreg Clayton break; 10084c39663SGreg Clayton 1010c5ef693SEnrico Granata case 'Y': 1020c5ef693SEnrico Granata if (option_arg) 1030c5ef693SEnrico Granata { 1040c5ef693SEnrico Granata no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 1050c5ef693SEnrico Granata if (!success) 10686edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg); 1070c5ef693SEnrico Granata } 1080c5ef693SEnrico Granata else 1090c5ef693SEnrico Granata no_summary_depth = 1; 1100c5ef693SEnrico Granata break; 1110c5ef693SEnrico Granata 112d55546b2SEnrico Granata case 'S': 113d55546b2SEnrico Granata use_synth = Args::StringToBoolean(option_arg, true, &success); 114d55546b2SEnrico Granata if (!success) 11586edbf41SGreg Clayton error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg); 116d55546b2SEnrico Granata break; 11784c39663SGreg Clayton default: 11886edbf41SGreg Clayton error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 11984c39663SGreg Clayton break; 12084c39663SGreg Clayton } 12184c39663SGreg Clayton 12284c39663SGreg Clayton return error; 12384c39663SGreg Clayton } 12484c39663SGreg Clayton 12584c39663SGreg Clayton void 12684c39663SGreg Clayton OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 12784c39663SGreg Clayton { 12882f4cf46SGreg Clayton // If these defaults change, be sure to modify AnyOptionWasSet(). 12984c39663SGreg Clayton show_types = false; 1300c5ef693SEnrico Granata no_summary_depth = 0; 13184c39663SGreg Clayton show_location = false; 13284c39663SGreg Clayton flat_output = false; 13384c39663SGreg Clayton use_objc = false; 13484c39663SGreg Clayton max_depth = UINT32_MAX; 13584c39663SGreg Clayton ptr_depth = 0; 136d55546b2SEnrico Granata use_synth = true; 137ce68b02cSEnrico Granata be_raw = false; 13822c55d18SEnrico Granata ignore_cap = false; 13984c39663SGreg Clayton 140c14ee32dSGreg Clayton Target *target = interpreter.GetExecutionContext().GetTargetPtr(); 1412837b766SJim Ingham if (target != NULL) 1422837b766SJim Ingham use_dynamic = target->GetPreferDynamicValue(); 1432837b766SJim Ingham else 1442837b766SJim Ingham { 1452837b766SJim Ingham // If we don't have any targets, then dynamic values won't do us much good. 1462837b766SJim Ingham use_dynamic = lldb::eNoDynamicValues; 1472837b766SJim Ingham } 1482837b766SJim Ingham } 149