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 | |
Johnny Chen | a0f3469 | 2011-05-13 20:21:08 +0000 | [diff] [blame] | 10 | #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 16 | #include "lldb/Target/Target.h" |
| 17 | #include "lldb/Interpreter/CommandInterpreter.h" |
Johnny Chen | 4003f57 | 2011-09-10 00:48:33 +0000 | [diff] [blame^] | 18 | #include "lldb/Utility/Utils.h" |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 19 | |
| 20 | using namespace lldb; |
| 21 | using namespace lldb_private; |
| 22 | |
| 23 | OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () |
| 28 | { |
| 29 | } |
| 30 | |
Greg Clayton | 56bbdaf | 2011-04-28 20:55:26 +0000 | [diff] [blame] | 31 | static OptionDefinition |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 32 | g_option_table[] = |
| 33 | { |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 34 | { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 35 | 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 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."}, |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 46 | { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } |
| 47 | }; |
| 48 | |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 49 | uint32_t |
| 50 | OptionGroupValueObjectDisplay::GetNumDefinitions () |
| 51 | { |
Johnny Chen | 4003f57 | 2011-09-10 00:48:33 +0000 | [diff] [blame^] | 52 | return arraysize(g_option_table); |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 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 | { |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 73 | case 'd': |
| 74 | { |
| 75 | bool success; |
| 76 | int32_t result; |
| 77 | result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); |
| 78 | if (!success) |
| 79 | error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); |
| 80 | else |
| 81 | use_dynamic = (lldb::DynamicValueType) result; |
| 82 | } |
| 83 | break; |
Greg Clayton | 56bbdaf | 2011-04-28 20:55:26 +0000 | [diff] [blame] | 84 | case 'T': show_types = true; break; |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 85 | case 'L': show_location= true; break; |
| 86 | case 'F': flat_output = true; break; |
Enrico Granata | 840eb26 | 2011-08-09 23:50:01 +0000 | [diff] [blame] | 87 | case 'O': use_objc = true; break; |
| 88 | case 'R': be_raw = true; break; |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 89 | case 'A': ignore_cap = true; break; |
Enrico Granata | 840eb26 | 2011-08-09 23:50:01 +0000 | [diff] [blame] | 90 | |
Greg Clayton | 56bbdaf | 2011-04-28 20:55:26 +0000 | [diff] [blame] | 91 | case 'D': |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 92 | max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); |
| 93 | if (!success) |
| 94 | error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); |
| 95 | break; |
| 96 | |
Greg Clayton | 56bbdaf | 2011-04-28 20:55:26 +0000 | [diff] [blame] | 97 | case 'P': |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 98 | ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); |
| 99 | if (!success) |
| 100 | error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); |
| 101 | break; |
| 102 | |
Enrico Granata | 7f163b3 | 2011-07-16 01:22:04 +0000 | [diff] [blame] | 103 | case 'Y': |
| 104 | if (option_arg) |
| 105 | { |
| 106 | no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); |
| 107 | if (!success) |
| 108 | error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); |
| 109 | } |
| 110 | else |
| 111 | no_summary_depth = 1; |
| 112 | break; |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 113 | |
| 114 | case 'S': |
| 115 | use_synth = Args::StringToBoolean(option_arg, true, &success); |
| 116 | if (!success) |
| 117 | error.SetErrorStringWithFormat("Invalid synthetic-type '%s'.\n", option_arg); |
| 118 | break; |
Greg Clayton | 57b3c6b | 2011-04-27 22:04:39 +0000 | [diff] [blame] | 119 | default: |
| 120 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | return error; |
| 125 | } |
| 126 | |
| 127 | void |
| 128 | OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) |
| 129 | { |
Enrico Granata | 7f163b3 | 2011-07-16 01:22:04 +0000 | [diff] [blame] | 130 | show_types = false; |
| 131 | no_summary_depth = 0; |
| 132 | show_location = false; |
| 133 | flat_output = false; |
| 134 | use_objc = false; |
| 135 | max_depth = UINT32_MAX; |
| 136 | ptr_depth = 0; |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 137 | use_synth = true; |
Enrico Granata | 840eb26 | 2011-08-09 23:50:01 +0000 | [diff] [blame] | 138 | be_raw = false; |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 139 | ignore_cap = false; |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 140 | |
| 141 | Target *target = interpreter.GetExecutionContext().target; |
| 142 | if (target != NULL) |
| 143 | use_dynamic = target->GetPreferDynamicValue(); |
| 144 | else |
| 145 | { |
| 146 | // If we don't have any targets, then dynamic values won't do us much good. |
| 147 | use_dynamic = lldb::eNoDynamicValues; |
| 148 | } |
Johnny Chen | a0f3469 | 2011-05-13 20:21:08 +0000 | [diff] [blame] | 149 | } |