1 //===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionGroupWatchpoint.h"
14 // Other libraries and framework includes
16 #include "lldb/lldb-enumerations.h"
17 #include "lldb/Interpreter/Args.h"
18 #include "lldb/Utility/Utils.h"
21 using namespace lldb_private;
23 static OptionEnumValueElement g_watch_type[] =
25 { OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
26 { OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
27 { OptionGroupWatchpoint::eWatchReadWrite, "read_write", "Watch for read/write"},
31 static OptionEnumValueElement g_watch_size[] =
33 { 1, "1", "Watch for byte size of 1"},
34 { 2, "2", "Watch for byte size of 2"},
35 { 4, "4", "Watch for byte size of 4"},
36 { 8, "8", "Watch for byte size of 8"},
40 static OptionDefinition
43 { LLDB_OPT_SET_1, false, "watch", 'w', OptionParser::eRequiredArgument, g_watch_type, 0, eArgTypeWatchType, "Specify the type of watching to perform."},
44 { LLDB_OPT_SET_1, false, "xsize", 'x', OptionParser::eRequiredArgument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a region."}
49 OptionGroupWatchpoint::IsWatchSizeSupported(uint32_t watch_size)
51 for (uint32_t i = 0; i < llvm::array_lengthof(g_watch_size); ++i)
53 if (g_watch_size[i].value == 0)
55 if (watch_size == g_watch_size[i].value)
61 OptionGroupWatchpoint::OptionGroupWatchpoint () :
66 OptionGroupWatchpoint::~OptionGroupWatchpoint ()
71 OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
73 const char *option_arg)
76 const int short_option = g_option_table[option_idx].short_option;
81 WatchType tmp_watch_type;
82 tmp_watch_type = (WatchType) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error);
85 watch_type = tmp_watch_type;
86 watch_type_specified = true;
91 watch_size = (uint32_t) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error);
95 error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
103 OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
105 watch_type_specified = false;
106 watch_type = eWatchInvalid;
111 const OptionDefinition*
112 OptionGroupWatchpoint::GetDefinitions ()
114 return g_option_table;
118 OptionGroupWatchpoint::GetNumDefinitions ()
120 return llvm::array_lengthof(g_option_table);