blob: dac44b10f84e670768c47330285087e218885e38 [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
10#include "OptionGroupValueObjectDisplay.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16
17using namespace lldb;
18using namespace lldb_private;
19
20OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay()
21{
22}
23
24OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
25{
26}
27
Greg Clayton56bbdaf2011-04-28 20:55:26 +000028static OptionDefinition
Greg Clayton57b3c6b2011-04-27 22:04:39 +000029g_option_table[] =
30{
Greg Clayton56bbdaf2011-04-28 20:55:26 +000031 { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
Greg Clayton57b3c6b2011-04-27 22:04:39 +000032 { 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."},
Greg Clayton56bbdaf2011-04-28 20:55:26 +000034 { 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."},
Greg Clayton57b3c6b2011-04-27 22:04:39 +000038 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
39};
40
41const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
42
43uint32_t
44OptionGroupValueObjectDisplay::GetNumDefinitions ()
45{
46 return k_num_file_options;
47}
48
49const OptionDefinition *
50OptionGroupValueObjectDisplay::GetDefinitions ()
51{
52 return g_option_table;
53}
54
55
56Error
57OptionGroupValueObjectDisplay::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 {
Greg Clayton56bbdaf2011-04-28 20:55:26 +000067 case 'T': show_types = true; break;
68 case 'Y': show_summary = false; break;
Greg Clayton57b3c6b2011-04-27 22:04:39 +000069 case 'L': show_location= true; break;
70 case 'F': flat_output = true; break;
Greg Clayton56bbdaf2011-04-28 20:55:26 +000071 case 'O': use_objc = true; break;
72 case 'D':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000073 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
Greg Clayton56bbdaf2011-04-28 20:55:26 +000078 case 'P':
Greg Clayton57b3c6b2011-04-27 22:04:39 +000079 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
92void
93OptionGroupValueObjectDisplay::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;
Greg Clayton57b3c6b2011-04-27 22:04:39 +0000102}
103