diff options
44 files changed, 737 insertions, 776 deletions
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index 0b340083e11..c8c6758dfd9 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -12,6 +12,7 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBValueList.h" +#include "lldb/API/SBWatchpoint.h" namespace lldb { @@ -220,7 +221,6 @@ private: #endif - void SetFrame (const lldb::StackFrameSP &lldb_object_sp); diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 371dd70194e..72eb65f9841 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -360,6 +360,10 @@ protected: #endif private: + // Helper function for SBValue::Watch() and SBValue::WatchPointee(). + lldb::SBWatchpoint + WatchValue(bool read, bool write, bool watch_pointee); + lldb::ValueObjectSP m_opaque_sp; }; diff --git a/lldb/include/lldb/API/SBWatchpoint.h b/lldb/include/lldb/API/SBWatchpoint.h index 16cebb963df..17272f34bf6 100644 --- a/lldb/include/lldb/API/SBWatchpoint.h +++ b/lldb/include/lldb/API/SBWatchpoint.h @@ -67,26 +67,27 @@ public: GetDescription (lldb::SBStream &description, DescriptionLevel level); #ifndef SWIG - SBWatchpoint (const lldb::WatchpointLocationSP &watch_loc_sp); + SBWatchpoint (const lldb::WatchpointSP &wp_sp); #endif private: friend class SBTarget; + friend class SBValue; #ifndef SWIG - lldb_private::WatchpointLocation * + lldb_private::Watchpoint * operator->(); - lldb_private::WatchpointLocation * + lldb_private::Watchpoint * get(); - lldb::WatchpointLocationSP & + lldb::WatchpointSP & operator *(); #endif - lldb::WatchpointLocationSP m_opaque_sp; + lldb::WatchpointSP m_opaque_sp; }; diff --git a/lldb/include/lldb/Breakpoint/WatchpointLocation.h b/lldb/include/lldb/Breakpoint/Watchpoint.h index 08b9539491c..854723fc7d9 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointLocation.h +++ b/lldb/include/lldb/Breakpoint/Watchpoint.h @@ -1,4 +1,4 @@ -//===-- WatchpointLocation.h ------------------------------------*- C++ -*-===// +//===-- Watchpoint.h --------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_WatchpointLocation_h_ -#define liblldb_WatchpointLocation_h_ +#ifndef liblldb_Watchpoint_h_ +#define liblldb_Watchpoint_h_ // C Includes @@ -26,14 +26,14 @@ namespace lldb_private { -class WatchpointLocation : +class Watchpoint : public StoppointLocation { public: - WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware = true); + Watchpoint (lldb::addr_t addr, size_t size, bool hardware = true); - ~WatchpointLocation (); + ~Watchpoint (); bool IsEnabled () const; @@ -79,9 +79,9 @@ private: static lldb::break_id_t GetNextID(); - DISALLOW_COPY_AND_ASSIGN (WatchpointLocation); + DISALLOW_COPY_AND_ASSIGN (Watchpoint); }; } // namespace lldb_private -#endif // liblldb_WatchpointLocation_h_ +#endif // liblldb_Watchpoint_h_ diff --git a/lldb/include/lldb/Breakpoint/WatchpointLocationList.h b/lldb/include/lldb/Breakpoint/WatchpointList.h index 84b3f3c9d07..396d63caddb 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointLocationList.h +++ b/lldb/include/lldb/Breakpoint/WatchpointList.h @@ -1,4 +1,4 @@ -//===-- WatchpointLocationList.h --------------------------------*- C++ -*-===// +//===-- WatchpointList.h ----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_WatchpointLocationList_h_ -#define liblldb_WatchpointLocationList_h_ +#ifndef liblldb_WatchpointList_h_ +#define liblldb_WatchpointList_h_ // C Includes // C++ Includes @@ -23,41 +23,41 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class WatchpointLocationList WatchpointLocationList.h "lldb/Breakpoint/WatchpointLocationList.h" -/// @brief This class is used by Watchpoint to manage a list of watchpoint locations, -// each watchpoint location in the list -/// has a unique ID, and is unique by Address as well. +/// @class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h" +/// @brief This class is used by Watchpoint to manage a list of watchpoints, +// each watchpoint in the list has a unique ID, and is unique by Address as +// well. //---------------------------------------------------------------------- -class WatchpointLocationList +class WatchpointList { -// Only Target can make the location list, or add elements to it. -// This is not just some random collection of locations. Rather, the act of adding the location -// to this list sets its ID. -friend class WatchpointLocation; +// Only Target can make the watchpoint list, or add elements to it. +// This is not just some random collection of watchpoints. Rather, the act of +// adding the watchpoint to this list sets its ID. +friend class Watchpoint; public: //------------------------------------------------------------------ /// Default constructor makes an empty list. //------------------------------------------------------------------ - WatchpointLocationList(); + WatchpointList(); //------------------------------------------------------------------ /// Destructor, currently does nothing. //------------------------------------------------------------------ - ~WatchpointLocationList(); + ~WatchpointList(); //------------------------------------------------------------------ - /// Add a WatchpointLocation to the list. + /// Add a Watchpoint to the list. /// - /// @param[in] wp_loc_sp - /// A shared pointer to a watchpoint location being added to the list. + /// @param[in] wp_sp + /// A shared pointer to a watchpoint being added to the list. /// /// @return - /// The ID of the WatchpointLocation in the list. + /// The ID of the Watchpoint in the list. //------------------------------------------------------------------ lldb::watch_id_t - Add (const lldb::WatchpointLocationSP& wp_loc_sp); + Add (const lldb::WatchpointSP& wp_sp); //------------------------------------------------------------------ /// Standard "Dump" method. @@ -72,8 +72,8 @@ public: DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint location at address - /// \a addr - const version. + /// Returns a shared pointer to the watchpoint at address /// \a addr - + /// const version. /// /// @param[in] addr /// The address to look for. @@ -82,12 +82,12 @@ public: /// A shared pointer to the watchpoint. May contain a NULL /// pointer if the watchpoint doesn't exist. //------------------------------------------------------------------ - const lldb::WatchpointLocationSP + const lldb::WatchpointSP FindByAddress (lldb::addr_t addr) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint location with id - /// \a breakID, const version. + /// Returns a shared pointer to the watchpoint with id /// \a breakID, const + /// version. /// /// @param[in] breakID /// The watchpoint location ID to seek for. @@ -96,74 +96,72 @@ public: /// A shared pointer to the watchpoint. May contain a NULL /// pointer if the watchpoint doesn't exist. //------------------------------------------------------------------ - lldb::WatchpointLocationSP + lldb::WatchpointSP FindByID (lldb::watch_id_t watchID) const; //------------------------------------------------------------------ - /// Returns the watchpoint location id to the watchpoint location - /// at address \a addr. + /// Returns the watchpoint id to the watchpoint /// at address \a addr. /// /// @param[in] addr /// The address to match. /// /// @result - /// The ID of the watchpoint location, or LLDB_INVALID_WATCH_ID. + /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID. //------------------------------------------------------------------ lldb::watch_id_t FindIDByAddress (lldb::addr_t addr); //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint location with - /// index \a i. + /// Returns a shared pointer to the watchpoint with index \a i. /// /// @param[in] i - /// The watchpoint location index to seek for. + /// The watchpoint index to seek for. /// /// @result - /// A shared pointer to the watchpoint location. May contain a NULL - /// pointer if the watchpoint location doesn't exist. + /// A shared pointer to the watchpoint. May contain a NULL pointer if + /// the watchpoint doesn't exist. //------------------------------------------------------------------ - lldb::WatchpointLocationSP + lldb::WatchpointSP GetByIndex (uint32_t i); //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint location with index - /// \a i, const version. + /// Returns a shared pointer to the watchpoint with index \a i, const + /// version. /// /// @param[in] i - /// The watchpoint location index to seek for. + /// The watchpoint index to seek for. /// /// @result - /// A shared pointer to the watchpoint location. May contain a NULL - /// pointer if the watchpoint location doesn't exist. + /// A shared pointer to the watchpoint. May contain a NULL pointer if + /// the watchpoint location doesn't exist. //------------------------------------------------------------------ - const lldb::WatchpointLocationSP + const lldb::WatchpointSP GetByIndex (uint32_t i) const; //------------------------------------------------------------------ - /// Removes the watchpoint location given by \b watchID from this list. + /// Removes the watchpoint given by \b watchID from this list. /// /// @param[in] watchID - /// The watchpoint location ID to remove. + /// The watchpoint ID to remove. /// /// @result - /// \b true if the watchpoint location \a watchID was in the list. + /// \b true if the watchpoint \a watchID was in the list. //------------------------------------------------------------------ bool Remove (lldb::watch_id_t watchID); //------------------------------------------------------------------ - /// Returns the number hit count of all locations in this list. + /// Returns the number hit count of all watchpoints in this list. /// /// @result - /// Hit count of all locations in this list. + /// Hit count of all watchpoints in this list. //------------------------------------------------------------------ uint32_t GetHitCount () const; //------------------------------------------------------------------ - /// Enquires of the watchpoint location in this list with ID \a - /// watchID whether we should stop. + /// Enquires of the watchpoint in this list with ID \a watchID whether we + /// should stop. /// /// @param[in] context /// This contains the information about this stop. @@ -179,7 +177,7 @@ public: lldb::watch_id_t watchID); //------------------------------------------------------------------ - /// Returns the number of elements in this watchpoint location list. + /// Returns the number of elements in this watchpoint list. /// /// @result /// The number of elements. @@ -188,12 +186,11 @@ public: GetSize() const { Mutex::Locker locker(m_mutex); - return m_address_to_location.size(); + return m_address_to_watchpoint.size(); } //------------------------------------------------------------------ - /// Print a description of the watchpoint locations in this list to - /// the stream \a s. + /// Print a description of the watchpoints in this list to the stream \a s. /// /// @param[in] s /// The stream to which to print the description. @@ -215,7 +212,7 @@ public: RemoveAll (); //------------------------------------------------------------------ - /// Sets the passed in Locker to hold the Watchpoint Location List mutex. + /// Sets the passed in Locker to hold the Watchpoint List mutex. /// /// @param[in] locker /// The locker object that is set. @@ -224,7 +221,7 @@ public: GetListMutex (lldb_private::Mutex::Locker &locker); protected: - typedef std::map<lldb::addr_t, lldb::WatchpointLocationSP> addr_map; + typedef std::map<lldb::addr_t, lldb::WatchpointSP> addr_map; addr_map::iterator GetIDIterator(lldb::watch_id_t watchID); @@ -232,10 +229,10 @@ protected: addr_map::const_iterator GetIDConstIterator(lldb::watch_id_t watchID) const; - addr_map m_address_to_location; + addr_map m_address_to_watchpoint; mutable Mutex m_mutex; }; } // namespace lldb_private -#endif // liblldb_WatchpointLocationList_h_ +#endif // liblldb_WatchpointList_h_ diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 3914a72f97f..35ddb603dba 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2480,10 +2480,10 @@ public: // Process Watchpoints (optional) //---------------------------------------------------------------------- virtual Error - EnableWatchpoint (WatchpointLocation *bp_loc); + EnableWatchpoint (Watchpoint *wp); virtual Error - DisableWatchpoint (WatchpointLocation *bp_loc); + DisableWatchpoint (Watchpoint *wp); //------------------------------------------------------------------ // Thread Queries diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index d7ce81b51c3..cc98258a179 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -18,7 +18,7 @@ #include "lldb/lldb-public.h" #include "lldb/Breakpoint/BreakpointList.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" -#include "lldb/Breakpoint/WatchpointLocationList.h" +#include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Event.h" #include "lldb/Core/ModuleList.h" @@ -292,22 +292,22 @@ public: lldb::BreakpointResolverSP &resolver_sp, bool internal = false); - // Use this to create a watchpoint location: - lldb::WatchpointLocationSP - CreateWatchpointLocation (lldb::addr_t addr, - size_t size, - uint32_t type); + // Use this to create a watchpoint: + lldb::WatchpointSP + CreateWatchpoint (lldb::addr_t addr, + size_t size, + uint32_t type); - lldb::WatchpointLocationSP - GetLastCreatedWatchpointLocation () + lldb::WatchpointSP + GetLastCreatedWatchpoint () { - return m_last_created_watchpoint_location; + return m_last_created_watchpoint; } - WatchpointLocationList & - GetWatchpointLocationList() + WatchpointList & + GetWatchpointList() { - return m_watchpoint_location_list; + return m_watchpoint_list; } void @@ -332,28 +332,28 @@ public: // performed end to end, for both the debugger and the debuggee. bool - RemoveAllWatchpointLocations (bool end_to_end = true); + RemoveAllWatchpoints (bool end_to_end = true); bool - DisableAllWatchpointLocations (bool end_to_end = true); + DisableAllWatchpoints (bool end_to_end = true); bool - EnableAllWatchpointLocations (bool end_to_end = true); + EnableAllWatchpoints (bool end_to_end = true); bool - IgnoreAllWatchpointLocations (uint32_t ignore_count); + IgnoreAllWatchpoints (uint32_t ignore_count); bool - DisableWatchpointLocationByID (lldb::watch_id_t watch_id); + DisableWatchpointByID (lldb::watch_id_t watch_id); bool - EnableWatchpointLocationByID (lldb::watch_id_t watch_id); + EnableWatchpointByID (lldb::watch_id_t watch_id); bool - RemoveWatchpointLocationByID (lldb::watch_id_t watch_id); + RemoveWatchpointByID (lldb::watch_id_t watch_id); bool - IgnoreWatchpointLocationByID (lldb::watch_id_t watch_id, uint32_t ignore_count); + IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count); void ModulesDidLoad (ModuleList &module_list); @@ -877,8 +877,8 @@ protected: BreakpointList m_breakpoint_list; BreakpointList m_internal_breakpoint_list; lldb::BreakpointSP m_last_created_breakpoint; - WatchpointLocationList m_watchpoint_location_list; - lldb::WatchpointLocationSP m_last_created_watchpoint_location; + WatchpointList m_watchpoint_list; + lldb::WatchpointSP m_last_created_watchpoint; // We want to tightly control the process destruction process so // we can correctly tear down everything that we need to, so the only // class that knows about the process lifespan is this target class. diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index d935d6d5b7e..1cbb5915e19 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -87,7 +87,7 @@ namespace lldb { typedef SharedPtr<lldb_private::Variable>::Type VariableSP; typedef SharedPtr<lldb_private::VariableList>::Type VariableListSP; typedef SharedPtr<lldb_private::ValueObjectList>::Type ValueObjectListSP; - typedef SharedPtr<lldb_private::WatchpointLocation>::Type WatchpointLocationSP; + typedef SharedPtr<lldb_private::Watchpoint>::Type WatchpointSP; } // namespace lldb diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 90987e7e96e..18920c364c5 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -197,8 +197,8 @@ class ValueObjectConstResultImpl; class ValueObjectList; class Variable; class VariableList; -class WatchpointLocation; -class WatchpointLocationList; +class Watchpoint; +class WatchpointList; struct LineEntry; } // namespace lldb_private diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 50c8fcd9704..66bfbf297c2 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -92,7 +92,7 @@ 2689000B13353DB600698AC0 /* Stoppoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */; }; 2689000D13353DB600698AC0 /* StoppointCallbackContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0910F1B83100F91463 /* StoppointCallbackContext.cpp */; }; 2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */; }; - 2689001113353DB600698AC0 /* WatchpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */; }; + 2689001113353DB600698AC0 /* Watchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* Watchpoint.cpp */; }; 2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; 2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; }; 2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */; }; @@ -450,7 +450,7 @@ B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B207C4921429607D00F36E4E /* CommandObjectWatchpoint.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 */; }; + B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointList.cpp */; }; B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; }; B2A58722143119810092BFBA /* SBWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B2A58721143119810092BFBA /* SBWatchpoint.h */; settings = {ATTRIBUTES = (Public, ); }; }; B2A58724143119D50092BFBA /* SBWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A58723143119D50092BFBA /* SBWatchpoint.cpp */; }; @@ -843,7 +843,7 @@ 26BC7CF910F1B71400F91463 /* SearchFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SearchFilter.h; path = include/lldb/Core/SearchFilter.h; sourceTree = "<group>"; }; 26BC7CFA10F1B71400F91463 /* Stoppoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stoppoint.h; path = include/lldb/Breakpoint/Stoppoint.h; sourceTree = "<group>"; }; 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StoppointLocation.h; path = include/lldb/Breakpoint/StoppointLocation.h; sourceTree = "<group>"; }; - 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointLocation.h; path = include/lldb/Breakpoint/WatchpointLocation.h; sourceTree = "<group>"; }; + 26BC7CFC10F1B71400F91463 /* Watchpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Watchpoint.h; path = include/lldb/Breakpoint/Watchpoint.h; sourceTree = "<group>"; }; 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = "<group>"; }; 26BC7D1710F1B76300F91463 /* CommandObjectDisassemble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectDisassemble.h; path = source/Commands/CommandObjectDisassemble.h; sourceTree = "<group>"; }; 26BC7D1810F1B76300F91463 /* CommandObjectExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectExpression.h; path = source/Commands/CommandObjectExpression.h; sourceTree = "<group>"; }; @@ -946,7 +946,7 @@ 26BC7E1510F1B83100F91463 /* SearchFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SearchFilter.cpp; path = source/Core/SearchFilter.cpp; sourceTree = "<group>"; }; 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stoppoint.cpp; path = source/Breakpoint/Stoppoint.cpp; sourceTree = "<group>"; }; 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StoppointLocation.cpp; path = source/Breakpoint/StoppointLocation.cpp; sourceTree = "<group>"; }; - 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocation.cpp; path = source/Breakpoint/WatchpointLocation.cpp; sourceTree = "<group>"; }; + 26BC7E1810F1B83100F91463 /* Watchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Watchpoint.cpp; path = source/Breakpoint/Watchpoint.cpp; sourceTree = "<group>"; }; 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = "<group>"; }; 26BC7E3010F1B84700F91463 /* CommandObjectDisassemble.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectDisassemble.cpp; path = source/Commands/CommandObjectDisassemble.cpp; sourceTree = "<group>"; }; 26BC7E3110F1B84700F91463 /* CommandObjectExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectExpression.cpp; path = source/Commands/CommandObjectExpression.cpp; sourceTree = "<group>"; }; @@ -1361,8 +1361,8 @@ 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>"; }; B2462249141AE62200F3D409 /* Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = include/lldb/Utility/Utils.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>"; }; + B27318411416AC12006039C8 /* WatchpointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointList.cpp; path = source/Breakpoint/WatchpointList.cpp; sourceTree = "<group>"; }; + B27318431416AC43006039C8 /* WatchpointList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WatchpointList.h; path = include/lldb/Breakpoint/WatchpointList.h; sourceTree = "<group>"; }; B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InferiorCallPOSIX.cpp; path = Utility/InferiorCallPOSIX.cpp; sourceTree = "<group>"; }; B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InferiorCallPOSIX.h; path = Utility/InferiorCallPOSIX.h; sourceTree = "<group>"; }; B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMDefines.h; path = Utility/ARMDefines.h; sourceTree = "<group>"; }; @@ -2309,10 +2309,10 @@ 26BC7E0910F1B83100F91463 /* StoppointCallbackContext.cpp */, 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */, 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */, - 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */, - B27318431416AC43006039C8 /* WatchpointLocationList.h */, - 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */, - B27318411416AC12006039C8 /* WatchpointLocationList.cpp */, + 26BC7CFC10F1B71400F91463 /* Watchpoint.h */, + B27318431416AC43006039C8 /* WatchpointList.h */, + 26BC7E1810F1B83100F91463 /* Watchpoint.cpp */, + B27318411416AC12006039C8 /* WatchpointList.cpp */, ); name = Breakpoint; sourceTree = "<group>"; @@ -3199,7 +3199,7 @@ 2689000B13353DB600698AC0 /* Stoppoint.cpp in Sources */, 2689000D13353DB600698AC0 /* StoppointCallbackContext.cpp in Sources */, 2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */, - 2689001113353DB600698AC0 /* WatchpointLocation.cpp in Sources */, + 2689001113353DB600698AC0 /* Watchpoint.cpp in Sources */, 2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */, 2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */, 2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */, @@ -3498,7 +3498,7 @@ 94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */, 949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */, 26A0DA4E140F7226006DA411 /* HashedNameToDIE.cpp in Sources */, - B27318421416AC12006039C8 /* WatchpointLocationList.cpp in Sources */, + B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */, 26E152261419CAD4007967D0 /* ObjectFilePECOFF.cpp in Sources */, B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */, 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */, diff --git a/lldb/scripts/Python/interface/SBFrame.i b/lldb/scripts/Python/interface/SBFrame.i index 40d65725405..28526ab7478 100644 --- a/lldb/scripts/Python/interface/SBFrame.i +++ b/lldb/scripts/Python/interface/SBFrame.i @@ -215,25 +215,6 @@ public: lldb::SBValue FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); - %feature("docstring", " - /// Find and watch a variable using the frame as the scope. - /// It returns an SBValue, similar to FindValue() method, if find-and-watch - /// operation succeeds. Otherwise, an invalid SBValue is returned. - /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. - ") WatchValue; - lldb::SBValue - WatchValue (const char *name, ValueType value_type, uint32_t watch_type); - - %feature("docstring", " - /// Find and watch the location pointed to by a variable using the frame as - /// the scope. - /// It returns an SBValue, similar to FindValue() method, if find-and-watch - /// operation succeeds. Otherwise, an invalid SBValue is returned. - /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. - ") WatchLocation; - lldb::SBValue - WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size); - bool GetDescription (lldb::SBStream &description); diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i index 9c628a621ff..d462ed91b18 100644 --- a/lldb/scripts/Python/interface/SBTarget.i +++ b/lldb/scripts/Python/interface/SBTarget.i @@ -12,8 +12,7 @@ namespace lldb { %feature("docstring", "Represents the target program running under the debugger. -SBTarget supports module, breakpoint, and watchpoint_location iterations. For -example, +SBTarget supports module, breakpoint, and watchpoint iterations. For example, for m in target.module_iter(): print m @@ -39,14 +38,14 @@ SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 and, - for wp_loc in target.watchpoint_location_iter(): + for wp_loc in target.watchpoint_iter(): print wp_loc produces: -WatchpointLocation 1: addr = 0x1034ca048 size = 4 state = enabled type = rw +Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' - hw_index = 0 hit_count = 2 ignore_count = 0 callback = 0x0 baton = 0x0" + hw_index = 0 hit_count = 2 ignore_count = 0" ) SBTarget; class SBTarget { diff --git a/lldb/scripts/Python/interface/SBValue.i b/lldb/scripts/Python/interface/SBValue.i index 439e0abb7f7..39a92c6503e 100644 --- a/lldb/scripts/Python/interface/SBValue.i +++ b/lldb/scripts/Python/interface/SBValue.i @@ -278,9 +278,17 @@ public: lldb::SBFrame GetFrame(); + %feature("docstring", " + /// Find and watch a variable. + /// It returns an SBWatchpoint, which may be invalid. + ") Watch; lldb::SBWatchpoint Watch (bool resolve_location, bool read, bool write); + %feature("docstring", " + /// Find and watch the location pointed to by a variable. + /// It returns an SBWatchpoint, which may be invalid. + ") WatchPointee; lldb::SBWatchpoint WatchPointee (bool resolve_location, bool read, bool write); diff --git a/lldb/scripts/Python/interface/SBWatchpoint.i b/lldb/scripts/Python/interface/SBWatchpoint.i index 5ddba459aaa..58a15e7d8d5 100644 --- a/lldb/scripts/Python/interface/SBWatchpoint.i +++ b/lldb/scripts/Python/interface/SBWatchpoint.i @@ -10,14 +10,13 @@ namespace lldb { %feature("docstring", -"Represents an instance of watchpoint location for a specific target program. +"Represents an instance of watchpoint for a specific target program. -A watchpoint location is determined by the address and the byte size that -resulted in this particular instantiation. Each watchpoint location has its -settable options. +A watchpoint is determined by the address and the byte size that resulted in +this particular instantiation. Each watchpoint has its settable options. -See also SBTarget.watchpoint_location_iter() for for example usage of iterating -through the watchpoint locations of the target." +See also SBTarget.watchpoint_iter() for for example usage of iterating through +the watchpoints of the target." ) SBWatchpoint; class SBWatchpoint { diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index 15f42a46009..06be3037790 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -173,7 +173,7 @@ linked_list_iter_def = ''' iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" -watchpoint_location_iter = " def watchpoint_location_iter(self): return lldb_iter(self, '%s', '%s')" +watchpoint_iter = " def watchpoint_iter(self): return lldb_iter(self, '%s', '%s')" section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')" # Called to implement the built-in function len(). @@ -222,7 +222,7 @@ d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), # SBTarget needs special processing, see below. 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'), - 'watchpoint_location': ('GetNumWatchpointLocations', 'GetWatchpointLocationAtIndex') + 'watchpoint': ('GetNumWatchpoints', 'GetWatchpointAtIndex') }, # SBModule has an additional section_iter(), see below. @@ -369,7 +369,7 @@ for line in content.splitlines(): if cls == "SBTarget": new_content.add_line(module_iter % (d[cls]['module'])) new_content.add_line(breakpoint_iter % (d[cls]['breakpoint'])) - new_content.add_line(watchpoint_location_iter % (d[cls]['watchpoint_location'])) + new_content.add_line(watchpoint_iter % (d[cls]['watchpoint'])) else: if (state & DEFINING_ITERATOR): new_content.add_line(iter_def % d[cls]) diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 7c186871dc6..f72f8bfacf4 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -14,7 +14,6 @@ #include "lldb/lldb-types.h" -#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/Address.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" @@ -406,119 +405,6 @@ SBFrame::FindValue (const char *name, ValueType value_type) return value; } -/// Find and watch a variable using the frame as the scope. -/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. -SBValue -SBFrame::WatchValue (const char *name, ValueType value_type, uint32_t watch_type) -{ - SBValue sb_value_empty; - - if (!IsValid()) - return sb_value_empty; - - // Acquire the API locker, to be released at the end of the method call. - Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); - - switch (value_type) { - case eValueTypeVariableGlobal: // global variable - case eValueTypeVariableStatic: // static variable - case eValueTypeVariableArgument: // function argument variables - case eValueTypeVariableLocal: // function local variables - break; - default: - return sb_value_empty; // these are not eligible for watching - } - - SBValue sb_value = FindValue(name, value_type); - // If the SBValue is not valid, there's no point in even trying to watch it. - if (!sb_value.IsValid()) - return sb_value; - - addr_t addr = sb_value.GetLoadAddress(); - size_t size = sb_value.GetByteSize(); - - WatchpointLocationSP wp_loc_sp = m_opaque_sp->GetThread().GetProcess().GetTarget(). - CreateWatchpointLocation(addr, size, watch_type); - - if (wp_loc_sp) { - // StackFrame::GetInScopeVariableList(true) to get file globals as well. - VariableListSP var_list_sp(m_opaque_sp->GetInScopeVariableList(true)); - VariableSP var_sp = var_list_sp->FindVariable(ConstString(name)); - if (var_sp && var_sp->GetDeclaration().GetFile()) { - StreamString ss; - // True to show fullpath for declaration file. - var_sp->GetDeclaration().DumpStopContext(&ss, true); - wp_loc_sp->SetDeclInfo(ss.GetString()); - } - } - - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (log) - log->Printf ("SBFrame(%p)::WatchValue (name=\"%s\", value_type=%i, watch_type=%i) => SBValue(%p) & wp_loc(%p)", - m_opaque_sp.get(), name, value_type, watch_type, sb_value.get(), wp_loc_sp.get()); - - return wp_loc_sp ? sb_value : sb_value_empty; -} - -/// Find and watch the location pointed to by a variable using the frame as -/// the scope. -/// It returns an SBValue, similar to FindValue() method, if find-and-watch -/// operation succeeds. Otherwise, an invalid SBValue is returned. -/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. -SBValue -SBFrame::WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size) -{ - SBValue sb_value_empty; - - if (!IsValid()) - return sb_value_empty; - - // Acquire the API locker, to be released at the end of the method call. - Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); - - switch (value_type) { - case eValueTypeVariableGlobal: // global variable - case eValueTypeVariableStatic: // static variable - case eValueTypeVariableArgument: // function argument variables - case eValueTypeVariableLocal: // function local variables - break; - default: - return sb_value_empty; // these are not eligible for watching - } - - SBValue sb_pointer = FindValue(name, value_type); - // If the sb_pointer is not valid, there's no point in even trying to watch it. - if (!sb_pointer.IsValid() || !sb_pointer.GetType().IsPointerType()) - return sb_value_empty; - - addr_t addr = sb_pointer.GetValueAsUnsigned(0); - if (!addr) - return sb_value_empty; - - SBValue sb_value = sb_pointer.CreateValueFromAddress("pointee", addr, sb_pointer.GetType().GetPointeeType()); - WatchpointLocationSP wp_loc_sp = m_opaque_sp->GetThread().GetProcess().GetTarget(). - CreateWatchpointLocation(addr, size, watch_type); - - if (wp_loc_sp) { - // StackFrame::GetInScopeVariableList(true) to get file globals as well. - VariableListSP var_list_sp(m_opaque_sp->GetInScopeVariableList(true)); - VariableSP var_sp = var_list_sp->FindVariable(ConstString(name)); - if (var_sp && var_sp->GetDeclaration().GetFile()) { - StreamString ss; - // True to show fullpath for declaration file. - var_sp->GetDeclaration().DumpStopContext(&ss, true); - wp_loc_sp->SetDeclInfo(ss.GetString()); - } - } - - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (log) - log->Printf ("SBFrame(%p)::WatchLocation (name=\"%s\", value_type=%i, watch_type=%i, size=%lu) => SBValue(%p) & wp_loc(%p)", - m_opaque_sp.get(), name, value_type, watch_type, size, sb_value.get(), wp_loc_sp.get()); - - return wp_loc_sp ? sb_value : sb_value_empty; -} - SBValue SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 3cdfe1d23e5..652d4705fea 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -887,8 +887,8 @@ SBTarget::GetNumWatchpoints () const { if (m_opaque_sp) { - // The watchpoint location list is thread safe, no need to lock - return m_opaque_sp->GetWatchpointLocationList().GetSize(); + // The watchpoint list is thread safe, no need to lock + return m_opaque_sp->GetWatchpointList().GetSize(); } return 0; } @@ -896,13 +896,13 @@ SBTarget::GetNumWatchpoints () const SBWatchpoint SBTarget::GetWatchpointAtIndex (uint32_t idx) const { - SBWatchpoint sb_watchpoint_location; + SBWatchpoint sb_watchpoint; if (m_opaque_sp) { - // The watchpoint location list is thread safe, no need to lock - *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().GetByIndex(idx); + // The watchpoint list is thread safe, no need to lock + *sb_watchpoint = m_opaque_sp->GetWatchpointList().GetByIndex(idx); } - return sb_watchpoint_location; + return sb_watchpoint; } bool @@ -914,12 +914,12 @@ SBTarget::DeleteWatchpoint (watch_id_t wp_id) if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - result = m_opaque_sp->RemoveWatchpointLocationByID (wp_id); + result = m_opaque_sp->RemoveWatchpointByID (wp_id); } if (log) { - log->Printf ("SBTarget(%p)::WatchpointLocationDelete (wp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) wp_id, result); + log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) wp_id, result); } return result; @@ -934,12 +934,12 @@ SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id) if (m_opaque_sp && wp_id != LLDB_INVALID_WATCH_ID) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - *sb_watchpoint = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id); + *sb_watchpoint = m_opaque_sp->GetWatchpointList().FindByID(wp_id); } if (log) { - log->Printf ("SBTarget(%p)::FindWatchpointLocationByID (bp_id=%d) => SBWatchpoint(%p)", + log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)", m_opaque_sp.get(), (uint32_t) wp_id, sb_watchpoint.get()); } @@ -955,8 +955,9 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write) if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - // TODO: Johnny fill this in - //*sb_watchpoint = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id); + uint32_t watch_type = (read ? LLDB_WATCH_TYPE_READ : 0) | + (write ? LLDB_WATCH_TYPE_WRITE : 0); + WatchpointSP wp_sp = m_opaque_sp->CreateWatchpoint(addr, size, watch_type); } if (log) @@ -974,7 +975,7 @@ SBTarget::EnableAllWatchpoints () if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->EnableAllWatchpointLocations (); + m_opaque_sp->EnableAllWatchpoints (); return true; } return false; @@ -986,7 +987,7 @@ SBTarget::DisableAllWatchpoints () if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->DisableAllWatchpointLocations (); + m_opaque_sp->DisableAllWatchpoints (); return true; } return false; @@ -998,7 +999,7 @@ SBTarget::DeleteAllWatchpoints () if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->RemoveAllWatchpointLocations (); + m_opaque_sp->RemoveAllWatchpoints (); return true; } return false; diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 8afd5641201..dc594cbfcba 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -10,6 +10,7 @@ #include "lldb/API/SBValue.h" #include "lldb/API/SBStream.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" @@ -22,6 +23,7 @@ #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" @@ -1102,12 +1104,19 @@ lldb::SBWatchpoint SBValue::Watch (bool resolve_location, bool read, bool write) { lldb::SBWatchpoint sb_watchpoint; + if (!m_opaque_sp) + return sb_watchpoint; + Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); if (target) { Mutex::Locker api_locker (target->GetAPIMutex()); - // TODO: Johnny fill this in + sb_watchpoint = WatchValue(read, write, false); } + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBValue(%p)::Watch (resolve_location=%i, read=%i, write=%i) => wp(%p)", + m_opaque_sp.get(), resolve_location, read, write, sb_watchpoint.get()); return sb_watchpoint; } @@ -1115,13 +1124,70 @@ lldb::SBWatchpoint SBValue::WatchPointee (bool resolve_location, bool read, bool write) { lldb::SBWatchpoint sb_watchpoint; + if (!m_opaque_sp) + return sb_watchpoint; + Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); if (target) { Mutex::Locker api_locker (target->GetAPIMutex()); - // TODO: Johnny fill this in + sb_watchpoint = WatchValue(read, write, true); } + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBValue(%p)::WatchPointee (resolve_location=%i, read=%i, write=%i) => wp(%p)", + m_opaque_sp.get(), resolve_location, read, write, sb_watchpoint.get()); return sb_watchpoint; } +// Helper function for SBValue::Watch() and SBValue::WatchPointee(). +SBWatchpoint +SBValue::WatchValue(bool read, bool write, bool watch_pointee) +{ + SBWatchpoint sb_wp_empty; + + // If the SBValue is not valid, there's no point in even trying to watch it. + if (!IsValid() || !GetFrame().IsValid()) + return sb_wp_empty; + + // Read and Write cannot both be false. + if (!read && !write) + return sb_wp_empty; + + // If we are watching the pointee, check that the SBValue is a pointer type. + if (watch_pointee && !GetType().IsPointerType()) + return sb_wp_empty; + + addr_t addr; + size_t size; + if (watch_pointee) { + addr = GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + size = GetType().GetPointeeType().GetByteSize(); + } else { + addr = GetLoadAddress(); + size = GetByteSize(); + } + + // Sanity check the address and the size before calling Target::CreateWatchpoint(). + if (addr == LLDB_INVALID_ADDRESS || size == 0) + return sb_wp_empty; + + uint32_t watch_type = (read ? LLDB_WATCH_TYPE_READ : 0) | + (write ? LLDB_WATCH_TYPE_WRITE : 0); + WatchpointSP wp_sp = GetFrame().m_opaque_sp->GetThread().GetProcess().GetTarget(). + CreateWatchpoint(addr, size, watch_type); + + if (wp_sp) { + // StackFrame::GetInScopeVariableList(true) to get file globals as well. + VariableListSP var_list_sp(GetFrame().m_opaque_sp->GetInScopeVariableList(true)); + VariableSP var_sp = var_list_sp->FindVariable(ConstString(GetName())); + if (var_sp && var_sp->GetDeclaration().GetFile()) { + StreamString ss; + // True to show fullpath for declaration file. + var_sp->GetDeclaration().DumpStopContext(&ss, true); + wp_sp->SetDeclInfo(ss.GetString()); + } + } + return wp_sp; +} diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp index a921ea120f5..e3f9d8cc522 100644 --- a/lldb/source/API/SBWatchpoint.cpp +++ b/lldb/source/API/SBWatchpoint.cpp @@ -15,8 +15,8 @@ #include "lldb/lldb-types.h" #include "lldb/lldb-defines.h" -#include "lldb/Breakpoint/WatchpointLocation.h" -#include "lldb/Breakpoint/WatchpointLocationList.h" +#include "lldb/Breakpoint/Watchpoint.h" +#include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" @@ -31,8 +31,8 @@ SBWatchpoint::SBWatchpoint () : { } -SBWatchpoint::SBWatchpoint (const lldb::WatchpointLocationSP &watch_loc_sp) : - m_opaque_sp (watch_loc_sp) +SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp) : + m_opaque_sp (wp_sp) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -40,8 +40,8 @@ SBWatchpoint::SBWatchpoint (const lldb::WatchpointLocationSP &watch_loc_sp) : { SBStream sstr; GetDescription (sstr, lldb::eDescriptionLevelBrief); - log->Printf ("SBWatchpoint::SBWatchpoint (const lldb::WatchpointLocationsSP &watch_loc_sp" - "=%p) => this.sp = %p (%s)", watch_loc_sp.get(), m_opaque_sp.get(), sstr.GetData()); + log->Printf ("SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp" + "=%p) => this.sp = %p (%s)", wp_sp.get(), m_opaque_sp.get(), sstr.GetData()); } } @@ -156,7 +156,7 @@ SBWatchpoint::SetEnabled (bool enabled) if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->GetTarget().DisableWatchpointLocationByID(m_opaque_sp->GetID()); + m_opaque_sp->GetTarget().DisableWatchpointByID(m_opaque_sp->GetID()); } } @@ -227,19 +227,19 @@ SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level) return true; } -lldb_private::WatchpointLocation * +lldb_private::Watchpoint * SBWatchpoint::operator->() { return m_opaque_sp.get(); } -lldb_private::WatchpointLocation * +lldb_private::Watchpoint * SBWatchpoint::get() { return m_opaque_sp.get(); } -lldb::WatchpointLocationSP & +lldb::WatchpointSP & SBWatchpoint::operator *() { return m_opaque_sp; diff --git a/lldb/source/Breakpoint/WatchpointLocation.cpp b/lldb/source/Breakpoint/Watchpoint.cpp index 46f24caedd7..43f443a47fe 100644 --- a/lldb/source/Breakpoint/WatchpointLocation.cpp +++ b/lldb/source/Breakpoint/Watchpoint.cpp @@ -1,4 +1,4 @@ -//===-- WatchpointLocation.cpp ----------------------------------*- C++ -*-===// +//===-- Watchpoint.cpp ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" // C Includes // C++ Includes @@ -18,7 +18,7 @@ using namespace lldb; using namespace lldb_private; -WatchpointLocation::WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware) : +Watchpoint::Watchpoint (lldb::addr_t addr, size_t size, bool hardware) : StoppointLocation (GetNextID(), addr, size, hardware), m_target(NULL), m_enabled(0), @@ -33,19 +33,19 @@ WatchpointLocation::WatchpointLocation (lldb::addr_t addr, size_t size, bool har { } -WatchpointLocation::~WatchpointLocation() +Watchpoint::~Watchpoint() { } break_id_t -WatchpointLocation::GetNextID() +Watchpoint::GetNextID() { static break_id_t g_next_ID = 0; return ++g_next_ID; } bool -WatchpointLocation::SetCallback (WatchpointHitCallback callback, void *callback_baton) +Watchpoint::SetCallback (WatchpointHitCallback callback, void *callback_baton) { m_callback = callback; m_callback_baton = callback_baton; @@ -53,7 +53,7 @@ WatchpointLocation::SetCallback (WatchpointHitCallback callback, void *callback_ } void -WatchpointLocation::SetDeclInfo (std::string &str) +Watchpoint::SetDeclInfo (std::string &str) { m_decl_str = str; return; @@ -61,7 +61,7 @@ WatchpointLocation::SetDeclInfo (std::string &str) bool -WatchpointLocation::IsHardware () const +Watchpoint::IsHardware () const { return m_is_hardware; } @@ -70,7 +70,7 @@ WatchpointLocation::IsHardware () const // should continue. bool -WatchpointLocation::ShouldStop (StoppointCallbackContext *context) +Watchpoint::ShouldStop (StoppointCallbackContext *context) { ++m_hit_count; @@ -93,20 +93,20 @@ WatchpointLocation::ShouldStop (StoppointCallbackContext *context) } void -WatchpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) +Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level) { DumpWithLevel(s, level); return; } void -WatchpointLocation::Dump(Stream *s) const +Watchpoint::Dump(Stream *s) const { DumpWithLevel(s, lldb::eDescriptionLevelBrief); } void -WatchpointLocation::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const +Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const { if (s == NULL) return; @@ -114,7 +114,7 @@ WatchpointLocation::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_ assert(description_level >= lldb::eDescriptionLevelBrief && description_level <= lldb::eDescriptionLevelVerbose); - s->Printf("WatchpointLocation %u: addr = 0x%8.8llx size = %zu state = %s type = %s%s", + s->Printf("Watchpoint %u: addr = 0x%8.8llx size = %zu state = %s type = %s%s", GetID(), (uint64_t)m_addr, m_byte_size, @@ -141,13 +141,13 @@ WatchpointLocation::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_ } bool -WatchpointLocation::IsEnabled() const +Watchpoint::IsEnabled() const { return m_enabled; } void -WatchpointLocation::SetEnabled(bool enabled) +Watchpoint::SetEnabled(bool enabled) { if (!enabled) SetHardwareIndex(LLDB_INVALID_INDEX32); @@ -155,30 +155,30 @@ WatchpointLocation::SetEnabled(bool enabled) } void -WatchpointLocation::SetWatchpointType (uint32_t type) +Watchpoint::SetWatchpointType (uint32_t type) { m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0; m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0; } bool -WatchpointLocation::WatchpointRead () const +Watchpoint::WatchpointRead () const { return m_watch_read != 0; } bool -WatchpointLocation::WatchpointWrite () const +Watchpoint::WatchpointWrite () const { return m_watch_write != 0; } uint32_t -WatchpointLocation::GetIgnoreCount () const +Watchpoint::GetIgnoreCount () const { return m_ignore_count; } void -WatchpointLocation::SetIgnoreCount (uint32_t n) +Watchpoint::SetIgnoreCount (uint32_t n) { m_ignore_count = n; } diff --git a/lldb/source/Breakpoint/WatchpointList.cpp b/lldb/source/Breakpoint/WatchpointList.cpp new file mode 100644 index 00000000000..9721b085e2e --- /dev/null +++ b/lldb/source/Breakpoint/WatchpointList.cpp @@ -0,0 +1,242 @@ +//===-- WatchpointList.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Breakpoint/WatchpointList.h" +#include "lldb/Breakpoint/Watchpoint.h" + +using namespace lldb; +using namespace lldb_private; + +WatchpointList::WatchpointList() : + m_address_to_watchpoint (), + m_mutex (Mutex::eMutexTypeRecursive) +{ +} + +WatchpointList::~WatchpointList() +{ +} + +// Add watchpoint loc to the list. However, if the element already exists in the +// list, then replace it with the input one. + +lldb::watch_id_t +WatchpointList::Add (const WatchpointSP &wp_sp) +{ + Mutex::Locker locker (m_mutex); + lldb::addr_t wp_addr = wp_sp->GetLoadAddress(); + addr_map::iterator iter = m_address_to_watchpoint.find(wp_addr); + + if (iter == m_address_to_watchpoint.end()) + m_address_to_watchpoint.insert(iter, addr_map::value_type(wp_addr, wp_sp)); + else + m_address_to_watchpoint[wp_addr] = wp_sp; + + return wp_sp->GetID(); +} + +void +WatchpointList::Dump (Stream *s) const +{ + DumpWithLevel(s, lldb::eDescriptionLevelBrief); +} + +void +WatchpointList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const +{ + Mutex::Locker locker (m_mutex); + s->Printf("%p: ", this); + //s->Indent(); + s->Printf("WatchpointList with %zu Watchpoints:\n", + m_address_to_watchpoint.size()); + s->IndentMore(); + addr_map::const_iterator pos, end = m_address_to_watchpoint.end(); + for (pos = m_address_to_watchpoint.begin(); pos != end; ++pos) + pos->second->DumpWithLevel(s, description_level); + s->IndentLess(); +} + +const WatchpointSP +WatchpointList::FindByAddress (lldb::addr_t addr) const +{ + WatchpointSP wp_sp; + Mutex::Locker locker (m_mutex); + if (!m_address_to_watchpoint.empty()) + { + addr_map::const_iterator pos = m_address_to_watchpoint.find (addr); + if (pos != m_address_to_watchpoint.end()) + wp_sp = pos->second; + } + + return wp_sp; +} + +class WatchpointIDMatches +{ +public: + WatchpointIDMatches (lldb::watch_id_t watch_id) : + m_watch_id(watch_id) + { + } + + bool operator() (std::pair <lldb::addr_t, WatchpointSP> val_pair) const + { + return m_watch_id == val_pair.second.get()->GetID(); + } + +private: + const lldb::watch_id_t m_watch_id; +}; + +WatchpointList::addr_map::iterator +WatchpointList::GetIDIterator (lldb::watch_id_t watch_id) +{ + return std::find_if(m_address_to_watchpoint.begin(), m_address_to_watchpoint.end(), // Search full range + WatchpointIDMatches(watch_id)); // Predicate +} + +WatchpointList::addr_map::const_iterator +WatchpointList::GetIDConstIterator (lldb::watch_id_t watch_id) const +{ + return std::find_if(m_address_to_watchpoint.begin(), m_address_to_watchpoint.end(), // Search full range + WatchpointIDMatches(watch_id)); // Predicate +} + +WatchpointSP +WatchpointList::FindByID (lldb::watch_id_t watch_id) const +{ + WatchpointSP wp_sp; + Mutex::Locker locker (m_mutex); + addr_map::const_iterator pos = GetIDConstIterator(watch_id); + if (pos != m_address_to_watchpoint.end()) + wp_sp = pos->second; + + return wp_sp; +} + +lldb::watch_id_t +WatchpointList::FindIDByAddress (lldb::addr_t addr) +{ + WatchpointSP wp_sp = FindByAddress (addr); + if (wp_sp) + { + return wp_sp->GetID(); + } + return LLDB_INVALID_WATCH_ID; +} + +WatchpointSP +WatchpointList::GetByIndex (uint32_t i) +{ + Mutex::Locker locker (m_mutex); + WatchpointSP wp_sp; + if (i < m_address_to_watchpoint.size()) + { + addr_map::const_iterator pos = m_address_to_watchpoint.begin(); + std::advance(pos, i); + wp_sp = pos->second; + } + return wp_sp; +} + +const WatchpointSP +WatchpointList::GetByIndex (uint32_t i) const +{ + Mutex::Locker locker (m_mutex); + WatchpointSP wp_sp; + if (i < m_address_to_watchpoint.size()) + { + addr_map::const_iterator pos = m_address_to_watchpoint.begin(); + std::advance(pos, i); + wp_sp = pos->second; + } + return wp_sp; +} + +bool +WatchpointList::Remove (lldb::watch_id_t watch_id) +{ + Mutex::Locker locker (m_mutex); + addr_map::iterator pos = GetIDIterator(watch_id); + if (pos != m_address_to_watchpoint.end()) + { + m_address_to_watchpoint.erase(pos); + return true; + } + return false; +} + +uint32_t +WatchpointList::GetHitCount () const +{ + uint32_t hit_count = 0; + Mutex::Locker locker (m_mutex); + addr_map::const_iterator pos, end = m_address_to_watchpoint.end(); + for (pos = m_address_to_watchpoint.begin(); pos != end; ++pos) + hit_count += pos->second->GetHitCount(); + return hit_count; +} + +bool +WatchpointList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t watch_id) +{ + + WatchpointSP wp_sp = FindByID (watch_id); + if (wp_sp) + { + // Let the Watchpoint decide if it should stop here (could not have + // reached it's target hit count yet, or it could have a callback + // that decided it shouldn't stop. + return wp_sp->ShouldStop (context); + } + // We should stop here since this Watchpoint isn't valid anymore or it + // doesn't exist. + return true; +} + +void +WatchpointList::GetDescription (Stream *s, lldb::DescriptionLevel level) +{ + Mutex::Locker locker (m_mutex); + addr_map::iterator pos, end = m_address_to_watchpoint.end(); + + for (pos = m_address_to_watchpoint.begin(); pos != end; ++pos) + { + s->Printf(" "); + pos->second->Dump(s); + } +} + +void +WatchpointList::SetEnabledAll (bool enabled) +{ + Mutex::Locker locker(m_mutex); + + addr_map::iterator pos, end = m_address_to_watchpoint.end(); + for (pos = m_address_to_watchpoint.begin(); pos != end; ++pos) + pos->second->SetEnabled (enabled); +} + +void +WatchpointList::RemoveAll () +{ + Mutex::Locker locker(m_mutex); + m_address_to_watchpoint.clear(); +} + +void +WatchpointList::GetListMutex (Mutex::Locker &locker) +{ + return locker.Reset (m_mutex.GetMutex()); +} diff --git a/lldb/source/Breakpoint/WatchpointLocationList.cpp b/lldb/source/Breakpoint/WatchpointLocationList.cpp deleted file mode 100644 index b2ff26663a1..00000000000 --- a/lldb/source/Breakpoint/WatchpointLocationList.cpp +++ /dev/null @@ -1,242 +0,0 @@ -//===-- WatchpointLocationList.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Breakpoint/WatchpointLocationList.h" -#include "lldb/Breakpoint/WatchpointLocation.h" - -using namespace lldb; -using namespace lldb_private; - -WatchpointLocationList::WatchpointLocationList() : - m_address_to_location (), - m_mutex (Mutex::eMutexTypeRecursive) -{ -} - -WatchpointLocationList::~WatchpointLocationList() -{ -} - -// Add watchpoint loc to the list. However, if the element already exists in the -// list, then replace it with the input one. - -lldb::watch_id_t -WatchpointLocationList::Add (const WatchpointLocationSP &wp_loc_sp) -{ - Mutex::Locker locker (m_mutex); - lldb::addr_t wp_addr = wp_loc_sp->GetLoadAddress(); - addr_map::iterator iter = m_address_to_location.find(wp_addr); - - if (iter == m_address_to_location.end()) - m_address_to_location.insert(iter, addr_map::value_type(wp_addr, wp_loc_sp)); - else - m_address_to_location[wp_addr] = wp_loc_sp; - - return wp_loc_sp->GetID(); -} - -void -WatchpointLocationList::Dump (Stream *s) const -{ - DumpWithLevel(s, lldb::eDescriptionLevelBrief); -} - -void -WatchpointLocationList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const -{ - Mutex::Locker locker (m_mutex); - s->Printf("%p: ", this); - //s->Indent(); - s->Printf("WatchpointLocationList with %zu WatchpointLocations:\n", - m_address_to_location.size()); - s->IndentMore(); - addr_map::const_iterator pos, end = m_address_to_location.end(); - for (pos = m_address_to_location.begin(); pos != end; ++pos) - pos->second->DumpWithLevel(s, description_level); - s->IndentLess(); -} - -const WatchpointLocationSP -WatchpointLocationList::FindByAddress (lldb::addr_t addr) const -{ - WatchpointLocationSP wp_loc_sp; - Mutex::Locker locker (m_mutex); - if (!m_address_to_location.empty()) - { - addr_map::const_iterator pos = m_address_to_location.find (addr); - if (pos != m_address_to_location.end()) - wp_loc_sp = pos->second; - } - - return wp_loc_sp; -} - -class WatchpointLocationIDMatches -{ -public: - WatchpointLocationIDMatches (lldb::watch_id_t watch_id) : - m_watch_id(watch_id) - { - } - - bool operator() (std::pair <lldb::addr_t, WatchpointLocationSP> val_pair) const - { - return m_watch_id == val_pair.second.get()->GetID(); - } - -private: - const lldb::watch_id_t m_watch_id; -}; - -WatchpointLocationList::addr_map::iterator -WatchpointLocationList::GetIDIterator (lldb::watch_id_t watch_id) -{ - return std::find_if(m_address_to_location.begin(), m_address_to_location.end(), // Search full range - WatchpointLocationIDMatches(watch_id)); // Predicate -} - -WatchpointLocationList::addr_map::const_iterator -WatchpointLocationList::GetIDConstIterator (lldb::watch_id_t watch_id) const -{ - return std::find_if(m_address_to_location.begin(), m_address_to_location.end(), // Search full range - WatchpointLocationIDMatches(watch_id)); // Predicate -} - -WatchpointLocationSP -WatchpointLocationList::FindByID (lldb::watch_id_t watch_id) const -{ - WatchpointLocationSP wp_loc_sp; - Mutex::Locker locker (m_mutex); - addr_map::const_iterator pos = GetIDConstIterator(watch_id); - if (pos != m_address_to_location.end()) - wp_loc_sp = pos->second; - - return wp_loc_sp; -} - -lldb::watch_id_t -WatchpointLocationList::FindIDByAddress (lldb::addr_t addr) -{ - WatchpointLocationSP wp_loc_sp = FindByAddress (addr); - if (wp_loc_sp) - { - return wp_loc_sp->GetID(); - } - return LLDB_INVALID_WATCH_ID; -} - -WatchpointLocationSP -WatchpointLocationList::GetByIndex (uint32_t i) -{ - Mutex::Locker locker (m_mutex); - WatchpointLocationSP wp_loc_sp; - if (i < m_address_to_location.size()) - { - addr_map::const_iterator pos = m_address_to_location.begin(); - std::advance(pos, i); - wp_loc_sp = pos->second; - } - return wp_loc_sp; -} - -const WatchpointLocationSP -WatchpointLocationList::GetByIndex (uint32_t i) const -{ - Mutex::Locker locker (m_mutex); - WatchpointLocationSP wp_loc_sp; - if (i < m_address_to_location.size()) - { - addr_map::const_iterator pos = m_address_to_location.begin(); - std::advance(pos, i); - wp_loc_sp = pos->second; - } - return wp_loc_sp; -} - -bool -WatchpointLocationList::Remove (lldb::watch_id_t watch_id) -{ - Mutex::Locker locker (m_mutex); - addr_map::iterator pos = GetIDIterator(watch_id); - if (pos != m_address_to_location.end()) - { - m_address_to_location.erase(pos); - return true; - } - return false; -} - -uint32_t -WatchpointLocationList::GetHitCount () const -{ - uint32_t hit_count = 0; - Mutex::Locker locker (m_mutex); - addr_map::const_iterator pos, end = m_address_to_location.end(); - for (pos = m_address_to_location.begin(); pos != end; ++pos) - hit_count += pos->second->GetHitCount(); - return hit_count; -} - -bool -WatchpointLocationList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t watch_id) -{ - - WatchpointLocationSP wp_loc_sp = FindByID (watch_id); - if (wp_loc_sp) - { - // Let the WatchpointLocation decide if it should stop here (could not have - // reached it's target hit count yet, or it could have a callback - // that decided it shouldn't stop. - return wp_loc_sp->ShouldStop (context); - } - // We should stop here since this WatchpointLocation isn't valid anymore or it - // doesn't exist. - return true; -} - -void -WatchpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level) -{ - Mutex::Locker locker (m_mutex); - addr_map::iterator pos, end = m_address_to_location.end(); - - for (pos = m_address_to_location.begin(); pos != end; ++pos) - { - s->Printf(" "); - pos->second->Dump(s); - } -} - -void -WatchpointLocationList::SetEnabledAll (bool enabled) -{ - Mutex::Locker locker(m_mutex); - - addr_map::iterator pos, end = m_address_to_location.end(); - for (pos = m_address_to_location.begin(); pos != end; ++pos) - pos->second->SetEnabled (enabled); -} - -void -WatchpointLocationList::RemoveAll () -{ - Mutex::Locker locker(m_mutex); - m_address_to_location.clear(); -} - -void -WatchpointLocationList::GetListMutex (Mutex::Locker &locker) -{ - return locker.Reset (m_mutex.GetMutex()); -} diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index b16589d2659..d8326946fa6 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -14,7 +14,7 @@ #include <string> // Other libraries and framework includes // Project includes -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -550,19 +550,19 @@ public: size = m_option_watchpoint.watch_size; } uint32_t watch_type = m_option_watchpoint.watch_type; - WatchpointLocation *wp_loc = exe_ctx.GetTargetRef().CreateWatchpointLocation(addr, size, watch_type).get(); - if (wp_loc) + Watchpoint *wp = exe_ctx.GetTargetRef().CreateWatchpoint(addr, size, watch_type).get(); + if (wp) { if (var_sp && var_sp->GetDeclaration().GetFile()) { StreamString ss; // True to show fullpath for declaration file. var_sp->GetDeclaration().DumpStopContext(&ss, true); - wp_loc->SetDeclInfo(ss.GetString()); + wp->SetDeclInfo(ss.GetString()); } StreamString ss; output_stream.Printf("Watchpoint created: "); - wp_loc->GetDescription(&output_stream, lldb::eDescriptionLevelFull); + wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull); output_stream.EOL(); result.SetStatus(eReturnStatusSuccessFinishResult); } @@ -571,7 +571,7 @@ public: result.AppendErrorWithFormat("Watchpoint creation failed.\n"); result.SetStatus(eReturnStatusFailed); } - return (wp_loc != NULL); + return (wp != NULL); } } else diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 7c07a03eb85..02b43a31073 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -13,8 +13,8 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Breakpoint/WatchpointLocation.h" -#include "lldb/Breakpoint/WatchpointLocationList.h" +#include "lldb/Breakpoint/Watchpoint.h" +#include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/StreamString.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -27,10 +27,10 @@ using namespace lldb; using namespace lldb_private; static void -AddWatchpointDescription(Stream *s, WatchpointLocation *wp_loc, lldb::DescriptionLevel level) +AddWatchpointDescription(Stream *s, Watchpoint *wp, lldb::DescriptionLevel level) { s->IndentMore(); - wp_loc->GetDescription(s, level); + wp->GetDescription(s, level); s->IndentLess(); s->EOL(); } @@ -280,9 +280,9 @@ CommandObjectWatchpointList::Execute(Args& args, CommandReturnObject &result) return true; } - const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + const WatchpointList &watchpoints = target->GetWatchpointList(); Mutex::Locker locker; - target->GetWatchpointLocationList().GetListMutex(locker); + target->GetWatchpointList().GetListMutex(locker); size_t num_watchpoints = watchpoints.GetSize(); @@ -301,8 +301,8 @@ CommandObjectWatchpointList::Execute(Args& args, CommandReturnObject &result) result.AppendMessage ("Current watchpoints:"); for (size_t i = 0; i < num_watchpoints; ++i) { - WatchpointLocation *wp_loc = watchpoints.GetByIndex(i).get(); - AddWatchpointDescription(&output_stream, wp_loc, m_options.m_level); + Watchpoint *wp = watchpoints.GetByIndex(i).get(); + AddWatchpointDescription(&output_stream, wp, m_options.m_level); } result.SetStatus(eReturnStatusSuccessFinishNoResult); } @@ -320,9 +320,9 @@ CommandObjectWatchpointList::Execute(Args& args, CommandReturnObject &result) const size_t size = wp_ids.size(); for (size_t i = 0; i < size; ++i) { - WatchpointLocation *wp_loc = watchpoints.FindByID(wp_ids[i]).get(); - if (wp_loc) - AddWatchpointDescription(&output_stream, wp_loc, m_options.m_level); + Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get(); + if (wp) + AddWatchpointDescription(&output_stream, wp, m_options.m_level); result.SetStatus(eReturnStatusSuccessFinishNoResult); } } @@ -359,9 +359,9 @@ CommandObjectWatchpointEnable::Execute(Args& args, CommandReturnObject &result) return false; Mutex::Locker locker; - target->GetWatchpointLocationList().GetListMutex(locker); + target->GetWatchpointList().GetListMutex(locker); - const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -375,7 +375,7 @@ CommandObjectWatchpointEnable::Execute(Args& args, CommandReturnObject &result) if (args.GetArgumentCount() == 0) { // No watchpoint selected; enable all currently set watchpoints. - target->EnableAllWatchpointLocations(); + target->EnableAllWatchpoints(); result.AppendMessageWithFormat("All watchpoints enabled. (%lu watchpoints)\n", num_watchpoints); result.SetStatus(eReturnStatusSuccessFinishNoResult); } @@ -393,7 +393,7 @@ CommandObjectWatchpointEnable::Execute(Args& args, CommandReturnObject &result) int count = 0; const size_t size = wp_ids.size(); for (size_t i = 0; i < size; ++i) - if (target->EnableWatchpointLocationByID(wp_ids[i])) + if (target->EnableWatchpointByID(wp_ids[i])) ++count; result.AppendMessageWithFormat("%d watchpoints enabled.\n", count); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -431,9 +431,9 @@ CommandObjectWatchpointDisable::Execute(Args& args, CommandReturnObject &result) return false; Mutex::Locker locker; - target->GetWatchpointLocationList().GetListMutex(locker); + target->GetWatchpointList().GetListMutex(locker); - const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); if (num_watchpoints == 0) @@ -446,7 +446,7 @@ CommandObjectWatchpointDisable::Execute(Args& args, CommandReturnObject &result) if (args.GetArgumentCount() == 0) { // No watchpoint selected; disable all currently set watchpoints. - if (target->DisableAllWatchpointLocations()) + if (target->DisableAllWatchpoints()) { result.AppendMessageWithFormat("All watchpoints disabled. (%lu watchpoints)\n", num_watchpoints); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -471,7 +471,7 @@ CommandObjectWatchpointDisable::Execute(Args& args, CommandReturnObject &result) int count = 0; const size_t size = wp_ids.size(); for (size_t i = 0; i < size; ++i) - if (target->DisableWatchpointLocationByID(wp_ids[i])) + if (target->DisableWatchpointByID(wp_ids[i])) ++count; result.AppendMessageWithFormat("%d watchpoints disabled.\n", count); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -509,9 +509,9 @@ CommandObjectWatchpointDelete::Execute(Args& args, CommandReturnObject &result) return false; Mutex::Locker locker; - target->GetWatchpointLocationList().GetListMutex(locker); + target->GetWatchpointList().GetListMutex(locker); - const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -530,7 +530,7 @@ CommandObjectWatchpointDelete::Execute(Args& args, CommandReturnObject &result) } else { - target->RemoveAllWatchpointLocations(); + target->RemoveAllWatchpoints(); result.AppendMessageWithFormat("All watchpoints removed. (%lu watchpoints)\n", num_watchpoints); } result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -549,7 +549,7 @@ CommandObjectWatchpointDelete::Execute(Args& args, CommandReturnObject &result) int count = 0; const size_t size = wp_ids.size(); for (size_t i = 0; i < size; ++i) - if (target->RemoveWatchpointLocationByID(wp_ids[i])) + if (target->RemoveWatchpointByID(wp_ids[i])) ++count; result.AppendMessageWithFormat("%d watchpoints deleted.\n",count); result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -651,9 +651,9 @@ CommandObjectWatchpointIgnore::Execute(Args& args, CommandReturnObject &result) return false; Mutex::Locker locker; - target->GetWatchpointLocationList().GetListMutex(locker); + target->GetWatchpointList().GetListMutex(locker); - const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -666,7 +666,7 @@ CommandObjectWatchpointIgnore::Execute(Args& args, CommandReturnObject &result) if (args.GetArgumentCount() == 0) { - target->IgnoreAllWatchpointLocations(m_options.m_ignore_count); + target->IgnoreAllWatchpoints(m_options.m_ignore_count); result.AppendMessageWithFormat("All watchpoints ignored. (%lu watchpoints)\n", num_watchpoints); result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -684,7 +684,7 @@ CommandObjectWatchpointIgnore::Execute(Args& args, CommandReturnObject &result) int count = 0; const size_t size = wp_ids.size(); for (size_t i = 0; i < size; ++i) - if (target->IgnoreWatchpointLocationByID(wp_ids[i], m_options.m_ignore_count)) + if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count)) ++count; result.AppendMessageWithFormat("%d watchpoints ignored.\n",count); result.SetStatus (eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 44ad68a2312..bca099c0242 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -607,7 +607,7 @@ ProcessKDP::DisableBreakpoint (BreakpointSite *bp_site) } Error -ProcessKDP::EnableWatchpoint (WatchpointLocation *wp) +ProcessKDP::EnableWatchpoint (Watchpoint *wp) { Error error; error.SetErrorString ("watchpoints are not suppported in kdp remote debugging"); @@ -615,7 +615,7 @@ ProcessKDP::EnableWatchpoint (WatchpointLocation *wp) } Error -ProcessKDP::DisableWatchpoint (WatchpointLocation *wp) +ProcessKDP::DisableWatchpoint (Watchpoint *wp) { Error error; error.SetErrorString ("watchpoints are not suppported in kdp remote debugging"); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h index 05907526594..85ed7b3c73b 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h @@ -178,10 +178,10 @@ public: // Process Watchpoints //---------------------------------------------------------------------- virtual lldb_private::Error - EnableWatchpoint (lldb_private::WatchpointLocation *wp_loc); + EnableWatchpoint (lldb_private::Watchpoint *wp); virtual lldb_private::Error - DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc); + DisableWatchpoint (lldb_private::Watchpoint *wp); CommunicationKDP & GetCommunication() diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index d0c4afd9fdd..3b37d7866f3 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -21,7 +21,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Unwind.h" -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "ProcessKDP.h" #include "ProcessKDPLog.h" diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 637835010fd..8915dd789bb 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -13,7 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/StreamString.h" #include "lldb/Target/Process.h" @@ -306,15 +306,15 @@ StopInfoMachException::CreateStopReasonWithMachException // It's a watchpoint, then. // The exc_sub_code indicates the data break address. - lldb::WatchpointLocationSP wp_loc_sp = - thread.GetProcess().GetTarget().GetWatchpointLocationList().FindByAddress((lldb::addr_t)exc_sub_code); - if (wp_loc_sp) + lldb::WatchpointSP wp_sp = + thread.GetProcess().GetTarget().GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code); + if (wp_sp) { // Debugserver may piggyback the hardware index of the fired watchpoint in the exception data. // Set the hardware index if that's the case. if (exc_data_count >=3) - wp_loc_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); - return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_loc_sp->GetID()); + wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); + return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID()); } } else if (exc_code == 2) // EXC_I386_BPT diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index beed1f28f37..e1f86a685a0 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -22,7 +22,7 @@ // Other libraries and framework includes -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Interpreter/Args.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" @@ -1900,7 +1900,7 @@ ProcessGDBRemote::DisableBreakpoint (BreakpointSite *bp_site) // Pre-requisite: wp != NULL. static GDBStoppointType -GetGDBStoppointType (WatchpointLocation *wp) +GetGDBStoppointType (Watchpoint *wp) { assert(wp); bool watch_read = wp->WatchpointRead(); @@ -1917,7 +1917,7 @@ GetGDBStoppointType (WatchpointLocation *wp) } Error -ProcessGDBRemote::EnableWatchpoint (WatchpointLocation *wp) +ProcessGDBRemote::EnableWatchpoint (Watchpoint *wp) { Error error; if (wp) @@ -1951,7 +1951,7 @@ ProcessGDBRemote::EnableWatchpoint (WatchpointLocation *wp) } else { - error.SetErrorString("Watchpoint location argument was NULL."); + error.SetErrorString("Watchpoint argument was NULL."); } if (error.Success()) error.SetErrorToGenericError(); @@ -1959,7 +1959,7 @@ ProcessGDBRemote::EnableWatchpoint (WatchpointLocation *wp) } Error -ProcessGDBRemote::DisableWatchpoint (WatchpointLocation *wp) +ProcessGDBRemote::DisableWatchpoint (Watchpoint *wp) { Error error; if (wp) @@ -1995,7 +1995,7 @@ ProcessGDBRemote::DisableWatchpoint (WatchpointLocation *wp) } else { - error.SetErrorString("Watchpoint location argument was NULL."); + error.SetErrorString("Watchpoint argument was NULL."); } if (error.Success()) error.SetErrorToGenericError(); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 886eb60eed6..ed3aeb80d94 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -200,10 +200,10 @@ public: // Process Watchpoints //---------------------------------------------------------------------- virtual lldb_private::Error - EnableWatchpoint (lldb_private::WatchpointLocation *wp_loc); + EnableWatchpoint (lldb_private::Watchpoint *wp); virtual lldb_private::Error - DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc); + DisableWatchpoint (lldb_private::Watchpoint *wp); virtual bool StartNoticingNewThreads(); diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 23a71f1f33b..2f9ee0fd5f2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -19,7 +19,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Unwind.h" -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 15fa5d0e990..aa577587ed2 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1997,7 +1997,7 @@ Process::DeallocateMemory (addr_t ptr) Error -Process::EnableWatchpoint (WatchpointLocation *watchpoint) +Process::EnableWatchpoint (Watchpoint *watchpoint) { Error error; error.SetErrorString("watchpoints are not supported"); @@ -2005,7 +2005,7 @@ Process::EnableWatchpoint (WatchpointLocation *watchpoint) } Error -Process::DisableWatchpoint (WatchpointLocation *watchpoint) +Process::DisableWatchpoint (Watchpoint *watchpoint) { Error error; error.SetErrorString("watchpoints are not supported"); diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index b66e2da0565..83847478540 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -19,7 +19,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" #include "lldb/Expression/ClangUserExpression.h" @@ -349,9 +349,9 @@ public: if (m_should_stop_is_valid) return m_should_stop; - WatchpointLocationSP wp_loc_sp = - m_thread.GetProcess().GetTarget().GetWatchpointLocationList().FindByID(GetValue()); - if (wp_loc_sp) + WatchpointSP wp_sp = + m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue()); + if (wp_sp) { // Check if we should stop at a watchpoint. StoppointCallbackContext context (event_ptr, @@ -360,7 +360,7 @@ public: m_thread.GetStackFrameAtIndex(0).get(), true); - m_should_stop = wp_loc_sp->ShouldStop (&context); + m_should_stop = wp_sp->ShouldStop (&context); } else { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 0cb1617f402..5423e4cd405 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -18,7 +18,7 @@ #include "lldb/Breakpoint/BreakpointResolverFileLine.h" #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" #include "lldb/Breakpoint/BreakpointResolverName.h" -#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" #include "lldb/Core/Log.h" @@ -55,7 +55,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat m_section_load_list (), m_breakpoint_list (false), m_internal_breakpoint_list (true), - m_watchpoint_location_list (), + m_watchpoint_list (), m_process_sp (), m_search_filter_sp (), m_image_search_paths (ImageSearchPathsChanged, this), @@ -126,8 +126,8 @@ Target::DeleteCurrentProcess () // clean up needs some help from the process. m_breakpoint_list.ClearAllBreakpointSites(); m_internal_breakpoint_list.ClearAllBreakpointSites(); - // Disable watchpoint locations just on the debugger side. - DisableAllWatchpointLocations(false); + // Disable watchpoints just on the debugger side. + DisableAllWatchpoints(false); m_process_sp.reset(); } } @@ -167,7 +167,7 @@ Target::Destroy() m_breakpoint_list.RemoveAll(notify); m_internal_breakpoint_list.RemoveAll(notify); m_last_created_breakpoint.reset(); - m_last_created_watchpoint_location.reset(); + m_last_created_watchpoint.reset(); m_search_filter_sp.reset(); m_image_search_paths.Clear(notify); m_scratch_ast_context_ap.reset(); @@ -397,67 +397,66 @@ Target::ProcessIsValid() return (m_process_sp && m_process_sp->IsAlive()); } -// See also WatchpointLocation::SetWatchpointType(uint32_t type) and +// See also Watchpoint::SetWatchpointType(uint32_t type) and // the OptionGroupWatchpoint::WatchType enum type. -WatchpointLocationSP -Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type) +WatchpointSP +Target::CreateWatchpoint(lldb::addr_t addr, size_t size, uint32_t type) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n", __FUNCTION__, addr, size, type); - WatchpointLocationSP wp_loc_sp; + WatchpointSP wp_sp; if (!ProcessIsValid()) - return wp_loc_sp; + return wp_sp; if (addr == LLDB_INVALID_ADDRESS || size == 0) - return wp_loc_sp; + return wp_sp; - // Currently we only support one watchpoint location per address, with total - // number of watchpoint locations limited by the hardware which the inferior - // is running on. - WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr); + // Currently we only support one watchpoint per address, with total number + // of watchpoints limited by the hardware which the inferior is running on. + WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr); if (matched_sp) { size_t old_size = matched_sp->GetByteSize(); uint32_t old_type = (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) | (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0); - // Return the existing watchpoint location if both size and type match. + // Return the existing watchpoint if both size and type match. if (size == old_size && type == old_type) { - wp_loc_sp = matched_sp; - wp_loc_sp->SetEnabled(false); + wp_sp = matched_sp; + wp_sp->SetEnabled(false); } else { - // Nil the matched watchpoint location; we will be creating a new one. + // Nil the matched watchpoint; we will be creating a new one. m_process_sp->DisableWatchpoint(matched_sp.get()); - m_watchpoint_location_list.Remove(matched_sp->GetID()); + m_watchpoint_list.Remove(matched_sp->GetID()); } } - if (!wp_loc_sp) { - WatchpointLocation *new_loc = new WatchpointLocation(addr, size); - if (!new_loc) { - printf("WatchpointLocation ctor failed, out of memory?\n"); - return wp_loc_sp; + if (!wp_sp) { + Watchpoint *new_wp = new Watchpoint(addr, size); + if (!new_wp) { + printf("Watchpoint ctor failed, out of memory?\n"); + return wp_sp; } - new_loc->SetWatchpointType(type); - new_loc->SetTarget(this); - wp_loc_sp.reset(new_loc); - m_watchpoint_location_list.Add(wp_loc_sp); + new_wp->SetWatchpointType(type); + new_wp->SetTarget(this); + wp_sp.reset(new_wp); + m_watchpoint_list.Add(wp_sp); } - Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); if (log) log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n", __FUNCTION__, rc.Success() ? "succeeded" : "failed", - wp_loc_sp->GetID()); + wp_sp->GetID()); if (rc.Fail()) - wp_loc_sp.reset(); + wp_sp.reset(); else - m_last_created_watchpoint_location = wp_loc_sp; - return wp_loc_sp; + m_last_created_watchpoint = wp_sp; + return wp_sp; } void @@ -572,17 +571,17 @@ Target::EnableBreakpointByID (break_id_t break_id) // The flag 'end_to_end', default to true, signifies that the operation is // performed end to end, for both the debugger and the debuggee. -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list -// for end to end operations. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end +// to end operations. bool -Target::RemoveAllWatchpointLocations (bool end_to_end) +Target::RemoveAllWatchpoints (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); if (!end_to_end) { - m_watchpoint_location_list.RemoveAll(); + m_watchpoint_list.RemoveAll(); return true; } @@ -591,32 +590,32 @@ Target::RemoveAllWatchpointLocations (bool end_to_end) if (!ProcessIsValid()) return false; - size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + size_t num_watchpoints = m_watchpoint_list.GetSize(); for (size_t i = 0; i < num_watchpoints; ++i) { - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); - if (!wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); + if (!wp_sp) return false; - Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); if (rc.Fail()) return false; } - m_watchpoint_location_list.RemoveAll (); + m_watchpoint_list.RemoveAll (); return true; // Success! } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list -// for end to end operations. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to +// end operations. bool -Target::DisableAllWatchpointLocations (bool end_to_end) +Target::DisableAllWatchpoints (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); if (!end_to_end) { - m_watchpoint_location_list.SetEnabledAll(false); + m_watchpoint_list.SetEnabledAll(false); return true; } @@ -625,31 +624,31 @@ Target::DisableAllWatchpointLocations (bool end_to_end) if (!ProcessIsValid()) return false; - size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + size_t num_watchpoints = m_watchpoint_list.GetSize(); for (size_t i = 0; i < num_watchpoints; ++i) { - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); - if (!wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); + if (!wp_sp) return false; - Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); if (rc.Fail()) return false; } return true; // Success! } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list -// for end to end operations. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to +// end operations. bool -Target::EnableAllWatchpointLocations (bool end_to_end) +Target::EnableAllWatchpoints (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); if (!end_to_end) { - m_watchpoint_location_list.SetEnabledAll(true); + m_watchpoint_list.SetEnabledAll(true); return true; } @@ -658,24 +657,24 @@ Target::EnableAllWatchpointLocations (bool end_to_end) if (!ProcessIsValid()) return false; - size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + size_t num_watchpoints = m_watchpoint_list.GetSize(); for (size_t i = 0; i < num_watchpoints; ++i) { - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); - if (!wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); + if (!wp_sp) return false; - Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); if (rc.Fail()) return false; } return true; // Success! } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list +// Assumption: Caller holds the list mutex lock for m_watchpoint_list // during these operations. bool -Target::IgnoreAllWatchpointLocations (uint32_t ignore_count) +Target::IgnoreAllWatchpoints (uint32_t ignore_count) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) @@ -684,21 +683,21 @@ Target::IgnoreAllWatchpointLocations (uint32_t ignore_count) if (!ProcessIsValid()) return false; - size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + size_t num_watchpoints = m_watchpoint_list.GetSize(); for (size_t i = 0; i < num_watchpoints; ++i) { - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); - if (!wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); + if (!wp_sp) return false; - wp_loc_sp->SetIgnoreCount(ignore_count); + wp_sp->SetIgnoreCount(ignore_count); } return true; // Success! } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list. bool -Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) +Target::DisableWatchpointByID (lldb::watch_id_t watch_id) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) @@ -707,10 +706,10 @@ Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) if (!ProcessIsValid()) return false; - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); - if (wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); + if (wp_sp) { - Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); if (rc.Success()) return true; @@ -719,9 +718,9 @@ Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) return false; } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list. bool -Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) +Target::EnableWatchpointByID (lldb::watch_id_t watch_id) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) @@ -730,10 +729,10 @@ Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) if (!ProcessIsValid()) return false; - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); - if (wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); + if (wp_sp) { - Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); + Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); if (rc.Success()) return true; @@ -742,25 +741,25 @@ Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) return false; } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list. bool -Target::RemoveWatchpointLocationByID (lldb::watch_id_t watch_id) +Target::RemoveWatchpointByID (lldb::watch_id_t watch_id) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); - if (DisableWatchpointLocationByID (watch_id)) + if (DisableWatchpointByID (watch_id)) { - m_watchpoint_location_list.Remove(watch_id); + m_watchpoint_list.Remove(watch_id); return true; } return false; } -// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_list. bool -Target::IgnoreWatchpointLocationByID (lldb::watch_id_t watch_id, uint32_t ignore_count) +Target::IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) @@ -769,10 +768,10 @@ Target::IgnoreWatchpointLocationByID (lldb::watch_id_t watch_id, uint32_t ignore if (!ProcessIsValid()) return false; - WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); - if (wp_loc_sp) + WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); + if (wp_sp) { - wp_loc_sp->SetIgnoreCount(ignore_count); + wp_sp->SetIgnoreCount(ignore_count); return true; } return false; diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 740c932fc8f..9c7a5265b6d 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -105,8 +105,9 @@ def bytearray_to_int(bytes, bytesize): def get_description(obj, option=None): """Calls lldb_obj.GetDescription() and returns a string, or None. - For SBTarget and SBBreakpointLocation lldb objects, an extra option can be - passed in to describe the detailed level of description desired: + For SBTarget, SBBreakpointLocation, and SBWatchpoint lldb objects, an extra + option can be passed in to describe the detailed level of description + desired: o lldb.eDescriptionLevelBrief o lldb.eDescriptionLevelFull o lldb.eDescriptionLevelVerbose @@ -114,7 +115,7 @@ def get_description(obj, option=None): method = getattr(obj, 'GetDescription') if not method: return None - tuple = (lldb.SBTarget, lldb.SBBreakpointLocation, lldb.SBWatchpointLocation) + tuple = (lldb.SBTarget, lldb.SBBreakpointLocation, lldb.SBWatchpoint) if isinstance(obj, tuple): if option is None: option = lldb.eDescriptionLevelBrief diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py index 2340a6130a7..f5f9aef0014 100644 --- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py +++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py @@ -350,14 +350,14 @@ class APIDefaultConstructorTestCase(TestBase): sb_valuelist.fuzz_obj(obj) @python_api_test - def test_SBWatchpointLocation(self): - obj = lldb.SBWatchpointLocation() + def test_SBWatchpoint(self): + obj = lldb.SBWatchpoint() if self.TraceOn(): print obj self.assertFalse(obj) # Do fuzz testing on the invalid obj, it should not crash lldb. - import sb_watchpointlocation - sb_watchpointlocation.fuzz_obj(obj) + import sb_watchpoint + sb_watchpoint.fuzz_obj(obj) if __name__ == '__main__': diff --git a/lldb/test/python_api/default-constructor/sb_frame.py b/lldb/test/python_api/default-constructor/sb_frame.py index db0e82d4307..41edaff02ed 100644 --- a/lldb/test/python_api/default-constructor/sb_frame.py +++ b/lldb/test/python_api/default-constructor/sb_frame.py @@ -33,6 +33,5 @@ def fuzz_obj(obj): obj.FindVariable("my_var", lldb.eDynamicCanRunTarget) obj.FindValue("your_var", lldb.eValueTypeVariableGlobal) obj.FindValue("your_var", lldb.eValueTypeVariableStatic, lldb.eDynamicCanRunTarget) - obj.WatchValue("global_var", lldb.eValueTypeVariableGlobal, lldb.LLDB_WATCH_TYPE_READ) obj.GetDescription(lldb.SBStream()) obj.Clear() diff --git a/lldb/test/python_api/default-constructor/sb_target.py b/lldb/test/python_api/default-constructor/sb_target.py index 6b7bf777a06..3f15a1a0565 100644 --- a/lldb/test/python_api/default-constructor/sb_target.py +++ b/lldb/test/python_api/default-constructor/sb_target.py @@ -40,14 +40,13 @@ def fuzz_obj(obj): obj.EnableAllBreakpoints() obj.DisableAllBreakpoints() obj.DeleteAllBreakpoints() - obj.GetNumWatchpointLocations() - obj.GetLastCreatedWatchpointLocation() - obj.GetWatchpointLocationAtIndex(0) - obj.WatchpointLocationDelete(0) - obj.FindWatchpointLocationByID(0) - obj.EnableAllWatchpointLocations() - obj.DisableAllWatchpointLocations() - obj.DeleteAllWatchpointLocations() + obj.GetNumWatchpoints() + obj.GetWatchpointAtIndex(0) + obj.DeleteWatchpoint(0) + obj.FindWatchpointByID(0) + obj.EnableAllWatchpoints() + obj.DisableAllWatchpoints() + obj.DeleteAllWatchpoints() obj.GetBroadcaster() obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) obj.Clear() @@ -55,5 +54,5 @@ def fuzz_obj(obj): print module for bp in obj.breakpoint_iter(): print bp - for wp_loc in obj.watchpoint_location_iter(): + for wp_loc in obj.watchpoint_iter(): print wp_loc diff --git a/lldb/test/python_api/default-constructor/sb_value.py b/lldb/test/python_api/default-constructor/sb_value.py index 715ba1ce493..b3a26def772 100644 --- a/lldb/test/python_api/default-constructor/sb_value.py +++ b/lldb/test/python_api/default-constructor/sb_value.py @@ -33,5 +33,7 @@ def fuzz_obj(obj): obj.GetDescription(stream) obj.GetExpressionPath(stream) obj.GetExpressionPath(stream, True) + obj.Watch(True, True, False) + obj.WatchPointee(True, False, True) for child_val in obj: print child_val diff --git a/lldb/test/python_api/default-constructor/sb_watchpointlocation.py b/lldb/test/python_api/default-constructor/sb_watchpoint.py index 8b0b1ecc481..8b0b1ecc481 100644 --- a/lldb/test/python_api/default-constructor/sb_watchpointlocation.py +++ b/lldb/test/python_api/default-constructor/sb_watchpoint.py diff --git a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py index 61526ab0f02..d16d0cb058f 100644 --- a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py @@ -1,5 +1,5 @@ """ -Use lldb Python SBFrame API to create a watchpoint for read_write of 'globl' var. +Use lldb Python SBValue API to create a watchpoint for read_write of 'globl' var. """ import os, time @@ -23,13 +23,13 @@ class SetWatchpointAPITestCase(TestBase): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test def test_watch_val_with_dsym(self): - """Exercise SBFrame.WatchValue() API to set a watchpoint.""" + """Exercise SBValue.Watch() API to set a watchpoint.""" self.buildDsym() self.do_set_watchpoint() @python_api_test def test_watch_val_with_dwarf(self): - """Exercise SBFrame.WatchValue() API to set a watchpoint.""" + """Exercise SBValue.Watch() API to set a watchpoint.""" self.buildDwarf() self.do_set_watchpoint() @@ -57,12 +57,19 @@ class SetWatchpointAPITestCase(TestBase): thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) - value = frame0.WatchValue('global', - lldb.eValueTypeVariableGlobal, - lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) - self.assertTrue(value, "Successfully found the variable and set a watchpoint") + # Watch 'global' for read and write. + value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) + watchpoint = value.Watch(True, True, True) + self.assertTrue(value and watchpoint, + "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + print watchpoint + # Continue. Expect the program to stop due to the variable being written to. process.Continue() diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index 7b16a10d02e..53b86bc9706 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -1,5 +1,5 @@ """ -Use lldb Python SBWatchpointLocation API to set the ignore count. +Use lldb Python SBWatchpoint API to set the ignore count. """ import os, time @@ -22,19 +22,19 @@ class WatchpointIgnoreCountTestCase(TestBase): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test - def test_set_watch_loc_ignore_count_with_dsym(self): - """Test SBWatchpointLocation.SetIgnoreCount() API.""" + def test_set_watch_ignore_count_with_dsym(self): + """Test SBWatchpoint.SetIgnoreCount() API.""" self.buildDsym() - self.do_watchpoint_location_ignore_count() + self.do_watchpoint_ignore_count() @python_api_test - def test_set_watch_loc_ignore_count_with_dwarf(self): - """Test SBWatchpointLocation.SetIgnoreCount() API.""" + def test_set_watch_ignore_count_with_dwarf(self): + """Test SBWatchpoint.SetIgnoreCount() API.""" self.buildDwarf() - self.do_watchpoint_location_ignore_count() + self.do_watchpoint_ignore_count() - def do_watchpoint_location_ignore_count(self): - """Test SBWatchpointLocation.SetIgnoreCount() API.""" + def do_watchpoint_ignore_count(self): + """Test SBWatchpoint.SetIgnoreCount() API.""" exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -58,10 +58,10 @@ class WatchpointIgnoreCountTestCase(TestBase): frame0 = thread.GetFrameAtIndex(0) # Watch 'global' for read and write. - value = frame0.WatchValue('global', - lldb.eValueTypeVariableGlobal, - lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) - self.assertTrue(value, "Successfully found the variable and set a watchpoint") + value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) + watchpoint = value.Watch(True, True, True) + self.assertTrue(value and watchpoint, + "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) # Hide stdout if not running with '-t' option. @@ -69,30 +69,28 @@ class WatchpointIgnoreCountTestCase(TestBase): self.HideStdout() # There should be only 1 watchpoint location under the target. - self.assertTrue(target.GetNumWatchpointLocations() == 1) - wp_loc = target.GetWatchpointLocationAtIndex(0) - last_created = target.GetLastCreatedWatchpointLocation() - self.assertTrue(wp_loc == last_created) - self.assertTrue(wp_loc.IsEnabled()) - self.assertTrue(wp_loc.GetIgnoreCount() == 0) - watch_id = wp_loc.GetID() + self.assertTrue(target.GetNumWatchpoints() == 1) + watchpoint = target.GetWatchpointAtIndex(0) + self.assertTrue(watchpoint.IsEnabled()) + self.assertTrue(watchpoint.GetIgnoreCount() == 0) + watch_id = watchpoint.GetID() self.assertTrue(watch_id != 0) - print wp_loc + print watchpoint # Now immediately set the ignore count to 2. When we continue, expect the # inferior to run to its completion without stopping due to watchpoint. - wp_loc.SetIgnoreCount(2) - print wp_loc + watchpoint.SetIgnoreCount(2) + print watchpoint process.Continue() # At this point, the inferior process should have exited. self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) # Verify some vital statistics. - self.assertTrue(wp_loc) - self.assertTrue(wp_loc.GetWatchSize() == 4) - self.assertTrue(wp_loc.GetHitCount() == 2) - print wp_loc + self.assertTrue(watchpoint) + self.assertTrue(watchpoint.GetWatchSize() == 4) + self.assertTrue(watchpoint.GetHitCount() == 2) + print watchpoint if __name__ == '__main__': diff --git a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py b/lldb/test/python_api/watchpoint/TestWatchpointIter.py index ec67831b68a..2d70648fde1 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIter.py @@ -8,7 +8,7 @@ import unittest2 import lldb, lldbutil from lldbtest import * -class WatchpointLocationIteratorTestCase(TestBase): +class WatchpointIteratorTestCase(TestBase): mydir = os.path.join("python_api", "watchpoint") @@ -22,19 +22,19 @@ class WatchpointLocationIteratorTestCase(TestBase): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test - def test_watch_loc_iter_with_dsym(self): - """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations.""" + def test_watch_iter_with_dsym(self): + """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" self.buildDsym() - self.do_watchpoint_location_iter() + self.do_watchpoint_iter() @python_api_test - def test_watch_loc_iter_with_dwarf(self): - """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations.""" + def test_watch_iter_with_dwarf(self): + """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" self.buildDwarf() - self.do_watchpoint_location_iter() + self.do_watchpoint_iter() - def do_watchpoint_location_iter(self): - """Use SBTarget.watchpoint_location_iter() to do Pythonic iteration on the available watchpoint locations.""" + def do_watchpoint_iter(self): + """Use SBTarget.watchpoint_iter() to do Pythonic iteration on the available watchpoints.""" exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -57,19 +57,21 @@ class WatchpointLocationIteratorTestCase(TestBase): thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) - value = frame0.WatchValue('global', - lldb.eValueTypeVariableGlobal, - lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) - self.assertTrue(value, "Successfully found the variable and set a watchpoint") + # Watch 'global' for read and write. + value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) + watchpoint = value.Watch(True, True, True) + self.assertTrue(value and watchpoint, + "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + # There should be only 1 watchpoint location under the target. - self.assertTrue(target.GetNumWatchpointLocations() == 1) - wp_loc = target.GetWatchpointLocationAtIndex(0) - last_created = target.GetLastCreatedWatchpointLocation() - self.assertTrue(wp_loc == last_created) - self.assertTrue(wp_loc.IsEnabled()) - watch_id = wp_loc.GetID() + self.assertTrue(target.GetNumWatchpoints() == 1) + self.assertTrue(watchpoint.IsEnabled()) + watch_id = watchpoint.GetID() self.assertTrue(watch_id != 0) # Continue. Expect the program to stop due to the variable being written to. @@ -89,17 +91,17 @@ class WatchpointLocationIteratorTestCase(TestBase): # We currently only support hardware watchpoint. Verify that we have a # meaningful hardware index at this point. Exercise the printed repr of # SBWatchpointLocation. - print wp_loc - self.assertTrue(wp_loc.GetHardwareIndex() != -1) + print watchpoint + self.assertTrue(watchpoint.GetHardwareIndex() != -1) - # SBWatchpointLocation.GetDescription() takes a description level arg. - print lldbutil.get_description(wp_loc, lldb.eDescriptionLevelFull) + # SBWatchpoint.GetDescription() takes a description level arg. + print lldbutil.get_description(watchpoint, lldb.eDescriptionLevelFull) # Now disable the 'rw' watchpoint. The program won't stop when it reads # 'global' next. - wp_loc.SetEnabled(False) - self.assertTrue(wp_loc.GetHardwareIndex() == -1) - self.assertFalse(wp_loc.IsEnabled()) + watchpoint.SetEnabled(False) + self.assertTrue(watchpoint.GetHardwareIndex() == -1) + self.assertFalse(watchpoint.IsEnabled()) # Continue. The program does not stop again when the variable is being # read from because the watchpoint location has been disabled. @@ -109,11 +111,11 @@ class WatchpointLocationIteratorTestCase(TestBase): self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) # Verify some vital statistics and exercise the iterator API. - for wp_loc in target.watchpoint_location_iter(): - self.assertTrue(wp_loc) - self.assertTrue(wp_loc.GetWatchSize() == 4) - self.assertTrue(wp_loc.GetHitCount() == 1) - print wp_loc + for watchpoint in target.watchpoint_iter(): + self.assertTrue(watchpoint) + self.assertTrue(watchpoint.GetWatchSize() == 4) + self.assertTrue(watchpoint.GetHitCount() == 1) + print watchpoint if __name__ == '__main__': diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index 7a78b1533fc..455a8c27483 100644 --- a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -1,5 +1,5 @@ """ -Use lldb Python SBFrame.WatchLocation() API to create a watchpoint for write of '*g_char_ptr'. +Use lldb Python SBValue.WatchPointee() API to create a watchpoint for write of '*g_char_ptr'. """ import os, time @@ -59,12 +59,23 @@ class SetWatchlocationAPITestCase(TestBase): thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) - value = frame0.WatchLocation('g_char_ptr', - lldb.eValueTypeVariableGlobal, - lldb.LLDB_WATCH_TYPE_WRITE, - 1) - self.assertTrue(value, "Successfully found the location and set a watchpoint") + value = frame0.FindValue('g_char_ptr', + lldb.eValueTypeVariableGlobal) + pointee = value.CreateValueFromAddress("pointee", + value.GetValueAsUnsigned(0), + value.GetType().GetPointeeType()) + # Watch for write to *g_char_ptr. + watchpoint = value.WatchPointee(True, False, True) + self.assertTrue(value and watchpoint, + "Successfully found the pointer and set a watchpoint") self.DebugSBValue(value) + self.DebugSBValue(pointee) + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + print watchpoint # Continue. Expect the program to stop due to the variable being written to. process.Continue() @@ -75,6 +86,7 @@ class SetWatchlocationAPITestCase(TestBase): thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint) self.assertTrue(thread, "The thread stopped due to watchpoint") self.DebugSBValue(value) + self.DebugSBValue(pointee) self.expect(lldbutil.print_stacktrace(thread, string_buffer=True), exe=False, substrs = [self.violating_func]) |