blob: e553e1bea479a37be4b6df8a3529c5f601e662c9 [file] [log] [blame]
Greg Clayton368f8222011-07-07 04:38:25 +00001//===-- OptionGroupVariable.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 "lldb/Interpreter/OptionGroupVariable.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/Target/Target.h"
17#include "lldb/Interpreter/CommandInterpreter.h"
18
19using namespace lldb;
20using namespace lldb_private;
21
22static OptionDefinition
23g_option_table[] =
24{
25 { LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."},
26 { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."},
27 { LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
28 { LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
29 { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."},
30 { LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
31 { LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}
32};
33
34
35OptionGroupVariable::OptionGroupVariable (bool show_frame_options) :
36 OptionGroup(),
37 include_frame_options (show_frame_options)
38{
39}
40
41OptionGroupVariable::~OptionGroupVariable ()
42{
43}
44
45Error
46OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter,
47 uint32_t option_idx,
48 const char *option_arg)
49{
50 Error error;
51 if (!include_frame_options)
52 option_idx += 3;
53 char short_option = (char) g_option_table[option_idx].short_option;
54 switch (short_option)
55 {
56 case 'r': use_regex = true; break;
57 case 'a': show_args = false; break;
58 case 'l': show_locals = false; break;
59 case 'g': show_globals = true; break;
60 case 'c': show_decl = true; break;
61 case 'f': error = Args::StringToFormat(option_arg, format, NULL); break;
62 case 's':
63 show_scope = true;
64 break;
65
66 default:
67 error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
68 break;
69 }
70
71 return error;
72}
73
74void
75OptionGroupVariable::OptionParsingStarting (CommandInterpreter &interpreter)
76{
77 show_args = true; // Frame option only
78 show_locals = true; // Frame option only
79 show_globals = false; // Frame option only
80 show_decl = false;
81 format = lldb::eFormatDefault;
82 use_regex = false;
83 show_scope = false;
84}
85
86
87const OptionDefinition*
88OptionGroupVariable::GetDefinitions ()
89{
90 // Show the "--no-args", "--no-locals" and "--show-globals"
91 // options if we are showing frame specific options
92 if (include_frame_options)
93 return g_option_table;
94
95 // Skip the "--no-args", "--no-locals" and "--show-globals"
96 // options if we are not showing frame specific options (globals only)
97 return &g_option_table[3];
98}
99
100uint32_t
101OptionGroupVariable::GetNumDefinitions ()
102{
103 if (include_frame_options)
104 return 7;
105 else
106 return 4;
107}
108
109