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 "OptionGroupValueObjectDisplay.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() 21 { 22 } 23 24 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () 25 { 26 } 27 28 static OptionDefinition 29 g_option_table[] = 30 { 31 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, 32 { 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."}, 33 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, 34 { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, 35 { 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)."}, 36 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, 37 { LLDB_OPT_SET_1, false, "no-summary", 'Y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, 38 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } 39 }; 40 41 const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); 42 43 uint32_t 44 OptionGroupValueObjectDisplay::GetNumDefinitions () 45 { 46 return k_num_file_options; 47 } 48 49 const OptionDefinition * 50 OptionGroupValueObjectDisplay::GetDefinitions () 51 { 52 return g_option_table; 53 } 54 55 56 Error 57 OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, 58 uint32_t option_idx, 59 const char *option_arg) 60 { 61 Error error; 62 char short_option = (char) g_option_table[option_idx].short_option; 63 bool success = false; 64 65 switch (short_option) 66 { 67 case 'T': show_types = true; break; 68 case 'Y': show_summary = false; break; 69 case 'L': show_location= true; break; 70 case 'F': flat_output = true; break; 71 case 'O': use_objc = true; break; 72 case 'D': 73 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); 74 if (!success) 75 error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); 76 break; 77 78 case 'P': 79 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); 80 if (!success) 81 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); 82 break; 83 84 default: 85 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); 86 break; 87 } 88 89 return error; 90 } 91 92 void 93 OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) 94 { 95 show_types = false; 96 show_summary = true; 97 show_location = false; 98 flat_output = false; 99 use_objc = false; 100 max_depth = UINT32_MAX; 101 ptr_depth = 0; 102 } 103 104