[Lldb-commits] [lldb] r139434 - in /lldb/trunk: include/lldb/Interpreter/OptionGroupWatchpoint.h include/lldb/lldb-enumerations.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectFrame.cpp source/Interpreter/CommandObject.cpp source/Interpreter/OptionGroupWatchpoint.cpp

Johnny Chen johnny.chen at apple.com
Fri Sep 9 16:25:26 PDT 2011


Author: johnny
Date: Fri Sep  9 18:25:26 2011
New Revision: 139434

URL: http://llvm.org/viewvc/llvm-project?rev=139434&view=rev
Log:
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. :-)

Added:
    lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
    lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp

Added: lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h?rev=139434&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h (added)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h Fri Sep  9 18:25:26 2011
@@ -0,0 +1,63 @@
+//===-- OptionGroupWatchpoint.h ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_OptionGroupWatchpoint_h_
+#define liblldb_OptionGroupWatchpoint_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/Options.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// OptionGroupWatchpoint
+//-------------------------------------------------------------------------
+
+    class OptionGroupWatchpoint : public OptionGroup
+    {
+    public:
+        
+        OptionGroupWatchpoint ();
+
+        virtual
+        ~OptionGroupWatchpoint ();
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        virtual const OptionDefinition*
+        GetDefinitions ();
+        
+        virtual Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx, 
+                        const char *option_arg);
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter);
+        
+        typedef enum WatchMode {
+            eWatchRead,
+            eWatchWrite,
+            eWatchReadWrite
+        } WatchMode;
+
+        bool watch_variable;
+        WatchMode watch_mode;
+
+    private:
+        DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint);
+    };
+    
+} // namespace lldb_private
+
+#endif  // liblldb_OptionGroupWatchpoint_h_

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=139434&r1=139433&r2=139434&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep  9 18:25:26 2011
@@ -408,6 +408,7 @@
         eArgTypeWidth,
         eArgTypeNone,
         eArgTypePlatform,
+        eArgTypeWatchMode,
         eArgTypeLastArg  // Always keep this entry as the last entry in this enumeration!!
     } CommandArgumentType;
 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=139434&r1=139433&r2=139434&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep  9 18:25:26 2011
@@ -437,6 +437,7 @@
 		9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; };
 		9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; };
+		B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */; };
 		B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; };
 		B27318421416AC12006039C8 /* WatchpointLocationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointLocationList.cpp */; };
 		B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; };
@@ -1295,6 +1296,8 @@
 		AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = "<group>"; };
 		AF94005711C03F6500085DB9 /* SymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolVendor.cpp; path = source/Symbol/SymbolVendor.cpp; sourceTree = "<group>"; };
 		B23DD24F12EDFAC1000C3894 /* ARMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMUtils.h; path = Utility/ARMUtils.h; sourceTree = "<group>"; };
+		B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupWatchpoint.cpp; path = source/Interpreter/OptionGroupWatchpoint.cpp; sourceTree = "<group>"; };
+		B2462248141AD39B00F3D409 /* OptionGroupWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupWatchpoint.h; path = include/lldb/Interpreter/OptionGroupWatchpoint.h; sourceTree = "<group>"; };
 		B27318411416AC12006039C8 /* WatchpointLocationList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocationList.cpp; path = source/Breakpoint/WatchpointLocationList.cpp; sourceTree = "<group>"; };
 		B27318431416AC43006039C8 /* WatchpointLocationList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WatchpointLocationList.h; path = include/lldb/Breakpoint/WatchpointLocationList.h; sourceTree = "<group>"; };
 		B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InferiorCallPOSIX.cpp; path = Utility/InferiorCallPOSIX.cpp; sourceTree = "<group>"; };
@@ -2351,7 +2354,9 @@
 				267C0128136880C7006E963E /* OptionGroupValueObjectDisplay.h */,
 				267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */,
 				26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */,
+				B2462248141AD39B00F3D409 /* OptionGroupWatchpoint.h */,
 				26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */,
+				B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */,
 				26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */,
 				9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */,
 				9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */,
@@ -3358,6 +3363,7 @@
 				26A0DA4E140F7226006DA411 /* HashedNameToDIE.cpp in Sources */,
 				B27318421416AC12006039C8 /* WatchpointLocationList.cpp in Sources */,
 				26E152261419CAD4007967D0 /* ObjectFilePECOFF.cpp in Sources */,
+				B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139434&r1=139433&r2=139434&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep  9 18:25:26 2011
@@ -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;
 };
 

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=139434&r1=139433&r2=139434&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Sep  9 18:25:26 2011
@@ -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*

Added: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=139434&view=auto
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (added)
+++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Fri Sep  9 18:25:26 2011
@@ -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;
+}
+
+





More information about the lldb-commits mailing list