blob: be1bf57f51a039f63ed6d39fcbdd0da2c50d2b78 [file] [log] [blame]
Johnny Chen58dba3c2011-09-09 23:25:26 +00001//===-- OptionGroupWatchpoint.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/OptionGroupWatchpoint.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/lldb-enumerations.h"
17#include "lldb/Interpreter/Args.h"
Johnny Chen4003f572011-09-10 00:48:33 +000018#include "lldb/Utility/Utils.h"
Johnny Chen58dba3c2011-09-09 23:25:26 +000019
20using namespace lldb;
21using namespace lldb_private;
22
23static OptionEnumValueElement g_watch_mode[] =
24{
25 { OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
26 { OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
27 { OptionGroupWatchpoint::eWatchReadWrite, "read_write", "Watch for read/write"},
28 { 0, NULL, NULL }
29};
30
31// if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions()
32static OptionDefinition
33g_option_table[] =
34{
35 { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_mode, 0, eArgTypeWatchMode, "Determine how to watch a memory location (read, write, or read/write)."}
36};
37
38
39OptionGroupWatchpoint::OptionGroupWatchpoint () :
40 OptionGroup()
41{
42}
43
44OptionGroupWatchpoint::~OptionGroupWatchpoint ()
45{
46}
47
48Error
49OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
50 uint32_t option_idx,
51 const char *option_arg)
52{
53 Error error;
54 char short_option = (char) g_option_table[option_idx].short_option;
55 switch (short_option)
56 {
57 case 'w': {
58 watch_variable = false;
59 OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
60 watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable);
61 break;
62 }
63 default:
64 error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
65 break;
66 }
67
68 return error;
69}
70
71void
72OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
73{
74 watch_variable = false;
75 watch_mode = eWatchRead;
76}
77
78
79const OptionDefinition*
80OptionGroupWatchpoint::GetDefinitions ()
81{
82 return g_option_table;
83}
84
85uint32_t
86OptionGroupWatchpoint::GetNumDefinitions ()
87{
Johnny Chen4003f572011-09-10 00:48:33 +000088 return arraysize(g_option_table);
Johnny Chen58dba3c2011-09-09 23:25:26 +000089}