blob: 6d1fcb75e5bd012788522017d9fa0aa37017c2b9 [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"
18
19using namespace lldb;
20using namespace lldb_private;
21
22static OptionEnumValueElement g_watch_mode[] =
23{
24 { OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
25 { OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
26 { OptionGroupWatchpoint::eWatchReadWrite, "read_write", "Watch for read/write"},
27 { 0, NULL, NULL }
28};
29
30// if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions()
31static OptionDefinition
32g_option_table[] =
33{
34 { 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)."}
35};
36
37
38OptionGroupWatchpoint::OptionGroupWatchpoint () :
39 OptionGroup()
40{
41}
42
43OptionGroupWatchpoint::~OptionGroupWatchpoint ()
44{
45}
46
47Error
48OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
49 uint32_t option_idx,
50 const char *option_arg)
51{
52 Error error;
53 char short_option = (char) g_option_table[option_idx].short_option;
54 switch (short_option)
55 {
56 case 'w': {
57 watch_variable = false;
58 OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
59 watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable);
60 break;
61 }
62 default:
63 error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
64 break;
65 }
66
67 return error;
68}
69
70void
71OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
72{
73 watch_variable = false;
74 watch_mode = eWatchRead;
75}
76
77
78const OptionDefinition*
79OptionGroupWatchpoint::GetDefinitions ()
80{
81 return g_option_table;
82}
83
84uint32_t
85OptionGroupWatchpoint::GetNumDefinitions ()
86{
87 return 1;
88}
89
90