1 //===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Target/Target.h" 17 #include "lldb/Interpreter/CommandInterpreter.h" 18 #include "lldb/Utility/Utils.h" 19 20 using namespace lldb; 21 using namespace lldb_private; 22 23 OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() 24 { 25 } 26 27 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () 28 { 29 } 30 31 static OptionDefinition 32 g_option_table[] = 33 { 34 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, 35 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, 36 { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, 37 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, 38 { 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."}, 39 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 40 { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 41 { 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)."}, 42 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 43 { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."}, 44 { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, 45 { 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."}, 46 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } 47 }; 48 49 uint32_t 50 OptionGroupValueObjectDisplay::GetNumDefinitions () 51 { 52 return arraysize(g_option_table); 53 } 54 55 const OptionDefinition * 56 OptionGroupValueObjectDisplay::GetDefinitions () 57 { 58 return g_option_table; 59 } 60 61 62 Error 63 OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 64 uint32_t option_idx, 65 const char *option_arg) 66 { 67 Error error; 68 char short_option = (char) g_option_table[option_idx].short_option; 69 bool success = false; 70 71 switch (short_option) 72 { 73 case 'd': 74 { 75 int32_t result; 76 result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, error); 77 if (error.Success()) 78 use_dynamic = (lldb::DynamicValueType) result; 79 } 80 break; 81 case 'T': show_types = true; break; 82 case 'L': show_location= true; break; 83 case 'F': flat_output = true; break; 84 case 'O': use_objc = true; break; 85 case 'R': be_raw = true; break; 86 case 'A': ignore_cap = true; break; 87 88 case 'D': 89 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 90 if (!success) 91 error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); 92 break; 93 94 case 'P': 95 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 96 if (!success) 97 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 98 break; 99 100 case 'Y': 101 if (option_arg) 102 { 103 no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 104 if (!success) 105 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 106 } 107 else 108 no_summary_depth = 1; 109 break; 110 111 case 'S': 112 use_synth = Args::StringToBoolean(option_arg, true, &success); 113 if (!success) 114 error.SetErrorStringWithFormat("Invalid synthetic-type '%s'.\n", option_arg); 115 break; 116 default: 117 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); 118 break; 119 } 120 121 return error; 122 } 123 124 void 125 OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 126 { 127 show_types = false; 128 no_summary_depth = 0; 129 show_location = false; 130 flat_output = false; 131 use_objc = false; 132 max_depth = UINT32_MAX; 133 ptr_depth = 0; 134 use_synth = true; 135 be_raw = false; 136 ignore_cap = false; 137 138 Target *target = interpreter.GetExecutionContext().GetTargetPtr(); 139 if (target != NULL) 140 use_dynamic = target->GetPreferDynamicValue(); 141 else 142 { 143 // If we don't have any targets, then dynamic values won't do us much good. 144 use_dynamic = lldb::eNoDynamicValues; 145 } 146 } 147