blob: c6d2e1ec1628f2795a9e9e9e3078ae092a3eb908 [file] [log] [blame]
Greg Clayton57b3c6b2011-04-27 22:04:39 +00001//===-- 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
Daniel Malead891f9b2012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Johnny Chena0f34692011-05-13 20:21:08 +000012#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000013
14// C Includes
15// C++ Includes
16// Other libraries and framework includes
17// Project includes
Jim Ingham10de7d12011-05-04 03:43:18 +000018#include "lldb/Target/Target.h"
19#include "lldb/Interpreter/CommandInterpreter.h"
Johnny Chen4003f572011-09-10 00:48:33 +000020#include "lldb/Utility/Utils.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000021
22using namespace lldb;
23using namespace lldb_private;
24
25OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay()
26{
27}
28
29OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
30{
31}
32
Greg Clayton56bbdaf2011-04-28 20:55:26 +000033static OptionDefinition
Greg Clayton57b3c6b2011-04-27 22:04:39 +000034g_option_table[] =
35{
Enrico Granata992d2272012-12-12 03:23:37 +000036 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
37 { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
38 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
39 { 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."},
40 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."},
41 { LLDB_OPT_SET_1, false, "object-description", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."},
42 { 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)."},
43 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."},
44 { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set the depth at which omitting summary information stops (default is 1)."},
45 { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."},
46 { 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."},
Filipe Cabecinhas5ebd51f2012-09-11 18:11:07 +000047 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Greg Clayton57b3c6b2011-04-27 22:04:39 +000048};
49
Greg Clayton57b3c6b2011-04-27 22:04:39 +000050uint32_t
51OptionGroupValueObjectDisplay::GetNumDefinitions ()
52{
Johnny Chen08af5982012-05-15 23:21:36 +000053 return llvm::array_lengthof(g_option_table);
Greg Clayton57b3c6b2011-04-27 22:04:39 +000054}
55
56const OptionDefinition *
57OptionGroupValueObjectDisplay::GetDefinitions ()
58{
59 return g_option_table;
60}
61
62
63Error
64OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
65 uint32_t option_idx,
66 const char *option_arg)
67{
68 Error error;
Greg Clayton6475c422012-12-04 00:32:51 +000069 const int short_option = g_option_table[option_idx].short_option;
Greg Clayton57b3c6b2011-04-27 22:04:39 +000070 bool success = false;
71
72 switch (short_option)
73 {
Jim Ingham10de7d12011-05-04 03:43:18 +000074 case 'd':
75 {
Jim Ingham10de7d12011-05-04 03:43:18 +000076 int32_t result;
Greg Clayton73844aa2012-08-22 17:17:09 +000077 result = Args::StringToOptionEnum (option_arg, g_dynamic_value_types, 2, error);
Greg Clayton61aca5d2011-10-07 18:58:12 +000078 if (error.Success())
Jim Ingham10de7d12011-05-04 03:43:18 +000079 use_dynamic = (lldb::DynamicValueType) result;
80 }
81 break;
Greg Clayton56bbdaf2011-04-28 20:55:26 +000082 case 'T': show_types = true; break;
Greg Clayton57b3c6b2011-04-27 22:04:39 +000083 case 'L': show_location= true; break;
84 case 'F': flat_output = true; break;
Enrico Granata840eb262011-08-09 23:50:01 +000085 case 'O': use_objc = true; break;
86 case 'R': be_raw = true; break;
Enrico Granata018921d2011-08-12 02:00:06 +000087 case 'A': ignore_cap = true; break;
Enrico Granata840eb262011-08-09 23:50:01 +000088
Greg Clayton56bbdaf2011-04-28 20:55:26 +000089 case 'D':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000090 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
91 if (!success)
Greg Clayton9c236732011-10-26 00:56:27 +000092 error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg);
Greg Clayton57b3c6b2011-04-27 22:04:39 +000093 break;
94
Greg Clayton56bbdaf2011-04-28 20:55:26 +000095 case 'P':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000096 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
97 if (!success)
Greg Clayton9c236732011-10-26 00:56:27 +000098 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
Greg Clayton57b3c6b2011-04-27 22:04:39 +000099 break;
100
Enrico Granata7f163b32011-07-16 01:22:04 +0000101 case 'Y':
102 if (option_arg)
103 {
104 no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
105 if (!success)
Greg Clayton9c236732011-10-26 00:56:27 +0000106 error.SetErrorStringWithFormat("invalid pointer depth '%s'", option_arg);
Enrico Granata7f163b32011-07-16 01:22:04 +0000107 }
108 else
109 no_summary_depth = 1;
110 break;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000111
112 case 'S':
113 use_synth = Args::StringToBoolean(option_arg, true, &success);
114 if (!success)
Greg Clayton9c236732011-10-26 00:56:27 +0000115 error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg);
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000116 break;
Greg Clayton57b3c6b2011-04-27 22:04:39 +0000117 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000118 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Greg Clayton57b3c6b2011-04-27 22:04:39 +0000119 break;
120 }
121
122 return error;
123}
124
125void
126OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter)
127{
Greg Clayton902b5be2011-10-26 04:32:38 +0000128 // If these defaults change, be sure to modify AnyOptionWasSet().
Enrico Granata7f163b32011-07-16 01:22:04 +0000129 show_types = false;
130 no_summary_depth = 0;
131 show_location = false;
132 flat_output = false;
133 use_objc = false;
134 max_depth = UINT32_MAX;
135 ptr_depth = 0;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000136 use_synth = true;
Enrico Granata840eb262011-08-09 23:50:01 +0000137 be_raw = false;
Enrico Granata018921d2011-08-12 02:00:06 +0000138 ignore_cap = false;
Jim Ingham10de7d12011-05-04 03:43:18 +0000139
Greg Clayton567e7f32011-09-22 04:58:26 +0000140 Target *target = interpreter.GetExecutionContext().GetTargetPtr();
Jim Ingham10de7d12011-05-04 03:43:18 +0000141 if (target != NULL)
142 use_dynamic = target->GetPreferDynamicValue();
143 else
144 {
145 // If we don't have any targets, then dynamic values won't do us much good.
146 use_dynamic = lldb::eNoDynamicValues;
147 }
Johnny Chena0f34692011-05-13 20:21:08 +0000148}