Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame^] | 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 | 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, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat,"Specify the format that the variable output should use."}, |
| 33 | { 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."}, |
| 34 | { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, |
| 35 | { LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, |
| 36 | { 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)."}, |
| 37 | { LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, |
| 38 | { LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, |
| 39 | { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } |
| 40 | }; |
| 41 | |
| 42 | const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); |
| 43 | |
| 44 | uint32_t |
| 45 | OptionGroupValueObjectDisplay::GetNumDefinitions () |
| 46 | { |
| 47 | return k_num_file_options; |
| 48 | } |
| 49 | |
| 50 | const OptionDefinition * |
| 51 | OptionGroupValueObjectDisplay::GetDefinitions () |
| 52 | { |
| 53 | return g_option_table; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | Error |
| 58 | OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, |
| 59 | uint32_t option_idx, |
| 60 | const char *option_arg) |
| 61 | { |
| 62 | Error error; |
| 63 | char short_option = (char) g_option_table[option_idx].short_option; |
| 64 | bool success = false; |
| 65 | |
| 66 | switch (short_option) |
| 67 | { |
| 68 | case 't': show_types = true; break; |
| 69 | case 'y': show_summary = false; break; |
| 70 | case 'L': show_location= true; break; |
| 71 | case 'F': flat_output = true; break; |
| 72 | case 'f': error = Args::StringToFormat(option_arg, format); break; |
| 73 | case 'o': use_objc = true; break; |
| 74 | case 'd': |
| 75 | max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); |
| 76 | if (!success) |
| 77 | error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); |
| 78 | break; |
| 79 | |
| 80 | case 'p': |
| 81 | ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); |
| 82 | if (!success) |
| 83 | error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); |
| 84 | break; |
| 85 | |
| 86 | default: |
| 87 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | return error; |
| 92 | } |
| 93 | |
| 94 | void |
| 95 | OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) |
| 96 | { |
| 97 | show_types = false; |
| 98 | show_summary = true; |
| 99 | show_location = false; |
| 100 | flat_output = false; |
| 101 | use_objc = false; |
| 102 | max_depth = UINT32_MAX; |
| 103 | ptr_depth = 0; |
| 104 | format = eFormatDefault; |
| 105 | } |
| 106 | |