Add OptionGroupWatchpoint.cpp/.h (preparatory work) for hooking up watchpoint to the 'frame variable' comand.
To watch a variable for read/write, issue:
frame variable -w read_write
Note that '-w' option is not working yet. :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139434 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index ed27b38..1247209 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -28,6 +28,7 @@
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Interpreter/OptionGroupVariable.h"
+#include "lldb/Interpreter/OptionGroupWatchpoint.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -315,11 +316,15 @@
"If any arguments are specified, they can be names of "
"argument, local, file static and file global variables. "
"Children of aggregate variables can be specified such as "
- "'var->child.x'.",
+ "'var->child.x'. "
+ "NOTE that '-w' option is not working yet!!! "
+ "You can choose to watch a variable with the '-w' option. "
+ "Note that hardware resources for watching are often limited.",
NULL,
eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
m_option_group (interpreter),
m_option_variable(true), // Include the frame specific options by passing "true"
+ m_option_watchpoint(),
m_varobj_options()
{
CommandArgumentEntry arg;
@@ -336,6 +341,7 @@
m_arguments.push_back (arg);
m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
@@ -601,6 +607,7 @@
OptionGroupOptions m_option_group;
OptionGroupVariable m_option_variable;
+ OptionGroupWatchpoint m_option_watchpoint;
OptionGroupValueObjectDisplay m_varobj_options;
};
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index b1eafd5..c3547e2 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -829,7 +829,8 @@
{ eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." },
{ eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
{ eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." },
- { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }
+ { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
+ { eArgTypeWatchMode, "watch-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the mode for a watchpoint." }
};
const CommandObject::ArgumentTableEntry*
diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp
new file mode 100644
index 0000000..6d1fcb7
--- /dev/null
+++ b/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -0,0 +1,90 @@
+//===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Interpreter/OptionGroupWatchpoint.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-enumerations.h"
+#include "lldb/Interpreter/Args.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static OptionEnumValueElement g_watch_mode[] =
+{
+ { OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
+ { OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
+ { OptionGroupWatchpoint::eWatchReadWrite, "read_write", "Watch for read/write"},
+ { 0, NULL, NULL }
+};
+
+// if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions()
+static OptionDefinition
+g_option_table[] =
+{
+ { 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)."}
+};
+
+
+OptionGroupWatchpoint::OptionGroupWatchpoint () :
+ OptionGroup()
+{
+}
+
+OptionGroupWatchpoint::~OptionGroupWatchpoint ()
+{
+}
+
+Error
+OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg)
+{
+ Error error;
+ char short_option = (char) g_option_table[option_idx].short_option;
+ switch (short_option)
+ {
+ case 'w': {
+ watch_variable = false;
+ OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
+ watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable);
+ break;
+ }
+ default:
+ error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+}
+
+void
+OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+ watch_variable = false;
+ watch_mode = eWatchRead;
+}
+
+
+const OptionDefinition*
+OptionGroupWatchpoint::GetDefinitions ()
+{
+ return g_option_table;
+}
+
+uint32_t
+OptionGroupWatchpoint::GetNumDefinitions ()
+{
+ return 1;
+}
+
+