blob: 5f540d60d06abf72293bfce41eb07d15dad96e24 [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
Johnny Chena0f34692011-05-13 20:21:08 +000010#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000011
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
Jim Ingham10de7d12011-05-04 03:43:18 +000016#include "lldb/Target/Target.h"
17#include "lldb/Interpreter/CommandInterpreter.h"
Greg Clayton57b3c6b2011-04-27 22:04:39 +000018
19using namespace lldb;
20using namespace lldb_private;
21
22OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay()
23{
24}
25
26OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
27{
28}
29
Greg Clayton56bbdaf2011-04-28 20:55:26 +000030static OptionDefinition
Greg Clayton57b3c6b2011-04-27 22:04:39 +000031g_option_table[] =
32{
Enrico Granata018921d2011-08-12 02:00:06 +000033 { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types,
Enrico Granatae4e3e2c2011-07-22 00:16:08 +000034 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
Enrico Granata018921d2011-08-12 02:00:06 +000035 { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
36 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
37 { 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."},
38 { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."},
39 { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."},
40 { 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)."},
41 { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."},
42 { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."},
43 { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."},
44 { 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 Clayton57b3c6b2011-04-27 22:04:39 +000045 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
46};
47
48const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
49
50uint32_t
51OptionGroupValueObjectDisplay::GetNumDefinitions ()
52{
53 return k_num_file_options;
54}
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;
69 char short_option = (char) g_option_table[option_idx].short_option;
70 bool success = false;
71
72 switch (short_option)
73 {
Jim Ingham10de7d12011-05-04 03:43:18 +000074 case 'd':
75 {
76 bool success;
77 int32_t result;
78 result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success);
79 if (!success)
80 error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg);
81 else
82 use_dynamic = (lldb::DynamicValueType) result;
83 }
84 break;
Greg Clayton56bbdaf2011-04-28 20:55:26 +000085 case 'T': show_types = true; break;
Greg Clayton57b3c6b2011-04-27 22:04:39 +000086 case 'L': show_location= true; break;
87 case 'F': flat_output = true; break;
Enrico Granata840eb262011-08-09 23:50:01 +000088 case 'O': use_objc = true; break;
89 case 'R': be_raw = true; break;
Enrico Granata018921d2011-08-12 02:00:06 +000090 case 'A': ignore_cap = true; break;
Enrico Granata840eb262011-08-09 23:50:01 +000091
Greg Clayton56bbdaf2011-04-28 20:55:26 +000092 case 'D':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000093 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
94 if (!success)
95 error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg);
96 break;
97
Greg Clayton56bbdaf2011-04-28 20:55:26 +000098 case 'P':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000099 ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
100 if (!success)
101 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg);
102 break;
103
Enrico Granata7f163b32011-07-16 01:22:04 +0000104 case 'Y':
105 if (option_arg)
106 {
107 no_summary_depth = Args::StringToUInt32 (option_arg, 0, 0, &success);
108 if (!success)
109 error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg);
110 }
111 else
112 no_summary_depth = 1;
113 break;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000114
115 case 'S':
116 use_synth = Args::StringToBoolean(option_arg, true, &success);
117 if (!success)
118 error.SetErrorStringWithFormat("Invalid synthetic-type '%s'.\n", option_arg);
119 break;
Greg Clayton57b3c6b2011-04-27 22:04:39 +0000120 default:
121 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
122 break;
123 }
124
125 return error;
126}
127
128void
129OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter)
130{
Enrico Granata7f163b32011-07-16 01:22:04 +0000131 show_types = false;
132 no_summary_depth = 0;
133 show_location = false;
134 flat_output = false;
135 use_objc = false;
136 max_depth = UINT32_MAX;
137 ptr_depth = 0;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000138 use_synth = true;
Enrico Granata840eb262011-08-09 23:50:01 +0000139 be_raw = false;
Enrico Granata018921d2011-08-12 02:00:06 +0000140 ignore_cap = false;
Jim Ingham10de7d12011-05-04 03:43:18 +0000141
142 Target *target = interpreter.GetExecutionContext().target;
143 if (target != NULL)
144 use_dynamic = target->GetPreferDynamicValue();
145 else
146 {
147 // If we don't have any targets, then dynamic values won't do us much good.
148 use_dynamic = lldb::eNoDynamicValues;
149 }
Johnny Chena0f34692011-05-13 20:21:08 +0000150}