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 19 using namespace lldb; 20 using namespace lldb_private; 21 22 OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() 23 { 24 } 25 26 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () 27 { 28 } 29 30 static OptionDefinition 31 g_option_table[] = 32 { 33 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, 34 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, 35 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, 36 { 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."}, 37 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 38 { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 39 { 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)."}, 40 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 41 { LLDB_OPT_SET_1, false, "no-summary", 'Y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, 42 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } 43 }; 44 45 const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); 46 47 uint32_t 48 OptionGroupValueObjectDisplay::GetNumDefinitions () 49 { 50 return k_num_file_options; 51 } 52 53 const OptionDefinition * 54 OptionGroupValueObjectDisplay::GetDefinitions () 55 { 56 return g_option_table; 57 } 58 59 60 Error 61 OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 62 uint32_t option_idx, 63 const char *option_arg) 64 { 65 Error error; 66 char short_option = (char) g_option_table[option_idx].short_option; 67 bool success = false; 68 69 switch (short_option) 70 { 71 case 'd': 72 { 73 bool success; 74 int32_t result; 75 result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); 76 if (!success) 77 error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); 78 else 79 use_dynamic = (lldb::DynamicValueType) result; 80 } 81 break; 82 case 'T': show_types = true; break; 83 case 'Y': show_summary = false; break; 84 case 'L': show_location= true; break; 85 case 'F': flat_output = true; break; 86 case 'O': use_objc = true; break; 87 case 'D': 88 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 89 if (!success) 90 error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); 91 break; 92 93 case 'P': 94 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 95 if (!success) 96 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 97 break; 98 99 default: 100 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); 101 break; 102 } 103 104 return error; 105 } 106 107 void 108 OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 109 { 110 show_types = false; 111 show_summary = true; 112 show_location = false; 113 flat_output = false; 114 use_objc = false; 115 max_depth = UINT32_MAX; 116 ptr_depth = 0; 117 118 Target *target = interpreter.GetExecutionContext().target; 119 if (target != NULL) 120 use_dynamic = target->GetPreferDynamicValue(); 121 else 122 { 123 // If we don't have any targets, then dynamic values won't do us much good. 124 use_dynamic = lldb::eNoDynamicValues; 125 } 126 } 127