[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Tue Sep 6 15:57:50 2016
@@ -31,204 +31,181 @@ namespace lldb_private {
/// Allows adding and removing breakpoints and find by ID and index.
//----------------------------------------------------------------------
-class BreakpointList
-{
+class BreakpointList {
public:
- BreakpointList (bool is_internal);
+ BreakpointList(bool is_internal);
- ~BreakpointList();
+ ~BreakpointList();
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint that will get added to the list.
- ///
- /// @result
- /// Returns breakpoint id.
- //------------------------------------------------------------------
- lldb::break_id_t
- Add (lldb::BreakpointSP& bp_sp, bool notify);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with id \a breakID.
- ///
- /// @param[in] breakID
- /// The breakpoint ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSP
- FindBreakpointByID (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with id \a breakID. Const version.
- ///
- /// @param[in] breakID
- /// The breakpoint ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSP
- FindBreakpointByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with index \a i.
- ///
- /// @param[in] i
- /// The breakpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSP
- GetBreakpointAtIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint with index \a i, const version
- ///
- /// @param[in] i
- /// The breakpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSP
- GetBreakpointAtIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_breakpoints.size();
- }
-
- //------------------------------------------------------------------
- /// Removes the breakpoint given by \b breakID from this list.
- ///
- /// @param[in] breakID
- /// The breakpoint index to remove.
- ///
- /// @result
- /// \b true if the breakpoint \a breakID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t breakID, bool notify);
-
-
- //------------------------------------------------------------------
- /// Removes all invalid breakpoint locations.
- ///
- /// Removes all breakpoint locations in the list with architectures
- /// that aren't compatible with \a arch. Also remove any breakpoint
- /// locations with whose locations have address where the section
- /// has been deleted (module and object files no longer exist).
- ///
- /// This is typically used after the process calls exec, or anytime
- /// the architecture of the target changes.
- ///
- /// @param[in] arch
- /// If valid, check the module in each breakpoint to make sure
- /// they are compatible, otherwise, ignore architecture.
- //------------------------------------------------------------------
- void
- RemoveInvalidLocations (const ArchSpec &arch);
-
- void
- SetEnabledAll (bool enabled);
-
- //------------------------------------------------------------------
- /// Removes all the breakpoints from this list.
- //------------------------------------------------------------------
- void
- RemoveAll (bool notify);
-
- //------------------------------------------------------------------
- /// Tell all the breakpoints to update themselves due to a change in the
- /// modules in \a module_list. \a added says whether the module was loaded
- /// or unloaded.
- ///
- /// @param[in] module_list
- /// The module list that has changed.
- ///
- /// @param[in] load
- /// \b true if the modules are loaded, \b false if unloaded.
- ///
- /// @param[in] delete_locations
- /// If \a load is \b false, then delete breakpoint locations when
- /// when updating breakpoints.
- //------------------------------------------------------------------
- void
- UpdateBreakpoints (ModuleList &module_list,
- bool load,
- bool delete_locations);
-
- void
- UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
-
- void
- ClearAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Sets the passed in Locker to hold the Breakpoint List mutex.
- ///
- /// @param[in] locker
- /// The locker object that is set.
- //------------------------------------------------------------------
- void
- GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint that will get added to the list.
+ ///
+ /// @result
+ /// Returns breakpoint id.
+ //------------------------------------------------------------------
+ lldb::break_id_t Add(lldb::BreakpointSP &bp_sp, bool notify);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with id \a breakID.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with id \a breakID. Const
+ /// version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with index \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSP GetBreakpointAtIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint with index \a i, const version
+ ///
+ /// @param[in] i
+ /// The breakpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL pointer if the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_breakpoints.size();
+ }
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint given by \b breakID from this list.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint index to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint \a breakID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t breakID, bool notify);
+
+ //------------------------------------------------------------------
+ /// Removes all invalid breakpoint locations.
+ ///
+ /// Removes all breakpoint locations in the list with architectures
+ /// that aren't compatible with \a arch. Also remove any breakpoint
+ /// locations with whose locations have address where the section
+ /// has been deleted (module and object files no longer exist).
+ ///
+ /// This is typically used after the process calls exec, or anytime
+ /// the architecture of the target changes.
+ ///
+ /// @param[in] arch
+ /// If valid, check the module in each breakpoint to make sure
+ /// they are compatible, otherwise, ignore architecture.
+ //------------------------------------------------------------------
+ void RemoveInvalidLocations(const ArchSpec &arch);
+
+ void SetEnabledAll(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Removes all the breakpoints from this list.
+ //------------------------------------------------------------------
+ void RemoveAll(bool notify);
+
+ //------------------------------------------------------------------
+ /// Tell all the breakpoints to update themselves due to a change in the
+ /// modules in \a module_list. \a added says whether the module was loaded
+ /// or unloaded.
+ ///
+ /// @param[in] module_list
+ /// The module list that has changed.
+ ///
+ /// @param[in] load
+ /// \b true if the modules are loaded, \b false if unloaded.
+ ///
+ /// @param[in] delete_locations
+ /// If \a load is \b false, then delete breakpoint locations when
+ /// when updating breakpoints.
+ //------------------------------------------------------------------
+ void UpdateBreakpoints(ModuleList &module_list, bool load,
+ bool delete_locations);
+
+ void UpdateBreakpointsWhenModuleIsReplaced(lldb::ModuleSP old_module_sp,
+ lldb::ModuleSP new_module_sp);
+
+ void ClearAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Sets the passed in Locker to hold the Breakpoint List mutex.
+ ///
+ /// @param[in] locker
+ /// The locker object that is set.
+ //------------------------------------------------------------------
+ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
- typedef std::list<lldb::BreakpointSP> bp_collection;
+ typedef std::list<lldb::BreakpointSP> bp_collection;
- bp_collection::iterator
- GetBreakpointIDIterator(lldb::break_id_t breakID);
+ bp_collection::iterator GetBreakpointIDIterator(lldb::break_id_t breakID);
- bp_collection::const_iterator
- GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
+ bp_collection::const_iterator
+ GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
- std::recursive_mutex &
- GetMutex() const
- {
- return m_mutex;
- }
-
- mutable std::recursive_mutex m_mutex;
- bp_collection m_breakpoints; // The breakpoint list, currently a list.
- lldb::break_id_t m_next_break_id;
- bool m_is_internal;
+ std::recursive_mutex &GetMutex() const { return m_mutex; }
+
+ mutable std::recursive_mutex m_mutex;
+ bp_collection m_breakpoints; // The breakpoint list, currently a list.
+ lldb::break_id_t m_next_break_id;
+ bool m_is_internal;
public:
- typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter, std::recursive_mutex>
- BreakpointIterable;
- BreakpointIterable
- Breakpoints()
- {
- return BreakpointIterable(m_breakpoints, GetMutex());
- }
+ typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP,
+ list_adapter, std::recursive_mutex>
+ BreakpointIterable;
+ BreakpointIterable Breakpoints() {
+ return BreakpointIterable(m_breakpoints, GetMutex());
+ }
private:
- DISALLOW_COPY_AND_ASSIGN (BreakpointList);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointList);
};
} // namespace lldb_private
-#endif // liblldb_BreakpointList_h_
+#endif // liblldb_BreakpointList_h_
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h Tue Sep 6 15:57:50 2016
@@ -17,16 +17,18 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointLocation BreakpointLocation.h "lldb/Breakpoint/BreakpointLocation.h"
-/// @brief Class that manages one unique (by address) instance of a logical breakpoint.
+/// @class BreakpointLocation BreakpointLocation.h
+/// "lldb/Breakpoint/BreakpointLocation.h"
+/// @brief Class that manages one unique (by address) instance of a logical
+/// breakpoint.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
@@ -42,438 +44,384 @@ namespace lldb_private {
/// would be useful if you've set options on the locations.
//----------------------------------------------------------------------
-class BreakpointLocation :
- public std::enable_shared_from_this<BreakpointLocation>,
- public StoppointLocation
-{
+class BreakpointLocation
+ : public std::enable_shared_from_this<BreakpointLocation>,
+ public StoppointLocation {
public:
- ~BreakpointLocation() override;
+ ~BreakpointLocation() override;
+
+ //------------------------------------------------------------------
+ /// Gets the load address for this breakpoint location
+ /// @return
+ /// Returns breakpoint location load address, \b
+ /// LLDB_INVALID_ADDRESS if not yet set.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLoadAddress() const override;
+
+ //------------------------------------------------------------------
+ /// Gets the Address for this breakpoint location
+ /// @return
+ /// Returns breakpoint location Address.
+ //------------------------------------------------------------------
+ Address &GetAddress();
+ //------------------------------------------------------------------
+ /// Gets the Breakpoint that created this breakpoint location
+ /// @return
+ /// Returns the owning breakpoint.
+ //------------------------------------------------------------------
+ Breakpoint &GetBreakpoint();
+
+ Target &GetTarget();
+
+ //------------------------------------------------------------------
+ /// Determines whether we should stop due to a hit at this
+ /// breakpoint location.
+ ///
+ /// Side Effects: This may evaluate the breakpoint condition, and
+ /// run the callback. So this command may do a considerable amount
+ /// of work.
+ ///
+ /// @return
+ /// \b true if this breakpoint location thinks we should stop,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ //------------------------------------------------------------------
+ // The next section deals with various breakpoint options.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false
+ /// disable it.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Check the Enable/Disable state.
+ ///
+ /// @return
+ /// \b true if the breakpoint is enabled, \b false if disabled.
+ //------------------------------------------------------------------
+ bool IsEnabled() const;
+
+ //------------------------------------------------------------------
+ /// Return the current Ignore Count.
+ ///
+ /// @return
+ /// The number of breakpoint hits to be ignored.
+ //------------------------------------------------------------------
+ uint32_t GetIgnoreCount();
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint to ignore the next \a count breakpoint hits.
+ ///
+ /// @param[in] count
+ /// The number of breakpoint hits to ignore.
+ //------------------------------------------------------------------
+ void SetIgnoreCount(uint32_t n);
+
+ //------------------------------------------------------------------
+ /// Set the callback action invoked when the breakpoint is hit.
+ ///
+ /// The callback will return a bool indicating whether the target
+ /// should stop at this breakpoint or not.
+ ///
+ /// @param[in] callback
+ /// The method that will get called when the breakpoint is hit.
+ ///
+ /// @param[in] callback_baton_sp
+ /// A shared pointer to a Baton that provides the void * needed
+ /// for the callback.
+ ///
+ /// @see lldb_private::Baton
+ //------------------------------------------------------------------
+ void SetCallback(BreakpointHitCallback callback,
+ const lldb::BatonSP &callback_baton_sp, bool is_synchronous);
+
+ void SetCallback(BreakpointHitCallback callback, void *baton,
+ bool is_synchronous);
+
+ void ClearCallback();
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint location's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the breakpoint is hit.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText(size_t *hash = nullptr) const;
+
+ bool ConditionSaysStop(ExecutionContext &exe_ctx, Error &error);
+
+ //------------------------------------------------------------------
+ /// Set the valid thread to be checked when the breakpoint is hit.
+ ///
+ /// @param[in] thread_id
+ /// If this thread hits the breakpoint, we stop, otherwise not.
+ //------------------------------------------------------------------
+ void SetThreadID(lldb::tid_t thread_id);
+
+ lldb::tid_t GetThreadID();
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
+
+ //------------------------------------------------------------------
+ // The next section deals with this location's breakpoint sites.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Try to resolve the breakpoint site for this location.
+ ///
+ /// @return
+ /// \b true if we were successful at setting a breakpoint site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool ResolveBreakpointSite();
+
+ //------------------------------------------------------------------
+ /// Clear this breakpoint location's breakpoint site - for instance
+ /// when disabling the breakpoint.
+ ///
+ /// @return
+ /// \b true if there was a breakpoint site to be cleared, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool ClearBreakpointSite();
+
+ //------------------------------------------------------------------
+ /// Return whether this breakpoint location has a breakpoint site.
+ /// @return
+ /// \b true if there was a breakpoint site for this breakpoint
+ /// location, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsResolved() const;
+
+ lldb::BreakpointSiteSP GetBreakpointSite() const;
+
+ //------------------------------------------------------------------
+ // The next section are generic report functions.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Print a description of this breakpoint location to the stream
+ /// \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const override;
+
+ //------------------------------------------------------------------
+ /// Use this to set location specific breakpoint options.
+ ///
+ /// It will create a copy of the containing breakpoint's options if
+ /// that hasn't been done already
+ ///
+ /// @return
+ /// A pointer to the breakpoint options.
+ //------------------------------------------------------------------
+ BreakpointOptions *GetLocationOptions();
+
+ //------------------------------------------------------------------
+ /// Use this to access breakpoint options from this breakpoint location.
+ /// This will point to the owning breakpoint's options unless options have
+ /// been set specifically on this location.
+ ///
+ /// @return
+ /// A pointer to the containing breakpoint's options if this
+ /// location doesn't have its own copy.
+ //------------------------------------------------------------------
+ const BreakpointOptions *GetOptionsNoCreate() const;
+
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Invoke the callback action when the breakpoint is hit.
+ ///
+ /// Meant to be used by the BreakpointLocation class.
+ ///
+ /// @param[in] context
+ /// Described the breakpoint event.
+ ///
+ /// @param[in] bp_loc_id
+ /// Which breakpoint location hit this breakpoint.
+ ///
+ /// @return
+ /// \b true if the target should stop at this breakpoint and \b
+ /// false not.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ /// Returns whether we should resolve Indirect functions in setting the
+ /// breakpoint site
+ /// for this location.
+ ///
+ /// @return
+ /// \b true if the breakpoint SITE for this location should be set on the
+ /// resolved location for Indirect functions.
+ //------------------------------------------------------------------
+ bool ShouldResolveIndirectFunctions() {
+ return m_should_resolve_indirect_functions;
+ }
+
+ //------------------------------------------------------------------
+ /// Returns whether the address set in the breakpoint site for this location
+ /// was found by resolving
+ /// an indirect symbol.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool IsIndirect() { return m_is_indirect; }
+
+ void SetIsIndirect(bool is_indirect) { m_is_indirect = is_indirect; }
+
+ //------------------------------------------------------------------
+ /// Returns whether the address set in the breakpoint location was re-routed
+ /// to the target of a
+ /// re-exported symbol.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool IsReExported() { return m_is_reexported; }
+
+ void SetIsReExported(bool is_reexported) { m_is_reexported = is_reexported; }
+
+ //------------------------------------------------------------------
+ /// Returns whether the two breakpoint locations might represent "equivalent
+ /// locations".
+ /// This is used when modules changed to determine if a Location in the old
+ /// module might
+ /// be the "same as" the input location.
+ ///
+ /// @param[in] location
+ /// The location to compare against.
+ ///
+ /// @return
+ /// \b true or \b false as given in the description above.
+ //------------------------------------------------------------------
+ bool EquivalentToLocation(BreakpointLocation &location);
- //------------------------------------------------------------------
- /// Gets the load address for this breakpoint location
- /// @return
- /// Returns breakpoint location load address, \b
- /// LLDB_INVALID_ADDRESS if not yet set.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLoadAddress() const override;
-
- //------------------------------------------------------------------
- /// Gets the Address for this breakpoint location
- /// @return
- /// Returns breakpoint location Address.
- //------------------------------------------------------------------
- Address &
- GetAddress ();
- //------------------------------------------------------------------
- /// Gets the Breakpoint that created this breakpoint location
- /// @return
- /// Returns the owning breakpoint.
- //------------------------------------------------------------------
- Breakpoint &
- GetBreakpoint ();
-
- Target &
- GetTarget();
-
- //------------------------------------------------------------------
- /// Determines whether we should stop due to a hit at this
- /// breakpoint location.
- ///
- /// Side Effects: This may evaluate the breakpoint condition, and
- /// run the callback. So this command may do a considerable amount
- /// of work.
- ///
- /// @return
- /// \b true if this breakpoint location thinks we should stop,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- //------------------------------------------------------------------
- // The next section deals with various breakpoint options.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false
- /// disable it.
- //------------------------------------------------------------------
- void
- SetEnabled(bool enabled);
-
- //------------------------------------------------------------------
- /// Check the Enable/Disable state.
- ///
- /// @return
- /// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
- bool
- IsEnabled () const;
-
- //------------------------------------------------------------------
- /// Return the current Ignore Count.
- ///
- /// @return
- /// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
- uint32_t
- GetIgnoreCount ();
-
- //------------------------------------------------------------------
- /// Set the breakpoint to ignore the next \a count breakpoint hits.
- ///
- /// @param[in] count
- /// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
- void
- SetIgnoreCount (uint32_t n);
-
- //------------------------------------------------------------------
- /// Set the callback action invoked when the breakpoint is hit.
- ///
- /// The callback will return a bool indicating whether the target
- /// should stop at this breakpoint or not.
- ///
- /// @param[in] callback
- /// The method that will get called when the breakpoint is hit.
- ///
- /// @param[in] callback_baton_sp
- /// A shared pointer to a Baton that provides the void * needed
- /// for the callback.
- ///
- /// @see lldb_private::Baton
- //------------------------------------------------------------------
- void
- SetCallback (BreakpointHitCallback callback,
- const lldb::BatonSP &callback_baton_sp,
- bool is_synchronous);
-
- void
- SetCallback (BreakpointHitCallback callback,
- void *baton,
- bool is_synchronous);
-
- void
- ClearCallback ();
-
- //------------------------------------------------------------------
- /// Set the breakpoint location's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the breakpoint is hit.
- //------------------------------------------------------------------
- void
- SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *
- GetConditionText(size_t *hash = nullptr) const;
-
- bool
- ConditionSaysStop (ExecutionContext &exe_ctx, Error &error);
-
- //------------------------------------------------------------------
- /// Set the valid thread to be checked when the breakpoint is hit.
- ///
- /// @param[in] thread_id
- /// If this thread hits the breakpoint, we stop, otherwise not.
- //------------------------------------------------------------------
- void
- SetThreadID (lldb::tid_t thread_id);
-
- lldb::tid_t
- GetThreadID ();
-
- void
- SetThreadIndex (uint32_t index);
-
- uint32_t
- GetThreadIndex() const;
-
- void
- SetThreadName (const char *thread_name);
-
- const char *
- GetThreadName () const;
-
- void
- SetQueueName (const char *queue_name);
-
- const char *
- GetQueueName () const;
-
- //------------------------------------------------------------------
- // The next section deals with this location's breakpoint sites.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Try to resolve the breakpoint site for this location.
- ///
- /// @return
- /// \b true if we were successful at setting a breakpoint site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- ResolveBreakpointSite ();
-
- //------------------------------------------------------------------
- /// Clear this breakpoint location's breakpoint site - for instance
- /// when disabling the breakpoint.
- ///
- /// @return
- /// \b true if there was a breakpoint site to be cleared, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- ClearBreakpointSite ();
-
- //------------------------------------------------------------------
- /// Return whether this breakpoint location has a breakpoint site.
- /// @return
- /// \b true if there was a breakpoint site for this breakpoint
- /// location, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsResolved () const;
-
- lldb::BreakpointSiteSP
- GetBreakpointSite() const;
-
- //------------------------------------------------------------------
- // The next section are generic report functions.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Print a description of this breakpoint location to the stream
- /// \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const override;
-
- //------------------------------------------------------------------
- /// Use this to set location specific breakpoint options.
- ///
- /// It will create a copy of the containing breakpoint's options if
- /// that hasn't been done already
- ///
- /// @return
- /// A pointer to the breakpoint options.
- //------------------------------------------------------------------
- BreakpointOptions *
- GetLocationOptions ();
-
- //------------------------------------------------------------------
- /// Use this to access breakpoint options from this breakpoint location.
- /// This will point to the owning breakpoint's options unless options have
- /// been set specifically on this location.
- ///
- /// @return
- /// A pointer to the containing breakpoint's options if this
- /// location doesn't have its own copy.
- //------------------------------------------------------------------
- const BreakpointOptions *
- GetOptionsNoCreate () const;
-
- bool
- ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Invoke the callback action when the breakpoint is hit.
- ///
- /// Meant to be used by the BreakpointLocation class.
- ///
- /// @param[in] context
- /// Described the breakpoint event.
- ///
- /// @param[in] bp_loc_id
- /// Which breakpoint location hit this breakpoint.
- ///
- /// @return
- /// \b true if the target should stop at this breakpoint and \b
- /// false not.
- //------------------------------------------------------------------
- bool
- InvokeCallback (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- /// Returns whether we should resolve Indirect functions in setting the breakpoint site
- /// for this location.
- ///
- /// @return
- /// \b true if the breakpoint SITE for this location should be set on the
- /// resolved location for Indirect functions.
- //------------------------------------------------------------------
- bool
- ShouldResolveIndirectFunctions ()
- {
- return m_should_resolve_indirect_functions;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the address set in the breakpoint site for this location was found by resolving
- /// an indirect symbol.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool
- IsIndirect ()
- {
- return m_is_indirect;
- }
-
- void
- SetIsIndirect (bool is_indirect)
- {
- m_is_indirect = is_indirect;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the address set in the breakpoint location was re-routed to the target of a
- /// re-exported symbol.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool
- IsReExported ()
- {
- return m_is_reexported;
- }
-
- void
- SetIsReExported (bool is_reexported)
- {
- m_is_reexported = is_reexported;
- }
-
- //------------------------------------------------------------------
- /// Returns whether the two breakpoint locations might represent "equivalent locations".
- /// This is used when modules changed to determine if a Location in the old module might
- /// be the "same as" the input location.
- ///
- /// @param[in] location
- /// The location to compare against.
- ///
- /// @return
- /// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
- bool EquivalentToLocation(BreakpointLocation &location);
-
protected:
- friend class BreakpointSite;
- friend class BreakpointLocationList;
- friend class Process;
- friend class StopInfoBreakpoint;
-
- //------------------------------------------------------------------
- /// Set the breakpoint site for this location to \a bp_site_sp.
- ///
- /// @param[in] bp_site_sp
- /// The breakpoint site we are setting for this location.
- ///
- /// @return
- /// \b true if we were successful at setting the breakpoint site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
-
- void
- DecrementIgnoreCount();
-
- bool
- IgnoreCountShouldStop();
-
+ friend class BreakpointSite;
+ friend class BreakpointLocationList;
+ friend class Process;
+ friend class StopInfoBreakpoint;
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint site for this location to \a bp_site_sp.
+ ///
+ /// @param[in] bp_site_sp
+ /// The breakpoint site we are setting for this location.
+ ///
+ /// @return
+ /// \b true if we were successful at setting the breakpoint site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool SetBreakpointSite(lldb::BreakpointSiteSP &bp_site_sp);
+
+ void DecrementIgnoreCount();
+
+ bool IgnoreCountShouldStop();
+
private:
- void
- SwapLocation (lldb::BreakpointLocationSP swap_from);
+ void SwapLocation(lldb::BreakpointLocationSP swap_from);
+
+ void BumpHitCount();
+
+ void UndoBumpHitCount();
- void
- BumpHitCount();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //
+ // Only the Breakpoint can make breakpoint locations, and it owns
+ // them.
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Constructor.
+ ///
+ /// @param[in] owner
+ /// A back pointer to the breakpoint that owns this location.
+ ///
+ /// @param[in] addr
+ /// The Address defining this location.
+ ///
+ /// @param[in] tid
+ /// The thread for which this breakpoint location is valid, or
+ /// LLDB_INVALID_THREAD_ID if it is valid for all threads.
+ ///
+ /// @param[in] hardware
+ /// \b true if a hardware breakpoint is requested.
+ //------------------------------------------------------------------
+
+ BreakpointLocation(lldb::break_id_t bid, Breakpoint &owner,
+ const Address &addr, lldb::tid_t tid, bool hardware,
+ bool check_for_resolver = true);
+
+ //------------------------------------------------------------------
+ // Data members:
+ //------------------------------------------------------------------
+ bool m_being_created;
+ bool m_should_resolve_indirect_functions;
+ bool m_is_reexported;
+ bool m_is_indirect;
+ Address m_address; ///< The address defining this location.
+ Breakpoint &m_owner; ///< The breakpoint that produced this object.
+ std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options
+ ///pointer, nullptr if we're
+ ///using our breakpoint's
+ ///options.
+ lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be
+ ///shared by more than one location.)
+ lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to
+ ///use in testing our condition.
+ std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the
+ ///condition, which could be evaluated by
+ /// multiple processes.
+ size_t m_condition_hash; ///< For testing whether the condition source code
+ ///changed.
+
+ void SetShouldResolveIndirectFunctions(bool do_resolve) {
+ m_should_resolve_indirect_functions = do_resolve;
+ }
- void
- UndoBumpHitCount();
+ void SendBreakpointLocationChangedEvent(lldb::BreakpointEventType eventKind);
- //------------------------------------------------------------------
- // Constructors and Destructors
- //
- // Only the Breakpoint can make breakpoint locations, and it owns
- // them.
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Constructor.
- ///
- /// @param[in] owner
- /// A back pointer to the breakpoint that owns this location.
- ///
- /// @param[in] addr
- /// The Address defining this location.
- ///
- /// @param[in] tid
- /// The thread for which this breakpoint location is valid, or
- /// LLDB_INVALID_THREAD_ID if it is valid for all threads.
- ///
- /// @param[in] hardware
- /// \b true if a hardware breakpoint is requested.
- //------------------------------------------------------------------
-
- BreakpointLocation (lldb::break_id_t bid,
- Breakpoint &owner,
- const Address &addr,
- lldb::tid_t tid,
- bool hardware,
- bool check_for_resolver = true);
-
- //------------------------------------------------------------------
- // Data members:
- //------------------------------------------------------------------
- bool m_being_created;
- bool m_should_resolve_indirect_functions;
- bool m_is_reexported;
- bool m_is_indirect;
- Address m_address; ///< The address defining this location.
- Breakpoint &m_owner; ///< The breakpoint that produced this object.
- std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options.
- lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.)
- lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition.
- std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by
- /// multiple processes.
- size_t m_condition_hash; ///< For testing whether the condition source code changed.
-
- void
- SetShouldResolveIndirectFunctions (bool do_resolve)
- {
- m_should_resolve_indirect_functions = do_resolve;
- }
-
- void
- SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind);
-
- DISALLOW_COPY_AND_ASSIGN (BreakpointLocation);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointLocation);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocationCollection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocationCollection.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocationCollection.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocationCollection.h Tue Sep 6 15:57:50 2016
@@ -12,210 +12,202 @@
// C Includes
// C++ Includes
-#include <vector>
#include <mutex>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class BreakpointLocationCollection
-{
+class BreakpointLocationCollection {
public:
- BreakpointLocationCollection();
-
- ~BreakpointLocationCollection();
+ BreakpointLocationCollection();
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_loc_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint location that will get added
- /// to the list.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- void
- Add (const lldb::BreakpointLocationSP& bp_loc_sp);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint location given by \b breakID from this
- /// list.
- ///
- /// @param[in] break_id
- /// The breakpoint index to remove.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location index in break_id to remove.
- ///
- /// @result
- /// \b true if the breakpoint was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id \a
- /// breakID.
- ///
- /// @param[in] break_id
- /// The breakpoint ID to seek for.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID in \a break_id to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id \a
- /// breakID, const version.
- ///
- /// @param[in] breakID
- /// The breakpoint location ID to seek for.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID in \a break_id to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetByIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i, const version.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a NULL
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- GetByIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint location list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const { return m_break_loc_collection.size(); }
-
- //------------------------------------------------------------------
- /// Enquires of all the breakpoint locations in this list whether
- /// we should stop at a hit at \a breakID.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- /// Print a description of the breakpoint locations in this list
- /// to the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void GetDescription (Stream *s, lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Check whether this collection of breakpoint locations have any
- /// thread specifiers, and if yes, is \a thread_id contained in any
- /// of these specifiers.
- ///
- /// @param[in] thread
- /// The thread against which to test.
- ///
- /// return
- /// \b true if the collection contains at least one location that
- /// would be valid for this thread, false otherwise.
- //------------------------------------------------------------------
- bool ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Tell whether ALL the breakpoints in the location collection are internal.
- ///
- /// @result
- /// \b true if all breakpoint locations are owned by internal breakpoints,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool IsInternal() const;
+ ~BreakpointLocationCollection();
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_loc_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint location that will get added
+ /// to the list.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint location given by \b breakID from this
+ /// list.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint index to remove.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location index in break_id to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id \a
+ /// breakID.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint ID to seek for.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID in \a break_id to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id \a
+ /// breakID, const version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint location ID to seek for.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID in \a break_id to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP
+ FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetByIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i, const version.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a NULL
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint location list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_break_loc_collection.size(); }
+
+ //------------------------------------------------------------------
+ /// Enquires of all the breakpoint locations in this list whether
+ /// we should stop at a hit at \a breakID.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ /// Print a description of the breakpoint locations in this list
+ /// to the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Check whether this collection of breakpoint locations have any
+ /// thread specifiers, and if yes, is \a thread_id contained in any
+ /// of these specifiers.
+ ///
+ /// @param[in] thread
+ /// The thread against which to test.
+ ///
+ /// return
+ /// \b true if the collection contains at least one location that
+ /// would be valid for this thread, false otherwise.
+ //------------------------------------------------------------------
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Tell whether ALL the breakpoints in the location collection are internal.
+ ///
+ /// @result
+ /// \b true if all breakpoint locations are owned by internal breakpoints,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsInternal() const;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from BreakpointLocationCollection can see
- // and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from BreakpointLocationCollection can see
+ // and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For BreakpointLocationCollection only
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // For BreakpointLocationCollection only
+ //------------------------------------------------------------------
- typedef std::vector<lldb::BreakpointLocationSP> collection;
+ typedef std::vector<lldb::BreakpointLocationSP> collection;
- collection::iterator
- GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+ collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id);
- collection::const_iterator
- GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
+ collection::const_iterator
+ GetIDPairConstIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) const;
- collection m_break_loc_collection;
- mutable std::mutex m_collection_mutex;
+ collection m_break_loc_collection;
+ mutable std::mutex m_collection_mutex;
public:
- typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationCollectionIterable;
- BreakpointLocationCollectionIterable
- BreakpointLocations()
- {
- return BreakpointLocationCollectionIterable(m_break_loc_collection);
- }
-
+ typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
+ vector_adapter>
+ BreakpointLocationCollectionIterable;
+ BreakpointLocationCollectionIterable BreakpointLocations() {
+ return BreakpointLocationCollectionIterable(m_break_loc_collection);
+ }
};
} // namespace lldb_private
-#endif // liblldb_BreakpointLocationCollection_h_
+#endif // liblldb_BreakpointLocationCollection_h_
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h Tue Sep 6 15:57:50 2016
@@ -18,270 +18,248 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointLocationList BreakpointLocationList.h "lldb/Breakpoint/BreakpointLocationList.h"
-/// @brief This class is used by Breakpoint to manage a list of breakpoint locations,
+/// @class BreakpointLocationList BreakpointLocationList.h
+/// "lldb/Breakpoint/BreakpointLocationList.h"
+/// @brief This class is used by Breakpoint to manage a list of breakpoint
+/// locations,
// each breakpoint location in the list
/// has a unique ID, and is unique by Address as well.
//----------------------------------------------------------------------
-class BreakpointLocationList
-{
-// Only Breakpoints 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, and implicitly all the locations have the same breakpoint ID as
-// well. If you need a generic container for breakpoint locations, use BreakpointLocationCollection.
-friend class Breakpoint;
+class BreakpointLocationList {
+ // Only Breakpoints 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, and implicitly all the locations have the same
+ // breakpoint ID as
+ // well. If you need a generic container for breakpoint locations, use
+ // BreakpointLocationCollection.
+ friend class Breakpoint;
public:
- virtual
- ~BreakpointLocationList();
+ virtual ~BreakpointLocationList();
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location at address
- /// \a addr - const version.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- FindByAddress (const Address &addr) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with id
- /// \a breakID, const version.
- ///
- /// @param[in] breakID
- /// The breakpoint location ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- FindByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns the breakpoint location id to the breakpoint location
- /// at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
- //------------------------------------------------------------------
- lldb::break_id_t
- FindIDByAddress (const Address &addr);
-
- //------------------------------------------------------------------
- /// Returns a breakpoint location list of the breakpoint locations
- /// in the module \a module. This list is allocated, and owned by
- /// the caller.
- ///
- /// @param[in] module
- /// The module to seek in.
- ///
- /// @param[in]
- /// A breakpoint collection that gets any breakpoint locations
- /// that match \a module appended to.
- ///
- /// @result
- /// The number of matches
- //------------------------------------------------------------------
- size_t
- FindInModule (Module *module,
- BreakpointLocationCollection& bp_loc_list);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with
- /// index \a i.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetByIndex (size_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint location with index
- /// \a i, const version.
- ///
- /// @param[in] i
- /// The breakpoint location index to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint. May contain a nullptr
- /// pointer if the breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointLocationSP
- GetByIndex (size_t i) const;
-
- //------------------------------------------------------------------
- /// Removes all the locations in this list from their breakpoint site
- /// owners list.
- //------------------------------------------------------------------
- void
- ClearAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Tells all the breakpoint locations in this list to attempt to
- /// resolve any possible breakpoint sites.
- //------------------------------------------------------------------
- void
- ResolveAllBreakpointSites ();
-
- //------------------------------------------------------------------
- /// Returns the number of breakpoint locations in this list with
- /// resolved breakpoints.
- ///
- /// @result
- /// Number of qualifying breakpoint locations.
- //------------------------------------------------------------------
- size_t
- GetNumResolvedLocations() const;
-
- //------------------------------------------------------------------
- /// Returns the number hit count of all locations in this list.
- ///
- /// @result
- /// Hit count of all locations in this list.
- //------------------------------------------------------------------
- uint32_t
- GetHitCount () const;
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint location in this list with ID \a
- /// breakID whether we should stop.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context,
- lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this breakpoint location list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- return m_locations.size();
- }
-
- //------------------------------------------------------------------
- /// Print a description of the breakpoint locations in this list to
- /// the stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location at address
+ /// \a addr - const version.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with id
+ /// \a breakID, const version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint location ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the breakpoint location id to the breakpoint location
+ /// at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
+ //------------------------------------------------------------------
+ lldb::break_id_t FindIDByAddress(const Address &addr);
+
+ //------------------------------------------------------------------
+ /// Returns a breakpoint location list of the breakpoint locations
+ /// in the module \a module. This list is allocated, and owned by
+ /// the caller.
+ ///
+ /// @param[in] module
+ /// The module to seek in.
+ ///
+ /// @param[in]
+ /// A breakpoint collection that gets any breakpoint locations
+ /// that match \a module appended to.
+ ///
+ /// @result
+ /// The number of matches
+ //------------------------------------------------------------------
+ size_t FindInModule(Module *module,
+ BreakpointLocationCollection &bp_loc_list);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with
+ /// index \a i.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetByIndex(size_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint location with index
+ /// \a i, const version.
+ ///
+ /// @param[in] i
+ /// The breakpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint. May contain a nullptr
+ /// pointer if the breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
+
+ //------------------------------------------------------------------
+ /// Removes all the locations in this list from their breakpoint site
+ /// owners list.
+ //------------------------------------------------------------------
+ void ClearAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Tells all the breakpoint locations in this list to attempt to
+ /// resolve any possible breakpoint sites.
+ //------------------------------------------------------------------
+ void ResolveAllBreakpointSites();
+
+ //------------------------------------------------------------------
+ /// Returns the number of breakpoint locations in this list with
+ /// resolved breakpoints.
+ ///
+ /// @result
+ /// Number of qualifying breakpoint locations.
+ //------------------------------------------------------------------
+ size_t GetNumResolvedLocations() const;
+
+ //------------------------------------------------------------------
+ /// Returns the number hit count of all locations in this list.
+ ///
+ /// @result
+ /// Hit count of all locations in this list.
+ //------------------------------------------------------------------
+ uint32_t GetHitCount() const;
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint location in this list with ID \a
+ /// breakID whether we should stop.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this breakpoint location list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_locations.size(); }
+
+ //------------------------------------------------------------------
+ /// Print a description of the breakpoint locations in this list to
+ /// the stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
protected:
- //------------------------------------------------------------------
- /// This is the standard constructor.
- ///
- /// It creates an empty breakpoint location list. It is protected
- /// here because only Breakpoints are allowed to create the
- /// breakpoint location list.
- //------------------------------------------------------------------
- BreakpointLocationList(Breakpoint &owner);
-
- //------------------------------------------------------------------
- /// Add the breakpoint \a bp_loc_sp to the list.
- ///
- /// @param[in] bp_sp
- /// Shared pointer to the breakpoint location that will get
- /// added to the list.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- Create (const Address &addr, bool resolve_indirect_symbols);
-
- void
- StartRecordingNewLocations(BreakpointLocationCollection &new_locations);
-
- void
- StopRecordingNewLocations();
-
- lldb::BreakpointLocationSP
- AddLocation(const Address &addr,
- bool resolve_indirect_symbols,
- bool *new_location = nullptr);
-
- void
- SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp);
-
- bool
- RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp);
-
- void
- RemoveInvalidLocations (const ArchSpec &arch);
-
- void
- Compact();
-
- typedef std::vector<lldb::BreakpointLocationSP> collection;
- typedef std::map<lldb_private::Address,
- lldb::BreakpointLocationSP,
- Address::ModulePointerAndOffsetLessThanFunctionObject> addr_map;
-
- Breakpoint &m_owner;
- collection m_locations; // Vector of locations, sorted by ID
- addr_map m_address_to_location;
- mutable std::recursive_mutex m_mutex;
- lldb::break_id_t m_next_id;
- BreakpointLocationCollection *m_new_location_recorder;
+ //------------------------------------------------------------------
+ /// This is the standard constructor.
+ ///
+ /// It creates an empty breakpoint location list. It is protected
+ /// here because only Breakpoints are allowed to create the
+ /// breakpoint location list.
+ //------------------------------------------------------------------
+ BreakpointLocationList(Breakpoint &owner);
+
+ //------------------------------------------------------------------
+ /// Add the breakpoint \a bp_loc_sp to the list.
+ ///
+ /// @param[in] bp_sp
+ /// Shared pointer to the breakpoint location that will get
+ /// added to the list.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP Create(const Address &addr,
+ bool resolve_indirect_symbols);
+
+ void StartRecordingNewLocations(BreakpointLocationCollection &new_locations);
+
+ void StopRecordingNewLocations();
+
+ lldb::BreakpointLocationSP AddLocation(const Address &addr,
+ bool resolve_indirect_symbols,
+ bool *new_location = nullptr);
+
+ void SwapLocation(lldb::BreakpointLocationSP to_location_sp,
+ lldb::BreakpointLocationSP from_location_sp);
+
+ bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp);
+
+ void RemoveInvalidLocations(const ArchSpec &arch);
+
+ void Compact();
+
+ typedef std::vector<lldb::BreakpointLocationSP> collection;
+ typedef std::map<lldb_private::Address, lldb::BreakpointLocationSP,
+ Address::ModulePointerAndOffsetLessThanFunctionObject>
+ addr_map;
+
+ Breakpoint &m_owner;
+ collection m_locations; // Vector of locations, sorted by ID
+ addr_map m_address_to_location;
+ mutable std::recursive_mutex m_mutex;
+ lldb::break_id_t m_next_id;
+ BreakpointLocationCollection *m_new_location_recorder;
public:
- typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable;
-
- BreakpointLocationIterable
- BreakpointLocations()
- {
- return BreakpointLocationIterable(m_locations);
- }
+ typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
+ vector_adapter>
+ BreakpointLocationIterable;
+
+ BreakpointLocationIterable BreakpointLocations() {
+ return BreakpointLocationIterable(m_locations);
+ }
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Tue Sep 6 15:57:50 2016
@@ -17,341 +17,318 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Baton.h"
#include "lldb/Core/StringList.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointOptions BreakpointOptions.h "lldb/Breakpoint/BreakpointOptions.h"
-/// @brief Class that manages the options on a breakpoint or breakpoint location.
+/// @class BreakpointOptions BreakpointOptions.h
+/// "lldb/Breakpoint/BreakpointOptions.h"
+/// @brief Class that manages the options on a breakpoint or breakpoint
+/// location.
//----------------------------------------------------------------------
-class BreakpointOptions
-{
+class BreakpointOptions {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Default constructor. The breakpoint is enabled, and has no condition,
- /// callback, ignore count, etc...
- //------------------------------------------------------------------
- BreakpointOptions();
- BreakpointOptions(const BreakpointOptions& rhs);
-
- static BreakpointOptions *
- CopyOptionsNoCallback (BreakpointOptions &rhs);
- //------------------------------------------------------------------
- /// This constructor allows you to specify all the breakpoint options.
- ///
- /// @param[in] condition
- /// The expression which if it evaluates to \b true if we are to stop
- ///
- /// @param[in] callback
- /// This is the plugin for some code that gets run, returns \b true if we are to stop.
- ///
- /// @param[in] baton
- /// Client data that will get passed to the callback.
- ///
- /// @param[in] enabled
- /// Is this breakpoint enabled.
- ///
- /// @param[in] ignore
- /// How many breakpoint hits we should ignore before stopping.
- ///
- /// @param[in] thread_id
- /// Only stop if \a thread_id hits the breakpoint.
- //------------------------------------------------------------------
- BreakpointOptions(void *condition,
- BreakpointHitCallback callback,
- void *baton,
- bool enabled = true,
- int32_t ignore = 0,
- lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID,
- bool one_shot = false);
-
- virtual ~BreakpointOptions();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const BreakpointOptions&
- operator=(const BreakpointOptions& rhs);
-
- //------------------------------------------------------------------
- // Callbacks
- //
- // Breakpoint callbacks come in two forms, synchronous and asynchronous. Synchronous callbacks will get
- // run before any of the thread plans are consulted, and if they return false the target will continue
- // "under the radar" of the thread plans. There are a couple of restrictions to synchronous callbacks:
- // 1) They should NOT resume the target themselves. Just return false if you want the target to restart.
- // 2) Breakpoints with synchronous callbacks can't have conditions (or rather, they can have them, but they
- // won't do anything. Ditto with ignore counts, etc... You are supposed to control that all through the
- // callback.
- // Asynchronous callbacks get run as part of the "ShouldStop" logic in the thread plan. The logic there is:
- // a) If the breakpoint is thread specific and not for this thread, continue w/o running the callback.
- // NB. This is actually enforced underneath the breakpoint system, the Process plugin is expected to
- // call BreakpointSite::IsValidForThread, and set the thread's StopInfo to "no reason". That way,
- // thread displays won't show stops for breakpoints not for that thread...
- // b) If the ignore count says we shouldn't stop, then ditto.
- // c) If the condition says we shouldn't stop, then ditto.
- // d) Otherwise, the callback will get run, and if it returns true we will stop, and if false we won't.
- // The asynchronous callback can run the target itself, but at present that should be the last action the
- // callback does. We will relax this condition at some point, but it will take a bit of plumbing to get
- // that to work.
- //
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Adds a callback to the breakpoint option set.
- ///
- /// @param[in] callback
- /// The function to be called when the breakpoint gets hit.
- ///
- /// @param[in] baton_sp
- /// A baton which will get passed back to the callback when it is invoked.
- ///
- /// @param[in] synchronous
- /// Whether this is a synchronous or asynchronous callback. See discussion above.
- //------------------------------------------------------------------
- void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
- //------------------------------------------------------------------
- /// Remove the callback from this option set.
- //------------------------------------------------------------------
- void ClearCallback ();
-
- // The rest of these functions are meant to be used only within the breakpoint handling mechanism.
-
- //------------------------------------------------------------------
- /// Use this function to invoke the callback for a specific stop.
- ///
- /// @param[in] context
- /// The context in which the callback is to be invoked. This includes the stop event, the
- /// execution context of the stop (since you might hit the same breakpoint on multiple threads) and
- /// whether we are currently executing synchronous or asynchronous callbacks.
- ///
- /// @param[in] break_id
- /// The breakpoint ID that owns this option set.
- ///
- /// @param[in] break_loc_id
- /// The breakpoint location ID that owns this option set.
- ///
- /// @return
- /// The callback return value.
- //------------------------------------------------------------------
- bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
-
- //------------------------------------------------------------------
- /// Used in InvokeCallback to tell whether it is the right time to run this kind of callback.
- ///
- /// @return
- /// The synchronicity of our callback.
- //------------------------------------------------------------------
- bool IsCallbackSynchronous () const
- {
- return m_callback_is_synchronous;
- }
-
- //------------------------------------------------------------------
- /// Fetch the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- Baton *GetBaton ();
-
- //------------------------------------------------------------------
- /// Fetch a const version of the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- const Baton *GetBaton () const;
-
- //------------------------------------------------------------------
- // Condition
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Set the breakpoint option's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the breakpoint is hit.
- //------------------------------------------------------------------
- void SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *GetConditionText(size_t *hash = nullptr) const;
-
- //------------------------------------------------------------------
- // Enabled/Ignore Count
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Check the Enable/Disable state.
- /// @return
- /// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
-
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
- //------------------------------------------------------------------
- void
- SetEnabled (bool enabled)
- {
- m_enabled = enabled;
- }
-
- //------------------------------------------------------------------
- /// Check the One-shot state.
- /// @return
- /// \b true if the breakpoint is one-shot, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsOneShot () const
- {
- return m_one_shot;
- }
-
- //------------------------------------------------------------------
- /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
- //------------------------------------------------------------------
- void
- SetOneShot (bool one_shot)
- {
- m_one_shot = one_shot;
- }
-
- //------------------------------------------------------------------
- /// Set the breakpoint to ignore the next \a count breakpoint hits.
- /// @param[in] count
- /// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
-
- void
- SetIgnoreCount (uint32_t n)
- {
- m_ignore_count = n;
- }
-
- //------------------------------------------------------------------
- /// Return the current Ignore Count.
- /// @return
- /// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
- uint32_t
- GetIgnoreCount () const
- {
- return m_ignore_count;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Default constructor. The breakpoint is enabled, and has no condition,
+ /// callback, ignore count, etc...
+ //------------------------------------------------------------------
+ BreakpointOptions();
+ BreakpointOptions(const BreakpointOptions &rhs);
+
+ static BreakpointOptions *CopyOptionsNoCallback(BreakpointOptions &rhs);
+ //------------------------------------------------------------------
+ /// This constructor allows you to specify all the breakpoint options.
+ ///
+ /// @param[in] condition
+ /// The expression which if it evaluates to \b true if we are to stop
+ ///
+ /// @param[in] callback
+ /// This is the plugin for some code that gets run, returns \b true if we
+ /// are to stop.
+ ///
+ /// @param[in] baton
+ /// Client data that will get passed to the callback.
+ ///
+ /// @param[in] enabled
+ /// Is this breakpoint enabled.
+ ///
+ /// @param[in] ignore
+ /// How many breakpoint hits we should ignore before stopping.
+ ///
+ /// @param[in] thread_id
+ /// Only stop if \a thread_id hits the breakpoint.
+ //------------------------------------------------------------------
+ BreakpointOptions(void *condition, BreakpointHitCallback callback,
+ void *baton, bool enabled = true, int32_t ignore = 0,
+ lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID,
+ bool one_shot = false);
+
+ virtual ~BreakpointOptions();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const BreakpointOptions &operator=(const BreakpointOptions &rhs);
+
+ //------------------------------------------------------------------
+ // Callbacks
+ //
+ // Breakpoint callbacks come in two forms, synchronous and asynchronous.
+ // Synchronous callbacks will get
+ // run before any of the thread plans are consulted, and if they return false
+ // the target will continue
+ // "under the radar" of the thread plans. There are a couple of restrictions
+ // to synchronous callbacks:
+ // 1) They should NOT resume the target themselves. Just return false if you
+ // want the target to restart.
+ // 2) Breakpoints with synchronous callbacks can't have conditions (or rather,
+ // they can have them, but they
+ // won't do anything. Ditto with ignore counts, etc... You are supposed
+ // to control that all through the
+ // callback.
+ // Asynchronous callbacks get run as part of the "ShouldStop" logic in the
+ // thread plan. The logic there is:
+ // a) If the breakpoint is thread specific and not for this thread, continue
+ // w/o running the callback.
+ // NB. This is actually enforced underneath the breakpoint system, the
+ // Process plugin is expected to
+ // call BreakpointSite::IsValidForThread, and set the thread's StopInfo
+ // to "no reason". That way,
+ // thread displays won't show stops for breakpoints not for that
+ // thread...
+ // b) If the ignore count says we shouldn't stop, then ditto.
+ // c) If the condition says we shouldn't stop, then ditto.
+ // d) Otherwise, the callback will get run, and if it returns true we will
+ // stop, and if false we won't.
+ // The asynchronous callback can run the target itself, but at present that
+ // should be the last action the
+ // callback does. We will relax this condition at some point, but it will
+ // take a bit of plumbing to get
+ // that to work.
+ //
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Adds a callback to the breakpoint option set.
+ ///
+ /// @param[in] callback
+ /// The function to be called when the breakpoint gets hit.
+ ///
+ /// @param[in] baton_sp
+ /// A baton which will get passed back to the callback when it is invoked.
+ ///
+ /// @param[in] synchronous
+ /// Whether this is a synchronous or asynchronous callback. See discussion
+ /// above.
+ //------------------------------------------------------------------
+ void SetCallback(BreakpointHitCallback callback,
+ const lldb::BatonSP &baton_sp, bool synchronous = false);
+
+ //------------------------------------------------------------------
+ /// Remove the callback from this option set.
+ //------------------------------------------------------------------
+ void ClearCallback();
+
+ // The rest of these functions are meant to be used only within the breakpoint
+ // handling mechanism.
+
+ //------------------------------------------------------------------
+ /// Use this function to invoke the callback for a specific stop.
+ ///
+ /// @param[in] context
+ /// The context in which the callback is to be invoked. This includes the
+ /// stop event, the
+ /// execution context of the stop (since you might hit the same breakpoint
+ /// on multiple threads) and
+ /// whether we are currently executing synchronous or asynchronous
+ /// callbacks.
+ ///
+ /// @param[in] break_id
+ /// The breakpoint ID that owns this option set.
+ ///
+ /// @param[in] break_loc_id
+ /// The breakpoint location ID that owns this option set.
+ ///
+ /// @return
+ /// The callback return value.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
+ //------------------------------------------------------------------
+ /// Used in InvokeCallback to tell whether it is the right time to run this
+ /// kind of callback.
+ ///
+ /// @return
+ /// The synchronicity of our callback.
+ //------------------------------------------------------------------
+ bool IsCallbackSynchronous() const { return m_callback_is_synchronous; }
+
+ //------------------------------------------------------------------
+ /// Fetch the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ Baton *GetBaton();
+
+ //------------------------------------------------------------------
+ /// Fetch a const version of the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ const Baton *GetBaton() const;
+
+ //------------------------------------------------------------------
+ // Condition
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Set the breakpoint option's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the breakpoint is hit.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText(size_t *hash = nullptr) const;
+
+ //------------------------------------------------------------------
+ // Enabled/Ignore Count
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Check the Enable/Disable state.
+ /// @return
+ /// \b true if the breakpoint is enabled, \b false if disabled.
+ //------------------------------------------------------------------
+ bool IsEnabled() const { return m_enabled; }
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled) { m_enabled = enabled; }
+
+ //------------------------------------------------------------------
+ /// Check the One-shot state.
+ /// @return
+ /// \b true if the breakpoint is one-shot, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsOneShot() const { return m_one_shot; }
+
+ //------------------------------------------------------------------
+ /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
+ //------------------------------------------------------------------
+ void SetOneShot(bool one_shot) { m_one_shot = one_shot; }
+
+ //------------------------------------------------------------------
+ /// Set the breakpoint to ignore the next \a count breakpoint hits.
+ /// @param[in] count
+ /// The number of breakpoint hits to ignore.
+ //------------------------------------------------------------------
+
+ void SetIgnoreCount(uint32_t n) { m_ignore_count = n; }
+
+ //------------------------------------------------------------------
+ /// Return the current Ignore Count.
+ /// @return
+ /// The number of breakpoint hits to be ignored.
+ //------------------------------------------------------------------
+ uint32_t GetIgnoreCount() const { return m_ignore_count; }
+
+ //------------------------------------------------------------------
+ /// Return the current thread spec for this option. This will return nullptr
+ /// if the no thread
+ /// specifications have been set for this Option yet.
+ /// @return
+ /// The thread specification pointer for this option, or nullptr if none
+ /// has
+ /// been set yet.
+ //------------------------------------------------------------------
+ const ThreadSpec *GetThreadSpecNoCreate() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the ThreadSpec for this option, creating it.
+ /// if it hasn't been created already. This API is used for setting the
+ /// ThreadSpec items for this option.
+ //------------------------------------------------------------------
+ ThreadSpec *GetThreadSpec();
+
+ void SetThreadID(lldb::tid_t thread_id);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the breakpoint option has a callback set.
+ //------------------------------------------------------------------
+ bool HasCallback() const;
+
+ //------------------------------------------------------------------
+ /// This is the default empty callback.
+ /// @return
+ /// The thread id for which the breakpoint hit will stop,
+ /// LLDB_INVALID_THREAD_ID for all threads.
+ //------------------------------------------------------------------
+ static bool NullCallback(void *baton, StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+
+ struct CommandData {
+ CommandData() : user_source(), script_source(), stop_on_error(true) {}
+
+ ~CommandData() = default;
+
+ StringList user_source;
+ std::string script_source;
+ bool stop_on_error;
+ };
+
+ class CommandBaton : public Baton {
+ public:
+ CommandBaton(CommandData *data) : Baton(data) {}
+
+ ~CommandBaton() override {
+ delete ((CommandData *)m_data);
+ m_data = nullptr;
}
- //------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return nullptr if the no thread
- /// specifications have been set for this Option yet.
- /// @return
- /// The thread specification pointer for this option, or nullptr if none has
- /// been set yet.
- //------------------------------------------------------------------
- const ThreadSpec *
- GetThreadSpecNoCreate () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the ThreadSpec for this option, creating it.
- /// if it hasn't been created already. This API is used for setting the
- /// ThreadSpec items for this option.
- //------------------------------------------------------------------
- ThreadSpec *
- GetThreadSpec ();
-
- void
- SetThreadID(lldb::tid_t thread_id);
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Returns true if the breakpoint option has a callback set.
- //------------------------------------------------------------------
- bool
- HasCallback() const;
-
- //------------------------------------------------------------------
- /// This is the default empty callback.
- /// @return
- /// The thread id for which the breakpoint hit will stop,
- /// LLDB_INVALID_THREAD_ID for all threads.
- //------------------------------------------------------------------
- static bool
- NullCallback (void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- struct CommandData
- {
- CommandData () :
- user_source(),
- script_source(),
- stop_on_error(true)
- {
- }
-
- ~CommandData() = default;
-
- StringList user_source;
- std::string script_source;
- bool stop_on_error;
- };
-
- class CommandBaton : public Baton
- {
- public:
- CommandBaton (CommandData *data) :
- Baton (data)
- {
- }
-
- ~CommandBaton() override
- {
- delete ((CommandData *)m_data);
- m_data = nullptr;
- }
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const override;
- };
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
+ };
protected:
- //------------------------------------------------------------------
- // Classes that inherit from BreakpointOptions can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from BreakpointOptions can see and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For BreakpointOptions only
- //------------------------------------------------------------------
- BreakpointHitCallback m_callback; // This is the callback function pointer
- lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
- bool m_callback_is_synchronous;
- bool m_enabled;
- bool m_one_shot;
- uint32_t m_ignore_count; // Number of times to ignore this breakpoint
- std::unique_ptr<ThreadSpec> m_thread_spec_ap; // Thread for which this breakpoint will take
- std::string m_condition_text; // The condition to test.
- size_t m_condition_text_hash; // Its hash, so that locations know when the condition is updated.
+ //------------------------------------------------------------------
+ // For BreakpointOptions only
+ //------------------------------------------------------------------
+ BreakpointHitCallback m_callback; // This is the callback function pointer
+ lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
+ bool m_callback_is_synchronous;
+ bool m_enabled;
+ bool m_one_shot;
+ uint32_t m_ignore_count; // Number of times to ignore this breakpoint
+ std::unique_ptr<ThreadSpec>
+ m_thread_spec_ap; // Thread for which this breakpoint will take
+ std::string m_condition_text; // The condition to test.
+ size_t m_condition_text_hash; // Its hash, so that locations know when the
+ // condition is updated.
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Tue Sep 6 15:57:50 2016
@@ -14,20 +14,22 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolver BreakpointResolver.h "lldb/Breakpoint/BreakpointResolver.h"
-/// @brief This class works with SearchFilter to resolve logical breakpoints to their
+/// @class BreakpointResolver BreakpointResolver.h
+/// "lldb/Breakpoint/BreakpointResolver.h"
+/// @brief This class works with SearchFilter to resolve logical breakpoints to
+/// their
/// of concrete breakpoint locations.
//----------------------------------------------------------------------
@@ -35,150 +37,151 @@ namespace lldb_private {
/// General Outline:
/// The BreakpointResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
-/// descent do you want your callback to get called?" of the filter. The resolver
-/// answers this question (in the GetDepth method) and provides the resolution callback.
-/// Each Breakpoint has a BreakpointResolver, and it calls either ResolveBreakpoint
-/// or ResolveBreakpointInModules to tell it to look for new breakpoint locations.
+/// descent do you want your callback to get called?" of the filter. The
+/// resolver
+/// answers this question (in the GetDepth method) and provides the resolution
+/// callback.
+/// Each Breakpoint has a BreakpointResolver, and it calls either
+/// ResolveBreakpoint
+/// or ResolveBreakpointInModules to tell it to look for new breakpoint
+/// locations.
//----------------------------------------------------------------------
-class BreakpointResolver :
- public Searcher
-{
-friend class Breakpoint;
+class BreakpointResolver : public Searcher {
+ friend class Breakpoint;
public:
- //------------------------------------------------------------------
- /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
- /// to make sense. It can be constructed without a breakpoint, but you have to
- /// call SetBreakpoint before ResolveBreakpoint.
- ///
- /// @param[in] bkpt
- /// The breakpoint that owns this resolver.
- /// @param[in] resolverType
- /// The concrete breakpoint resolver type for this breakpoint.
- ///
- /// @result
- /// Returns breakpoint location id.
- //------------------------------------------------------------------
- BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType, lldb::addr_t offset = 0);
-
- //------------------------------------------------------------------
- /// The Destructor is virtual, all significant breakpoint resolvers derive
- /// from this class.
- //------------------------------------------------------------------
- ~BreakpointResolver() override;
-
- //------------------------------------------------------------------
- /// This sets the breakpoint for this resolver.
- ///
- /// @param[in] bkpt
- /// The breakpoint that owns this resolver.
- //------------------------------------------------------------------
- void
- SetBreakpoint (Breakpoint *bkpt);
-
- //------------------------------------------------------------------
- /// This updates the offset for this breakpoint. All the locations currently
- /// set for this breakpoint will have their offset adjusted when this is called.
- ///
- /// @param[in] offset
- /// The offset to add to all locations.
- //------------------------------------------------------------------
- void
- SetOffset (lldb::addr_t offset);
-
- //------------------------------------------------------------------
- /// This updates the offset for this breakpoint. All the locations currently
- /// set for this breakpoint will have their offset adjusted when this is called.
- ///
- /// @param[in] offset
- /// The offset to add to all locations.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOffset () const
- {
- return m_offset;
- }
-
- //------------------------------------------------------------------
- /// In response to this method the resolver scans all the modules in the breakpoint's
- /// target, and adds any new locations it finds.
- ///
- /// @param[in] filter
- /// The filter that will manage the search for this resolver.
- //------------------------------------------------------------------
- virtual void
- ResolveBreakpoint (SearchFilter &filter);
-
- //------------------------------------------------------------------
- /// In response to this method the resolver scans the modules in the module list
- /// \a modules, and adds any new locations it finds.
- ///
- /// @param[in] filter
- /// The filter that will manage the search for this resolver.
- //------------------------------------------------------------------
- virtual void
- ResolveBreakpointInModules (SearchFilter &filter,
- ModuleList &modules);
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the breakpoint to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- void
- GetDescription(Stream *s) override = 0;
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) const = 0;
-
- //------------------------------------------------------------------
- /// An enumeration for keeping track of the concrete subclass that
- /// is actually instantiated. Values of this enumeration are kept in the
- /// BreakpointResolver's SubclassID field. They are used for concrete type
- /// identification.
- enum ResolverTy {
- FileLineResolver, // This is an instance of BreakpointResolverFileLine
- AddressResolver, // This is an instance of BreakpointResolverAddress
- NameResolver, // This is an instance of BreakpointResolverName
- FileRegexResolver,
- ExceptionResolver,
- LastKnownResolverType = ExceptionResolver
- };
-
- //------------------------------------------------------------------
- /// getResolverID - Return an ID for the concrete type of this object. This
- /// is used to implement the LLVM classof checks. This should not be used
- /// for any other purpose, as the values may change as LLDB evolves.
- unsigned getResolverID() const {
- return SubclassID;
- }
+ //------------------------------------------------------------------
+ /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
+ /// to make sense. It can be constructed without a breakpoint, but you have
+ /// to
+ /// call SetBreakpoint before ResolveBreakpoint.
+ ///
+ /// @param[in] bkpt
+ /// The breakpoint that owns this resolver.
+ /// @param[in] resolverType
+ /// The concrete breakpoint resolver type for this breakpoint.
+ ///
+ /// @result
+ /// Returns breakpoint location id.
+ //------------------------------------------------------------------
+ BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType,
+ lldb::addr_t offset = 0);
+
+ //------------------------------------------------------------------
+ /// The Destructor is virtual, all significant breakpoint resolvers derive
+ /// from this class.
+ //------------------------------------------------------------------
+ ~BreakpointResolver() override;
+
+ //------------------------------------------------------------------
+ /// This sets the breakpoint for this resolver.
+ ///
+ /// @param[in] bkpt
+ /// The breakpoint that owns this resolver.
+ //------------------------------------------------------------------
+ void SetBreakpoint(Breakpoint *bkpt);
+
+ //------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is
+ /// called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ void SetOffset(lldb::addr_t offset);
+
+ //------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is
+ /// called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOffset() const { return m_offset; }
+
+ //------------------------------------------------------------------
+ /// In response to this method the resolver scans all the modules in the
+ /// breakpoint's
+ /// target, and adds any new locations it finds.
+ ///
+ /// @param[in] filter
+ /// The filter that will manage the search for this resolver.
+ //------------------------------------------------------------------
+ virtual void ResolveBreakpoint(SearchFilter &filter);
+
+ //------------------------------------------------------------------
+ /// In response to this method the resolver scans the modules in the module
+ /// list
+ /// \a modules, and adds any new locations it finds.
+ ///
+ /// @param[in] filter
+ /// The filter that will manage the search for this resolver.
+ //------------------------------------------------------------------
+ virtual void ResolveBreakpointInModules(SearchFilter &filter,
+ ModuleList &modules);
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the breakpoint to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s) override = 0;
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) const = 0;
+
+ //------------------------------------------------------------------
+ /// An enumeration for keeping track of the concrete subclass that
+ /// is actually instantiated. Values of this enumeration are kept in the
+ /// BreakpointResolver's SubclassID field. They are used for concrete type
+ /// identification.
+ enum ResolverTy {
+ FileLineResolver, // This is an instance of BreakpointResolverFileLine
+ AddressResolver, // This is an instance of BreakpointResolverAddress
+ NameResolver, // This is an instance of BreakpointResolverName
+ FileRegexResolver,
+ ExceptionResolver,
+ LastKnownResolverType = ExceptionResolver
+ };
+
+ //------------------------------------------------------------------
+ /// getResolverID - Return an ID for the concrete type of this object. This
+ /// is used to implement the LLVM classof checks. This should not be used
+ /// for any other purpose, as the values may change as LLDB evolves.
+ unsigned getResolverID() const { return SubclassID; }
- virtual lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) = 0;
+ virtual lldb::BreakpointResolverSP
+ CopyForBreakpoint(Breakpoint &breakpoint) = 0;
protected:
- //------------------------------------------------------------------
- /// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and
- /// line number in a CU, and find the nearest actual line number that matches, and then filter down the
- /// matching addresses to unique entries, and skip the prologue if asked to do so, and then set
- /// breakpoint locations in this breakpoint for all the resultant addresses.
- void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident);
-
- lldb::BreakpointLocationSP
- AddLocation(Address loc_addr, bool *new_location = NULL);
-
- Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
- lldb::addr_t m_offset; // A random offset the user asked us to add to any breakpoints we set.
+ //------------------------------------------------------------------
+ /// SetSCMatchesByLine - Takes a symbol context list of matches which
+ /// supposedly represent the same file and
+ /// line number in a CU, and find the nearest actual line number that matches,
+ /// and then filter down the
+ /// matching addresses to unique entries, and skip the prologue if asked to do
+ /// so, and then set
+ /// breakpoint locations in this breakpoint for all the resultant addresses.
+ void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
+ bool skip_prologue, const char *log_ident);
+
+ lldb::BreakpointLocationSP AddLocation(Address loc_addr,
+ bool *new_location = NULL);
+
+ Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
+ lldb::addr_t m_offset; // A random offset the user asked us to add to any
+ // breakpoints we set.
private:
- // Subclass identifier (for llvm isa/dyn_cast)
- const unsigned char SubclassID;
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
+ // Subclass identifier (for llvm isa/dyn_cast)
+ const unsigned char SubclassID;
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h Tue Sep 6 15:57:50 2016
@@ -20,63 +20,57 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverAddress BreakpointResolverAddress.h "lldb/Breakpoint/BreakpointResolverAddress.h"
-/// @brief This class sets breakpoints on a given Address. This breakpoint only takes
+/// @class BreakpointResolverAddress BreakpointResolverAddress.h
+/// "lldb/Breakpoint/BreakpointResolverAddress.h"
+/// @brief This class sets breakpoints on a given Address. This breakpoint only
+/// takes
/// once, and then it won't attempt to reset itself.
//----------------------------------------------------------------------
-class BreakpointResolverAddress:
- public BreakpointResolver
-{
+class BreakpointResolverAddress : public BreakpointResolver {
public:
- BreakpointResolverAddress (Breakpoint *bkpt,
- const Address &addr);
+ BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr);
- BreakpointResolverAddress (Breakpoint *bkpt,
- const Address &addr,
- const FileSpec &module_spec);
+ BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr,
+ const FileSpec &module_spec);
- ~BreakpointResolverAddress() override;
+ ~BreakpointResolverAddress() override;
- void
- ResolveBreakpoint (SearchFilter &filter) override;
+ void ResolveBreakpoint(SearchFilter &filter) override;
- void
- ResolveBreakpointInModules (SearchFilter &filter,
- ModuleList &modules) override;
+ void ResolveBreakpointInModules(SearchFilter &filter,
+ ModuleList &modules) override;
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- Searcher::Depth
- GetDepth () override;
+ Searcher::Depth GetDepth() override;
- void
- GetDescription (Stream *s) override;
+ void GetDescription(Stream *s) override;
- void
- Dump (Stream *s) const override;
+ void Dump(Stream *s) const override;
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverAddress *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::AddressResolver;
- }
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverAddress *) { return true; }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::AddressResolver;
+ }
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- Address m_addr; // The address - may be Section Offset or may be just an offset
- lldb::addr_t m_resolved_addr; // The current value of the resolved load address for this breakpoint,
- FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an offset, then it will be converted
- // to a Section+Offset address in this module, whenever that module gets around to
- // being loaded.
+ Address
+ m_addr; // The address - may be Section Offset or may be just an offset
+ lldb::addr_t m_resolved_addr; // The current value of the resolved load
+ // address for this breakpoint,
+ FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an
+ // offset, then it will be converted
+ // to a Section+Offset address in this module, whenever that module gets
+ // around to
+ // being loaded.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h Tue Sep 6 15:57:50 2016
@@ -19,59 +19,53 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h "lldb/Breakpoint/BreakpointResolverFileLine.h"
-/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined
+/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h
+/// "lldb/Breakpoint/BreakpointResolverFileLine.h"
+/// @brief This class sets breakpoints by file and line. Optionally, it will
+/// look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class BreakpointResolverFileLine :
- public BreakpointResolver
-{
+class BreakpointResolverFileLine : public BreakpointResolver {
public:
- BreakpointResolverFileLine (Breakpoint *bkpt,
- const FileSpec &resolver,
- uint32_t line_no,
- lldb::addr_t m_offset,
- bool check_inlines,
- bool skip_prologue,
- bool exact_match);
-
- ~BreakpointResolverFileLine() override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- void
- Dump (Stream *s) const override;
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverFileLine *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::FileLineResolver;
- }
+ BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver,
+ uint32_t line_no, lldb::addr_t m_offset,
+ bool check_inlines, bool skip_prologue,
+ bool exact_match);
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ ~BreakpointResolverFileLine() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ void Dump(Stream *s) const override;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverFileLine *) {
+ return true;
+ }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::FileLineResolver;
+ }
+
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- friend class Breakpoint;
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
- bool m_skip_prologue;
- bool m_exact_match;
+ friend class Breakpoint;
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
+ bool m_skip_prologue;
+ bool m_exact_match;
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- BreakpointResolverFileRegex.h ----------------------------*- C++ -*-===//
+//===-- BreakpointResolverFileRegex.h ----------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,57 +22,55 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h "lldb/Breakpoint/BreakpointResolverFileRegex.h"
-/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined
+/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h
+/// "lldb/Breakpoint/BreakpointResolverFileRegex.h"
+/// @brief This class sets breakpoints by file and line. Optionally, it will
+/// look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class BreakpointResolverFileRegex :
- public BreakpointResolver
-{
+class BreakpointResolverFileRegex : public BreakpointResolver {
public:
- BreakpointResolverFileRegex (Breakpoint *bkpt,
- RegularExpression ®ex,
- const std::unordered_set<std::string> &func_name_set,
- bool exact_match);
-
- ~BreakpointResolverFileRegex() override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- void
- Dump (Stream *s) const override;
-
- void
- AddFunctionName(const char *func_name);
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverFileRegex *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::FileRegexResolver;
- }
+ BreakpointResolverFileRegex(
+ Breakpoint *bkpt, RegularExpression ®ex,
+ const std::unordered_set<std::string> &func_name_set, bool exact_match);
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ ~BreakpointResolverFileRegex() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ void Dump(Stream *s) const override;
+
+ void AddFunctionName(const char *func_name);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverFileRegex *) {
+ return true;
+ }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::FileRegexResolver;
+ }
+
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- friend class Breakpoint;
- RegularExpression m_regex; // This is the line expression that we are looking for.
- bool m_exact_match; // If true, then if the source we match is in a comment, we won't set a location there.
- std::unordered_set<std::string> m_function_names; // Limit the search to functions in the comp_unit passed in.
+ friend class Breakpoint;
+ RegularExpression
+ m_regex; // This is the line expression that we are looking for.
+ bool m_exact_match; // If true, then if the source we match is in a comment,
+ // we won't set a location there.
+ std::unordered_set<std::string> m_function_names; // Limit the search to
+ // functions in the
+ // comp_unit passed in.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
// C Includes
// C++ Includes
-#include <vector>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -23,93 +23,72 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointResolverName BreakpointResolverName.h "lldb/Breakpoint/BreakpointResolverName.h"
-/// @brief This class sets breakpoints on a given function name, either by exact match
+/// @class BreakpointResolverName BreakpointResolverName.h
+/// "lldb/Breakpoint/BreakpointResolverName.h"
+/// @brief This class sets breakpoints on a given function name, either by exact
+/// match
/// or by regular expression.
//----------------------------------------------------------------------
-class BreakpointResolverName:
- public BreakpointResolver
-{
+class BreakpointResolverName : public BreakpointResolver {
public:
+ BreakpointResolverName(Breakpoint *bkpt, const char *name,
+ uint32_t name_type_mask, lldb::LanguageType language,
+ Breakpoint::MatchType type, lldb::addr_t offset,
+ bool skip_prologue);
+
+ // This one takes an array of names. It is always MatchType = Exact.
+ BreakpointResolverName(Breakpoint *bkpt, const char *names[],
+ size_t num_names, uint32_t name_type_mask,
+ lldb::LanguageType language, lldb::addr_t offset,
+ bool skip_prologue);
+
+ // This one takes a C++ array of names. It is always MatchType = Exact.
+ BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
+ uint32_t name_type_mask, lldb::LanguageType language,
+ lldb::addr_t offset, bool skip_prologue);
+
+ // Creates a function breakpoint by regular expression. Takes over control of
+ // the lifespan of func_regex.
+ BreakpointResolverName(Breakpoint *bkpt, RegularExpression &func_regex,
+ lldb::LanguageType language, lldb::addr_t offset,
+ bool skip_prologue);
+
+ BreakpointResolverName(Breakpoint *bkpt, const char *class_name,
+ const char *method, Breakpoint::MatchType type,
+ lldb::addr_t offset, bool skip_prologue);
+
+ ~BreakpointResolverName() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ void Dump(Stream *s) const override;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BreakpointResolverName *) { return true; }
+ static inline bool classof(const BreakpointResolver *V) {
+ return V->getResolverID() == BreakpointResolver::NameResolver;
+ }
- BreakpointResolverName (Breakpoint *bkpt,
- const char *name,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // This one takes an array of names. It is always MatchType = Exact.
- BreakpointResolverName (Breakpoint *bkpt,
- const char *names[],
- size_t num_names,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // This one takes a C++ array of names. It is always MatchType = Exact.
- BreakpointResolverName (Breakpoint *bkpt,
- std::vector<std::string> names,
- uint32_t name_type_mask,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
- BreakpointResolverName (Breakpoint *bkpt,
- RegularExpression &func_regex,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue);
-
- BreakpointResolverName (Breakpoint *bkpt,
- const char *class_name,
- const char *method,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue);
-
- ~BreakpointResolverName() override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- void
- Dump (Stream *s) const override;
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const BreakpointResolverName *) { return true; }
- static inline bool classof(const BreakpointResolver *V) {
- return V->getResolverID() == BreakpointResolver::NameResolver;
- }
-
- lldb::BreakpointResolverSP
- CopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- BreakpointResolverName(const BreakpointResolverName &rhs);
+ BreakpointResolverName(const BreakpointResolverName &rhs);
- std::vector<Module::LookupInfo> m_lookups;
- ConstString m_class_name;
- RegularExpression m_regex;
- Breakpoint::MatchType m_match_type;
- lldb::LanguageType m_language;
- bool m_skip_prologue;
+ std::vector<Module::LookupInfo> m_lookups;
+ ConstString m_class_name;
+ RegularExpression m_regex;
+ Breakpoint::MatchType m_match_type;
+ lldb::LanguageType m_language;
+ bool m_skip_prologue;
- void
- AddNameLookup (const ConstString &name, uint32_t name_type_mask);
+ void AddNameLookup(const ConstString &name, uint32_t name_type_mask);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h Tue Sep 6 15:57:50 2016
@@ -19,10 +19,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
-#include "lldb/Core/UserID.h"
-#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
+#include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Core/UserID.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
@@ -39,277 +39,247 @@ namespace lldb_private {
/// site. Breakpoint sites are owned by the process.
//----------------------------------------------------------------------
-class BreakpointSite :
- public std::enable_shared_from_this<BreakpointSite>,
- public StoppointLocation
-{
+class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
+ public StoppointLocation {
public:
+ enum Type {
+ eSoftware, // Breakpoint opcode has been written to memory and
+ // m_saved_opcode
+ // and m_trap_opcode contain the saved and written opcode.
+ eHardware, // Breakpoint site is set as a hardware breakpoint
+ eExternal // Breakpoint site is managed by an external debug nub or
+ // debug interface where memory reads transparently will not
+ // display any breakpoint opcodes.
+ };
+
+ ~BreakpointSite() override;
+
+ //----------------------------------------------------------------------
+ // This section manages the breakpoint traps
+ //----------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Returns the Opcode Bytes for this breakpoint
+ //------------------------------------------------------------------
+ uint8_t *GetTrapOpcodeBytes();
+
+ //------------------------------------------------------------------
+ /// Returns the Opcode Bytes for this breakpoint - const version
+ //------------------------------------------------------------------
+ const uint8_t *GetTrapOpcodeBytes() const;
+
+ //------------------------------------------------------------------
+ /// Get the size of the trap opcode for this address
+ //------------------------------------------------------------------
+ size_t GetTrapOpcodeMaxByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Sets the trap opcode
+ //------------------------------------------------------------------
+ bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size);
+
+ //------------------------------------------------------------------
+ /// Gets the original instruction bytes that were overwritten by the trap
+ //------------------------------------------------------------------
+ uint8_t *GetSavedOpcodeBytes();
+
+ //------------------------------------------------------------------
+ /// Gets the original instruction bytes that were overwritten by the trap
+ /// const version
+ //------------------------------------------------------------------
+ const uint8_t *GetSavedOpcodeBytes() const;
+
+ //------------------------------------------------------------------
+ /// Says whether \a addr and size \a size intersects with the address \a
+ /// intersect_addr
+ //------------------------------------------------------------------
+ bool IntersectsRange(lldb::addr_t addr, size_t size,
+ lldb::addr_t *intersect_addr, size_t *intersect_size,
+ size_t *opcode_offset) const;
+
+ //------------------------------------------------------------------
+ /// Tells whether the current breakpoint site is enabled or not
+ ///
+ /// This is a low-level enable bit for the breakpoint sites. If a
+ /// breakpoint site has no enabled owners, it should just get
+ /// removed. This enable/disable is for the low-level target code
+ /// to enable and disable breakpoint sites when single stepping,
+ /// etc.
+ //------------------------------------------------------------------
+ bool IsEnabled() const;
+
+ //------------------------------------------------------------------
+ /// Sets whether the current breakpoint site is enabled or not
+ ///
+ /// @param[in] enabled
+ /// \b true if the breakpoint is enabled, \b false otherwise.
+ //------------------------------------------------------------------
+ void SetEnabled(bool enabled);
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint locations that produced this breakpoint site
+ /// whether
+ /// we should stop at this location.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ //------------------------------------------------------------------
+ /// Standard Dump method
+ ///
+ /// @param[in] context
+ /// The stream to dump this output.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const override;
+
+ //------------------------------------------------------------------
+ /// The "Owners" are the breakpoint locations that share this
+ /// breakpoint site. The method adds the \a owner to this breakpoint
+ /// site's owner list.
+ ///
+ /// @param[in] context
+ /// \a owner is the Breakpoint Location to add.
+ //------------------------------------------------------------------
+ void AddOwner(const lldb::BreakpointLocationSP &owner);
+
+ //------------------------------------------------------------------
+ /// This method returns the number of breakpoint locations currently
+ /// located at this breakpoint site.
+ ///
+ /// @return
+ /// The number of owners.
+ //------------------------------------------------------------------
+ size_t GetNumberOfOwners();
+
+ //------------------------------------------------------------------
+ /// This method returns the breakpoint location at index \a index
+ /// located at this breakpoint site. The owners are listed ordinally
+ /// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate
+ /// over the owners
+ ///
+ /// @param[in] index
+ /// The index in the list of owners for which you wish the owner location.
+ /// @return
+ /// A shared pointer to the breakpoint location at that index.
+ //------------------------------------------------------------------
+ lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx);
+
+ //------------------------------------------------------------------
+ /// This method copies the breakpoint site's owners into a new collection.
+ /// It does this while the owners mutex is locked.
+ ///
+ /// @param[out] out_collection
+ /// The BreakpointLocationCollection into which to put the owners
+ /// of this breakpoint site.
+ ///
+ /// @return
+ /// The number of elements copied into out_collection.
+ //------------------------------------------------------------------
+ size_t CopyOwnersList(BreakpointLocationCollection &out_collection);
+
+ //------------------------------------------------------------------
+ /// Check whether the owners of this breakpoint site have any
+ /// thread specifiers, and if yes, is \a thread contained in any
+ /// of these specifiers.
+ ///
+ /// @param[in] thread
+ /// The thread against which to test.
+ ///
+ /// return
+ /// \b true if the collection contains at least one location that
+ /// would be valid for this thread, false otherwise.
+ //------------------------------------------------------------------
+ bool ValidForThisThread(Thread *thread);
+
+ //------------------------------------------------------------------
+ /// Print a description of this breakpoint site to the stream \a s.
+ /// GetDescription tells you about the breakpoint site's owners.
+ /// Use BreakpointSite::Dump(Stream *) to get information about the
+ /// breakpoint site itself.
+ ///
+ /// @param[in] s
+ /// The stream to which to print the description.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ //------------------------------------------------------------------
+ /// Tell whether a breakpoint has a location at this site.
+ ///
+ /// @param[in] bp_id
+ /// The breakpoint id to query.
+ ///
+ /// @result
+ /// \b true if bp_id has a location that is at this site,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsBreakpointAtThisSite(lldb::break_id_t bp_id);
+
+ //------------------------------------------------------------------
+ /// Tell whether ALL the breakpoints in the location collection are internal.
+ ///
+ /// @result
+ /// \b true if all breakpoint locations are owned by internal breakpoints,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsInternal() const;
+
+ BreakpointSite::Type GetType() const { return m_type; }
- enum Type
- {
- eSoftware, // Breakpoint opcode has been written to memory and m_saved_opcode
- // and m_trap_opcode contain the saved and written opcode.
- eHardware, // Breakpoint site is set as a hardware breakpoint
- eExternal // Breakpoint site is managed by an external debug nub or
- // debug interface where memory reads transparently will not
- // display any breakpoint opcodes.
- };
-
- ~BreakpointSite() override;
-
- //----------------------------------------------------------------------
- // This section manages the breakpoint traps
- //----------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Returns the Opcode Bytes for this breakpoint
- //------------------------------------------------------------------
- uint8_t *
- GetTrapOpcodeBytes ();
-
- //------------------------------------------------------------------
- /// Returns the Opcode Bytes for this breakpoint - const version
- //------------------------------------------------------------------
- const uint8_t *
- GetTrapOpcodeBytes () const;
-
- //------------------------------------------------------------------
- /// Get the size of the trap opcode for this address
- //------------------------------------------------------------------
- size_t
- GetTrapOpcodeMaxByteSize () const;
-
- //------------------------------------------------------------------
- /// Sets the trap opcode
- //------------------------------------------------------------------
- bool
- SetTrapOpcode (const uint8_t *trap_opcode,
- uint32_t trap_opcode_size);
-
- //------------------------------------------------------------------
- /// Gets the original instruction bytes that were overwritten by the trap
- //------------------------------------------------------------------
- uint8_t *
- GetSavedOpcodeBytes ();
-
- //------------------------------------------------------------------
- /// Gets the original instruction bytes that were overwritten by the trap const version
- //------------------------------------------------------------------
- const uint8_t *
- GetSavedOpcodeBytes () const;
-
- //------------------------------------------------------------------
- /// Says whether \a addr and size \a size intersects with the address \a intersect_addr
- //------------------------------------------------------------------
- bool
- IntersectsRange (lldb::addr_t addr,
- size_t size,
- lldb::addr_t *intersect_addr,
- size_t *intersect_size,
- size_t *opcode_offset) const;
-
- //------------------------------------------------------------------
- /// Tells whether the current breakpoint site is enabled or not
- ///
- /// This is a low-level enable bit for the breakpoint sites. If a
- /// breakpoint site has no enabled owners, it should just get
- /// removed. This enable/disable is for the low-level target code
- /// to enable and disable breakpoint sites when single stepping,
- /// etc.
- //------------------------------------------------------------------
- bool
- IsEnabled () const;
-
- //------------------------------------------------------------------
- /// Sets whether the current breakpoint site is enabled or not
- ///
- /// @param[in] enabled
- /// \b true if the breakpoint is enabled, \b false otherwise.
- //------------------------------------------------------------------
- void
- SetEnabled (bool enabled);
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint locations that produced this breakpoint site whether
- /// we should stop at this location.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- //------------------------------------------------------------------
- /// Standard Dump method
- ///
- /// @param[in] context
- /// The stream to dump this output.
- //------------------------------------------------------------------
- void
- Dump(Stream *s) const override;
-
- //------------------------------------------------------------------
- /// The "Owners" are the breakpoint locations that share this
- /// breakpoint site. The method adds the \a owner to this breakpoint
- /// site's owner list.
- ///
- /// @param[in] context
- /// \a owner is the Breakpoint Location to add.
- //------------------------------------------------------------------
- void
- AddOwner (const lldb::BreakpointLocationSP &owner);
-
- //------------------------------------------------------------------
- /// This method returns the number of breakpoint locations currently
- /// located at this breakpoint site.
- ///
- /// @return
- /// The number of owners.
- //------------------------------------------------------------------
- size_t
- GetNumberOfOwners ();
-
- //------------------------------------------------------------------
- /// This method returns the breakpoint location at index \a index
- /// located at this breakpoint site. The owners are listed ordinally
- /// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate
- /// over the owners
- ///
- /// @param[in] index
- /// The index in the list of owners for which you wish the owner location.
- /// @return
- /// A shared pointer to the breakpoint location at that index.
- //------------------------------------------------------------------
- lldb::BreakpointLocationSP
- GetOwnerAtIndex (size_t idx);
-
- //------------------------------------------------------------------
- /// This method copies the breakpoint site's owners into a new collection.
- /// It does this while the owners mutex is locked.
- ///
- /// @param[out] out_collection
- /// The BreakpointLocationCollection into which to put the owners
- /// of this breakpoint site.
- ///
- /// @return
- /// The number of elements copied into out_collection.
- //------------------------------------------------------------------
- size_t
- CopyOwnersList (BreakpointLocationCollection &out_collection);
-
- //------------------------------------------------------------------
- /// Check whether the owners of this breakpoint site have any
- /// thread specifiers, and if yes, is \a thread contained in any
- /// of these specifiers.
- ///
- /// @param[in] thread
- /// The thread against which to test.
- ///
- /// return
- /// \b true if the collection contains at least one location that
- /// would be valid for this thread, false otherwise.
- //------------------------------------------------------------------
- bool
- ValidForThisThread (Thread *thread);
-
- //------------------------------------------------------------------
- /// Print a description of this breakpoint site to the stream \a s.
- /// GetDescription tells you about the breakpoint site's owners.
- /// Use BreakpointSite::Dump(Stream *) to get information about the
- /// breakpoint site itself.
- ///
- /// @param[in] s
- /// The stream to which to print the description.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
-
- //------------------------------------------------------------------
- /// Tell whether a breakpoint has a location at this site.
- ///
- /// @param[in] bp_id
- /// The breakpoint id to query.
- ///
- /// @result
- /// \b true if bp_id has a location that is at this site,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsBreakpointAtThisSite (lldb::break_id_t bp_id);
-
- //------------------------------------------------------------------
- /// Tell whether ALL the breakpoints in the location collection are internal.
- ///
- /// @result
- /// \b true if all breakpoint locations are owned by internal breakpoints,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsInternal () const;
-
- BreakpointSite::Type
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (BreakpointSite::Type type)
- {
- m_type = type;
- }
+ void SetType(BreakpointSite::Type type) { m_type = type; }
private:
- friend class Process;
- friend class BreakpointLocation;
- // The StopInfoBreakpoint knows when it is processing a hit for a thread for a site, so let it be the
- // one to manage setting the location hit count once and only once.
- friend class StopInfoBreakpoint;
-
- void
- BumpHitCounts();
-
- //------------------------------------------------------------------
- /// The method removes the owner at \a break_loc_id from this breakpoint list.
- ///
- /// @param[in] context
- /// \a break_loc_id is the Breakpoint Location to remove.
- //------------------------------------------------------------------
- size_t
- RemoveOwner (lldb::break_id_t break_id,
- lldb::break_id_t break_loc_id);
-
- BreakpointSite::Type m_type;///< The type of this breakpoint site.
- uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site uses trap opcodes.
- uint8_t m_trap_opcode[8]; ///< The opcode that was used to create the breakpoint if it is a software breakpoint site.
- bool m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
-
- // Consider adding an optimization where if there is only one
- // owner, we don't store a list. The usual case will be only one owner...
- BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site.
- std::recursive_mutex m_owners_mutex; ///< This mutex protects the owners collection.
-
- static lldb::break_id_t
- GetNextID();
-
- // Only the Process can create breakpoint sites in
- // Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
- BreakpointSite (BreakpointSiteList *list,
- const lldb::BreakpointLocationSP& owner,
- lldb::addr_t m_addr,
- bool use_hardware);
+ friend class Process;
+ friend class BreakpointLocation;
+ // The StopInfoBreakpoint knows when it is processing a hit for a thread for a
+ // site, so let it be the
+ // one to manage setting the location hit count once and only once.
+ friend class StopInfoBreakpoint;
+
+ void BumpHitCounts();
+
+ //------------------------------------------------------------------
+ /// The method removes the owner at \a break_loc_id from this breakpoint list.
+ ///
+ /// @param[in] context
+ /// \a break_loc_id is the Breakpoint Location to remove.
+ //------------------------------------------------------------------
+ size_t RemoveOwner(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
+
+ BreakpointSite::Type m_type; ///< The type of this breakpoint site.
+ uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site
+ ///uses trap opcodes.
+ uint8_t m_trap_opcode[8]; ///< The opcode that was used to create the
+ ///breakpoint if it is a software breakpoint site.
+ bool
+ m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
+
+ // Consider adding an optimization where if there is only one
+ // owner, we don't store a list. The usual case will be only one owner...
+ BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations
+ ///that share this breakpoint site.
+ std::recursive_mutex
+ m_owners_mutex; ///< This mutex protects the owners collection.
+
+ static lldb::break_id_t GetNextID();
+
+ // Only the Process can create breakpoint sites in
+ // Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
+ BreakpointSite(BreakpointSiteList *list,
+ const lldb::BreakpointLocationSP &owner, lldb::addr_t m_addr,
+ bool use_hardware);
- DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
+ DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h Tue Sep 6 15:57:50 2016
@@ -23,197 +23,185 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class BreakpointSiteList BreakpointSiteList.h "lldb/Breakpoint/BreakpointSiteList.h"
+/// @class BreakpointSiteList BreakpointSiteList.h
+/// "lldb/Breakpoint/BreakpointSiteList.h"
/// @brief Class that manages lists of BreakpointSite shared pointers.
//----------------------------------------------------------------------
-class BreakpointSiteList
-{
-// At present Process directly accesses the map of BreakpointSites so it can
-// do quick lookups into the map (using GetMap).
-// FIXME: Find a better interface for this.
-friend class Process;
+class BreakpointSiteList {
+ // At present Process directly accesses the map of BreakpointSites so it can
+ // do quick lookups into the map (using GetMap).
+ // FIXME: Find a better interface for this.
+ friend class Process;
public:
- //------------------------------------------------------------------
- /// Default constructor makes an empty list.
- //------------------------------------------------------------------
- BreakpointSiteList();
-
- //------------------------------------------------------------------
- /// Destructor, currently does nothing.
- //------------------------------------------------------------------
- ~BreakpointSiteList();
-
- //------------------------------------------------------------------
- /// Add a BreakpointSite to the list.
- ///
- /// @param[in] bp_site_sp
- /// A shared pointer to a breakpoint site being added to the list.
- ///
- /// @return
- /// The ID of the BreakpointSite in the list.
- //------------------------------------------------------------------
- lldb::break_id_t
- Add (const lldb::BreakpointSiteSP& bp_site_sp);
-
- //------------------------------------------------------------------
- /// Standard Dump routine, doesn't do anything at present.
- /// @param[in] s
- /// Stream into which to dump the description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site at address
- /// \a addr.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL
- /// pointer if no breakpoint site exists with a matching address.
- //------------------------------------------------------------------
- lldb::BreakpointSiteSP
- FindByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site with id \a breakID.
- ///
- /// @param[in] breakID
- /// The breakpoint site ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::BreakpointSiteSP
- FindByID (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the breakpoint site with id \a breakID - const version.
- ///
- /// @param[in] breakID
- /// The breakpoint site ID to seek for.
- ///
- /// @result
- /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
- /// breakpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::BreakpointSiteSP
- FindByID (lldb::break_id_t breakID) const;
-
- //------------------------------------------------------------------
- /// Returns the breakpoint site id to the breakpoint site at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
- //------------------------------------------------------------------
- lldb::break_id_t
- FindIDByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
- // as one of its owners.
- ///
- /// @param[in] bp_site_id
- /// The breakpoint site id to query.
- ///
- /// @param[in] bp_id
- /// The breakpoint id to look for in \a bp_site_id.
- ///
- /// @result
- /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
- /// owners of that site.
- //------------------------------------------------------------------
- bool
- BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id);
-
- void
- ForEach (std::function <void(BreakpointSite *)> const &callback);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint site given by \b breakID from this list.
- ///
- /// @param[in] breakID
- /// The breakpoint site index to remove.
- ///
- /// @result
- /// \b true if the breakpoint site \a breakID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Removes the breakpoint site at address \a addr from this list.
- ///
- /// @param[in] addr
- /// The address from which to remove a breakpoint site.
- ///
- /// @result
- /// \b true if \a addr had a breakpoint site to remove from the list.
- //------------------------------------------------------------------
- bool
- RemoveByAddress (lldb::addr_t addr);
-
- bool
- FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const;
-
- typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
-
- //------------------------------------------------------------------
- /// Enquires of the breakpoint site on in this list with ID \a breakID whether
- /// we should stop for the breakpoint or not.
- ///
- /// @param[in] context
- /// This contains the information about this stop.
- ///
- /// @param[in] breakID
- /// This break ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context, lldb::break_id_t breakID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in the list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_bp_site_list.size();
- }
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_bp_site_list.empty();
- }
+ //------------------------------------------------------------------
+ /// Default constructor makes an empty list.
+ //------------------------------------------------------------------
+ BreakpointSiteList();
+
+ //------------------------------------------------------------------
+ /// Destructor, currently does nothing.
+ //------------------------------------------------------------------
+ ~BreakpointSiteList();
+
+ //------------------------------------------------------------------
+ /// Add a BreakpointSite to the list.
+ ///
+ /// @param[in] bp_site_sp
+ /// A shared pointer to a breakpoint site being added to the list.
+ ///
+ /// @return
+ /// The ID of the BreakpointSite in the list.
+ //------------------------------------------------------------------
+ lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp);
+
+ //------------------------------------------------------------------
+ /// Standard Dump routine, doesn't do anything at present.
+ /// @param[in] s
+ /// Stream into which to dump the description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site at address
+ /// \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL
+ /// pointer if no breakpoint site exists with a matching address.
+ //------------------------------------------------------------------
+ lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site with id \a breakID.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL pointer if
+ /// the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the breakpoint site with id \a breakID - const
+ /// version.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the breakpoint site. May contain a NULL pointer if
+ /// the
+ /// breakpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the breakpoint site id to the breakpoint site at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
+ //------------------------------------------------------------------
+ lldb::break_id_t FindIDByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
+ // as one of its owners.
+ ///
+ /// @param[in] bp_site_id
+ /// The breakpoint site id to query.
+ ///
+ /// @param[in] bp_id
+ /// The breakpoint id to look for in \a bp_site_id.
+ ///
+ /// @result
+ /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
+ /// owners of that site.
+ //------------------------------------------------------------------
+ bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id,
+ lldb::break_id_t bp_id);
+
+ void ForEach(std::function<void(BreakpointSite *)> const &callback);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint site given by \b breakID from this list.
+ ///
+ /// @param[in] breakID
+ /// The breakpoint site index to remove.
+ ///
+ /// @result
+ /// \b true if the breakpoint site \a breakID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Removes the breakpoint site at address \a addr from this list.
+ ///
+ /// @param[in] addr
+ /// The address from which to remove a breakpoint site.
+ ///
+ /// @result
+ /// \b true if \a addr had a breakpoint site to remove from the list.
+ //------------------------------------------------------------------
+ bool RemoveByAddress(lldb::addr_t addr);
+
+ bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound,
+ BreakpointSiteList &bp_site_list) const;
+
+ typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp,
+ void *baton);
+
+ //------------------------------------------------------------------
+ /// Enquires of the breakpoint site on in this list with ID \a breakID whether
+ /// we should stop for the breakpoint or not.
+ ///
+ /// @param[in] context
+ /// This contains the information about this stop.
+ ///
+ /// @param[in] breakID
+ /// This break ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in the list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_bp_site_list.size();
+ }
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_bp_site_list.empty();
+ }
protected:
- typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
+ typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
- collection::iterator
- GetIDIterator(lldb::break_id_t breakID);
+ collection::iterator GetIDIterator(lldb::break_id_t breakID);
- collection::const_iterator
- GetIDConstIterator(lldb::break_id_t breakID) const;
+ collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const;
- mutable std::recursive_mutex m_mutex;
- collection m_bp_site_list; // The breakpoint site list.
+ mutable std::recursive_mutex m_mutex;
+ collection m_bp_site_list; // The breakpoint site list.
};
} // namespace lldb_private
-#endif // liblldb_BreakpointSiteList_h_
+#endif // liblldb_BreakpointSiteList_h_
Modified: lldb/trunk/include/lldb/Breakpoint/Stoppoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Stoppoint.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Stoppoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Stoppoint.h Tue Sep 6 15:57:50 2016
@@ -14,50 +14,43 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Stoppoint
-{
+class Stoppoint {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Stoppoint();
-
- virtual
- ~Stoppoint();
-
- //------------------------------------------------------------------
- // Methods
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *) = 0;
-
- virtual bool
- IsEnabled () = 0;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Stoppoint();
+
+ virtual ~Stoppoint();
+
+ //------------------------------------------------------------------
+ // Methods
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *) = 0;
+
+ virtual bool IsEnabled() = 0;
- virtual void
- SetEnabled (bool enable) = 0;
+ virtual void SetEnabled(bool enable) = 0;
- lldb::break_id_t
- GetID () const;
+ lldb::break_id_t GetID() const;
- void
- SetID (lldb::break_id_t bid);
+ void SetID(lldb::break_id_t bid);
protected:
- lldb::break_id_t m_bid;
+ lldb::break_id_t m_bid;
private:
- //------------------------------------------------------------------
- // For Stoppoint only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Stoppoint);
+ //------------------------------------------------------------------
+ // For Stoppoint only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Stoppoint);
};
} // namespace lldb_private
-#endif // liblldb_Stoppoint_h_
+#endif // liblldb_Stoppoint_h_
Modified: lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h Tue Sep 6 15:57:50 2016
@@ -10,49 +10,54 @@
#ifndef liblldb_StoppointCallbackContext_h_
#define liblldb_StoppointCallbackContext_h_
-#include "lldb/lldb-private.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class StoppointCallbackContext StoppointCallbackContext.h "lldb/Breakpoint/StoppointCallbackContext.h"
-/// @brief Class holds the information that a breakpoint callback needs to evaluate this stop.
+/// @class StoppointCallbackContext StoppointCallbackContext.h
+/// "lldb/Breakpoint/StoppointCallbackContext.h"
+/// @brief Class holds the information that a breakpoint callback needs to
+/// evaluate this stop.
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/// General Outline:
-/// When we hit a breakpoint we need to package up whatever information is needed
-/// to evaluate breakpoint commands and conditions. This class is the container of
+/// When we hit a breakpoint we need to package up whatever information is
+/// needed
+/// to evaluate breakpoint commands and conditions. This class is the container
+/// of
/// that information.
//----------------------------------------------------------------------
-class StoppointCallbackContext
-{
+class StoppointCallbackContext {
public:
- StoppointCallbackContext();
+ StoppointCallbackContext();
- StoppointCallbackContext(Event *event, const ExecutionContext &exe_ctx, bool synchronously = false);
+ StoppointCallbackContext(Event *event, const ExecutionContext &exe_ctx,
+ bool synchronously = false);
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the event, process and thread to NULL, and the frame index to an
- /// invalid value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Event *event; // This is the event, the callback can modify this to indicate
- // the meaning of the breakpoint hit
- ExecutionContextRef exe_ctx_ref; // This tells us where we have stopped, what thread.
- bool is_synchronous; // Is the callback being executed synchronously with the breakpoint,
- // or asynchronously as the event is retrieved?
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the event, process and thread to NULL, and the frame index to an
+ /// invalid value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Event *event; // This is the event, the callback can modify this to indicate
+ // the meaning of the breakpoint hit
+ ExecutionContextRef
+ exe_ctx_ref; // This tells us where we have stopped, what thread.
+ bool is_synchronous; // Is the callback being executed synchronously with the
+ // breakpoint,
+ // or asynchronously as the event is retrieved?
};
} // namespace lldb_private
-#endif // liblldb_StoppointCallbackContext_h_
+#endif // liblldb_StoppointCallbackContext_h_
Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Tue Sep 6 15:57:50 2016
@@ -14,137 +14,88 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
+#include "lldb/lldb-private.h"
// #include "lldb/Breakpoint/BreakpointOptions.h"
namespace lldb_private {
-class StoppointLocation
-{
+class StoppointLocation {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StoppointLocation (lldb::break_id_t bid,
- lldb::addr_t m_addr,
- bool hardware);
-
- StoppointLocation (lldb::break_id_t bid,
- lldb::addr_t m_addr,
- uint32_t byte_size,
- bool hardware);
-
- virtual
- ~StoppointLocation ();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- // Methods
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetLoadAddress() const
- {
- return m_addr;
- }
-
- virtual void
- SetLoadAddress (lldb::addr_t addr)
- {
- m_addr = addr;
- }
-
- uint32_t
- GetByteSize () const
- {
- return m_byte_size;
- }
-
- uint32_t
- GetHitCount () const
- {
- return m_hit_count;
- }
-
- uint32_t
- GetHardwareIndex () const
- {
- return m_hardware_index;
- }
-
-
- bool
- HardwareRequired () const
- {
- return m_hardware;
- }
-
- virtual bool
- IsHardware () const
- {
- return m_hardware_index != LLDB_INVALID_INDEX32;
- }
-
-
- virtual bool
- ShouldStop (StoppointCallbackContext *context)
- {
- return true;
- }
-
- virtual void
- Dump (Stream *stream) const
- {
- }
-
- void
- SetHardwareIndex (uint32_t index)
- {
- m_hardware_index = index;
- }
-
-
- lldb::break_id_t
- GetID () const
- {
- return m_loc_id;
- }
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
+
+ StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr,
+ uint32_t byte_size, bool hardware);
+
+ virtual ~StoppointLocation();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ // Methods
+ //------------------------------------------------------------------
+ virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
+
+ virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
+
+ uint32_t GetByteSize() const { return m_byte_size; }
+
+ uint32_t GetHitCount() const { return m_hit_count; }
+
+ uint32_t GetHardwareIndex() const { return m_hardware_index; }
+
+ bool HardwareRequired() const { return m_hardware; }
+
+ virtual bool IsHardware() const {
+ return m_hardware_index != LLDB_INVALID_INDEX32;
+ }
+
+ virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
+
+ virtual void Dump(Stream *stream) const {}
+
+ void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
+
+ lldb::break_id_t GetID() const { return m_loc_id; }
protected:
- //------------------------------------------------------------------
- // Classes that inherit from StoppointLocation can see and modify these
- //------------------------------------------------------------------
- lldb::break_id_t m_loc_id; // Stoppoint location ID
- lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't
- // store a full Address since that's not needed for the breakpoint sites.
- bool m_hardware; // True if this point has been is required to use hardware (which may fail due to lack of resources)
- uint32_t m_hardware_index; // The hardware resource index for this breakpoint/watchpoint
- uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for
- // software breakpoints, or the optional length in bytes for
- // hardware breakpoints, or the length of the watchpoint.
- uint32_t m_hit_count; // Number of times this breakpoint/watchpoint has been hit
-
- // If you override this, be sure to call the base class to increment the internal counter.
- void
- IncrementHitCount ()
- {
- ++m_hit_count;
- }
+ //------------------------------------------------------------------
+ // Classes that inherit from StoppointLocation can see and modify these
+ //------------------------------------------------------------------
+ lldb::break_id_t m_loc_id; // Stoppoint location ID
+ lldb::addr_t
+ m_addr; // The load address of this stop point. The base Stoppoint doesn't
+ // store a full Address since that's not needed for the breakpoint sites.
+ bool m_hardware; // True if this point has been is required to use hardware
+ // (which may fail due to lack of resources)
+ uint32_t m_hardware_index; // The hardware resource index for this
+ // breakpoint/watchpoint
+ uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length
+ // of the trap opcode for
+ // software breakpoints, or the optional length in bytes for
+ // hardware breakpoints, or the length of the watchpoint.
+ uint32_t
+ m_hit_count; // Number of times this breakpoint/watchpoint has been hit
+
+ // If you override this, be sure to call the base class to increment the
+ // internal counter.
+ void IncrementHitCount() { ++m_hit_count; }
- void
- DecrementHitCount ();
+ void DecrementHitCount();
private:
- //------------------------------------------------------------------
- // For StoppointLocation only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
- StoppointLocation(); // Disallow default constructor
+ //------------------------------------------------------------------
+ // For StoppointLocation only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
+ StoppointLocation(); // Disallow default constructor
};
} // namespace lldb_private
-#endif // liblldb_StoppointLocation_h_
+#endif // liblldb_StoppointLocation_h_
Modified: lldb/trunk/include/lldb/Breakpoint/Watchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Watchpoint.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Watchpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Watchpoint.h Tue Sep 6 15:57:50 2016
@@ -17,240 +17,214 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Watchpoint :
- public std::enable_shared_from_this<Watchpoint>,
- public StoppointLocation
-{
+class Watchpoint : public std::enable_shared_from_this<Watchpoint>,
+ public StoppointLocation {
public:
- class WatchpointEventData :
- public EventData
- {
- public:
- WatchpointEventData (lldb::WatchpointEventType sub_type,
- const lldb::WatchpointSP &new_watchpoint_sp);
-
- ~WatchpointEventData() override;
-
- static const ConstString &
- GetFlavorString ();
-
- const ConstString &
- GetFlavor() const override;
-
- lldb::WatchpointEventType
- GetWatchpointEventType () const;
-
- lldb::WatchpointSP &
- GetWatchpoint ();
-
- void
- Dump(Stream *s) const override;
-
- static lldb::WatchpointEventType
- GetWatchpointEventTypeFromEvent (const lldb::EventSP &event_sp);
-
- static lldb::WatchpointSP
- GetWatchpointFromEvent (const lldb::EventSP &event_sp);
-
- static const WatchpointEventData *
- GetEventDataFromEvent (const Event *event_sp);
-
- private:
- lldb::WatchpointEventType m_watchpoint_event;
- lldb::WatchpointSP m_new_watchpoint_sp;
-
- DISALLOW_COPY_AND_ASSIGN (WatchpointEventData);
- };
-
- Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware = true);
-
- ~Watchpoint() override;
-
- void
- IncrementFalseAlarmsAndReviseHitCount();
-
- bool
- IsEnabled () const;
-
- void
- SetEnabled (bool enabled, bool notify = true);
-
- bool
- IsHardware() const override;
-
- bool
- ShouldStop(StoppointCallbackContext *context) override;
-
- bool WatchpointRead () const;
- bool WatchpointWrite () const;
- uint32_t GetIgnoreCount () const;
- void SetIgnoreCount (uint32_t n);
- void SetWatchpointType (uint32_t type, bool notify = true);
- void SetDeclInfo (const std::string &str);
- std::string GetWatchSpec();
- void SetWatchSpec (const std::string &str);
-
- // Snapshot management interface.
- bool IsWatchVariable() const;
- void SetWatchVariable(bool val);
- bool CaptureWatchedValue (const ExecutionContext &exe_ctx);
-
- void GetDescription (Stream *s, lldb::DescriptionLevel level);
- void Dump (Stream *s) const override;
- void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;
- void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
- Target &GetTarget() { return m_target; }
- const Error &GetError() { return m_error; }
-
- //------------------------------------------------------------------
- /// Returns the WatchpointOptions structure set for this watchpoint.
- ///
- /// @return
- /// A pointer to this watchpoint's WatchpointOptions.
- //------------------------------------------------------------------
- WatchpointOptions *
- GetOptions () { return &m_options; }
-
- //------------------------------------------------------------------
- /// Set the callback action invoked when the watchpoint is hit.
- ///
- /// @param[in] callback
- /// The method that will get called when the watchpoint is hit.
- /// @param[in] callback_baton
- /// A void * pointer that will get passed back to the callback function.
- /// @param[in] is_synchronous
- /// If \b true the callback will be run on the private event thread
- /// before the stop event gets reported. If false, the callback will get
- /// handled on the public event thread after the stop has been posted.
- ///
- /// @return
- /// \b true if the process should stop when you hit the watchpoint.
- /// \b false if it should continue.
- //------------------------------------------------------------------
- void
- SetCallback (WatchpointHitCallback callback,
- void *callback_baton,
- bool is_synchronous = false);
-
- void
- SetCallback (WatchpointHitCallback callback,
- const lldb::BatonSP &callback_baton_sp,
- bool is_synchronous = false);
-
- void ClearCallback();
-
- //------------------------------------------------------------------
- /// Invoke the callback action when the watchpoint is hit.
- ///
- /// @param[in] context
- /// Described the watchpoint event.
- ///
- /// @return
- /// \b true if the target should stop at this watchpoint and \b false not.
- //------------------------------------------------------------------
- bool
- InvokeCallback (StoppointCallbackContext *context);
-
- //------------------------------------------------------------------
- // Condition
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Set the watchpoint's condition.
- ///
- /// @param[in] condition
- /// The condition expression to evaluate when the watchpoint is hit.
- /// Pass in nullptr to clear the condition.
- //------------------------------------------------------------------
- void SetCondition (const char *condition);
-
- //------------------------------------------------------------------
- /// Return a pointer to the text of the condition expression.
- ///
- /// @return
- /// A pointer to the condition expression text, or nullptr if no
- // condition has been set.
- //------------------------------------------------------------------
- const char *GetConditionText () const;
-
- void
- TurnOnEphemeralMode();
-
- void
- TurnOffEphemeralMode();
-
- bool
- IsDisabledDuringEphemeralMode();
-
- const CompilerType &
- GetCompilerType()
- {
- return m_type;
- }
+ class WatchpointEventData : public EventData {
+ public:
+ WatchpointEventData(lldb::WatchpointEventType sub_type,
+ const lldb::WatchpointSP &new_watchpoint_sp);
+
+ ~WatchpointEventData() override;
+
+ static const ConstString &GetFlavorString();
+
+ const ConstString &GetFlavor() const override;
+
+ lldb::WatchpointEventType GetWatchpointEventType() const;
+
+ lldb::WatchpointSP &GetWatchpoint();
+
+ void Dump(Stream *s) const override;
+
+ static lldb::WatchpointEventType
+ GetWatchpointEventTypeFromEvent(const lldb::EventSP &event_sp);
+
+ static lldb::WatchpointSP
+ GetWatchpointFromEvent(const lldb::EventSP &event_sp);
+
+ static const WatchpointEventData *
+ GetEventDataFromEvent(const Event *event_sp);
+
+ private:
+ lldb::WatchpointEventType m_watchpoint_event;
+ lldb::WatchpointSP m_new_watchpoint_sp;
+
+ DISALLOW_COPY_AND_ASSIGN(WatchpointEventData);
+ };
+
+ Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
+ const CompilerType *type, bool hardware = true);
+
+ ~Watchpoint() override;
+
+ void IncrementFalseAlarmsAndReviseHitCount();
+
+ bool IsEnabled() const;
+
+ void SetEnabled(bool enabled, bool notify = true);
+
+ bool IsHardware() const override;
+
+ bool ShouldStop(StoppointCallbackContext *context) override;
+
+ bool WatchpointRead() const;
+ bool WatchpointWrite() const;
+ uint32_t GetIgnoreCount() const;
+ void SetIgnoreCount(uint32_t n);
+ void SetWatchpointType(uint32_t type, bool notify = true);
+ void SetDeclInfo(const std::string &str);
+ std::string GetWatchSpec();
+ void SetWatchSpec(const std::string &str);
+
+ // Snapshot management interface.
+ bool IsWatchVariable() const;
+ void SetWatchVariable(bool val);
+ bool CaptureWatchedValue(const ExecutionContext &exe_ctx);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+ void Dump(Stream *s) const override;
+ void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;
+ void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const;
+ Target &GetTarget() { return m_target; }
+ const Error &GetError() { return m_error; }
+
+ //------------------------------------------------------------------
+ /// Returns the WatchpointOptions structure set for this watchpoint.
+ ///
+ /// @return
+ /// A pointer to this watchpoint's WatchpointOptions.
+ //------------------------------------------------------------------
+ WatchpointOptions *GetOptions() { return &m_options; }
+
+ //------------------------------------------------------------------
+ /// Set the callback action invoked when the watchpoint is hit.
+ ///
+ /// @param[in] callback
+ /// The method that will get called when the watchpoint is hit.
+ /// @param[in] callback_baton
+ /// A void * pointer that will get passed back to the callback function.
+ /// @param[in] is_synchronous
+ /// If \b true the callback will be run on the private event thread
+ /// before the stop event gets reported. If false, the callback will get
+ /// handled on the public event thread after the stop has been posted.
+ ///
+ /// @return
+ /// \b true if the process should stop when you hit the watchpoint.
+ /// \b false if it should continue.
+ //------------------------------------------------------------------
+ void SetCallback(WatchpointHitCallback callback, void *callback_baton,
+ bool is_synchronous = false);
+
+ void SetCallback(WatchpointHitCallback callback,
+ const lldb::BatonSP &callback_baton_sp,
+ bool is_synchronous = false);
+
+ void ClearCallback();
+
+ //------------------------------------------------------------------
+ /// Invoke the callback action when the watchpoint is hit.
+ ///
+ /// @param[in] context
+ /// Described the watchpoint event.
+ ///
+ /// @return
+ /// \b true if the target should stop at this watchpoint and \b false not.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context);
+
+ //------------------------------------------------------------------
+ // Condition
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Set the watchpoint's condition.
+ ///
+ /// @param[in] condition
+ /// The condition expression to evaluate when the watchpoint is hit.
+ /// Pass in nullptr to clear the condition.
+ //------------------------------------------------------------------
+ void SetCondition(const char *condition);
+
+ //------------------------------------------------------------------
+ /// Return a pointer to the text of the condition expression.
+ ///
+ /// @return
+ /// A pointer to the condition expression text, or nullptr if no
+ // condition has been set.
+ //------------------------------------------------------------------
+ const char *GetConditionText() const;
+
+ void TurnOnEphemeralMode();
+
+ void TurnOffEphemeralMode();
+
+ bool IsDisabledDuringEphemeralMode();
+
+ const CompilerType &GetCompilerType() { return m_type; }
private:
- friend class Target;
- friend class WatchpointList;
+ friend class Target;
+ friend class WatchpointList;
+
+ void ResetHitCount() { m_hit_count = 0; }
+
+ void ResetHistoricValues() {
+ m_old_value_sp.reset(nullptr);
+ m_new_value_sp.reset(nullptr);
+ }
+
+ Target &m_target;
+ bool m_enabled; // Is this watchpoint enabled
+ bool m_is_hardware; // Is this a hardware watchpoint
+ bool m_is_watch_variable; // True if set via 'watchpoint set variable'.
+ bool m_is_ephemeral; // True if the watchpoint is in the ephemeral mode,
+ // meaning that it is
+ // undergoing a pair of temporary disable/enable actions to avoid recursively
+ // triggering further watchpoint events.
+ uint32_t m_disabled_count; // Keep track of the count that the watchpoint is
+ // disabled while in ephemeral mode.
+ // At the end of the ephemeral mode when the watchpoint is to be enabled
+ // again,
+ // we check the count, if it is more than 1, it means the user-supplied
+ // actions
+ // actually want the watchpoint to be disabled!
+ uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from
+ m_watch_write : 1, // 1 if we stop when the watched data is written to
+ m_watch_was_read : 1, // Set to 1 when watchpoint is hit for a read access
+ m_watch_was_written : 1; // Set to 1 when watchpoint is hit for a write
+ // access
+ uint32_t m_ignore_count; // Number of times to ignore this watchpoint
+ uint32_t m_false_alarms; // Number of false alarms.
+ std::string m_decl_str; // Declaration information, if any.
+ std::string m_watch_spec_str; // Spec for the watchpoint.
+ lldb::ValueObjectSP m_old_value_sp;
+ lldb::ValueObjectSP m_new_value_sp;
+ CompilerType m_type;
+ Error m_error; // An error object describing errors associated with this
+ // watchpoint.
+ WatchpointOptions
+ m_options; // Settable watchpoint options, which is a delegate to handle
+ // the callback machinery.
+ bool m_being_created;
+
+ std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
+
+ void SetID(lldb::watch_id_t id) { m_loc_id = id; }
- void
- ResetHitCount ()
- {
- m_hit_count = 0;
- }
-
- void
- ResetHistoricValues ()
- {
- m_old_value_sp.reset(nullptr);
- m_new_value_sp.reset(nullptr);
- }
-
- Target &m_target;
- bool m_enabled; // Is this watchpoint enabled
- bool m_is_hardware; // Is this a hardware watchpoint
- bool m_is_watch_variable; // True if set via 'watchpoint set variable'.
- bool m_is_ephemeral; // True if the watchpoint is in the ephemeral mode, meaning that it is
- // undergoing a pair of temporary disable/enable actions to avoid recursively
- // triggering further watchpoint events.
- uint32_t m_disabled_count; // Keep track of the count that the watchpoint is disabled while in ephemeral mode.
- // At the end of the ephemeral mode when the watchpoint is to be enabled again,
- // we check the count, if it is more than 1, it means the user-supplied actions
- // actually want the watchpoint to be disabled!
- uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from
- m_watch_write:1, // 1 if we stop when the watched data is written to
- m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access
- m_watch_was_written:1; // Set to 1 when watchpoint is hit for a write access
- uint32_t m_ignore_count; // Number of times to ignore this watchpoint
- uint32_t m_false_alarms; // Number of false alarms.
- std::string m_decl_str; // Declaration information, if any.
- std::string m_watch_spec_str; // Spec for the watchpoint.
- lldb::ValueObjectSP m_old_value_sp;
- lldb::ValueObjectSP m_new_value_sp;
- CompilerType m_type;
- Error m_error; // An error object describing errors associated with this watchpoint.
- WatchpointOptions m_options; // Settable watchpoint options, which is a delegate to handle
- // the callback machinery.
- bool m_being_created;
-
- std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
-
- void SetID(lldb::watch_id_t id) { m_loc_id = id; }
-
- void
- SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind);
+ void SendWatchpointChangedEvent(lldb::WatchpointEventType eventKind);
- void
- SendWatchpointChangedEvent (WatchpointEventData *data);
+ void SendWatchpointChangedEvent(WatchpointEventData *data);
- DISALLOW_COPY_AND_ASSIGN (Watchpoint);
+ DISALLOW_COPY_AND_ASSIGN(Watchpoint);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointList.h Tue Sep 6 15:57:50 2016
@@ -18,8 +18,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -30,248 +30,224 @@ namespace lldb_private {
// well.
//----------------------------------------------------------------------
-class WatchpointList
-{
-// 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;
-friend class Target;
+class WatchpointList {
+ // 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;
+ friend class Target;
public:
- //------------------------------------------------------------------
- /// Default constructor makes an empty list.
- //------------------------------------------------------------------
- WatchpointList();
-
- //------------------------------------------------------------------
- /// Destructor, currently does nothing.
- //------------------------------------------------------------------
- ~WatchpointList();
-
- //------------------------------------------------------------------
- /// Add a Watchpoint to the list.
- ///
- /// @param[in] wp_sp
- /// A shared pointer to a watchpoint being added to the list.
- ///
- /// @return
- /// The ID of the Watchpoint in the list.
- //------------------------------------------------------------------
- lldb::watch_id_t
- Add (const lldb::WatchpointSP& wp_sp, bool notify);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method.
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Dump with lldb::DescriptionLevel.
- //------------------------------------------------------------------
- void
- DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint at address
- /// \a addr -
- /// const version.
- ///
- /// @param[in] addr
- /// The address to look for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- FindByAddress (lldb::addr_t addr) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with watchpoint spec
- /// \a spec -
- /// const version.
- ///
- /// @param[in] spec
- /// The watchpoint spec to look for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- FindBySpec (std::string spec) const;
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with id
- /// \a watchID, const
- /// version.
- ///
- /// @param[in] watchID
- /// The watchpoint location ID to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL
- /// pointer if the watchpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::WatchpointSP
- FindByID (lldb::watch_id_t watchID) const;
-
- //------------------------------------------------------------------
- /// Returns the watchpoint id to the watchpoint
- /// at address \a addr.
- ///
- /// @param[in] addr
- /// The address to match.
- ///
- /// @result
- /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
- //------------------------------------------------------------------
- lldb::watch_id_t
- FindIDByAddress (lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Returns the watchpoint id to the watchpoint
- /// with watchpoint spec \a spec.
- ///
- /// @param[in] spec
- /// The watchpoint spec to match.
- ///
- /// @result
- /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
- //------------------------------------------------------------------
- lldb::watch_id_t
- FindIDBySpec (std::string spec);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with index \a i.
- ///
- /// @param[in] i
- /// The watchpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL pointer if
- /// the watchpoint doesn't exist.
- //------------------------------------------------------------------
- lldb::WatchpointSP
- GetByIndex (uint32_t i);
-
- //------------------------------------------------------------------
- /// Returns a shared pointer to the watchpoint with index \a i, const
- /// version.
- ///
- /// @param[in] i
- /// The watchpoint index to seek for.
- ///
- /// @result
- /// A shared pointer to the watchpoint. May contain a NULL pointer if
- /// the watchpoint location doesn't exist.
- //------------------------------------------------------------------
- const lldb::WatchpointSP
- GetByIndex (uint32_t i) const;
-
- //------------------------------------------------------------------
- /// Removes the watchpoint given by \b watchID from this list.
- ///
- /// @param[in] watchID
- /// The watchpoint ID to remove.
- ///
- /// @result
- /// \b true if the watchpoint \a watchID was in the list.
- //------------------------------------------------------------------
- bool
- Remove (lldb::watch_id_t watchID, bool notify);
-
- //------------------------------------------------------------------
- /// Returns the number hit count of all watchpoints in this list.
- ///
- /// @result
- /// Hit count of all watchpoints in this list.
- //------------------------------------------------------------------
- uint32_t
- GetHitCount () const;
-
- //------------------------------------------------------------------
- /// 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.
- ///
- /// @param[in] watchID
- /// This watch ID that we hit.
- ///
- /// @return
- /// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ShouldStop (StoppointCallbackContext *context,
- lldb::watch_id_t watchID);
-
- //------------------------------------------------------------------
- /// Returns the number of elements in this watchpoint list.
- ///
- /// @result
- /// The number of elements.
- //------------------------------------------------------------------
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_watchpoints.size();
- }
-
- //------------------------------------------------------------------
- /// 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.
- ///
- /// @param[in] level
- /// The description level that indicates the detail level to
- /// provide.
- ///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level);
-
- void
- SetEnabledAll (bool enabled);
-
- void
- RemoveAll (bool notify);
-
- //------------------------------------------------------------------
- /// Sets the passed in Locker to hold the Watchpoint List mutex.
- ///
- /// @param[in] locker
- /// The locker object that is set.
- //------------------------------------------------------------------
- void
- GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
+ //------------------------------------------------------------------
+ /// Default constructor makes an empty list.
+ //------------------------------------------------------------------
+ WatchpointList();
+
+ //------------------------------------------------------------------
+ /// Destructor, currently does nothing.
+ //------------------------------------------------------------------
+ ~WatchpointList();
+
+ //------------------------------------------------------------------
+ /// Add a Watchpoint to the list.
+ ///
+ /// @param[in] wp_sp
+ /// A shared pointer to a watchpoint being added to the list.
+ ///
+ /// @return
+ /// The ID of the Watchpoint in the list.
+ //------------------------------------------------------------------
+ lldb::watch_id_t Add(const lldb::WatchpointSP &wp_sp, bool notify);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method.
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Dump with lldb::DescriptionLevel.
+ //------------------------------------------------------------------
+ void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint at address
+ /// \a addr -
+ /// const version.
+ ///
+ /// @param[in] addr
+ /// The address to look for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP FindByAddress(lldb::addr_t addr) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with watchpoint spec
+ /// \a spec -
+ /// const version.
+ ///
+ /// @param[in] spec
+ /// The watchpoint spec to look for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP FindBySpec(std::string spec) const;
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with id
+ /// \a watchID, const
+ /// version.
+ ///
+ /// @param[in] watchID
+ /// The watchpoint location ID to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL
+ /// pointer if the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::WatchpointSP FindByID(lldb::watch_id_t watchID) const;
+
+ //------------------------------------------------------------------
+ /// Returns the watchpoint id to the watchpoint
+ /// at address \a addr.
+ ///
+ /// @param[in] addr
+ /// The address to match.
+ ///
+ /// @result
+ /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
+ //------------------------------------------------------------------
+ lldb::watch_id_t FindIDByAddress(lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Returns the watchpoint id to the watchpoint
+ /// with watchpoint spec \a spec.
+ ///
+ /// @param[in] spec
+ /// The watchpoint spec to match.
+ ///
+ /// @result
+ /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID.
+ //------------------------------------------------------------------
+ lldb::watch_id_t FindIDBySpec(std::string spec);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with index \a i.
+ ///
+ /// @param[in] i
+ /// The watchpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL pointer if
+ /// the watchpoint doesn't exist.
+ //------------------------------------------------------------------
+ lldb::WatchpointSP GetByIndex(uint32_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint with index \a i, const
+ /// version.
+ ///
+ /// @param[in] i
+ /// The watchpoint index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint. May contain a NULL pointer if
+ /// the watchpoint location doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointSP GetByIndex(uint32_t i) const;
+
+ //------------------------------------------------------------------
+ /// Removes the watchpoint given by \b watchID from this list.
+ ///
+ /// @param[in] watchID
+ /// The watchpoint ID to remove.
+ ///
+ /// @result
+ /// \b true if the watchpoint \a watchID was in the list.
+ //------------------------------------------------------------------
+ bool Remove(lldb::watch_id_t watchID, bool notify);
+
+ //------------------------------------------------------------------
+ /// Returns the number hit count of all watchpoints in this list.
+ ///
+ /// @result
+ /// Hit count of all watchpoints in this list.
+ //------------------------------------------------------------------
+ uint32_t GetHitCount() const;
+
+ //------------------------------------------------------------------
+ /// 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.
+ ///
+ /// @param[in] watchID
+ /// This watch ID that we hit.
+ ///
+ /// @return
+ /// \b true if we should stop, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ShouldStop(StoppointCallbackContext *context, lldb::watch_id_t watchID);
+
+ //------------------------------------------------------------------
+ /// Returns the number of elements in this watchpoint list.
+ ///
+ /// @result
+ /// The number of elements.
+ //------------------------------------------------------------------
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_watchpoints.size();
+ }
+
+ //------------------------------------------------------------------
+ /// 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.
+ ///
+ /// @param[in] level
+ /// The description level that indicates the detail level to
+ /// provide.
+ ///
+ /// @see lldb::DescriptionLevel
+ //------------------------------------------------------------------
+ void GetDescription(Stream *s, lldb::DescriptionLevel level);
+
+ void SetEnabledAll(bool enabled);
+
+ void RemoveAll(bool notify);
+
+ //------------------------------------------------------------------
+ /// Sets the passed in Locker to hold the Watchpoint List mutex.
+ ///
+ /// @param[in] locker
+ /// The locker object that is set.
+ //------------------------------------------------------------------
+ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
- typedef std::list<lldb::WatchpointSP> wp_collection;
- typedef std::vector<lldb::watch_id_t> id_vector;
+ typedef std::list<lldb::WatchpointSP> wp_collection;
+ typedef std::vector<lldb::watch_id_t> id_vector;
- id_vector
- GetWatchpointIDs() const;
+ id_vector GetWatchpointIDs() const;
- wp_collection::iterator
- GetIDIterator(lldb::watch_id_t watchID);
+ wp_collection::iterator GetIDIterator(lldb::watch_id_t watchID);
- wp_collection::const_iterator
- GetIDConstIterator(lldb::watch_id_t watchID) const;
+ wp_collection::const_iterator
+ GetIDConstIterator(lldb::watch_id_t watchID) const;
- wp_collection m_watchpoints;
- mutable std::recursive_mutex m_mutex;
+ wp_collection m_watchpoints;
+ mutable std::recursive_mutex m_mutex;
- lldb::watch_id_t m_next_wp_id;
+ lldb::watch_id_t m_next_wp_id;
};
} // namespace lldb_private
-#endif // liblldb_WatchpointList_h_
+#endif // liblldb_WatchpointList_h_
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h Tue Sep 6 15:57:50 2016
@@ -17,234 +17,232 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Baton.h"
#include "lldb/Core/StringList.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class WatchpointOptions WatchpointOptions.h "lldb/Breakpoint/WatchpointOptions.h"
+/// @class WatchpointOptions WatchpointOptions.h
+/// "lldb/Breakpoint/WatchpointOptions.h"
/// @brief Class that manages the options on a watchpoint.
//----------------------------------------------------------------------
-class WatchpointOptions
-{
+class WatchpointOptions {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //------------------------------------------------------------------
- /// Default constructor. The watchpoint is enabled, and has no condition,
- /// callback, ignore count, etc...
- //------------------------------------------------------------------
- WatchpointOptions();
- WatchpointOptions(const WatchpointOptions& rhs);
-
- static WatchpointOptions *
- CopyOptionsNoCallback (WatchpointOptions &rhs);
- //------------------------------------------------------------------
- /// This constructor allows you to specify all the watchpoint options.
- ///
- /// @param[in] callback
- /// This is the plugin for some code that gets run, returns \b true if we are to stop.
- ///
- /// @param[in] baton
- /// Client data that will get passed to the callback.
- ///
- /// @param[in] thread_id
- /// Only stop if \a thread_id hits the watchpoint.
- //------------------------------------------------------------------
- WatchpointOptions(WatchpointHitCallback callback,
- void *baton,
- lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
-
- virtual ~WatchpointOptions();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const WatchpointOptions&
- operator=(const WatchpointOptions& rhs);
-
- //------------------------------------------------------------------
- // Callbacks
- //
- // Watchpoint callbacks come in two forms, synchronous and asynchronous. Synchronous callbacks will get
- // run before any of the thread plans are consulted, and if they return false the target will continue
- // "under the radar" of the thread plans. There are a couple of restrictions to synchronous callbacks:
- // 1) They should NOT resume the target themselves. Just return false if you want the target to restart.
- // 2) Watchpoints with synchronous callbacks can't have conditions (or rather, they can have them, but they
- // won't do anything. Ditto with ignore counts, etc... You are supposed to control that all through the
- // callback.
- // Asynchronous callbacks get run as part of the "ShouldStop" logic in the thread plan. The logic there is:
- // a) If the watchpoint is thread specific and not for this thread, continue w/o running the callback.
- // b) If the ignore count says we shouldn't stop, then ditto.
- // c) If the condition says we shouldn't stop, then ditto.
- // d) Otherwise, the callback will get run, and if it returns true we will stop, and if false we won't.
- // The asynchronous callback can run the target itself, but at present that should be the last action the
- // callback does. We will relax this condition at some point, but it will take a bit of plumbing to get
- // that to work.
- //
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Adds a callback to the watchpoint option set.
- ///
- /// @param[in] callback
- /// The function to be called when the watchpoint gets hit.
- ///
- /// @param[in] baton_sp
- /// A baton which will get passed back to the callback when it is invoked.
- ///
- /// @param[in] synchronous
- /// Whether this is a synchronous or asynchronous callback. See discussion above.
- //------------------------------------------------------------------
- void SetCallback (WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false);
-
- //------------------------------------------------------------------
- /// Remove the callback from this option set.
- //------------------------------------------------------------------
- void ClearCallback ();
-
- // The rest of these functions are meant to be used only within the watchpoint handling mechanism.
-
- //------------------------------------------------------------------
- /// Use this function to invoke the callback for a specific stop.
- ///
- /// @param[in] context
- /// The context in which the callback is to be invoked. This includes the stop event, the
- /// execution context of the stop (since you might hit the same watchpoint on multiple threads) and
- /// whether we are currently executing synchronous or asynchronous callbacks.
- ///
- /// @param[in] watch_id
- /// The watchpoint ID that owns this option set.
- ///
- /// @return
- /// The callback return value.
- //------------------------------------------------------------------
- bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t watch_id);
-
- //------------------------------------------------------------------
- /// Used in InvokeCallback to tell whether it is the right time to run this kind of callback.
- ///
- /// @return
- /// The synchronicity of our callback.
- //------------------------------------------------------------------
- bool IsCallbackSynchronous () {
- return m_callback_is_synchronous;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ /// Default constructor. The watchpoint is enabled, and has no condition,
+ /// callback, ignore count, etc...
+ //------------------------------------------------------------------
+ WatchpointOptions();
+ WatchpointOptions(const WatchpointOptions &rhs);
+
+ static WatchpointOptions *CopyOptionsNoCallback(WatchpointOptions &rhs);
+ //------------------------------------------------------------------
+ /// This constructor allows you to specify all the watchpoint options.
+ ///
+ /// @param[in] callback
+ /// This is the plugin for some code that gets run, returns \b true if we
+ /// are to stop.
+ ///
+ /// @param[in] baton
+ /// Client data that will get passed to the callback.
+ ///
+ /// @param[in] thread_id
+ /// Only stop if \a thread_id hits the watchpoint.
+ //------------------------------------------------------------------
+ WatchpointOptions(WatchpointHitCallback callback, void *baton,
+ lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
+
+ virtual ~WatchpointOptions();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const WatchpointOptions &operator=(const WatchpointOptions &rhs);
+
+ //------------------------------------------------------------------
+ // Callbacks
+ //
+ // Watchpoint callbacks come in two forms, synchronous and asynchronous.
+ // Synchronous callbacks will get
+ // run before any of the thread plans are consulted, and if they return false
+ // the target will continue
+ // "under the radar" of the thread plans. There are a couple of restrictions
+ // to synchronous callbacks:
+ // 1) They should NOT resume the target themselves. Just return false if you
+ // want the target to restart.
+ // 2) Watchpoints with synchronous callbacks can't have conditions (or rather,
+ // they can have them, but they
+ // won't do anything. Ditto with ignore counts, etc... You are supposed
+ // to control that all through the
+ // callback.
+ // Asynchronous callbacks get run as part of the "ShouldStop" logic in the
+ // thread plan. The logic there is:
+ // a) If the watchpoint is thread specific and not for this thread, continue
+ // w/o running the callback.
+ // b) If the ignore count says we shouldn't stop, then ditto.
+ // c) If the condition says we shouldn't stop, then ditto.
+ // d) Otherwise, the callback will get run, and if it returns true we will
+ // stop, and if false we won't.
+ // The asynchronous callback can run the target itself, but at present that
+ // should be the last action the
+ // callback does. We will relax this condition at some point, but it will
+ // take a bit of plumbing to get
+ // that to work.
+ //
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Adds a callback to the watchpoint option set.
+ ///
+ /// @param[in] callback
+ /// The function to be called when the watchpoint gets hit.
+ ///
+ /// @param[in] baton_sp
+ /// A baton which will get passed back to the callback when it is invoked.
+ ///
+ /// @param[in] synchronous
+ /// Whether this is a synchronous or asynchronous callback. See discussion
+ /// above.
+ //------------------------------------------------------------------
+ void SetCallback(WatchpointHitCallback callback,
+ const lldb::BatonSP &baton_sp, bool synchronous = false);
+
+ //------------------------------------------------------------------
+ /// Remove the callback from this option set.
+ //------------------------------------------------------------------
+ void ClearCallback();
+
+ // The rest of these functions are meant to be used only within the watchpoint
+ // handling mechanism.
+
+ //------------------------------------------------------------------
+ /// Use this function to invoke the callback for a specific stop.
+ ///
+ /// @param[in] context
+ /// The context in which the callback is to be invoked. This includes the
+ /// stop event, the
+ /// execution context of the stop (since you might hit the same watchpoint
+ /// on multiple threads) and
+ /// whether we are currently executing synchronous or asynchronous
+ /// callbacks.
+ ///
+ /// @param[in] watch_id
+ /// The watchpoint ID that owns this option set.
+ ///
+ /// @return
+ /// The callback return value.
+ //------------------------------------------------------------------
+ bool InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+
+ //------------------------------------------------------------------
+ /// Used in InvokeCallback to tell whether it is the right time to run this
+ /// kind of callback.
+ ///
+ /// @return
+ /// The synchronicity of our callback.
+ //------------------------------------------------------------------
+ bool IsCallbackSynchronous() { return m_callback_is_synchronous; }
+
+ //------------------------------------------------------------------
+ /// Fetch the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ Baton *GetBaton();
+
+ //------------------------------------------------------------------
+ /// Fetch a const version of the baton from the callback.
+ ///
+ /// @return
+ /// The baton.
+ //------------------------------------------------------------------
+ const Baton *GetBaton() const;
+
+ //------------------------------------------------------------------
+ /// Return the current thread spec for this option. This will return nullptr
+ /// if the no thread
+ /// specifications have been set for this Option yet.
+ /// @return
+ /// The thread specification pointer for this option, or nullptr if none
+ /// has
+ /// been set yet.
+ //------------------------------------------------------------------
+ const ThreadSpec *GetThreadSpecNoCreate() const;
+
+ //------------------------------------------------------------------
+ /// Returns a pointer to the ThreadSpec for this option, creating it.
+ /// if it hasn't been created already. This API is used for setting the
+ /// ThreadSpec items for this option.
+ //------------------------------------------------------------------
+ ThreadSpec *GetThreadSpec();
+
+ void SetThreadID(lldb::tid_t thread_id);
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Get description for callback only.
+ //------------------------------------------------------------------
+ void GetCallbackDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ //------------------------------------------------------------------
+ /// Returns true if the watchpoint option has a callback set.
+ //------------------------------------------------------------------
+ bool HasCallback();
+
+ //------------------------------------------------------------------
+ /// This is the default empty callback.
+ /// @return
+ /// The thread id for which the watchpoint hit will stop,
+ /// LLDB_INVALID_THREAD_ID for all threads.
+ //------------------------------------------------------------------
+ static bool NullCallback(void *baton, StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+
+ struct CommandData {
+ CommandData() : user_source(), script_source(), stop_on_error(true) {}
+
+ ~CommandData() = default;
+
+ StringList user_source;
+ std::string script_source;
+ bool stop_on_error;
+ };
+
+ class CommandBaton : public Baton {
+ public:
+ CommandBaton(CommandData *data) : Baton(data) {}
+
+ ~CommandBaton() override {
+ delete ((CommandData *)m_data);
+ m_data = nullptr;
}
-
- //------------------------------------------------------------------
- /// Fetch the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- Baton *GetBaton ();
-
- //------------------------------------------------------------------
- /// Fetch a const version of the baton from the callback.
- ///
- /// @return
- /// The baton.
- //------------------------------------------------------------------
- const Baton *GetBaton () const;
-
- //------------------------------------------------------------------
- /// Return the current thread spec for this option. This will return nullptr if the no thread
- /// specifications have been set for this Option yet.
- /// @return
- /// The thread specification pointer for this option, or nullptr if none has
- /// been set yet.
- //------------------------------------------------------------------
- const ThreadSpec *
- GetThreadSpecNoCreate () const;
-
- //------------------------------------------------------------------
- /// Returns a pointer to the ThreadSpec for this option, creating it.
- /// if it hasn't been created already. This API is used for setting the
- /// ThreadSpec items for this option.
- //------------------------------------------------------------------
- ThreadSpec *
- GetThreadSpec ();
-
- void
- SetThreadID(lldb::tid_t thread_id);
-
- void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Get description for callback only.
- //------------------------------------------------------------------
- void
- GetCallbackDescription (Stream *s, lldb::DescriptionLevel level) const;
-
- //------------------------------------------------------------------
- /// Returns true if the watchpoint option has a callback set.
- //------------------------------------------------------------------
- bool
- HasCallback();
-
- //------------------------------------------------------------------
- /// This is the default empty callback.
- /// @return
- /// The thread id for which the watchpoint hit will stop,
- /// LLDB_INVALID_THREAD_ID for all threads.
- //------------------------------------------------------------------
- static bool
- NullCallback (void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t watch_id);
-
- struct CommandData
- {
- CommandData () :
- user_source(),
- script_source(),
- stop_on_error(true)
- {
- }
-
- ~CommandData() = default;
-
- StringList user_source;
- std::string script_source;
- bool stop_on_error;
- };
-
- class CommandBaton : public Baton
- {
- public:
- CommandBaton (CommandData *data) :
- Baton (data)
- {
- }
-
- ~CommandBaton() override
- {
- delete ((CommandData *)m_data);
- m_data = nullptr;
- }
-
- void
- GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
- };
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override;
+ };
protected:
- //------------------------------------------------------------------
- // Classes that inherit from WatchpointOptions can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from WatchpointOptions can see and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For WatchpointOptions only
- //------------------------------------------------------------------
- WatchpointHitCallback m_callback; // This is the callback function pointer
- lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
- bool m_callback_is_synchronous;
- std::unique_ptr<ThreadSpec> m_thread_spec_ap; // Thread for which this watchpoint will take
+ //------------------------------------------------------------------
+ // For WatchpointOptions only
+ //------------------------------------------------------------------
+ WatchpointHitCallback m_callback; // This is the callback function pointer
+ lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback
+ bool m_callback_is_synchronous;
+ std::unique_ptr<ThreadSpec>
+ m_thread_spec_ap; // Thread for which this watchpoint will take
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Tue Sep 6 15:57:50 2016
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -52,541 +52,492 @@ namespace lldb_private {
/// this happens, breakpoints that are in one of these sections can be
/// set/cleared.
//----------------------------------------------------------------------
-class Address
-{
+class Address {
public:
- //------------------------------------------------------------------
- /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const
- /// function to display Address contents in a variety of ways.
- //------------------------------------------------------------------
- typedef enum {
- DumpStyleInvalid, ///< Invalid dump style
- DumpStyleSectionNameOffset, ///< Display as the section name + offset.
- ///< \code
- /// // address for printf in libSystem.B.dylib as a section name + offset
- /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf
- /// \endcode
- DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset (debug output).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a section pointer + offset
- /// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode
- DumpStyleFileAddress, ///< Display as the file address (if any).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a file address
- /// 0x000000000005dcff \endcode
- DumpStyleModuleWithFileAddress, ///< Display as the file address with the module name prepended (if any).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a file address
- /// libSystem.B.dylib[0x000000000005dcff] \endcode
- DumpStyleLoadAddress, ///< Display as the load address (if resolved).
- ///< \code
- /// // address for printf in libSystem.B.dylib as a load address
- /// 0x00007fff8306bcff \endcode
- DumpStyleResolvedDescription, ///< Display the details about what an address resolves to. This can
- ///< be anything from a symbol context summary (module, function/symbol,
- ///< and file and line), to information about what the pointer points to
- ///< if the address is in a section (section of pointers, c strings, etc).
- DumpStyleResolvedDescriptionNoModule,
- DumpStyleResolvedDescriptionNoFunctionArguments,
- DumpStyleNoFunctionName, ///< Elide the function name; display an offset into the current function.
- ///< Used primarily in disassembly symbolication
- DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for an address for all symbol
- ///< context members.
- DumpStyleResolvedPointerDescription ///< Dereference a pointer at the current address and then lookup the
- ///< dereferenced address using DumpStyleResolvedDescription
- } DumpStyle;
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with a invalid section (NULL) and an invalid
- /// offset (LLDB_INVALID_ADDRESS).
- //------------------------------------------------------------------
- Address () :
- m_section_wp (),
- m_offset (LLDB_INVALID_ADDRESS)
- {
- }
+ //------------------------------------------------------------------
+ /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const
+ /// function to display Address contents in a variety of ways.
+ //------------------------------------------------------------------
+ typedef enum {
+ DumpStyleInvalid, ///< Invalid dump style
+ DumpStyleSectionNameOffset, ///< Display as the section name + offset.
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a section name + offset
+ /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf
+ /// \endcode
+ DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset
+ ///(debug output).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a section pointer + offset
+ /// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode
+ DumpStyleFileAddress, ///< Display as the file address (if any).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a file address
+ /// 0x000000000005dcff \endcode
+ DumpStyleModuleWithFileAddress, ///< Display as the file address with the
+ ///module name prepended (if any).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a file address
+ /// libSystem.B.dylib[0x000000000005dcff] \endcode
+ DumpStyleLoadAddress, ///< Display as the load address (if resolved).
+ ///< \code
+ /// // address for printf in libSystem.B.dylib as a load address
+ /// 0x00007fff8306bcff \endcode
+ DumpStyleResolvedDescription, ///< Display the details about what an address
+ ///resolves to. This can
+ ///< be anything from a symbol context summary (module, function/symbol,
+ ///< and file and line), to information about what the pointer points to
+ ///< if the address is in a section (section of pointers, c strings, etc).
+ DumpStyleResolvedDescriptionNoModule,
+ DumpStyleResolvedDescriptionNoFunctionArguments,
+ DumpStyleNoFunctionName, ///< Elide the function name; display an offset
+ ///into the current function.
+ ///< Used primarily in disassembly symbolication
+ DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for
+ ///an address for all symbol
+ ///< context members.
+ DumpStyleResolvedPointerDescription ///< Dereference a pointer at the
+ ///current address and then lookup the
+ ///< dereferenced address using DumpStyleResolvedDescription
+ } DumpStyle;
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with a invalid section (NULL) and an invalid
+ /// offset (LLDB_INVALID_ADDRESS).
+ //------------------------------------------------------------------
+ Address() : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {}
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Makes a copy of the another Address object \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const Address object reference to copy.
+ //------------------------------------------------------------------
+ Address(const Address &rhs)
+ : m_section_wp(rhs.m_section_wp), m_offset(rhs.m_offset) {}
+
+ //------------------------------------------------------------------
+ /// Construct with a section pointer and offset.
+ ///
+ /// Initialize the address with the supplied \a section and \a
+ /// offset.
+ ///
+ /// @param[in] section
+ /// A section pointer to a valid lldb::Section, or NULL if the
+ /// address doesn't have a section or will get resolved later.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into \a section.
+ //------------------------------------------------------------------
+ Address(const lldb::SectionSP §ion_sp, lldb::addr_t offset)
+ : m_section_wp(), // Don't init with section_sp in case section_sp is
+ // invalid (the weak_ptr will throw)
+ m_offset(offset) {
+ if (section_sp)
+ m_section_wp = section_sp;
+ }
+
+ //------------------------------------------------------------------
+ /// Construct with a virtual address and section list.
+ ///
+ /// Initialize and resolve the address with the supplied virtual
+ /// address \a file_addr.
+ ///
+ /// @param[in] file_addr
+ /// A virtual file address.
+ ///
+ /// @param[in] section_list
+ /// A list of sections, one of which may contain the \a file_addr.
+ //------------------------------------------------------------------
+ Address(lldb::addr_t file_addr, const SectionList *section_list);
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Makes a copy of the another Address object \a rhs.
- ///
- /// @param[in] rhs
- /// A const Address object reference to copy.
- //------------------------------------------------------------------
- Address (const Address& rhs) :
- m_section_wp (rhs.m_section_wp),
- m_offset(rhs.m_offset)
- {
- }
+ Address(lldb::addr_t abs_addr);
- //------------------------------------------------------------------
- /// Construct with a section pointer and offset.
- ///
- /// Initialize the address with the supplied \a section and \a
- /// offset.
- ///
- /// @param[in] section
- /// A section pointer to a valid lldb::Section, or NULL if the
- /// address doesn't have a section or will get resolved later.
- ///
- /// @param[in] offset
- /// The offset in bytes into \a section.
- //------------------------------------------------------------------
- Address (const lldb::SectionSP §ion_sp, lldb::addr_t offset) :
- m_section_wp (), // Don't init with section_sp in case section_sp is invalid (the weak_ptr will throw)
- m_offset (offset)
- {
- if (section_sp)
- m_section_wp = section_sp;
- }
-
- //------------------------------------------------------------------
- /// Construct with a virtual address and section list.
- ///
- /// Initialize and resolve the address with the supplied virtual
- /// address \a file_addr.
- ///
- /// @param[in] file_addr
- /// A virtual file address.
- ///
- /// @param[in] section_list
- /// A list of sections, one of which may contain the \a file_addr.
- //------------------------------------------------------------------
- Address (lldb::addr_t file_addr, const SectionList * section_list);
-
- Address (lldb::addr_t abs_addr);
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies the address value from another Address object \a rhs
- /// into \a this object.
- ///
- /// @param[in] rhs
- /// A const Address object reference to copy.
- ///
- /// @return
- /// A const Address object reference to \a this.
- //------------------------------------------------------------------
+//------------------------------------------------------------------
+/// Assignment operator.
+///
+/// Copies the address value from another Address object \a rhs
+/// into \a this object.
+///
+/// @param[in] rhs
+/// A const Address object reference to copy.
+///
+/// @return
+/// A const Address object reference to \a this.
+//------------------------------------------------------------------
#ifndef SWIG
- const Address&
- operator= (const Address& rhs);
+ const Address &operator=(const Address &rhs);
#endif
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the section to an invalid value (NULL) and an invalid
- /// offset (LLDB_INVALID_ADDRESS).
- //------------------------------------------------------------------
- void
- Clear ()
- {
- m_section_wp.reset();
- m_offset = LLDB_INVALID_ADDRESS;
- }
-
- //------------------------------------------------------------------
- /// Compare two Address objects.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const Address object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const Address object reference.
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- CompareFileAddress (const Address& lhs, const Address& rhs);
-
- static int
- CompareLoadAddress (const Address& lhs, const Address& rhs, Target *target);
-
- static int
- CompareModulePointerAndOffset (const Address& lhs, const Address& rhs);
-
- // For use with std::map, std::multi_map
- class ModulePointerAndOffsetLessThanFunctionObject
- {
- public:
- ModulePointerAndOffsetLessThanFunctionObject() = default;
-
- bool
- operator() (const Address& a, const Address& b) const
- {
- return Address::CompareModulePointerAndOffset(a, b) < 0;
- }
- };
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. There are many ways to display a section
- /// offset based address, and \a style lets the user choose.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] style
- /// The display style for the address.
- ///
- /// @param[in] fallback_style
- /// The display style for the address.
- ///
- /// @return
- /// Returns \b true if the address was able to be displayed.
- /// File and load addresses may be unresolved and it may not be
- /// possible to display a valid value, \b false will be returned
- /// in such cases.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- bool
- Dump (Stream *s,
- ExecutionContextScope *exe_scope,
- DumpStyle style,
- DumpStyle fallback_style = DumpStyleInvalid,
- uint32_t addr_byte_size = UINT32_MAX) const;
-
- lldb::AddressClass
- GetAddressClass () const;
-
- //------------------------------------------------------------------
- /// Get the file address.
- ///
- /// If an address comes from a file on disk that has section
- /// relative addresses, then it has a virtual address that is
- /// relative to unique section in the object file.
- ///
- /// @return
- /// The valid file virtual address, or LLDB_INVALID_ADDRESS if
- /// the address doesn't have a file virtual address (image is
- /// from memory only with no representation on disk).
- //------------------------------------------------------------------
- lldb::addr_t
- GetFileAddress () const;
-
- //------------------------------------------------------------------
- /// Get the load address.
- ///
- /// If an address comes from a file on disk that has section
- /// relative addresses, then it has a virtual address that is
- /// relative to unique section in the object file. Sections get
- /// resolved at runtime by DynamicLoader plug-ins as images
- /// (executables and shared libraries) get loaded/unloaded. If a
- /// section is loaded, then the load address can be resolved.
- ///
- /// @return
- /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
- /// the address is currently not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetLoadAddress (Target *target) const;
-
- //------------------------------------------------------------------
- /// Get the load address as a callable code load address.
- ///
- /// This function will first resolve its address to a load address.
- /// Then, if the address turns out to be in code address, return the
- /// load address that would be required to call or return to. The
- /// address might have extra bits set (bit zero will be set to Thumb
- /// functions for an ARM target) that are required when changing the
- /// program counter to setting a return address.
- ///
- /// @return
- /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
- /// the address is currently not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetCallableLoadAddress (Target *target, bool is_indirect = false) const;
-
- //------------------------------------------------------------------
- /// Get the load address as an opcode load address.
- ///
- /// This function will first resolve its address to a load address.
- /// Then, if the address turns out to be in code address, return the
- /// load address for an opcode. This address object might have
- /// extra bits set (bit zero will be set to Thumb functions for an
- /// ARM target) that are required for changing the program counter
- /// and this function will remove any bits that are intended for
- /// these special purposes. The result of this function can be used
- /// to safely write a software breakpoint trap to memory.
- ///
- /// @return
- /// The valid load virtual address with extra callable bits
- /// removed, or LLDB_INVALID_ADDRESS if the address is currently
- /// not loaded.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOpcodeLoadAddress (Target *target,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
-
- //------------------------------------------------------------------
- /// Get the section relative offset value.
- ///
- /// @return
- /// The current offset, or LLDB_INVALID_ADDRESS if this address
- /// doesn't contain a valid offset.
- //------------------------------------------------------------------
- lldb::addr_t
- GetOffset () const { return m_offset; }
-
- //------------------------------------------------------------------
- /// Check if an address is section offset.
- ///
- /// When converting a virtual file or load address into a section
- /// offset based address, we often need to know if, given a section
- /// list, if the address was able to be converted to section offset.
- /// This function returns true if the current value contained in
- /// this object is section offset based.
- ///
- /// @return
- /// Returns \b true if the address has a valid section and
- /// offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsSectionOffset() const
- {
- return IsValid() && (GetSection().get() != nullptr);
- }
-
- //------------------------------------------------------------------
- /// Check if the object state is valid.
- ///
- /// A valid Address object contains either a section pointer and
- /// and offset (for section offset based addresses), or just a valid
- /// offset (for absolute addresses that have no section).
- ///
- /// @return
- /// Returns \b true if the offset is valid, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsValid() const
- {
- return m_offset != LLDB_INVALID_ADDRESS;
- }
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //------------------------------------------------------------------
- /// Resolve a file virtual address using a section list.
- ///
- /// Given a list of sections, attempt to resolve \a addr as a
- /// an offset into one of the file sections.
- ///
- /// @return
- /// Returns \b true if \a addr was able to be resolved, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- ResolveAddressUsingFileSections (lldb::addr_t addr, const SectionList *sections);
-
- //------------------------------------------------------------------
- /// Set the address to represent \a load_addr.
- ///
- /// The address will attempt to find a loaded section within
- /// \a target that contains \a load_addr. If successful, this
- /// address object will have a valid section and offset. Else this
- /// address object will have no section (NULL) and the offset will
- /// be \a load_addr.
- ///
- /// @param[in] load_addr
- /// A load address from a current process.
- ///
- /// @param[in] target
- /// The target to use when trying resolve the address into
- /// a section + offset. The Target's SectionLoadList object
- /// is used to resolve the address.
- ///
- /// @return
- /// Returns \b true if the load address was resolved to be
- /// section/offset, \b false otherwise. It is often ok for an
- /// address no not resolve to a section in a module, this often
- /// happens for JIT'ed code, or any load addresses on the stack
- /// or heap.
- //------------------------------------------------------------------
- bool
- SetLoadAddress (lldb::addr_t load_addr, Target *target);
-
- bool
- SetOpcodeLoadAddress (lldb::addr_t load_addr,
- Target *target,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
-
- bool
- SetCallableLoadAddress (lldb::addr_t load_addr, Target *target);
-
- //------------------------------------------------------------------
- /// Get accessor for the module for this address.
- ///
- /// @return
- /// Returns the Module pointer that this address is an offset
- /// in, or NULL if this address doesn't belong in a module, or
- /// isn't resolved yet.
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModule () const;
-
- //------------------------------------------------------------------
- /// Get const accessor for the section.
- ///
- /// @return
- /// Returns the const lldb::Section pointer that this address is an
- /// offset in, or NULL if this address is absolute.
- //------------------------------------------------------------------
- lldb::SectionSP
- GetSection () const { return m_section_wp.lock(); }
-
- //------------------------------------------------------------------
- /// Set accessor for the offset.
- ///
- /// @param[in] offset
- /// A new offset value for this object.
- ///
- /// @return
- /// Returns \b true if the offset changed, \b false otherwise.
- //------------------------------------------------------------------
- bool
- SetOffset (lldb::addr_t offset)
- {
- bool changed = m_offset != offset;
- m_offset = offset;
- return changed;
- }
-
- void
- SetRawAddress (lldb::addr_t addr)
- {
- m_section_wp.reset();
- m_offset = addr;
- }
-
- bool
- Slide (int64_t offset)
- {
- if (m_offset != LLDB_INVALID_ADDRESS)
- {
- m_offset += offset;
- return true;
- }
- return false;
- }
-
- //------------------------------------------------------------------
- /// Set accessor for the section.
- ///
- /// @param[in] section
- /// A new lldb::Section pointer to use as the section base. Can
- /// be NULL for absolute addresses that are not relative to
- /// any section.
- //------------------------------------------------------------------
- void
- SetSection (const lldb::SectionSP §ion_sp)
- {
- m_section_wp = section_sp;
- }
-
- void
- ClearSection ()
- {
- m_section_wp.reset();
- }
-
- //------------------------------------------------------------------
- /// Reconstruct a symbol context from an address.
- ///
- /// This class doesn't inherit from SymbolContextScope because many
- /// address objects have short lifespans. Address objects that are
- /// section offset can reconstruct their symbol context by looking
- /// up the address in the module found in the section.
- ///
- /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- //------------------------------------------------------------------
- uint32_t
- CalculateSymbolContext (SymbolContext *sc,
- uint32_t resolve_scope = lldb::eSymbolContextEverything) const;
-
- lldb::ModuleSP
- CalculateSymbolContextModule () const;
-
- CompileUnit *
- CalculateSymbolContextCompileUnit () const;
-
- Function *
- CalculateSymbolContextFunction () const;
-
- Block *
- CalculateSymbolContextBlock () const;
-
- Symbol *
- CalculateSymbolContextSymbol () const;
-
- bool
- CalculateSymbolContextLineEntry (LineEntry &line_entry) const;
-
- //------------------------------------------------------------------
- // Returns true if the section should be valid, but isn't because
- // the shared pointer to the section can't be reconstructed from
- // a weak pointer that contains a valid weak reference to a section.
- // Returns false if the section weak pointer has no reference to
- // a section, or if the section is still valid
- //------------------------------------------------------------------
- bool
- SectionWasDeleted() const;
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the section to an invalid value (NULL) and an invalid
+ /// offset (LLDB_INVALID_ADDRESS).
+ //------------------------------------------------------------------
+ void Clear() {
+ m_section_wp.reset();
+ m_offset = LLDB_INVALID_ADDRESS;
+ }
+
+ //------------------------------------------------------------------
+ /// Compare two Address objects.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const Address object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const Address object reference.
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int CompareFileAddress(const Address &lhs, const Address &rhs);
+
+ static int CompareLoadAddress(const Address &lhs, const Address &rhs,
+ Target *target);
+
+ static int CompareModulePointerAndOffset(const Address &lhs,
+ const Address &rhs);
+
+ // For use with std::map, std::multi_map
+ class ModulePointerAndOffsetLessThanFunctionObject {
+ public:
+ ModulePointerAndOffsetLessThanFunctionObject() = default;
+
+ bool operator()(const Address &a, const Address &b) const {
+ return Address::CompareModulePointerAndOffset(a, b) < 0;
+ }
+ };
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. There are many ways to display a section
+ /// offset based address, and \a style lets the user choose.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] style
+ /// The display style for the address.
+ ///
+ /// @param[in] fallback_style
+ /// The display style for the address.
+ ///
+ /// @return
+ /// Returns \b true if the address was able to be displayed.
+ /// File and load addresses may be unresolved and it may not be
+ /// possible to display a valid value, \b false will be returned
+ /// in such cases.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
+ DumpStyle fallback_style = DumpStyleInvalid,
+ uint32_t addr_byte_size = UINT32_MAX) const;
+
+ lldb::AddressClass GetAddressClass() const;
+
+ //------------------------------------------------------------------
+ /// Get the file address.
+ ///
+ /// If an address comes from a file on disk that has section
+ /// relative addresses, then it has a virtual address that is
+ /// relative to unique section in the object file.
+ ///
+ /// @return
+ /// The valid file virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address doesn't have a file virtual address (image is
+ /// from memory only with no representation on disk).
+ //------------------------------------------------------------------
+ lldb::addr_t GetFileAddress() const;
+
+ //------------------------------------------------------------------
+ /// Get the load address.
+ ///
+ /// If an address comes from a file on disk that has section
+ /// relative addresses, then it has a virtual address that is
+ /// relative to unique section in the object file. Sections get
+ /// resolved at runtime by DynamicLoader plug-ins as images
+ /// (executables and shared libraries) get loaded/unloaded. If a
+ /// section is loaded, then the load address can be resolved.
+ ///
+ /// @return
+ /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address is currently not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetLoadAddress(Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Get the load address as a callable code load address.
+ ///
+ /// This function will first resolve its address to a load address.
+ /// Then, if the address turns out to be in code address, return the
+ /// load address that would be required to call or return to. The
+ /// address might have extra bits set (bit zero will be set to Thumb
+ /// functions for an ARM target) that are required when changing the
+ /// program counter to setting a return address.
+ ///
+ /// @return
+ /// The valid load virtual address, or LLDB_INVALID_ADDRESS if
+ /// the address is currently not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetCallableLoadAddress(Target *target,
+ bool is_indirect = false) const;
+
+ //------------------------------------------------------------------
+ /// Get the load address as an opcode load address.
+ ///
+ /// This function will first resolve its address to a load address.
+ /// Then, if the address turns out to be in code address, return the
+ /// load address for an opcode. This address object might have
+ /// extra bits set (bit zero will be set to Thumb functions for an
+ /// ARM target) that are required for changing the program counter
+ /// and this function will remove any bits that are intended for
+ /// these special purposes. The result of this function can be used
+ /// to safely write a software breakpoint trap to memory.
+ ///
+ /// @return
+ /// The valid load virtual address with extra callable bits
+ /// removed, or LLDB_INVALID_ADDRESS if the address is currently
+ /// not loaded.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOpcodeLoadAddress(
+ Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
+
+ //------------------------------------------------------------------
+ /// Get the section relative offset value.
+ ///
+ /// @return
+ /// The current offset, or LLDB_INVALID_ADDRESS if this address
+ /// doesn't contain a valid offset.
+ //------------------------------------------------------------------
+ lldb::addr_t GetOffset() const { return m_offset; }
+
+ //------------------------------------------------------------------
+ /// Check if an address is section offset.
+ ///
+ /// When converting a virtual file or load address into a section
+ /// offset based address, we often need to know if, given a section
+ /// list, if the address was able to be converted to section offset.
+ /// This function returns true if the current value contained in
+ /// this object is section offset based.
+ ///
+ /// @return
+ /// Returns \b true if the address has a valid section and
+ /// offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsSectionOffset() const {
+ return IsValid() && (GetSection().get() != nullptr);
+ }
+
+ //------------------------------------------------------------------
+ /// Check if the object state is valid.
+ ///
+ /// A valid Address object contains either a section pointer and
+ /// and offset (for section offset based addresses), or just a valid
+ /// offset (for absolute addresses that have no section).
+ ///
+ /// @return
+ /// Returns \b true if the offset is valid, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const { return m_offset != LLDB_INVALID_ADDRESS; }
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //------------------------------------------------------------------
+ /// Resolve a file virtual address using a section list.
+ ///
+ /// Given a list of sections, attempt to resolve \a addr as a
+ /// an offset into one of the file sections.
+ ///
+ /// @return
+ /// Returns \b true if \a addr was able to be resolved, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool ResolveAddressUsingFileSections(lldb::addr_t addr,
+ const SectionList *sections);
+
+ //------------------------------------------------------------------
+ /// Set the address to represent \a load_addr.
+ ///
+ /// The address will attempt to find a loaded section within
+ /// \a target that contains \a load_addr. If successful, this
+ /// address object will have a valid section and offset. Else this
+ /// address object will have no section (NULL) and the offset will
+ /// be \a load_addr.
+ ///
+ /// @param[in] load_addr
+ /// A load address from a current process.
+ ///
+ /// @param[in] target
+ /// The target to use when trying resolve the address into
+ /// a section + offset. The Target's SectionLoadList object
+ /// is used to resolve the address.
+ ///
+ /// @return
+ /// Returns \b true if the load address was resolved to be
+ /// section/offset, \b false otherwise. It is often ok for an
+ /// address no not resolve to a section in a module, this often
+ /// happens for JIT'ed code, or any load addresses on the stack
+ /// or heap.
+ //------------------------------------------------------------------
+ bool SetLoadAddress(lldb::addr_t load_addr, Target *target);
+
+ bool SetOpcodeLoadAddress(
+ lldb::addr_t load_addr, Target *target,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+
+ bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module for this address.
+ ///
+ /// @return
+ /// Returns the Module pointer that this address is an offset
+ /// in, or NULL if this address doesn't belong in a module, or
+ /// isn't resolved yet.
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModule() const;
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the section.
+ ///
+ /// @return
+ /// Returns the const lldb::Section pointer that this address is an
+ /// offset in, or NULL if this address is absolute.
+ //------------------------------------------------------------------
+ lldb::SectionSP GetSection() const { return m_section_wp.lock(); }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the offset.
+ ///
+ /// @param[in] offset
+ /// A new offset value for this object.
+ ///
+ /// @return
+ /// Returns \b true if the offset changed, \b false otherwise.
+ //------------------------------------------------------------------
+ bool SetOffset(lldb::addr_t offset) {
+ bool changed = m_offset != offset;
+ m_offset = offset;
+ return changed;
+ }
+
+ void SetRawAddress(lldb::addr_t addr) {
+ m_section_wp.reset();
+ m_offset = addr;
+ }
+
+ bool Slide(int64_t offset) {
+ if (m_offset != LLDB_INVALID_ADDRESS) {
+ m_offset += offset;
+ return true;
+ }
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the section.
+ ///
+ /// @param[in] section
+ /// A new lldb::Section pointer to use as the section base. Can
+ /// be NULL for absolute addresses that are not relative to
+ /// any section.
+ //------------------------------------------------------------------
+ void SetSection(const lldb::SectionSP §ion_sp) {
+ m_section_wp = section_sp;
+ }
+
+ void ClearSection() { m_section_wp.reset(); }
+
+ //------------------------------------------------------------------
+ /// Reconstruct a symbol context from an address.
+ ///
+ /// This class doesn't inherit from SymbolContextScope because many
+ /// address objects have short lifespans. Address objects that are
+ /// section offset can reconstruct their symbol context by looking
+ /// up the address in the module found in the section.
+ ///
+ /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ //------------------------------------------------------------------
+ uint32_t CalculateSymbolContext(
+ SymbolContext *sc,
+ uint32_t resolve_scope = lldb::eSymbolContextEverything) const;
+
+ lldb::ModuleSP CalculateSymbolContextModule() const;
+
+ CompileUnit *CalculateSymbolContextCompileUnit() const;
+
+ Function *CalculateSymbolContextFunction() const;
+
+ Block *CalculateSymbolContextBlock() const;
+
+ Symbol *CalculateSymbolContextSymbol() const;
+
+ bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const;
+
+ //------------------------------------------------------------------
+ // Returns true if the section should be valid, but isn't because
+ // the shared pointer to the section can't be reconstructed from
+ // a weak pointer that contains a valid weak reference to a section.
+ // Returns false if the section weak pointer has no reference to
+ // a section, or if the section is still valid
+ //------------------------------------------------------------------
+ bool SectionWasDeleted() const;
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
- lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid...
-
- //------------------------------------------------------------------
- // Returns true if the m_section_wp once had a reference to a valid
- // section shared pointer, but no longer does. This can happen if
- // we have an address from a module that gets unloaded and deleted.
- // This function should only be called if GetSection() returns an
- // empty shared pointer and you want to know if this address used to
- // have a valid section.
- //------------------------------------------------------------------
- bool
- SectionWasDeletedPrivate() const;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
+ lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid...
+
+ //------------------------------------------------------------------
+ // Returns true if the m_section_wp once had a reference to a valid
+ // section shared pointer, but no longer does. This can happen if
+ // we have an address from a module that gets unloaded and deleted.
+ // This function should only be called if GetSection() returns an
+ // empty shared pointer and you want to know if this address used to
+ // have a valid section.
+ //------------------------------------------------------------------
+ bool SectionWasDeletedPrivate() const;
};
//----------------------------------------------------------------------
-// NOTE: Be careful using this operator. It can correctly compare two
-// addresses from the same Module correctly. It can't compare two
+// NOTE: Be careful using this operator. It can correctly compare two
+// addresses from the same Module correctly. It can't compare two
// addresses from different modules in any meaningful way, but it will
// compare the module pointers.
-//
+//
// To sum things up:
// - works great for addresses within the same module
// - it works for addresses across multiple modules, but don't expect the
// address results to make much sense
//
-// This basically lets Address objects be used in ordered collection
+// This basically lets Address objects be used in ordered collection
// classes.
//----------------------------------------------------------------------
-bool operator< (const Address& lhs, const Address& rhs);
-bool operator> (const Address& lhs, const Address& rhs);
-bool operator== (const Address& lhs, const Address& rhs);
-bool operator!= (const Address& lhs, const Address& rhs);
+bool operator<(const Address &lhs, const Address &rhs);
+bool operator>(const Address &lhs, const Address &rhs);
+bool operator==(const Address &lhs, const Address &rhs);
+bool operator!=(const Address &lhs, const Address &rhs);
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/AddressRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressRange.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/AddressRange.h (original)
+++ lldb/trunk/include/lldb/Core/AddressRange.h Tue Sep 6 15:57:50 2016
@@ -22,266 +22,257 @@ namespace lldb_private {
/// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h"
/// @brief A section + offset based address range class.
//----------------------------------------------------------------------
-class AddressRange
-{
+class AddressRange {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with a invalid section (NULL), an invalid
- /// offset (LLDB_INVALID_ADDRESS), and zero byte size.
- //------------------------------------------------------------------
- AddressRange ();
-
- //------------------------------------------------------------------
- /// Construct with a section pointer, offset, and byte_size.
- ///
- /// Initialize the address with the supplied \a section, \a
- /// offset and \a byte_size.
- ///
- /// @param[in] section
- /// A section pointer to a valid lldb::Section, or NULL if the
- /// address doesn't have a section or will get resolved later.
- ///
- /// @param[in] offset
- /// The offset in bytes into \a section.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- //------------------------------------------------------------------
- AddressRange (const lldb::SectionSP §ion, lldb::addr_t offset, lldb::addr_t byte_size);
-
- //------------------------------------------------------------------
- /// Construct with a virtual address, section list and byte size.
- ///
- /// Initialize and resolve the address with the supplied virtual
- /// address \a file_addr, and byte size \a byte_size.
- ///
- /// @param[in] file_addr
- /// A virtual address.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- ///
- /// @param[in] section_list
- /// A list of sections, one of which may contain the \a vaddr.
- //------------------------------------------------------------------
- AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = nullptr);
-
- //------------------------------------------------------------------
- /// Construct with a Address object address and byte size.
- ///
- /// Initialize by copying the section offset address in \a so_addr,
- /// and setting the byte size to \a byte_size.
- ///
- /// @param[in] so_addr
- /// A section offset address object.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the address range.
- //------------------------------------------------------------------
- AddressRange (const Address& so_addr, lldb::addr_t byte_size);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual in case this class is subclassed.
- //------------------------------------------------------------------
- ~AddressRange ();
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Sets the section to an invalid value (NULL), an invalid offset
- /// (LLDB_INVALID_ADDRESS) and a zero byte size.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Check if a section offset address is contained in this range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if \a so_addr is contained in this range,
- /// \b false otherwise.
- //------------------------------------------------------------------
-// bool
-// Contains (const Address &so_addr) const;
-
- //------------------------------------------------------------------
- /// Check if a section offset address is contained in this range.
- ///
- /// @param[in] so_addr_ptr
- /// A section offset address object pointer.
- ///
- /// @return
- /// Returns \b true if \a so_addr is contained in this range,
- /// \b false otherwise.
- //------------------------------------------------------------------
-// bool
-// Contains (const Address *so_addr_ptr) const;
-
- //------------------------------------------------------------------
- /// Check if a section offset \a so_addr when represented as a file
- /// address is contained within this object's file address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this and \a so_addr have
- /// resolvable file address values and \a so_addr is contained
- /// in the address range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsFileAddress (const Address &so_addr) const;
-
- //------------------------------------------------------------------
- /// Check if the resolved file address \a file_addr is contained
- /// within this object's file address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this has a resolvable file
- /// address value and \a so_addr is contained in the address
- /// range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsFileAddress (lldb::addr_t file_addr) const;
-
- //------------------------------------------------------------------
- /// Check if a section offset \a so_addr when represented as a load
- /// address is contained within this object's load address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this and \a so_addr have
- /// resolvable load address values and \a so_addr is contained
- /// in the address range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsLoadAddress (const Address &so_addr, Target *target) const;
-
- //------------------------------------------------------------------
- /// Check if the resolved load address \a load_addr is contained
- /// within this object's load address range.
- ///
- /// @param[in] so_addr
- /// A section offset address object reference.
- ///
- /// @return
- /// Returns \b true if both \a this has a resolvable load
- /// address value and \a so_addr is contained in the address
- /// range, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ContainsLoadAddress (lldb::addr_t load_addr, Target *target) const;
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. There are many ways to display a section
- /// offset based address range, and \a style lets the user choose
- /// how the base address gets displayed.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @param[in] style
- /// The display style for the address.
- ///
- /// @return
- /// Returns \b true if the address was able to be displayed.
- /// File and load addresses may be unresolved and it may not be
- /// possible to display a valid value, \b false will be returned
- /// in such cases.
- ///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
- bool
- Dump (Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const;
-
- //------------------------------------------------------------------
- /// Dump a debug description of this object to a Stream.
- ///
- /// Dump a debug description of the contents of this object to the
- /// supplied stream \a s.
- ///
- /// The debug description contains verbose internal state such
- /// and pointer values, reference counts, etc.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Get accessor for the base address of the range.
- ///
- /// @return
- /// A reference to the base address object.
- //------------------------------------------------------------------
- Address &
- GetBaseAddress() { return m_base_addr; }
-
- //------------------------------------------------------------------
- /// Get const accessor for the base address of the range.
- ///
- /// @return
- /// A const reference to the base address object.
- //------------------------------------------------------------------
- const Address &
- GetBaseAddress() const { return m_base_addr; }
-
- //------------------------------------------------------------------
- /// Get accessor for the byte size of this range.
- ///
- /// @return
- /// The size in bytes of this address range.
- //------------------------------------------------------------------
- lldb::addr_t
- GetByteSize () const { return m_byte_size; }
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize () const {
- // Noting special for the memory size of a single AddressRange object,
- // it is just the size of itself.
- return sizeof(AddressRange);
- }
-
- //------------------------------------------------------------------
- /// Set accessor for the byte size of this range.
- ///
- /// @param[in] byte_size
- /// The new size in bytes of this address range.
- //------------------------------------------------------------------
- void
- SetByteSize (lldb::addr_t byte_size) { m_byte_size = byte_size; }
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with a invalid section (NULL), an invalid
+ /// offset (LLDB_INVALID_ADDRESS), and zero byte size.
+ //------------------------------------------------------------------
+ AddressRange();
+
+ //------------------------------------------------------------------
+ /// Construct with a section pointer, offset, and byte_size.
+ ///
+ /// Initialize the address with the supplied \a section, \a
+ /// offset and \a byte_size.
+ ///
+ /// @param[in] section
+ /// A section pointer to a valid lldb::Section, or NULL if the
+ /// address doesn't have a section or will get resolved later.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into \a section.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ //------------------------------------------------------------------
+ AddressRange(const lldb::SectionSP §ion, lldb::addr_t offset,
+ lldb::addr_t byte_size);
+
+ //------------------------------------------------------------------
+ /// Construct with a virtual address, section list and byte size.
+ ///
+ /// Initialize and resolve the address with the supplied virtual
+ /// address \a file_addr, and byte size \a byte_size.
+ ///
+ /// @param[in] file_addr
+ /// A virtual address.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ ///
+ /// @param[in] section_list
+ /// A list of sections, one of which may contain the \a vaddr.
+ //------------------------------------------------------------------
+ AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size,
+ const SectionList *section_list = nullptr);
+
+ //------------------------------------------------------------------
+ /// Construct with a Address object address and byte size.
+ ///
+ /// Initialize by copying the section offset address in \a so_addr,
+ /// and setting the byte size to \a byte_size.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the address range.
+ //------------------------------------------------------------------
+ AddressRange(const Address &so_addr, lldb::addr_t byte_size);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual in case this class is subclassed.
+ //------------------------------------------------------------------
+ ~AddressRange();
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Sets the section to an invalid value (NULL), an invalid offset
+ /// (LLDB_INVALID_ADDRESS) and a zero byte size.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Check if a section offset address is contained in this range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if \a so_addr is contained in this range,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ // bool
+ // Contains (const Address &so_addr) const;
+
+ //------------------------------------------------------------------
+ /// Check if a section offset address is contained in this range.
+ ///
+ /// @param[in] so_addr_ptr
+ /// A section offset address object pointer.
+ ///
+ /// @return
+ /// Returns \b true if \a so_addr is contained in this range,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ // bool
+ // Contains (const Address *so_addr_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Check if a section offset \a so_addr when represented as a file
+ /// address is contained within this object's file address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this and \a so_addr have
+ /// resolvable file address values and \a so_addr is contained
+ /// in the address range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsFileAddress(const Address &so_addr) const;
+
+ //------------------------------------------------------------------
+ /// Check if the resolved file address \a file_addr is contained
+ /// within this object's file address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this has a resolvable file
+ /// address value and \a so_addr is contained in the address
+ /// range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsFileAddress(lldb::addr_t file_addr) const;
+
+ //------------------------------------------------------------------
+ /// Check if a section offset \a so_addr when represented as a load
+ /// address is contained within this object's load address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this and \a so_addr have
+ /// resolvable load address values and \a so_addr is contained
+ /// in the address range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsLoadAddress(const Address &so_addr, Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Check if the resolved load address \a load_addr is contained
+ /// within this object's load address range.
+ ///
+ /// @param[in] so_addr
+ /// A section offset address object reference.
+ ///
+ /// @return
+ /// Returns \b true if both \a this has a resolvable load
+ /// address value and \a so_addr is contained in the address
+ /// range, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ContainsLoadAddress(lldb::addr_t load_addr, Target *target) const;
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. There are many ways to display a section
+ /// offset based address range, and \a style lets the user choose
+ /// how the base address gets displayed.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @param[in] style
+ /// The display style for the address.
+ ///
+ /// @return
+ /// Returns \b true if the address was able to be displayed.
+ /// File and load addresses may be unresolved and it may not be
+ /// possible to display a valid value, \b false will be returned
+ /// in such cases.
+ ///
+ /// @see Address::DumpStyle
+ //------------------------------------------------------------------
+ bool
+ Dump(Stream *s, Target *target, Address::DumpStyle style,
+ Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const;
+
+ //------------------------------------------------------------------
+ /// Dump a debug description of this object to a Stream.
+ ///
+ /// Dump a debug description of the contents of this object to the
+ /// supplied stream \a s.
+ ///
+ /// The debug description contains verbose internal state such
+ /// and pointer values, reference counts, etc.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Get accessor for the base address of the range.
+ ///
+ /// @return
+ /// A reference to the base address object.
+ //------------------------------------------------------------------
+ Address &GetBaseAddress() { return m_base_addr; }
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the base address of the range.
+ ///
+ /// @return
+ /// A const reference to the base address object.
+ //------------------------------------------------------------------
+ const Address &GetBaseAddress() const { return m_base_addr; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the byte size of this range.
+ ///
+ /// @return
+ /// The size in bytes of this address range.
+ //------------------------------------------------------------------
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ //------------------------------------------------------------------
+ size_t MemorySize() const {
+ // Noting special for the memory size of a single AddressRange object,
+ // it is just the size of itself.
+ return sizeof(AddressRange);
+ }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the byte size of this range.
+ ///
+ /// @param[in] byte_size
+ /// The new size in bytes of this address range.
+ //------------------------------------------------------------------
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Address m_base_addr; ///< The section offset base address of this range.
- lldb::addr_t m_byte_size; ///< The size in bytes of this address range.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Address m_base_addr; ///< The section offset base address of this range.
+ lldb::addr_t m_byte_size; ///< The size in bytes of this address range.
};
-//bool operator== (const AddressRange& lhs, const AddressRange& rhs);
+// bool operator== (const AddressRange& lhs, const AddressRange& rhs);
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/AddressResolver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressResolver.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/AddressResolver.h (original)
+++ lldb/trunk/include/lldb/Core/AddressResolver.h Tue Sep 6 15:57:50 2016
@@ -16,12 +16,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Core/SearchFilter.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -35,52 +35,38 @@ namespace lldb_private {
/// General Outline:
/// The AddressResolver is a Searcher. In that protocol,
/// the SearchFilter asks the question "At what depth of the symbol context
-/// descent do you want your callback to get called?" of the filter. The resolver
-/// answers this question (in the GetDepth method) and provides the resolution callback.
+/// descent do you want your callback to get called?" of the filter. The
+/// resolver
+/// answers this question (in the GetDepth method) and provides the resolution
+/// callback.
//----------------------------------------------------------------------
-class AddressResolver :
- public Searcher
-{
+class AddressResolver : public Searcher {
public:
+ typedef enum { Exact, Regexp, Glob } MatchType;
- typedef enum
- {
- Exact,
- Regexp,
- Glob
- } MatchType;
-
+ AddressResolver();
- AddressResolver ();
+ ~AddressResolver() override;
- ~AddressResolver () override;
+ virtual void ResolveAddress(SearchFilter &filter);
- virtual void
- ResolveAddress (SearchFilter &filter);
+ virtual void ResolveAddressInModules(SearchFilter &filter,
+ ModuleList &modules);
- virtual void
- ResolveAddressInModules (SearchFilter &filter,
- ModuleList &modules);
+ void GetDescription(Stream *s) override = 0;
- void
- GetDescription (Stream *s) override = 0;
+ std::vector<AddressRange> &GetAddressRanges();
- std::vector<AddressRange> &
- GetAddressRanges ();
+ size_t GetNumberOfAddresses();
- size_t
- GetNumberOfAddresses ();
-
- AddressRange &
- GetAddressRangeAtIndex (size_t idx);
+ AddressRange &GetAddressRangeAtIndex(size_t idx);
protected:
-
- std::vector<AddressRange> m_address_ranges;
+ std::vector<AddressRange> m_address_ranges;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolver);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolver);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/AddressResolverFileLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressResolverFileLine.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/AddressResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Core/AddressResolverFileLine.h Tue Sep 6 15:57:50 2016
@@ -16,41 +16,36 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class AddressResolverFileLine AddressResolverFileLine.h "lldb/Core/AddressResolverFileLine.h"
-/// @brief This class finds address for source file and line. Optionally, it will look for inlined
+/// @class AddressResolverFileLine AddressResolverFileLine.h
+/// "lldb/Core/AddressResolverFileLine.h"
+/// @brief This class finds address for source file and line. Optionally, it
+/// will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class AddressResolverFileLine :
- public AddressResolver
-{
+class AddressResolverFileLine : public AddressResolver {
public:
+ AddressResolverFileLine(const FileSpec &resolver, uint32_t line_no,
+ bool check_inlines);
- AddressResolverFileLine (const FileSpec &resolver,
- uint32_t line_no,
- bool check_inlines);
-
- ~AddressResolverFileLine () override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ ~AddressResolverFileLine() override;
- Searcher::Depth
- GetDepth () override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- void
- GetDescription (Stream *s) override;
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
protected:
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/AddressResolverName.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressResolverName.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/AddressResolverName.h (original)
+++ lldb/trunk/include/lldb/Core/AddressResolverName.h Tue Sep 6 15:57:50 2016
@@ -18,48 +18,44 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class AddressResolverName AddressResolverName.h "lldb/Core/AddressResolverName.h"
-/// @brief This class finds addresses for a given function name, either by exact match
+/// @class AddressResolverName AddressResolverName.h
+/// "lldb/Core/AddressResolverName.h"
+/// @brief This class finds addresses for a given function name, either by exact
+/// match
/// or by regular expression.
//----------------------------------------------------------------------
-class AddressResolverName:
- public AddressResolver
-{
+class AddressResolverName : public AddressResolver {
public:
+ AddressResolverName(const char *func_name,
+ AddressResolver::MatchType type = Exact);
- AddressResolverName (const char *func_name,
- AddressResolver::MatchType type = Exact);
+ // Creates a function breakpoint by regular expression. Takes over control of
+ // the lifespan of func_regex.
+ AddressResolverName(RegularExpression &func_regex);
- // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
- AddressResolverName (RegularExpression &func_regex);
+ AddressResolverName(const char *class_name, const char *method,
+ AddressResolver::MatchType type);
- AddressResolverName (const char *class_name,
- const char *method,
- AddressResolver::MatchType type);
+ ~AddressResolverName() override;
- ~AddressResolverName () override;
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
+ Searcher::Depth GetDepth() override;
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
+ void GetDescription(Stream *s) override;
protected:
- ConstString m_func_name;
- ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop on methods of this class.
- RegularExpression m_regex;
- AddressResolver::MatchType m_match_type;
+ ConstString m_func_name;
+ ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop
+ // on methods of this class.
+ RegularExpression m_regex;
+ AddressResolver::MatchType m_match_type;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
+ DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Tue Sep 6 15:57:50 2016
@@ -12,13 +12,13 @@
#if defined(__cplusplus)
-#include "lldb/lldb-forward.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-forward.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
-struct CoreDefinition;
+struct CoreDefinition;
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
@@ -29,673 +29,586 @@ struct CoreDefinition;
/// conversions of strings to architecture enumeration values confined
/// to this class allows new architecture support to be added easily.
//----------------------------------------------------------------------
-class ArchSpec
-{
+class ArchSpec {
public:
- enum MIPSSubType
- {
- eMIPSSubType_unknown,
- eMIPSSubType_mips32,
- eMIPSSubType_mips32r2,
- eMIPSSubType_mips32r6,
- eMIPSSubType_mips32el,
- eMIPSSubType_mips32r2el,
- eMIPSSubType_mips32r6el,
- eMIPSSubType_mips64,
- eMIPSSubType_mips64r2,
- eMIPSSubType_mips64r6,
- eMIPSSubType_mips64el,
- eMIPSSubType_mips64r2el,
- eMIPSSubType_mips64r6el,
- };
-
- // Masks for the ases word of an ABI flags structure.
- enum MIPSASE
- {
- eMIPSAse_dsp = 0x00000001, // DSP ASE
- eMIPSAse_dspr2 = 0x00000002, // DSP R2 ASE
- eMIPSAse_eva = 0x00000004, // Enhanced VA Scheme
- eMIPSAse_mcu = 0x00000008, // MCU (MicroController) ASE
- eMIPSAse_mdmx = 0x00000010, // MDMX ASE
- eMIPSAse_mips3d = 0x00000020, // MIPS-3D ASE
- eMIPSAse_mt = 0x00000040, // MT ASE
- eMIPSAse_smartmips = 0x00000080, // SmartMIPS ASE
- eMIPSAse_virt = 0x00000100, // VZ ASE
- eMIPSAse_msa = 0x00000200, // MSA ASE
- eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
- eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
- eMIPSAse_xpa = 0x00001000, // XPA ASE
- eMIPSAse_mask = 0x00001fff,
- eMIPSABI_O32 = 0x00002000,
- eMIPSABI_N32 = 0x00004000,
- eMIPSABI_N64 = 0x00008000,
- eMIPSABI_O64 = 0x00020000,
- eMIPSABI_EABI32 = 0x00040000,
- eMIPSABI_EABI64 = 0x00080000,
- eMIPSABI_mask = 0x000ff000
- };
-
- // MIPS Floating point ABI Values
- enum MIPS_ABI_FP
- {
- eMIPS_ABI_FP_ANY = 0x00000000,
- eMIPS_ABI_FP_DOUBLE = 0x00100000, // hard float / -mdouble-float
- eMIPS_ABI_FP_SINGLE = 0x00200000, // hard float / -msingle-float
- eMIPS_ABI_FP_SOFT = 0x00300000, // soft float
- eMIPS_ABI_FP_OLD_64 = 0x00400000, // -mips32r2 -mfp64
- eMIPS_ABI_FP_XX = 0x00500000, // -mfpxx
- eMIPS_ABI_FP_64 = 0x00600000, // -mips32r2 -mfp64
- eMIPS_ABI_FP_64A = 0x00700000, // -mips32r2 -mfp64 -mno-odd-spreg
- eMIPS_ABI_FP_mask = 0x00700000
- };
-
- // ARM specific e_flags
- enum ARMeflags
- {
- eARM_abi_soft_float = 0x00000200,
- eARM_abi_hard_float = 0x00000400
- };
-
- enum Core
- {
- eCore_arm_generic,
- eCore_arm_armv4,
- eCore_arm_armv4t,
- eCore_arm_armv5,
- eCore_arm_armv5e,
- eCore_arm_armv5t,
- eCore_arm_armv6,
- eCore_arm_armv6m,
- eCore_arm_armv7,
- eCore_arm_armv7f,
- eCore_arm_armv7s,
- eCore_arm_armv7k,
- eCore_arm_armv7m,
- eCore_arm_armv7em,
- eCore_arm_xscale,
-
- eCore_thumb,
- eCore_thumbv4t,
- eCore_thumbv5,
- eCore_thumbv5e,
- eCore_thumbv6,
- eCore_thumbv6m,
- eCore_thumbv7,
- eCore_thumbv7s,
- eCore_thumbv7k,
- eCore_thumbv7f,
- eCore_thumbv7m,
- eCore_thumbv7em,
- eCore_arm_arm64,
- eCore_arm_armv8,
- eCore_arm_aarch64,
-
- eCore_mips32,
- eCore_mips32r2,
- eCore_mips32r3,
- eCore_mips32r5,
- eCore_mips32r6,
- eCore_mips32el,
- eCore_mips32r2el,
- eCore_mips32r3el,
- eCore_mips32r5el,
- eCore_mips32r6el,
- eCore_mips64,
- eCore_mips64r2,
- eCore_mips64r3,
- eCore_mips64r5,
- eCore_mips64r6,
- eCore_mips64el,
- eCore_mips64r2el,
- eCore_mips64r3el,
- eCore_mips64r5el,
- eCore_mips64r6el,
-
- eCore_ppc_generic,
- eCore_ppc_ppc601,
- eCore_ppc_ppc602,
- eCore_ppc_ppc603,
- eCore_ppc_ppc603e,
- eCore_ppc_ppc603ev,
- eCore_ppc_ppc604,
- eCore_ppc_ppc604e,
- eCore_ppc_ppc620,
- eCore_ppc_ppc750,
- eCore_ppc_ppc7400,
- eCore_ppc_ppc7450,
- eCore_ppc_ppc970,
-
- eCore_ppc64_generic,
- eCore_ppc64_ppc970_64,
-
- eCore_s390x_generic,
-
- eCore_sparc_generic,
-
- eCore_sparc9_generic,
-
- eCore_x86_32_i386,
- eCore_x86_32_i486,
- eCore_x86_32_i486sx,
- eCore_x86_32_i686,
-
- eCore_x86_64_x86_64,
- eCore_x86_64_x86_64h, // Haswell enabled x86_64
- eCore_hexagon_generic,
- eCore_hexagon_hexagonv4,
- eCore_hexagon_hexagonv5,
-
- eCore_uknownMach32,
- eCore_uknownMach64,
-
- eCore_kalimba3,
- eCore_kalimba4,
- eCore_kalimba5,
-
- kNumCores,
-
- kCore_invalid,
- // The following constants are used for wildcard matching only
- kCore_any,
- kCore_arm_any,
- kCore_ppc_any,
- kCore_ppc64_any,
- kCore_x86_32_any,
- kCore_x86_64_any,
- kCore_hexagon_any,
-
- kCore_arm_first = eCore_arm_generic,
- kCore_arm_last = eCore_arm_xscale,
-
- kCore_thumb_first = eCore_thumb,
- kCore_thumb_last = eCore_thumbv7em,
-
- kCore_ppc_first = eCore_ppc_generic,
- kCore_ppc_last = eCore_ppc_ppc970,
-
- kCore_ppc64_first = eCore_ppc64_generic,
- kCore_ppc64_last = eCore_ppc64_ppc970_64,
-
- kCore_x86_32_first = eCore_x86_32_i386,
- kCore_x86_32_last = eCore_x86_32_i686,
-
- kCore_x86_64_first = eCore_x86_64_x86_64,
- kCore_x86_64_last = eCore_x86_64_x86_64h,
-
- kCore_hexagon_first = eCore_hexagon_generic,
- kCore_hexagon_last = eCore_hexagon_hexagonv5,
-
- kCore_kalimba_first = eCore_kalimba3,
- kCore_kalimba_last = eCore_kalimba5,
-
- kCore_mips32_first = eCore_mips32,
- kCore_mips32_last = eCore_mips32r6,
-
- kCore_mips32el_first = eCore_mips32el,
- kCore_mips32el_last = eCore_mips32r6el,
-
- kCore_mips64_first = eCore_mips64,
- kCore_mips64_last = eCore_mips64r6,
-
- kCore_mips64el_first = eCore_mips64el,
- kCore_mips64el_last = eCore_mips64r6el,
-
- kCore_mips_first = eCore_mips32,
- kCore_mips_last = eCore_mips64r6el
-
- };
-
- typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Default constructor that initializes the object with invalid
- /// cpu type and subtype values.
- //------------------------------------------------------------------
- ArchSpec ();
-
- //------------------------------------------------------------------
- /// Constructor over triple.
- ///
- /// Constructs an ArchSpec with properties consistent with the given
- /// Triple.
- //------------------------------------------------------------------
- explicit
- ArchSpec (const llvm::Triple &triple);
- explicit
- ArchSpec (const char *triple_cstr);
- explicit
- ArchSpec (const char *triple_cstr, Platform *platform);
- //------------------------------------------------------------------
- /// Constructor over architecture name.
- ///
- /// Constructs an ArchSpec with properties consistent with the given
- /// object type and architecture name.
- //------------------------------------------------------------------
- explicit
- ArchSpec (ArchitectureType arch_type,
- uint32_t cpu_type,
- uint32_t cpu_subtype);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ArchSpec ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] rhs another ArchSpec object to copy.
- ///
- /// @return A const reference to this object.
- //------------------------------------------------------------------
- const ArchSpec&
- operator= (const ArchSpec& rhs);
-
- static size_t
- AutoComplete (const char *name,
- StringList &matches);
-
- //------------------------------------------------------------------
- /// Returns a static string representing the current architecture.
- ///
- /// @return A static string correcponding to the current
- /// architecture.
- //------------------------------------------------------------------
- const char *
- GetArchitectureName () const;
-
- //-----------------------------------------------------------------
- /// if MIPS architecture return true.
- ///
- /// @return a boolean value.
- //-----------------------------------------------------------------
- bool
- IsMIPS() const;
-
- //------------------------------------------------------------------
- /// Returns a string representing current architecture as a target CPU
- /// for tools like compiler, disassembler etc.
- ///
- /// @return A string representing target CPU for the current
- /// architecture.
- //------------------------------------------------------------------
- std::string
- GetClangTargetCPU ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object state back to a default invalid state.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Returns the size in bytes of an address of the current
- /// architecture.
- ///
- /// @return The byte size of an address of the current architecture.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const;
-
- //------------------------------------------------------------------
- /// Returns a machine family for the current architecture.
- ///
- /// @return An LLVM arch type.
- //------------------------------------------------------------------
- llvm::Triple::ArchType
- GetMachine () const;
-
- //------------------------------------------------------------------
- /// Returns the distribution id of the architecture.
- ///
- /// This will be something like "ubuntu", "fedora", etc. on Linux.
- ///
- /// @return A ConstString ref containing the distribution id,
- /// potentially empty.
- //------------------------------------------------------------------
- const ConstString&
- GetDistributionId () const;
-
- //------------------------------------------------------------------
- /// Set the distribution id of the architecture.
- ///
- /// This will be something like "ubuntu", "fedora", etc. on Linux.
- /// This should be the same value returned by
- /// HostInfo::GetDistributionId ().
- ///------------------------------------------------------------------
- void
- SetDistributionId (const char* distribution_id);
-
- //------------------------------------------------------------------
- /// Tests if this ArchSpec is valid.
- ///
- /// @return True if the current architecture is valid, false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsValid () const
- {
- return m_core >= eCore_arm_generic && m_core < kNumCores;
- }
-
- bool
- TripleVendorWasSpecified() const
- {
- return !m_triple.getVendorName().empty();
- }
-
- bool
- TripleVendorIsUnspecifiedUnknown() const
- {
- return m_triple.getVendor() == llvm::Triple::UnknownVendor && m_triple.getVendorName().empty();
- }
-
- bool
- TripleOSWasSpecified() const
- {
- return !m_triple.getOSName().empty();
- }
-
- bool
- TripleEnvironmentWasSpecified () const
- {
- return !m_triple.getEnvironmentName().empty();
- }
-
- bool
- TripleOSIsUnspecifiedUnknown() const
- {
- return m_triple.getOS() == llvm::Triple::UnknownOS && m_triple.getOSName().empty();
- }
-
- //------------------------------------------------------------------
- /// Merges fields from another ArchSpec into this ArchSpec.
- ///
- /// This will use the supplied ArchSpec to fill in any fields of
- /// the triple in this ArchSpec which were unspecified. This can
- /// be used to refine a generic ArchSpec with a more specific one.
- /// For example, if this ArchSpec's triple is something like
- /// i386-unknown-unknown-unknown, and we have a triple which is
- /// x64-pc-windows-msvc, then merging that triple into this one
- /// will result in the triple i386-pc-windows-msvc.
- ///
- //------------------------------------------------------------------
- void
- MergeFrom(const ArchSpec &other);
-
- //------------------------------------------------------------------
- /// Change the architecture object type, CPU type and OS type.
- ///
- /// @param[in] arch_type The object type of this ArchSpec.
- ///
- /// @param[in] cpu The required CPU type.
- ///
- /// @param[in] os The optional OS type
- /// The default value of 0 was chosen to from the ELF spec value
- /// ELFOSABI_NONE. ELF is the only one using this parameter. If another
- /// format uses this parameter and 0 does not work, use a value over
- /// 255 because in the ELF header this is value is only a byte.
- ///
- /// @return True if the object, and CPU were successfully set.
- ///
- /// As a side effect, the vendor value is usually set to unknown.
- /// The exections are
- /// aarch64-apple-ios
- /// arm-apple-ios
- /// thumb-apple-ios
- /// x86-apple-
- /// x86_64-apple-
- ///
- /// As a side effect, the os value is usually set to unknown
- /// The exceptions are
- /// *-*-aix
- /// aarch64-apple-ios
- /// arm-apple-ios
- /// thumb-apple-ios
- /// powerpc-apple-darwin
- /// *-*-freebsd
- /// *-*-linux
- /// *-*-netbsd
- /// *-*-openbsd
- /// *-*-solaris
- //------------------------------------------------------------------
- bool
- SetArchitecture (ArchitectureType arch_type,
- uint32_t cpu,
- uint32_t sub,
- uint32_t os = 0);
-
- //------------------------------------------------------------------
- /// Returns the byte order for the architecture specification.
- ///
- /// @return The endian enumeration for the current endianness of
- /// the architecture specification
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder () const;
-
- //------------------------------------------------------------------
- /// Sets this ArchSpec's byte order.
- ///
- /// In the common case there is no need to call this method as the
- /// byte order can almost always be determined by the architecture.
- /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
- /// and the default/assumed byte order may be incorrect.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
- uint32_t
- GetMinimumOpcodeByteSize() const;
-
- uint32_t
- GetMaximumOpcodeByteSize() const;
-
- Core
- GetCore () const
- {
- return m_core;
- }
-
- uint32_t
- GetMachOCPUType () const;
-
- uint32_t
- GetMachOCPUSubType () const;
-
- //------------------------------------------------------------------
- /// Architecture data byte width accessor
- ///
- /// @return the size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's data bus
- //------------------------------------------------------------------
- uint32_t
- GetDataByteSize() const;
-
- //------------------------------------------------------------------
- /// Architecture code byte width accessor
- ///
- /// @return the size in 8-bit (host) bytes of a minimum addressable
- /// unit from the Architecture's code bus
- //------------------------------------------------------------------
- uint32_t
- GetCodeByteSize() const;
-
- //------------------------------------------------------------------
- /// Architecture tripple accessor.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- llvm::Triple &
- GetTriple ()
- {
- return m_triple;
- }
-
- //------------------------------------------------------------------
- /// Architecture tripple accessor.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- const llvm::Triple &
- GetTriple () const
- {
- return m_triple;
- }
-
- void
- DumpTriple(Stream &s) const;
-
- //------------------------------------------------------------------
- /// Architecture tripple setter.
- ///
- /// Configures this ArchSpec according to the given triple. If the
- /// triple has unknown components in all of the vendor, OS, and
- /// the optional environment field (i.e. "i386-unknown-unknown")
- /// then default values are taken from the host. Architecture and
- /// environment components are used to further resolve the CPU type
- /// and subtype, endian characteristics, etc.
- ///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
- bool
- SetTriple (const llvm::Triple &triple);
-
- bool
- SetTriple (const char *triple_cstr);
-
- bool
- SetTriple (const char *triple_cstr,
- Platform *platform);
-
- //------------------------------------------------------------------
- /// Returns the default endianness of the architecture.
- ///
- /// @return The endian enumeration for the default endianness of
- /// the architecture.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetDefaultEndian () const;
-
- //------------------------------------------------------------------
- /// Returns true if 'char' is a signed type by defualt in the
- /// architecture false otherwise
- ///
- /// @return True if 'char' is a signed type by default on the
- /// architecture and false otherwise.
- //------------------------------------------------------------------
- bool
- CharIsSignedByDefault () const;
-
- //------------------------------------------------------------------
- /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
- /// type match between them.
- /// e.g. armv7s is not an exact match with armv7 - this would return false
- ///
- /// @return true if the two ArchSpecs match.
- //------------------------------------------------------------------
- bool
- IsExactMatch (const ArchSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Compare an ArchSpec to another ArchSpec, requiring a compatible
- /// cpu type match between them.
- /// e.g. armv7s is compatible with armv7 - this method would return true
- ///
- /// @return true if the two ArchSpecs are compatible
- //------------------------------------------------------------------
- bool
- IsCompatibleMatch (const ArchSpec& rhs) const;
-
- //------------------------------------------------------------------
- /// Get a stop info override callback for the current architecture.
- ///
- /// Most platform specific code should go in lldb_private::Platform,
- /// but there are cases where no matter which platform you are on
- /// certain things hold true.
- ///
- /// This callback is currently intended to handle cases where a
- /// program stops at an instruction that won't get executed and it
- /// allows the stop reasonm, like "breakpoint hit", to be replaced
- /// with a different stop reason like "no stop reason".
- ///
- /// This is specifically used for ARM in Thumb code when we stop in
- /// an IT instruction (if/then/else) where the instruction won't get
- /// executed and therefore it wouldn't be correct to show the program
- /// stopped at the current PC. The code is generic and applies to all
- /// ARM CPUs.
- ///
- /// @return NULL or a valid stop info override callback for the
- /// current architecture.
- //------------------------------------------------------------------
- StopInfoOverrideCallbackType
- GetStopInfoOverrideCallback () const;
-
- bool
- IsFullySpecifiedTriple () const;
-
- void
- PiecewiseTripleCompare (const ArchSpec &other,
- bool &arch_different,
- bool &vendor_different,
- bool &os_different,
- bool &os_version_different,
- bool &env_different);
-
- //------------------------------------------------------------------
- /// Detect whether this architecture uses thumb code exclusively
- ///
- /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can
- /// only execute the Thumb instructions, never Arm. We should normally
- /// pick up arm/thumbness from their the processor status bits (cpsr/xpsr)
- /// or hints on each function - but when doing bare-boards low level
- /// debugging (especially common with these embedded processors), we may
- /// not have those things easily accessible.
- ///
- /// @return true if this is an arm ArchSpec which can only execute Thumb
- /// instructions
- //------------------------------------------------------------------
- bool
- IsAlwaysThumbInstructions () const;
-
- uint32_t
- GetFlags () const
- {
- return m_flags;
- }
-
- void
- SetFlags (uint32_t flags)
- {
- m_flags = flags;
- }
+ enum MIPSSubType {
+ eMIPSSubType_unknown,
+ eMIPSSubType_mips32,
+ eMIPSSubType_mips32r2,
+ eMIPSSubType_mips32r6,
+ eMIPSSubType_mips32el,
+ eMIPSSubType_mips32r2el,
+ eMIPSSubType_mips32r6el,
+ eMIPSSubType_mips64,
+ eMIPSSubType_mips64r2,
+ eMIPSSubType_mips64r6,
+ eMIPSSubType_mips64el,
+ eMIPSSubType_mips64r2el,
+ eMIPSSubType_mips64r6el,
+ };
+
+ // Masks for the ases word of an ABI flags structure.
+ enum MIPSASE {
+ eMIPSAse_dsp = 0x00000001, // DSP ASE
+ eMIPSAse_dspr2 = 0x00000002, // DSP R2 ASE
+ eMIPSAse_eva = 0x00000004, // Enhanced VA Scheme
+ eMIPSAse_mcu = 0x00000008, // MCU (MicroController) ASE
+ eMIPSAse_mdmx = 0x00000010, // MDMX ASE
+ eMIPSAse_mips3d = 0x00000020, // MIPS-3D ASE
+ eMIPSAse_mt = 0x00000040, // MT ASE
+ eMIPSAse_smartmips = 0x00000080, // SmartMIPS ASE
+ eMIPSAse_virt = 0x00000100, // VZ ASE
+ eMIPSAse_msa = 0x00000200, // MSA ASE
+ eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
+ eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
+ eMIPSAse_xpa = 0x00001000, // XPA ASE
+ eMIPSAse_mask = 0x00001fff,
+ eMIPSABI_O32 = 0x00002000,
+ eMIPSABI_N32 = 0x00004000,
+ eMIPSABI_N64 = 0x00008000,
+ eMIPSABI_O64 = 0x00020000,
+ eMIPSABI_EABI32 = 0x00040000,
+ eMIPSABI_EABI64 = 0x00080000,
+ eMIPSABI_mask = 0x000ff000
+ };
+
+ // MIPS Floating point ABI Values
+ enum MIPS_ABI_FP {
+ eMIPS_ABI_FP_ANY = 0x00000000,
+ eMIPS_ABI_FP_DOUBLE = 0x00100000, // hard float / -mdouble-float
+ eMIPS_ABI_FP_SINGLE = 0x00200000, // hard float / -msingle-float
+ eMIPS_ABI_FP_SOFT = 0x00300000, // soft float
+ eMIPS_ABI_FP_OLD_64 = 0x00400000, // -mips32r2 -mfp64
+ eMIPS_ABI_FP_XX = 0x00500000, // -mfpxx
+ eMIPS_ABI_FP_64 = 0x00600000, // -mips32r2 -mfp64
+ eMIPS_ABI_FP_64A = 0x00700000, // -mips32r2 -mfp64 -mno-odd-spreg
+ eMIPS_ABI_FP_mask = 0x00700000
+ };
+
+ // ARM specific e_flags
+ enum ARMeflags {
+ eARM_abi_soft_float = 0x00000200,
+ eARM_abi_hard_float = 0x00000400
+ };
+
+ enum Core {
+ eCore_arm_generic,
+ eCore_arm_armv4,
+ eCore_arm_armv4t,
+ eCore_arm_armv5,
+ eCore_arm_armv5e,
+ eCore_arm_armv5t,
+ eCore_arm_armv6,
+ eCore_arm_armv6m,
+ eCore_arm_armv7,
+ eCore_arm_armv7f,
+ eCore_arm_armv7s,
+ eCore_arm_armv7k,
+ eCore_arm_armv7m,
+ eCore_arm_armv7em,
+ eCore_arm_xscale,
+
+ eCore_thumb,
+ eCore_thumbv4t,
+ eCore_thumbv5,
+ eCore_thumbv5e,
+ eCore_thumbv6,
+ eCore_thumbv6m,
+ eCore_thumbv7,
+ eCore_thumbv7s,
+ eCore_thumbv7k,
+ eCore_thumbv7f,
+ eCore_thumbv7m,
+ eCore_thumbv7em,
+ eCore_arm_arm64,
+ eCore_arm_armv8,
+ eCore_arm_aarch64,
+
+ eCore_mips32,
+ eCore_mips32r2,
+ eCore_mips32r3,
+ eCore_mips32r5,
+ eCore_mips32r6,
+ eCore_mips32el,
+ eCore_mips32r2el,
+ eCore_mips32r3el,
+ eCore_mips32r5el,
+ eCore_mips32r6el,
+ eCore_mips64,
+ eCore_mips64r2,
+ eCore_mips64r3,
+ eCore_mips64r5,
+ eCore_mips64r6,
+ eCore_mips64el,
+ eCore_mips64r2el,
+ eCore_mips64r3el,
+ eCore_mips64r5el,
+ eCore_mips64r6el,
+
+ eCore_ppc_generic,
+ eCore_ppc_ppc601,
+ eCore_ppc_ppc602,
+ eCore_ppc_ppc603,
+ eCore_ppc_ppc603e,
+ eCore_ppc_ppc603ev,
+ eCore_ppc_ppc604,
+ eCore_ppc_ppc604e,
+ eCore_ppc_ppc620,
+ eCore_ppc_ppc750,
+ eCore_ppc_ppc7400,
+ eCore_ppc_ppc7450,
+ eCore_ppc_ppc970,
+
+ eCore_ppc64_generic,
+ eCore_ppc64_ppc970_64,
+
+ eCore_s390x_generic,
+
+ eCore_sparc_generic,
+
+ eCore_sparc9_generic,
+
+ eCore_x86_32_i386,
+ eCore_x86_32_i486,
+ eCore_x86_32_i486sx,
+ eCore_x86_32_i686,
+
+ eCore_x86_64_x86_64,
+ eCore_x86_64_x86_64h, // Haswell enabled x86_64
+ eCore_hexagon_generic,
+ eCore_hexagon_hexagonv4,
+ eCore_hexagon_hexagonv5,
+
+ eCore_uknownMach32,
+ eCore_uknownMach64,
+
+ eCore_kalimba3,
+ eCore_kalimba4,
+ eCore_kalimba5,
+
+ kNumCores,
+
+ kCore_invalid,
+ // The following constants are used for wildcard matching only
+ kCore_any,
+ kCore_arm_any,
+ kCore_ppc_any,
+ kCore_ppc64_any,
+ kCore_x86_32_any,
+ kCore_x86_64_any,
+ kCore_hexagon_any,
+
+ kCore_arm_first = eCore_arm_generic,
+ kCore_arm_last = eCore_arm_xscale,
+
+ kCore_thumb_first = eCore_thumb,
+ kCore_thumb_last = eCore_thumbv7em,
+
+ kCore_ppc_first = eCore_ppc_generic,
+ kCore_ppc_last = eCore_ppc_ppc970,
+
+ kCore_ppc64_first = eCore_ppc64_generic,
+ kCore_ppc64_last = eCore_ppc64_ppc970_64,
+
+ kCore_x86_32_first = eCore_x86_32_i386,
+ kCore_x86_32_last = eCore_x86_32_i686,
+
+ kCore_x86_64_first = eCore_x86_64_x86_64,
+ kCore_x86_64_last = eCore_x86_64_x86_64h,
+
+ kCore_hexagon_first = eCore_hexagon_generic,
+ kCore_hexagon_last = eCore_hexagon_hexagonv5,
+
+ kCore_kalimba_first = eCore_kalimba3,
+ kCore_kalimba_last = eCore_kalimba5,
+
+ kCore_mips32_first = eCore_mips32,
+ kCore_mips32_last = eCore_mips32r6,
+
+ kCore_mips32el_first = eCore_mips32el,
+ kCore_mips32el_last = eCore_mips32r6el,
+
+ kCore_mips64_first = eCore_mips64,
+ kCore_mips64_last = eCore_mips64r6,
+
+ kCore_mips64el_first = eCore_mips64el,
+ kCore_mips64el_last = eCore_mips64r6el,
+
+ kCore_mips_first = eCore_mips32,
+ kCore_mips_last = eCore_mips64r6el
+
+ };
+
+ typedef void (*StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Default constructor that initializes the object with invalid
+ /// cpu type and subtype values.
+ //------------------------------------------------------------------
+ ArchSpec();
+
+ //------------------------------------------------------------------
+ /// Constructor over triple.
+ ///
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// Triple.
+ //------------------------------------------------------------------
+ explicit ArchSpec(const llvm::Triple &triple);
+ explicit ArchSpec(const char *triple_cstr);
+ explicit ArchSpec(const char *triple_cstr, Platform *platform);
+ //------------------------------------------------------------------
+ /// Constructor over architecture name.
+ ///
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// object type and architecture name.
+ //------------------------------------------------------------------
+ explicit ArchSpec(ArchitectureType arch_type, uint32_t cpu_type,
+ uint32_t cpu_subtype);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ArchSpec();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] rhs another ArchSpec object to copy.
+ ///
+ /// @return A const reference to this object.
+ //------------------------------------------------------------------
+ const ArchSpec &operator=(const ArchSpec &rhs);
+
+ static size_t AutoComplete(const char *name, StringList &matches);
+
+ //------------------------------------------------------------------
+ /// Returns a static string representing the current architecture.
+ ///
+ /// @return A static string correcponding to the current
+ /// architecture.
+ //------------------------------------------------------------------
+ const char *GetArchitectureName() const;
+
+ //-----------------------------------------------------------------
+ /// if MIPS architecture return true.
+ ///
+ /// @return a boolean value.
+ //-----------------------------------------------------------------
+ bool IsMIPS() const;
+
+ //------------------------------------------------------------------
+ /// Returns a string representing current architecture as a target CPU
+ /// for tools like compiler, disassembler etc.
+ ///
+ /// @return A string representing target CPU for the current
+ /// architecture.
+ //------------------------------------------------------------------
+ std::string GetClangTargetCPU();
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object state back to a default invalid state.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Returns the size in bytes of an address of the current
+ /// architecture.
+ ///
+ /// @return The byte size of an address of the current architecture.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Returns a machine family for the current architecture.
+ ///
+ /// @return An LLVM arch type.
+ //------------------------------------------------------------------
+ llvm::Triple::ArchType GetMachine() const;
+
+ //------------------------------------------------------------------
+ /// Returns the distribution id of the architecture.
+ ///
+ /// This will be something like "ubuntu", "fedora", etc. on Linux.
+ ///
+ /// @return A ConstString ref containing the distribution id,
+ /// potentially empty.
+ //------------------------------------------------------------------
+ const ConstString &GetDistributionId() const;
+
+ //------------------------------------------------------------------
+ /// Set the distribution id of the architecture.
+ ///
+ /// This will be something like "ubuntu", "fedora", etc. on Linux.
+ /// This should be the same value returned by
+ /// HostInfo::GetDistributionId ().
+ ///------------------------------------------------------------------
+ void SetDistributionId(const char *distribution_id);
+
+ //------------------------------------------------------------------
+ /// Tests if this ArchSpec is valid.
+ ///
+ /// @return True if the current architecture is valid, false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const {
+ return m_core >= eCore_arm_generic && m_core < kNumCores;
+ }
+
+ bool TripleVendorWasSpecified() const {
+ return !m_triple.getVendorName().empty();
+ }
+
+ bool TripleVendorIsUnspecifiedUnknown() const {
+ return m_triple.getVendor() == llvm::Triple::UnknownVendor &&
+ m_triple.getVendorName().empty();
+ }
+
+ bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); }
+
+ bool TripleEnvironmentWasSpecified() const {
+ return !m_triple.getEnvironmentName().empty();
+ }
+
+ bool TripleOSIsUnspecifiedUnknown() const {
+ return m_triple.getOS() == llvm::Triple::UnknownOS &&
+ m_triple.getOSName().empty();
+ }
+
+ //------------------------------------------------------------------
+ /// Merges fields from another ArchSpec into this ArchSpec.
+ ///
+ /// This will use the supplied ArchSpec to fill in any fields of
+ /// the triple in this ArchSpec which were unspecified. This can
+ /// be used to refine a generic ArchSpec with a more specific one.
+ /// For example, if this ArchSpec's triple is something like
+ /// i386-unknown-unknown-unknown, and we have a triple which is
+ /// x64-pc-windows-msvc, then merging that triple into this one
+ /// will result in the triple i386-pc-windows-msvc.
+ ///
+ //------------------------------------------------------------------
+ void MergeFrom(const ArchSpec &other);
+
+ //------------------------------------------------------------------
+ /// Change the architecture object type, CPU type and OS type.
+ ///
+ /// @param[in] arch_type The object type of this ArchSpec.
+ ///
+ /// @param[in] cpu The required CPU type.
+ ///
+ /// @param[in] os The optional OS type
+ /// The default value of 0 was chosen to from the ELF spec value
+ /// ELFOSABI_NONE. ELF is the only one using this parameter. If another
+ /// format uses this parameter and 0 does not work, use a value over
+ /// 255 because in the ELF header this is value is only a byte.
+ ///
+ /// @return True if the object, and CPU were successfully set.
+ ///
+ /// As a side effect, the vendor value is usually set to unknown.
+ /// The exections are
+ /// aarch64-apple-ios
+ /// arm-apple-ios
+ /// thumb-apple-ios
+ /// x86-apple-
+ /// x86_64-apple-
+ ///
+ /// As a side effect, the os value is usually set to unknown
+ /// The exceptions are
+ /// *-*-aix
+ /// aarch64-apple-ios
+ /// arm-apple-ios
+ /// thumb-apple-ios
+ /// powerpc-apple-darwin
+ /// *-*-freebsd
+ /// *-*-linux
+ /// *-*-netbsd
+ /// *-*-openbsd
+ /// *-*-solaris
+ //------------------------------------------------------------------
+ bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub,
+ uint32_t os = 0);
+
+ //------------------------------------------------------------------
+ /// Returns the byte order for the architecture specification.
+ ///
+ /// @return The endian enumeration for the current endianness of
+ /// the architecture specification
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const;
+
+ //------------------------------------------------------------------
+ /// Sets this ArchSpec's byte order.
+ ///
+ /// In the common case there is no need to call this method as the
+ /// byte order can almost always be determined by the architecture.
+ /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
+ /// and the default/assumed byte order may be incorrect.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ uint32_t GetMinimumOpcodeByteSize() const;
+
+ uint32_t GetMaximumOpcodeByteSize() const;
+
+ Core GetCore() const { return m_core; }
+
+ uint32_t GetMachOCPUType() const;
+
+ uint32_t GetMachOCPUSubType() const;
+
+ //------------------------------------------------------------------
+ /// Architecture data byte width accessor
+ ///
+ /// @return the size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's data bus
+ //------------------------------------------------------------------
+ uint32_t GetDataByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Architecture code byte width accessor
+ ///
+ /// @return the size in 8-bit (host) bytes of a minimum addressable
+ /// unit from the Architecture's code bus
+ //------------------------------------------------------------------
+ uint32_t GetCodeByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ llvm::Triple &GetTriple() { return m_triple; }
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ const llvm::Triple &GetTriple() const { return m_triple; }
+
+ void DumpTriple(Stream &s) const;
+
+ //------------------------------------------------------------------
+ /// Architecture tripple setter.
+ ///
+ /// Configures this ArchSpec according to the given triple. If the
+ /// triple has unknown components in all of the vendor, OS, and
+ /// the optional environment field (i.e. "i386-unknown-unknown")
+ /// then default values are taken from the host. Architecture and
+ /// environment components are used to further resolve the CPU type
+ /// and subtype, endian characteristics, etc.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ bool SetTriple(const llvm::Triple &triple);
+
+ bool SetTriple(const char *triple_cstr);
+
+ bool SetTriple(const char *triple_cstr, Platform *platform);
+
+ //------------------------------------------------------------------
+ /// Returns the default endianness of the architecture.
+ ///
+ /// @return The endian enumeration for the default endianness of
+ /// the architecture.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetDefaultEndian() const;
+
+ //------------------------------------------------------------------
+ /// Returns true if 'char' is a signed type by defualt in the
+ /// architecture false otherwise
+ ///
+ /// @return True if 'char' is a signed type by default on the
+ /// architecture and false otherwise.
+ //------------------------------------------------------------------
+ bool CharIsSignedByDefault() const;
+
+ //------------------------------------------------------------------
+ /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
+ /// type match between them.
+ /// e.g. armv7s is not an exact match with armv7 - this would return false
+ ///
+ /// @return true if the two ArchSpecs match.
+ //------------------------------------------------------------------
+ bool IsExactMatch(const ArchSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Compare an ArchSpec to another ArchSpec, requiring a compatible
+ /// cpu type match between them.
+ /// e.g. armv7s is compatible with armv7 - this method would return true
+ ///
+ /// @return true if the two ArchSpecs are compatible
+ //------------------------------------------------------------------
+ bool IsCompatibleMatch(const ArchSpec &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Get a stop info override callback for the current architecture.
+ ///
+ /// Most platform specific code should go in lldb_private::Platform,
+ /// but there are cases where no matter which platform you are on
+ /// certain things hold true.
+ ///
+ /// This callback is currently intended to handle cases where a
+ /// program stops at an instruction that won't get executed and it
+ /// allows the stop reasonm, like "breakpoint hit", to be replaced
+ /// with a different stop reason like "no stop reason".
+ ///
+ /// This is specifically used for ARM in Thumb code when we stop in
+ /// an IT instruction (if/then/else) where the instruction won't get
+ /// executed and therefore it wouldn't be correct to show the program
+ /// stopped at the current PC. The code is generic and applies to all
+ /// ARM CPUs.
+ ///
+ /// @return NULL or a valid stop info override callback for the
+ /// current architecture.
+ //------------------------------------------------------------------
+ StopInfoOverrideCallbackType GetStopInfoOverrideCallback() const;
+
+ bool IsFullySpecifiedTriple() const;
+
+ void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
+ bool &vendor_different, bool &os_different,
+ bool &os_version_different, bool &env_different);
+
+ //------------------------------------------------------------------
+ /// Detect whether this architecture uses thumb code exclusively
+ ///
+ /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can
+ /// only execute the Thumb instructions, never Arm. We should normally
+ /// pick up arm/thumbness from their the processor status bits (cpsr/xpsr)
+ /// or hints on each function - but when doing bare-boards low level
+ /// debugging (especially common with these embedded processors), we may
+ /// not have those things easily accessible.
+ ///
+ /// @return true if this is an arm ArchSpec which can only execute Thumb
+ /// instructions
+ //------------------------------------------------------------------
+ bool IsAlwaysThumbInstructions() const;
+
+ uint32_t GetFlags() const { return m_flags; }
+
+ void SetFlags(uint32_t flags) { m_flags = flags; }
protected:
- bool
- IsEqualTo (const ArchSpec& rhs, bool exact_match) const;
+ bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
- llvm::Triple m_triple;
- Core m_core;
- lldb::ByteOrder m_byte_order;
-
- // Additional arch flags which we cannot get from triple and core
- // For MIPS these are application specific extensions like
- // micromips, mips16 etc.
- uint32_t m_flags;
-
- ConstString m_distribution_id;
-
- // Called when m_def or m_entry are changed. Fills in all remaining
- // members with default values.
- void
- CoreUpdated (bool update_triple);
+ llvm::Triple m_triple;
+ Core m_core;
+ lldb::ByteOrder m_byte_order;
+
+ // Additional arch flags which we cannot get from triple and core
+ // For MIPS these are application specific extensions like
+ // micromips, mips16 etc.
+ uint32_t m_flags;
+
+ ConstString m_distribution_id;
+
+ // Called when m_def or m_entry are changed. Fills in all remaining
+ // members with default values.
+ void CoreUpdated(bool update_triple);
};
//------------------------------------------------------------------
@@ -710,9 +623,9 @@ protected:
///
/// @return true if \a lhs is less than \a rhs
//------------------------------------------------------------------
-bool operator< (const ArchSpec& lhs, const ArchSpec& rhs);
+bool operator<(const ArchSpec &lhs, const ArchSpec &rhs);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_ArchSpec_h_
+#endif // #if defined(__cplusplus)
+#endif // #ifndef liblldb_ArchSpec_h_
Modified: lldb/trunk/include/lldb/Core/Baton.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Baton.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Baton.h (original)
+++ lldb/trunk/include/lldb/Core/Baton.h Tue Sep 6 15:57:50 2016
@@ -23,40 +23,33 @@ namespace lldb_private {
/// @brief A class designed to wrap callback batons so they can cleanup
/// any acquired resources
///
-/// This class is designed to be used by any objects that have a
+/// This class is designed to be used by any objects that have a
/// callback function that takes a baton where the baton might need to
/// free/delete/close itself.
///
-/// The default behavior is to not free anything. Subclasses can
+/// The default behavior is to not free anything. Subclasses can
/// free any needed resources in their destructors.
//----------------------------------------------------------------------
-class Baton
-{
+class Baton {
public:
- explicit Baton(void *p) :
- m_data (p)
- {
- }
-
- virtual
- ~Baton()
- {
- // The default destructor for a baton does NOT attempt to clean up
- // anything in m_baton
- }
-
- virtual void
- GetDescription (Stream *s, lldb::DescriptionLevel level) const;
+ explicit Baton(void *p) : m_data(p) {}
- void *m_data; // Leave baton public for easy access
+ virtual ~Baton() {
+ // The default destructor for a baton does NOT attempt to clean up
+ // anything in m_baton
+ }
+
+ virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
+
+ void *m_data; // Leave baton public for easy access
private:
- //------------------------------------------------------------------
- // For Baton only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Baton);
+ //------------------------------------------------------------------
+ // For Baton only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Baton);
};
} // namespace lldb_private
-#endif // lldb_Baton_h_
+#endif // lldb_Baton_h_
Modified: lldb/trunk/include/lldb/Core/Broadcaster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Broadcaster.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Broadcaster.h (original)
+++ lldb/trunk/include/lldb/Core/Broadcaster.h Tue Sep 6 15:57:50 2016
@@ -21,8 +21,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/SmallVector.h"
@@ -34,217 +34,181 @@ namespace lldb_private {
// This class is used to specify a kind of event to register for. The Debugger
// maintains a list of BroadcastEventSpec's and when it is made
//----------------------------------------------------------------------
-class BroadcastEventSpec
-{
+class BroadcastEventSpec {
public:
- BroadcastEventSpec (const ConstString &broadcaster_class, uint32_t event_bits) :
- m_broadcaster_class (broadcaster_class),
- m_event_bits (event_bits)
- {
- }
-
- BroadcastEventSpec (const BroadcastEventSpec &rhs);
-
- ~BroadcastEventSpec() = default;
-
- const ConstString &GetBroadcasterClass() const
- {
- return m_broadcaster_class;
- }
-
- uint32_t GetEventBits () const
- {
- return m_event_bits;
- }
-
- // Tell whether this BroadcastEventSpec is contained in in_spec.
- // That is:
- // (a) the two spec's share the same broadcaster class
- // (b) the event bits of this spec are wholly contained in those of in_spec.
- bool IsContainedIn (BroadcastEventSpec in_spec) const
- {
- if (m_broadcaster_class != in_spec.GetBroadcasterClass())
- return false;
- uint32_t in_bits = in_spec.GetEventBits();
- if (in_bits == m_event_bits)
- return true;
- else
- {
- if ((m_event_bits & in_bits) != 0
- && (m_event_bits & ~in_bits) == 0)
- return true;
- }
- return false;
+ BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits)
+ : m_broadcaster_class(broadcaster_class), m_event_bits(event_bits) {}
+
+ BroadcastEventSpec(const BroadcastEventSpec &rhs);
+
+ ~BroadcastEventSpec() = default;
+
+ const ConstString &GetBroadcasterClass() const { return m_broadcaster_class; }
+
+ uint32_t GetEventBits() const { return m_event_bits; }
+
+ // Tell whether this BroadcastEventSpec is contained in in_spec.
+ // That is:
+ // (a) the two spec's share the same broadcaster class
+ // (b) the event bits of this spec are wholly contained in those of in_spec.
+ bool IsContainedIn(BroadcastEventSpec in_spec) const {
+ if (m_broadcaster_class != in_spec.GetBroadcasterClass())
+ return false;
+ uint32_t in_bits = in_spec.GetEventBits();
+ if (in_bits == m_event_bits)
+ return true;
+ else {
+ if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0)
+ return true;
}
-
- bool operator< (const BroadcastEventSpec &rhs) const;
- BroadcastEventSpec &operator=(const BroadcastEventSpec &rhs);
-
+ return false;
+ }
+
+ bool operator<(const BroadcastEventSpec &rhs) const;
+ BroadcastEventSpec &operator=(const BroadcastEventSpec &rhs);
+
private:
- ConstString m_broadcaster_class;
- uint32_t m_event_bits;
+ ConstString m_broadcaster_class;
+ uint32_t m_event_bits;
};
-class BroadcasterManager :
- public std::enable_shared_from_this<BroadcasterManager>
-{
+class BroadcasterManager
+ : public std::enable_shared_from_this<BroadcasterManager> {
public:
- friend class Listener;
+ friend class Listener;
protected:
- BroadcasterManager ();
+ BroadcasterManager();
+
public:
- // Listeners hold onto weak pointers to their broadcaster managers. So they must be
- // made into shared pointers, which you do with MakeBroadcasterManager.
-
- static lldb::BroadcasterManagerSP
- MakeBroadcasterManager();
-
- ~BroadcasterManager() = default;
-
- uint32_t
- RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec);
-
- bool
- UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec);
-
- lldb::ListenerSP
- GetListenerForEventSpec (BroadcastEventSpec event_spec) const;
-
- void
- SignUpListenersForBroadcaster (Broadcaster &broadcaster);
-
- void
- RemoveListener (const lldb::ListenerSP &listener_sp);
+ // Listeners hold onto weak pointers to their broadcaster managers. So they
+ // must be
+ // made into shared pointers, which you do with MakeBroadcasterManager.
- void
- RemoveListener (Listener *listener);
+ static lldb::BroadcasterManagerSP MakeBroadcasterManager();
+
+ ~BroadcasterManager() = default;
+
+ uint32_t RegisterListenerForEvents(const lldb::ListenerSP &listener_sp,
+ BroadcastEventSpec event_spec);
+
+ bool UnregisterListenerForEvents(const lldb::ListenerSP &listener_sp,
+ BroadcastEventSpec event_spec);
+
+ lldb::ListenerSP GetListenerForEventSpec(BroadcastEventSpec event_spec) const;
+
+ void SignUpListenersForBroadcaster(Broadcaster &broadcaster);
+
+ void RemoveListener(const lldb::ListenerSP &listener_sp);
+
+ void RemoveListener(Listener *listener);
+
+ void Clear();
- void Clear();
-
private:
- typedef std::pair<BroadcastEventSpec, lldb::ListenerSP> event_listener_key;
- typedef std::map<BroadcastEventSpec, lldb::ListenerSP> collection;
- typedef std::set<lldb::ListenerSP> listener_collection;
- collection m_event_map;
- listener_collection m_listeners;
-
- mutable std::recursive_mutex m_manager_mutex;
-
- // A couple of comparator classes for find_if:
-
- class BroadcasterClassMatches
- {
- public:
- BroadcasterClassMatches (const ConstString &broadcaster_class) :
- m_broadcaster_class (broadcaster_class)
- {
- }
-
- ~BroadcasterClassMatches() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.GetBroadcasterClass() == m_broadcaster_class);
- }
-
- private:
- ConstString m_broadcaster_class;
- };
-
- class BroadcastEventSpecMatches
- {
- public:
- BroadcastEventSpecMatches (BroadcastEventSpec broadcaster_spec) :
- m_broadcaster_spec (broadcaster_spec)
- {
- }
-
- ~BroadcastEventSpecMatches() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.IsContainedIn (m_broadcaster_spec));
- }
-
- private:
- BroadcastEventSpec m_broadcaster_spec;
- };
-
- class ListenerMatchesAndSharedBits
- {
- public:
- explicit ListenerMatchesAndSharedBits (BroadcastEventSpec broadcaster_spec, const lldb::ListenerSP listener_sp) :
- m_broadcaster_spec (broadcaster_spec),
- m_listener_sp (listener_sp)
- {
- }
-
- ~ListenerMatchesAndSharedBits() = default;
-
- bool operator() (const event_listener_key input) const
- {
- return (input.first.GetBroadcasterClass() == m_broadcaster_spec.GetBroadcasterClass()
- && (input.first.GetEventBits() & m_broadcaster_spec.GetEventBits()) != 0
- && input.second == m_listener_sp);
- }
-
- private:
- BroadcastEventSpec m_broadcaster_spec;
- const lldb::ListenerSP m_listener_sp;
- };
-
- class ListenerMatches
- {
- public:
- explicit ListenerMatches (const lldb::ListenerSP in_listener_sp) :
- m_listener_sp (in_listener_sp)
- {
- }
-
- ~ListenerMatches() = default;
-
- bool operator () (const event_listener_key input) const
- {
- if (input.second == m_listener_sp)
- return true;
- else
- return false;
- }
-
- private:
- const lldb::ListenerSP m_listener_sp;
- };
-
- class ListenerMatchesPointer
- {
- public:
- ListenerMatchesPointer (const Listener *in_listener) :
- m_listener (in_listener)
- {
- }
-
- ~ListenerMatchesPointer() = default;
-
- bool operator () (const event_listener_key input) const
- {
- if (input.second.get() == m_listener)
- return true;
- else
- return false;
- }
-
- bool operator () (const lldb::ListenerSP input) const
- {
- if (input.get() == m_listener)
- return true;
- else
- return false;
- }
-
- private:
- const Listener *m_listener;
- };
+ typedef std::pair<BroadcastEventSpec, lldb::ListenerSP> event_listener_key;
+ typedef std::map<BroadcastEventSpec, lldb::ListenerSP> collection;
+ typedef std::set<lldb::ListenerSP> listener_collection;
+ collection m_event_map;
+ listener_collection m_listeners;
+
+ mutable std::recursive_mutex m_manager_mutex;
+
+ // A couple of comparator classes for find_if:
+
+ class BroadcasterClassMatches {
+ public:
+ BroadcasterClassMatches(const ConstString &broadcaster_class)
+ : m_broadcaster_class(broadcaster_class) {}
+
+ ~BroadcasterClassMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.GetBroadcasterClass() == m_broadcaster_class);
+ }
+
+ private:
+ ConstString m_broadcaster_class;
+ };
+
+ class BroadcastEventSpecMatches {
+ public:
+ BroadcastEventSpecMatches(BroadcastEventSpec broadcaster_spec)
+ : m_broadcaster_spec(broadcaster_spec) {}
+
+ ~BroadcastEventSpecMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.IsContainedIn(m_broadcaster_spec));
+ }
+
+ private:
+ BroadcastEventSpec m_broadcaster_spec;
+ };
+
+ class ListenerMatchesAndSharedBits {
+ public:
+ explicit ListenerMatchesAndSharedBits(BroadcastEventSpec broadcaster_spec,
+ const lldb::ListenerSP listener_sp)
+ : m_broadcaster_spec(broadcaster_spec), m_listener_sp(listener_sp) {}
+
+ ~ListenerMatchesAndSharedBits() = default;
+
+ bool operator()(const event_listener_key input) const {
+ return (input.first.GetBroadcasterClass() ==
+ m_broadcaster_spec.GetBroadcasterClass() &&
+ (input.first.GetEventBits() &
+ m_broadcaster_spec.GetEventBits()) != 0 &&
+ input.second == m_listener_sp);
+ }
+
+ private:
+ BroadcastEventSpec m_broadcaster_spec;
+ const lldb::ListenerSP m_listener_sp;
+ };
+
+ class ListenerMatches {
+ public:
+ explicit ListenerMatches(const lldb::ListenerSP in_listener_sp)
+ : m_listener_sp(in_listener_sp) {}
+
+ ~ListenerMatches() = default;
+
+ bool operator()(const event_listener_key input) const {
+ if (input.second == m_listener_sp)
+ return true;
+ else
+ return false;
+ }
+
+ private:
+ const lldb::ListenerSP m_listener_sp;
+ };
+
+ class ListenerMatchesPointer {
+ public:
+ ListenerMatchesPointer(const Listener *in_listener)
+ : m_listener(in_listener) {}
+
+ ~ListenerMatchesPointer() = default;
+
+ bool operator()(const event_listener_key input) const {
+ if (input.second.get() == m_listener)
+ return true;
+ else
+ return false;
+ }
+
+ bool operator()(const lldb::ListenerSP input) const {
+ if (input.get() == m_listener)
+ return true;
+ else
+ return false;
+ }
+
+ private:
+ const Listener *m_listener;
+ };
};
//----------------------------------------------------------------------
@@ -279,392 +243,351 @@ private:
/// };
/// \endcode
//----------------------------------------------------------------------
-class Broadcaster
-{
-friend class Listener;
-friend class Event;
+class Broadcaster {
+ friend class Listener;
+ friend class Event;
+
public:
- //------------------------------------------------------------------
- /// Construct with a broadcaster with a name.
- ///
- /// @param[in] name
- /// A NULL terminated C string that contains the name of the
- /// broadcaster object.
- //------------------------------------------------------------------
- Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name);
+ //------------------------------------------------------------------
+ /// Construct with a broadcaster with a name.
+ ///
+ /// @param[in] name
+ /// A NULL terminated C string that contains the name of the
+ /// broadcaster object.
+ //------------------------------------------------------------------
+ Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class gets subclassed.
+ //------------------------------------------------------------------
+ virtual ~Broadcaster();
+
+ void CheckInWithManager();
+
+ //------------------------------------------------------------------
+ /// Broadcast an event which has no associated data.
+ ///
+ /// @param[in] event_type
+ /// The element from the enum defining this broadcaster's events
+ /// that is being broadcast.
+ ///
+ /// @param[in] event_data
+ /// User event data that will be owned by the lldb::Event that
+ /// is created internally.
+ ///
+ /// @param[in] unique
+ /// If true, then only add an event of this type if there isn't
+ /// one already in the queue.
+ ///
+ //------------------------------------------------------------------
+ void BroadcastEvent(lldb::EventSP &event_sp) {
+ m_broadcaster_sp->BroadcastEvent(event_sp);
+ }
+
+ void BroadcastEventIfUnique(lldb::EventSP &event_sp) {
+ m_broadcaster_sp->BroadcastEventIfUnique(event_sp);
+ }
+
+ void BroadcastEvent(uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp) {
+ m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp);
+ }
+
+ void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr) {
+ m_broadcaster_sp->BroadcastEvent(event_type, event_data);
+ }
+
+ void BroadcastEventIfUnique(uint32_t event_type,
+ EventData *event_data = nullptr) {
+ m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+ }
+
+ void Clear() { m_broadcaster_sp->Clear(); }
+
+ virtual void AddInitialEventsToListener(const lldb::ListenerSP &listener_sp,
+ uint32_t requested_events);
+
+ //------------------------------------------------------------------
+ /// Listen for any events specified by \a event_mask.
+ ///
+ /// Only one listener can listen to each event bit in a given
+ /// Broadcaster. Once a listener has acquired an event bit, no
+ /// other broadcaster will have access to it until it is
+ /// relinquished by the first listener that gets it. The actual
+ /// event bits that get acquired by \a listener may be different
+ /// from what is requested in \a event_mask, and to track this the
+ /// actual event bits that are acquired get returned.
+ ///
+ /// @param[in] listener
+ /// The Listener object that wants to monitor the events that
+ /// get broadcast by this object.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events the listener is
+ /// asking to monitor.
+ ///
+ /// @return
+ /// The actual event bits that were acquired by \a listener.
+ //------------------------------------------------------------------
+ uint32_t AddListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask) {
+ return m_broadcaster_sp->AddListener(listener_sp, event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Get the NULL terminated C string name of this Broadcaster
+ /// object.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ const ConstString &GetBroadcasterName() { return m_broadcaster_name; }
+
+ //------------------------------------------------------------------
+ /// Get the event name(s) for one or more event bits.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events to get names for.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ bool GetEventNames(Stream &s, const uint32_t event_mask,
+ bool prefix_with_broadcaster_name) const {
+ return m_broadcaster_sp->GetEventNames(s, event_mask,
+ prefix_with_broadcaster_name);
+ }
+
+ //------------------------------------------------------------------
+ /// Set the name for an event bit.
+ ///
+ /// @param[in] event_mask
+ /// A bit mask that indicates which events the listener is
+ /// asking to monitor.
+ ///
+ /// @return
+ /// The NULL terminated C string name of this Broadcaster.
+ //------------------------------------------------------------------
+ void SetEventName(uint32_t event_mask, const char *name) {
+ m_broadcaster_sp->SetEventName(event_mask, name);
+ }
+
+ const char *GetEventName(uint32_t event_mask) const {
+ return m_broadcaster_sp->GetEventName(event_mask);
+ }
+
+ bool EventTypeHasListeners(uint32_t event_type) {
+ return m_broadcaster_sp->EventTypeHasListeners(event_type);
+ }
+
+ //------------------------------------------------------------------
+ /// Removes a Listener from this broadcasters list and frees the
+ /// event bits specified by \a event_mask that were previously
+ /// acquired by \a listener (assuming \a listener was listening to
+ /// this object) for other listener objects to use.
+ ///
+ /// @param[in] listener
+ /// A Listener object that previously called AddListener.
+ ///
+ /// @param[in] event_mask
+ /// The event bits \a listener wishes to relinquish.
+ ///
+ /// @return
+ /// \b True if the listener was listening to this broadcaster
+ /// and was removed, \b false otherwise.
+ ///
+ /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
+ //------------------------------------------------------------------
+ bool RemoveListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX) {
+ return m_broadcaster_sp->RemoveListener(listener_sp, event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Provides a simple mechanism to temporarily redirect events from
+ /// broadcaster. When you call this function passing in a listener and
+ /// event type mask, all events from the broadcaster matching the mask
+ /// will now go to the hijacking listener.
+ /// Only one hijack can occur at a time. If we need more than this we
+ /// will have to implement a Listener stack.
+ ///
+ /// @param[in] listener
+ /// A Listener object. You do not need to call StartListeningForEvents
+ /// for this broadcaster (that would fail anyway since the event bits
+ /// would most likely be taken by the listener(s) you are usurping.
+ ///
+ /// @param[in] event_mask
+ /// The event bits \a listener wishes to hijack.
+ ///
+ /// @return
+ /// \b True if the event mask could be hijacked, \b false otherwise.
+ ///
+ /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
+ //------------------------------------------------------------------
+ bool HijackBroadcaster(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX) {
+ return m_broadcaster_sp->HijackBroadcaster(listener_sp, event_mask);
+ }
+
+ bool IsHijackedForEvent(uint32_t event_mask) {
+ return m_broadcaster_sp->IsHijackedForEvent(event_mask);
+ }
+
+ //------------------------------------------------------------------
+ /// Restore the state of the Broadcaster from a previous hijack attempt.
+ ///
+ //------------------------------------------------------------------
+ void RestoreBroadcaster() { m_broadcaster_sp->RestoreBroadcaster(); }
+
+ // This needs to be filled in if you are going to register the broadcaster
+ // with the broadcaster
+ // manager and do broadcaster class matching.
+ // FIXME: Probably should make a ManagedBroadcaster subclass with all the bits
+ // needed to work
+ // with the BroadcasterManager, so that it is clearer how to add one.
+ virtual ConstString &GetBroadcasterClass() const;
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class gets subclassed.
- //------------------------------------------------------------------
- virtual
- ~Broadcaster();
+ lldb::BroadcasterManagerSP GetManager();
- void
- CheckInWithManager ();
-
- //------------------------------------------------------------------
- /// Broadcast an event which has no associated data.
- ///
- /// @param[in] event_type
- /// The element from the enum defining this broadcaster's events
- /// that is being broadcast.
- ///
- /// @param[in] event_data
- /// User event data that will be owned by the lldb::Event that
- /// is created internally.
- ///
- /// @param[in] unique
- /// If true, then only add an event of this type if there isn't
- /// one already in the queue.
- ///
- //------------------------------------------------------------------
- void
- BroadcastEvent (lldb::EventSP &event_sp)
- {
- m_broadcaster_sp->BroadcastEvent(event_sp);
- }
+protected:
+ // BroadcasterImpl contains the actual Broadcaster implementation. The
+ // Broadcaster makes a BroadcasterImpl
+ // which lives as long as it does. The Listeners & the Events hold a weak
+ // pointer to the BroadcasterImpl,
+ // so that they can survive if a Broadcaster they were listening to is
+ // destroyed w/o their being able to
+ // unregister from it (which can happen if the Broadcasters & Listeners are
+ // being destroyed on separate threads
+ // simultaneously.
+ // The Broadcaster itself can't be shared out as a weak pointer, because some
+ // things that are broadcasters
+ // (e.g. the Target and the Process) are shared in their own right.
+ //
+ // For the most part, the Broadcaster functions dispatch to the
+ // BroadcasterImpl, and are documented in the
+ // public Broadcaster API above.
- void
- BroadcastEventIfUnique (lldb::EventSP &event_sp)
- {
- m_broadcaster_sp->BroadcastEventIfUnique(event_sp);
- }
+ class BroadcasterImpl {
+ friend class Listener;
+ friend class Broadcaster;
- void
- BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp)
- {
- m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp);
- }
+ public:
+ BroadcasterImpl(Broadcaster &broadcaster);
- void
- BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr)
- {
- m_broadcaster_sp->BroadcastEvent(event_type, event_data);
- }
+ ~BroadcasterImpl() = default;
- void
- BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr)
- {
- m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
- }
+ void BroadcastEvent(lldb::EventSP &event_sp);
- void
- Clear()
- {
- m_broadcaster_sp->Clear();
- }
+ void BroadcastEventIfUnique(lldb::EventSP &event_sp);
- virtual void
- AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events);
+ void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
- //------------------------------------------------------------------
- /// Listen for any events specified by \a event_mask.
- ///
- /// Only one listener can listen to each event bit in a given
- /// Broadcaster. Once a listener has acquired an event bit, no
- /// other broadcaster will have access to it until it is
- /// relinquished by the first listener that gets it. The actual
- /// event bits that get acquired by \a listener may be different
- /// from what is requested in \a event_mask, and to track this the
- /// actual event bits that are acquired get returned.
- ///
- /// @param[in] listener
- /// The Listener object that wants to monitor the events that
- /// get broadcast by this object.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events the listener is
- /// asking to monitor.
- ///
- /// @return
- /// The actual event bits that were acquired by \a listener.
- //------------------------------------------------------------------
- uint32_t
- AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
- {
- return m_broadcaster_sp->AddListener(listener_sp, event_mask);
- }
+ void BroadcastEvent(uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp);
- //------------------------------------------------------------------
- /// Get the NULL terminated C string name of this Broadcaster
- /// object.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- const ConstString &
- GetBroadcasterName ()
- {
- return m_broadcaster_name;
- }
+ void BroadcastEventIfUnique(uint32_t event_type,
+ EventData *event_data = nullptr);
- //------------------------------------------------------------------
- /// Get the event name(s) for one or more event bits.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events to get names for.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- bool
- GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
- {
- return m_broadcaster_sp->GetEventNames(s, event_mask, prefix_with_broadcaster_name);
- }
+ void Clear();
- //------------------------------------------------------------------
- /// Set the name for an event bit.
- ///
- /// @param[in] event_mask
- /// A bit mask that indicates which events the listener is
- /// asking to monitor.
- ///
- /// @return
- /// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- void
- SetEventName (uint32_t event_mask, const char *name)
- {
- m_broadcaster_sp->SetEventName(event_mask, name);
- }
-
- const char *
- GetEventName (uint32_t event_mask) const
- {
- return m_broadcaster_sp->GetEventName(event_mask);
- }
+ uint32_t AddListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask);
- bool
- EventTypeHasListeners (uint32_t event_type)
- {
- return m_broadcaster_sp->EventTypeHasListeners(event_type);
+ const char *GetBroadcasterName() const {
+ return m_broadcaster.GetBroadcasterName().AsCString();
}
- //------------------------------------------------------------------
- /// Removes a Listener from this broadcasters list and frees the
- /// event bits specified by \a event_mask that were previously
- /// acquired by \a listener (assuming \a listener was listening to
- /// this object) for other listener objects to use.
- ///
- /// @param[in] listener
- /// A Listener object that previously called AddListener.
- ///
- /// @param[in] event_mask
- /// The event bits \a listener wishes to relinquish.
- ///
- /// @return
- /// \b True if the listener was listening to this broadcaster
- /// and was removed, \b false otherwise.
- ///
- /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
- //------------------------------------------------------------------
- bool
- RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX)
- {
- return m_broadcaster_sp->RemoveListener(listener_sp, event_mask);
- }
-
- //------------------------------------------------------------------
- /// Provides a simple mechanism to temporarily redirect events from
- /// broadcaster. When you call this function passing in a listener and
- /// event type mask, all events from the broadcaster matching the mask
- /// will now go to the hijacking listener.
- /// Only one hijack can occur at a time. If we need more than this we
- /// will have to implement a Listener stack.
- ///
- /// @param[in] listener
- /// A Listener object. You do not need to call StartListeningForEvents
- /// for this broadcaster (that would fail anyway since the event bits
- /// would most likely be taken by the listener(s) you are usurping.
- ///
- /// @param[in] event_mask
- /// The event bits \a listener wishes to hijack.
- ///
- /// @return
- /// \b True if the event mask could be hijacked, \b false otherwise.
- ///
- /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
- //------------------------------------------------------------------
- bool
- HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX)
- {
- return m_broadcaster_sp->HijackBroadcaster(listener_sp, event_mask);
- }
-
- bool
- IsHijackedForEvent (uint32_t event_mask)
- {
- return m_broadcaster_sp->IsHijackedForEvent(event_mask);
+ Broadcaster *GetBroadcaster();
+
+ bool GetEventNames(Stream &s, const uint32_t event_mask,
+ bool prefix_with_broadcaster_name) const;
+
+ void SetEventName(uint32_t event_mask, const char *name) {
+ m_event_names[event_mask] = name;
}
- //------------------------------------------------------------------
- /// Restore the state of the Broadcaster from a previous hijack attempt.
- ///
- //------------------------------------------------------------------
- void
- RestoreBroadcaster ()
- {
- m_broadcaster_sp->RestoreBroadcaster();
+ const char *GetEventName(uint32_t event_mask) const {
+ const auto pos = m_event_names.find(event_mask);
+ if (pos != m_event_names.end())
+ return pos->second.c_str();
+ return nullptr;
}
-
- // This needs to be filled in if you are going to register the broadcaster with the broadcaster
- // manager and do broadcaster class matching.
- // FIXME: Probably should make a ManagedBroadcaster subclass with all the bits needed to work
- // with the BroadcasterManager, so that it is clearer how to add one.
- virtual ConstString &GetBroadcasterClass() const;
-
- lldb::BroadcasterManagerSP GetManager();
-protected:
- // BroadcasterImpl contains the actual Broadcaster implementation. The Broadcaster makes a BroadcasterImpl
- // which lives as long as it does. The Listeners & the Events hold a weak pointer to the BroadcasterImpl,
- // so that they can survive if a Broadcaster they were listening to is destroyed w/o their being able to
- // unregister from it (which can happen if the Broadcasters & Listeners are being destroyed on separate threads
- // simultaneously.
- // The Broadcaster itself can't be shared out as a weak pointer, because some things that are broadcasters
- // (e.g. the Target and the Process) are shared in their own right.
- //
- // For the most part, the Broadcaster functions dispatch to the BroadcasterImpl, and are documented in the
- // public Broadcaster API above.
-
-
- class BroadcasterImpl
- {
- friend class Listener;
- friend class Broadcaster;
- public:
- BroadcasterImpl (Broadcaster &broadcaster);
+ bool EventTypeHasListeners(uint32_t event_type);
- ~BroadcasterImpl() = default;
+ bool RemoveListener(lldb_private::Listener *listener,
+ uint32_t event_mask = UINT32_MAX);
- void
- BroadcastEvent (lldb::EventSP &event_sp);
+ bool RemoveListener(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX);
+
+ bool HijackBroadcaster(const lldb::ListenerSP &listener_sp,
+ uint32_t event_mask = UINT32_MAX);
+
+ bool IsHijackedForEvent(uint32_t event_mask);
+
+ void RestoreBroadcaster();
+
+ protected:
+ void PrivateBroadcastEvent(lldb::EventSP &event_sp, bool unique);
+
+ const char *GetHijackingListenerName();
- void
- BroadcastEventIfUnique (lldb::EventSP &event_sp);
-
- void
- BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
-
- void
- BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
-
- void
- BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr);
-
- void
- Clear();
-
- uint32_t
- AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask);
-
- const char *
- GetBroadcasterName () const
- {
- return m_broadcaster.GetBroadcasterName().AsCString();
- }
-
- Broadcaster *
- GetBroadcaster();
-
- bool
- GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const;
-
- void
- SetEventName (uint32_t event_mask, const char *name)
- {
- m_event_names[event_mask] = name;
- }
-
- const char *
- GetEventName (uint32_t event_mask) const
- {
- const auto pos = m_event_names.find (event_mask);
- if (pos != m_event_names.end())
- return pos->second.c_str();
- return nullptr;
- }
-
- bool
- EventTypeHasListeners (uint32_t event_type);
-
- bool
- RemoveListener (lldb_private::Listener *listener, uint32_t event_mask = UINT32_MAX);
-
- bool
- RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX);
-
- bool
- HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX);
-
- bool
- IsHijackedForEvent (uint32_t event_mask);
-
- void
- RestoreBroadcaster ();
-
- protected:
- void
- PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique);
-
- const char *
- GetHijackingListenerName();
-
- //------------------------------------------------------------------
- //
- //------------------------------------------------------------------
- typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4> collection;
- typedef std::map<uint32_t, std::string> event_names_map;
-
- llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t&>, 4>
- GetListeners();
-
- Broadcaster &m_broadcaster; ///< The broadcsater that this implements
- event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit
- collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster.
- std::recursive_mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners.
- std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster
- std::vector<uint32_t> m_hijacking_masks; // At some point we may want to have a stack or Listener
- // collections, but for now this is just for private hijacking.
-
- private:
- //------------------------------------------------------------------
- // For Broadcaster only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (BroadcasterImpl);
- };
-
- typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP;
- typedef std::weak_ptr<BroadcasterImpl> BroadcasterImplWP;
-
- BroadcasterImplSP
- GetBroadcasterImpl()
- {
- return m_broadcaster_sp;
- }
-
- const char *
- GetHijackingListenerName()
- {
- return m_broadcaster_sp->GetHijackingListenerName();
- }
//------------------------------------------------------------------
- // Classes that inherit from Broadcaster can see and modify these
+ //
//------------------------------------------------------------------
-
-
-private:
+ typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4>
+ collection;
+ typedef std::map<uint32_t, std::string> event_names_map;
+
+ llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t &>, 4>
+ GetListeners();
+
+ Broadcaster &m_broadcaster; ///< The broadcsater that this implements
+ event_names_map m_event_names; ///< Optionally define event names for
+ ///readability and logging for each event bit
+ collection m_listeners; ///< A list of Listener / event_mask pairs that are
+ ///listening to this broadcaster.
+ std::recursive_mutex
+ m_listeners_mutex; ///< A mutex that protects \a m_listeners.
+ std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism
+ // to intercept events
+ // from a broadcaster
+ std::vector<uint32_t> m_hijacking_masks; // At some point we may want to
+ // have a stack or Listener
+ // collections, but for now this is just for private hijacking.
+
+ private:
//------------------------------------------------------------------
// For Broadcaster only
//------------------------------------------------------------------
- BroadcasterImplSP m_broadcaster_sp;
- lldb::BroadcasterManagerSP m_manager_sp;
- const ConstString m_broadcaster_name; ///< The name of this broadcaster object.
-
- DISALLOW_COPY_AND_ASSIGN (Broadcaster);
+ DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl);
+ };
+
+ typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP;
+ typedef std::weak_ptr<BroadcasterImpl> BroadcasterImplWP;
+
+ BroadcasterImplSP GetBroadcasterImpl() { return m_broadcaster_sp; }
+
+ const char *GetHijackingListenerName() {
+ return m_broadcaster_sp->GetHijackingListenerName();
+ }
+ //------------------------------------------------------------------
+ // Classes that inherit from Broadcaster can see and modify these
+ //------------------------------------------------------------------
+
+private:
+ //------------------------------------------------------------------
+ // For Broadcaster only
+ //------------------------------------------------------------------
+ BroadcasterImplSP m_broadcaster_sp;
+ lldb::BroadcasterManagerSP m_manager_sp;
+ const ConstString
+ m_broadcaster_name; ///< The name of this broadcaster object.
+
+ DISALLOW_COPY_AND_ASSIGN(Broadcaster);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ClangForward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ClangForward.h (original)
+++ lldb/trunk/include/lldb/Core/ClangForward.h Tue Sep 6 15:57:50 2016
@@ -17,126 +17,123 @@
#if defined(__cplusplus)
-namespace clang
-{
- namespace Builtin
- {
- class Context;
- }
+namespace clang {
+namespace Builtin {
+class Context;
+}
- class Action;
- class ASTConsumer;
- class ASTContext;
- class ASTRecordLayout;
- class AddrLabelExpr;
- class AnalyzerOptions;
- class BinaryOperator;
- class ClassTemplateDecl;
- class ClassTemplateSpecializationDecl;
- class CodeGenOptions;
- class CodeGenerator;
- class CompilerInstance;
- class CompoundStmt;
- class CXXBaseSpecifier;
- class CXXBoolLiteralExpr;
- class CXXFunctionalCastExpr;
- class CXXMethodDecl;
- class CXXNamedCastExpr;
- class CXXRecordDecl;
- class CXXThisExpr;
- class CharacterLiteral;
- class CompoundAssignOperator;
- class Decl;
- class DeclarationName;
- class DeclaratorDecl;
- class DeclContext;
- class DeclRefExpr;
- class DeclStmt;
- class DependencyOutputOptions;
- class Diagnostic;
- class DiagnosticConsumer;
- class DiagnosticsEngine;
- class DiagnosticOptions;
- class EnumDecl;
- class EnumConstantDecl;
- class Expr;
- class ExternalASTSource;
- class ExtVectorElementExpr;
- class FieldDecl;
- class FileManager;
- class FileSystemOptions;
- class FloatingLiteral;
- class FrontendOptions;
- class FunctionDecl;
- class FunctionTemplateDecl;
- class FunctionTemplateSpecializationInfo;
- class GotoStmt;
- class HeaderSearchOptions;
- class IdentifierInfo;
- class IdentifierTable;
- class IntegerLiteral;
- class LabelStmt;
- class LangOptions;
- class MacroDirective;
- class MemberExpr;
- class Module;
- class NamedDecl;
- class NamespaceDecl;
- class NonTypeTemplateParmDecl;
- class ObjCEncodeExpr;
- class ObjCImplicitSetterGetterRefExpr;
- class ObjCInterfaceDecl;
- class ObjCIvarDecl;
- class ObjCIvarRefExpr;
- class ObjCMessageExpr;
- class ObjCMethodDecl;
- class ObjCPropertyRefExpr;
- class ObjCProtocolDecl;
- class ObjCProtocolExpr;
- class ObjCSelectorExpr;
- class ObjCSuperExpr;
- class ParenExpr;
- class ParmVarDecl;
- class PredefinedExpr;
- class PreprocessorOptions;
- class PreprocessorOutputOptions;
- class QualType;
- class QualifiedNameType;
- class RecordDecl;
- class SelectorTable;
- class SizeOfAlignOfExpr;
- class SourceLocation;
- class SourceManager;
- class Stmt;
- class StmtIteratorBase;
- class StringLiteral;
- class TagDecl;
- class TargetInfo;
- class TargetOptions;
- class TemplateArgument;
- class TemplateDecl;
- class TemplateParameterList;
- class TemplateTemplateParmDecl;
- class TemplateTypeParmDecl;
- class TextDiagnosticBuffer;
- class TranslationUnitDecl;
- class Type;
- class TypeDecl;
- class TypedefDecl;
- class TypesCompatibleExpr;
- class UnaryOperator;
- class ValueDecl;
- class VarDecl;
- struct PrintingPolicy;
+class Action;
+class ASTConsumer;
+class ASTContext;
+class ASTRecordLayout;
+class AddrLabelExpr;
+class AnalyzerOptions;
+class BinaryOperator;
+class ClassTemplateDecl;
+class ClassTemplateSpecializationDecl;
+class CodeGenOptions;
+class CodeGenerator;
+class CompilerInstance;
+class CompoundStmt;
+class CXXBaseSpecifier;
+class CXXBoolLiteralExpr;
+class CXXFunctionalCastExpr;
+class CXXMethodDecl;
+class CXXNamedCastExpr;
+class CXXRecordDecl;
+class CXXThisExpr;
+class CharacterLiteral;
+class CompoundAssignOperator;
+class Decl;
+class DeclarationName;
+class DeclaratorDecl;
+class DeclContext;
+class DeclRefExpr;
+class DeclStmt;
+class DependencyOutputOptions;
+class Diagnostic;
+class DiagnosticConsumer;
+class DiagnosticsEngine;
+class DiagnosticOptions;
+class EnumDecl;
+class EnumConstantDecl;
+class Expr;
+class ExternalASTSource;
+class ExtVectorElementExpr;
+class FieldDecl;
+class FileManager;
+class FileSystemOptions;
+class FloatingLiteral;
+class FrontendOptions;
+class FunctionDecl;
+class FunctionTemplateDecl;
+class FunctionTemplateSpecializationInfo;
+class GotoStmt;
+class HeaderSearchOptions;
+class IdentifierInfo;
+class IdentifierTable;
+class IntegerLiteral;
+class LabelStmt;
+class LangOptions;
+class MacroDirective;
+class MemberExpr;
+class Module;
+class NamedDecl;
+class NamespaceDecl;
+class NonTypeTemplateParmDecl;
+class ObjCEncodeExpr;
+class ObjCImplicitSetterGetterRefExpr;
+class ObjCInterfaceDecl;
+class ObjCIvarDecl;
+class ObjCIvarRefExpr;
+class ObjCMessageExpr;
+class ObjCMethodDecl;
+class ObjCPropertyRefExpr;
+class ObjCProtocolDecl;
+class ObjCProtocolExpr;
+class ObjCSelectorExpr;
+class ObjCSuperExpr;
+class ParenExpr;
+class ParmVarDecl;
+class PredefinedExpr;
+class PreprocessorOptions;
+class PreprocessorOutputOptions;
+class QualType;
+class QualifiedNameType;
+class RecordDecl;
+class SelectorTable;
+class SizeOfAlignOfExpr;
+class SourceLocation;
+class SourceManager;
+class Stmt;
+class StmtIteratorBase;
+class StringLiteral;
+class TagDecl;
+class TargetInfo;
+class TargetOptions;
+class TemplateArgument;
+class TemplateDecl;
+class TemplateParameterList;
+class TemplateTemplateParmDecl;
+class TemplateTypeParmDecl;
+class TextDiagnosticBuffer;
+class TranslationUnitDecl;
+class Type;
+class TypeDecl;
+class TypedefDecl;
+class TypesCompatibleExpr;
+class UnaryOperator;
+class ValueDecl;
+class VarDecl;
+struct PrintingPolicy;
}
-namespace llvm
-{
- class APInt;
- class APSInt;
- class LLVMContext;
- class ExecutionEngine;
+namespace llvm {
+class APInt;
+class APSInt;
+class LLVMContext;
+class ExecutionEngine;
}
-#endif // #if defined(__cplusplus)
-#endif // liblldb_ClangForward_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_ClangForward_h_
Modified: lldb/trunk/include/lldb/Core/Communication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Communication.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Communication.h (original)
+++ lldb/trunk/include/lldb/Core/Communication.h Tue Sep 6 15:57:50 2016
@@ -18,11 +18,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
#include "lldb/lldb-private.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -82,343 +82,320 @@ namespace lldb_private {
/// can also post a \b eBroadcastBitReadThreadShouldExit event to this
/// object which will cause the read thread to exit.
//----------------------------------------------------------------------
-class Communication : public Broadcaster
-{
+class Communication : public Broadcaster {
public:
- FLAGS_ANONYMOUS_ENUM()
- {
- eBroadcastBitDisconnected = (1u << 0), ///< Sent when the communications connection is lost.
- eBroadcastBitReadThreadGotBytes = (1u << 1), ///< Sent by the read thread when bytes become available.
- eBroadcastBitReadThreadDidExit = (1u << 2), ///< Sent by the read thread when it exits to inform clients.
- eBroadcastBitReadThreadShouldExit = (1u << 3), ///< Sent by clients that need to cancel the read thread.
- eBroadcastBitPacketAvailable = (1u << 4), ///< Sent when data received makes a complete packet.
- eBroadcastBitNoMorePendingInput = (1u << 5), ///< Sent by the read thread to indicate all pending input has been processed.
- kLoUserBroadcastBit = (1u << 16),///< Subclasses can used bits 31:16 for any needed events.
- kHiUserBroadcastBit = (1u << 31),
- eAllEventBits = 0xffffffff
- };
-
- typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
-
- //------------------------------------------------------------------
- /// Construct the Communication object with the specified name for
- /// the Broadcaster that this object inherits from.
- ///
- /// @param[in] broadcaster_name
- /// The name of the broadcaster object. This name should be as
- /// complete as possible to uniquely identify this object. The
- /// broadcaster name can be updated after the connect function
- /// is called.
- //------------------------------------------------------------------
- Communication(const char * broadcaster_name);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// The destructor is virtual since this class gets subclassed.
- //------------------------------------------------------------------
- ~Communication() override;
-
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Connect using the current connection by passing \a url to its
- /// connect function.
- /// string.
- ///
- /// @param[in] url
- /// A string that contains all information needed by the
- /// subclass to connect to another client.
- ///
- /// @return
- /// \b True if the connect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- /// @see bool Connection::Connect (const char *url);
- //------------------------------------------------------------------
- lldb::ConnectionStatus
- Connect (const char *url, Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Disconnect the communications connection if one is currently
- /// connected.
- ///
- /// @return
- /// \b True if the disconnect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- /// @see bool Connection::Disconnect ();
- //------------------------------------------------------------------
- lldb::ConnectionStatus
- Disconnect(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Check if the connection is valid.
- ///
- /// @return
- /// \b True if this object is currently connected, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- IsConnected () const;
-
- bool
- HasConnection () const;
-
- lldb_private::Connection *
- GetConnection ()
- {
- return m_connection_sp.get();
- }
-
- //------------------------------------------------------------------
- /// Read bytes from the current connection.
- ///
- /// If no read thread is running, this function call the
- /// connection's Connection::Read(...) function to get any available.
- ///
- /// If a read thread has been started, this function will check for
- /// any cached bytes that have already been read and return any
- /// currently available bytes. If no bytes are cached, it will wait
- /// for the bytes to become available by listening for the \a
- /// eBroadcastBitReadThreadGotBytes event. If this function consumes
- /// all of the bytes in the cache, it will reset the
- /// \a eBroadcastBitReadThreadGotBytes event bit.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read, and also the max
- /// number of bytes that can be placed into \a dst.
- ///
- /// @param[in] timeout_usec
- /// A timeout value in micro-seconds.
- ///
- /// @return
- /// The number of bytes actually read.
- ///
- /// @see size_t Connection::Read (void *, size_t);
- //------------------------------------------------------------------
- size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// The actual write function that attempts to write to the
- /// communications protocol.
- ///
- /// Subclasses must override this function.
- ///
- /// @param[in] src
- /// A source buffer that must be at least \a src_len bytes
- /// long.
- ///
- /// @param[in] src_len
- /// The number of bytes to attempt to write, and also the
- /// number of bytes are currently available in \a src.
- ///
- /// @return
- /// The number of bytes actually Written.
- //------------------------------------------------------------------
- size_t
- Write (const void *src,
- size_t src_len,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Sets the connection that it to be used by this class.
- ///
- /// By making a communication class that uses different connections
- /// it allows a single communication interface to negotiate and
- /// change its connection without any interruption to the client.
- /// It also allows the Communication class to be subclassed for
- /// packet based communication.
- ///
- /// @param[in] connection
- /// A connection that this class will own and destroy.
- ///
- /// @see
- /// class Connection
- //------------------------------------------------------------------
- void
- SetConnection (Connection *connection);
-
- //------------------------------------------------------------------
- /// Starts a read thread whose sole purpose it to read bytes from
- /// the current connection. This function will call connection's
- /// read function:
- ///
- /// size_t Connection::Read (void *, size_t);
- ///
- /// When bytes are read and cached, this function will call:
- ///
- /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
- ///
- /// Subclasses should override this function if they wish to override
- /// the default action of caching the bytes and broadcasting a \b
- /// eBroadcastBitReadThreadGotBytes event.
- ///
- /// @return
- /// \b True if the read thread was successfully started, \b
- /// false otherwise.
- ///
- /// @see size_t Connection::Read (void *, size_t);
- /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
- //------------------------------------------------------------------
- virtual bool
- StartReadThread(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
- /// Stops the read thread by cancelling it.
- ///
- /// @return
- /// \b True if the read thread was successfully canceled, \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- StopReadThread(Error *error_ptr = nullptr);
-
- virtual bool
- JoinReadThread(Error *error_ptr = nullptr);
- //------------------------------------------------------------------
- /// Checks if there is a currently running read thread.
- ///
- /// @return
- /// \b True if the read thread is running, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ReadThreadIsRunning ();
-
- //------------------------------------------------------------------
- /// The static read thread function. This function will call
- /// the "DoRead" function continuously and wait for data to become
- /// available. When data is received it will append the available
- /// data to the internal cache and broadcast a
- /// \b eBroadcastBitReadThreadGotBytes event.
- ///
- /// @param[in] comm_ptr
- /// A pointer to an instance of this class.
- ///
- /// @return
- /// \b NULL.
- ///
- /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
- //------------------------------------------------------------------
- static lldb::thread_result_t
- ReadThread (lldb::thread_arg_t comm_ptr);
-
- void
- SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
- void *callback_baton);
-
- //------------------------------------------------------------------
- /// Wait for the read thread to process all outstanding data.
- ///
- /// After this function returns, the read thread has processed all data that
- /// has been waiting in the Connection queue.
- ///
- //------------------------------------------------------------------
- void SynchronizeWithReadThread ();
-
- static const char *
- ConnectionStatusAsCString (lldb::ConnectionStatus status);
-
- bool
- GetCloseOnEOF () const
- {
- return m_close_on_eof;
- }
-
- void
- SetCloseOnEOF (bool b)
- {
- m_close_on_eof = b;
- }
-
- static ConstString &GetStaticBroadcasterClass ();
-
- ConstString &GetBroadcasterClass() const override
- {
- return GetStaticBroadcasterClass();
- }
+ FLAGS_ANONYMOUS_ENUM(){
+ eBroadcastBitDisconnected =
+ (1u << 0), ///< Sent when the communications connection is lost.
+ eBroadcastBitReadThreadGotBytes =
+ (1u << 1), ///< Sent by the read thread when bytes become available.
+ eBroadcastBitReadThreadDidExit =
+ (1u
+ << 2), ///< Sent by the read thread when it exits to inform clients.
+ eBroadcastBitReadThreadShouldExit =
+ (1u << 3), ///< Sent by clients that need to cancel the read thread.
+ eBroadcastBitPacketAvailable =
+ (1u << 4), ///< Sent when data received makes a complete packet.
+ eBroadcastBitNoMorePendingInput = (1u << 5), ///< Sent by the read thread
+ ///to indicate all pending
+ ///input has been processed.
+ kLoUserBroadcastBit =
+ (1u << 16), ///< Subclasses can used bits 31:16 for any needed events.
+ kHiUserBroadcastBit = (1u << 31),
+ eAllEventBits = 0xffffffff};
+
+ typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
+ size_t src_len);
+
+ //------------------------------------------------------------------
+ /// Construct the Communication object with the specified name for
+ /// the Broadcaster that this object inherits from.
+ ///
+ /// @param[in] broadcaster_name
+ /// The name of the broadcaster object. This name should be as
+ /// complete as possible to uniquely identify this object. The
+ /// broadcaster name can be updated after the connect function
+ /// is called.
+ //------------------------------------------------------------------
+ Communication(const char *broadcaster_name);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// The destructor is virtual since this class gets subclassed.
+ //------------------------------------------------------------------
+ ~Communication() override;
+
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Connect using the current connection by passing \a url to its
+ /// connect function.
+ /// string.
+ ///
+ /// @param[in] url
+ /// A string that contains all information needed by the
+ /// subclass to connect to another client.
+ ///
+ /// @return
+ /// \b True if the connect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ /// @see bool Connection::Connect (const char *url);
+ //------------------------------------------------------------------
+ lldb::ConnectionStatus Connect(const char *url, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Disconnect the communications connection if one is currently
+ /// connected.
+ ///
+ /// @return
+ /// \b True if the disconnect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ /// @see bool Connection::Disconnect ();
+ //------------------------------------------------------------------
+ lldb::ConnectionStatus Disconnect(Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Check if the connection is valid.
+ ///
+ /// @return
+ /// \b True if this object is currently connected, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool IsConnected() const;
+
+ bool HasConnection() const;
+
+ lldb_private::Connection *GetConnection() { return m_connection_sp.get(); }
+
+ //------------------------------------------------------------------
+ /// Read bytes from the current connection.
+ ///
+ /// If no read thread is running, this function call the
+ /// connection's Connection::Read(...) function to get any available.
+ ///
+ /// If a read thread has been started, this function will check for
+ /// any cached bytes that have already been read and return any
+ /// currently available bytes. If no bytes are cached, it will wait
+ /// for the bytes to become available by listening for the \a
+ /// eBroadcastBitReadThreadGotBytes event. If this function consumes
+ /// all of the bytes in the cache, it will reset the
+ /// \a eBroadcastBitReadThreadGotBytes event bit.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read, and also the max
+ /// number of bytes that can be placed into \a dst.
+ ///
+ /// @param[in] timeout_usec
+ /// A timeout value in micro-seconds.
+ ///
+ /// @return
+ /// The number of bytes actually read.
+ ///
+ /// @see size_t Connection::Read (void *, size_t);
+ //------------------------------------------------------------------
+ size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// The actual write function that attempts to write to the
+ /// communications protocol.
+ ///
+ /// Subclasses must override this function.
+ ///
+ /// @param[in] src
+ /// A source buffer that must be at least \a src_len bytes
+ /// long.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to attempt to write, and also the
+ /// number of bytes are currently available in \a src.
+ ///
+ /// @return
+ /// The number of bytes actually Written.
+ //------------------------------------------------------------------
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
+ Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Sets the connection that it to be used by this class.
+ ///
+ /// By making a communication class that uses different connections
+ /// it allows a single communication interface to negotiate and
+ /// change its connection without any interruption to the client.
+ /// It also allows the Communication class to be subclassed for
+ /// packet based communication.
+ ///
+ /// @param[in] connection
+ /// A connection that this class will own and destroy.
+ ///
+ /// @see
+ /// class Connection
+ //------------------------------------------------------------------
+ void SetConnection(Connection *connection);
+
+ //------------------------------------------------------------------
+ /// Starts a read thread whose sole purpose it to read bytes from
+ /// the current connection. This function will call connection's
+ /// read function:
+ ///
+ /// size_t Connection::Read (void *, size_t);
+ ///
+ /// When bytes are read and cached, this function will call:
+ ///
+ /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool
+ /// broadcast);
+ ///
+ /// Subclasses should override this function if they wish to override
+ /// the default action of caching the bytes and broadcasting a \b
+ /// eBroadcastBitReadThreadGotBytes event.
+ ///
+ /// @return
+ /// \b True if the read thread was successfully started, \b
+ /// false otherwise.
+ ///
+ /// @see size_t Connection::Read (void *, size_t);
+ /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t
+ /// len, bool broadcast);
+ //------------------------------------------------------------------
+ virtual bool StartReadThread(Error *error_ptr = nullptr);
+
+ //------------------------------------------------------------------
+ /// Stops the read thread by cancelling it.
+ ///
+ /// @return
+ /// \b True if the read thread was successfully canceled, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool StopReadThread(Error *error_ptr = nullptr);
+
+ virtual bool JoinReadThread(Error *error_ptr = nullptr);
+ //------------------------------------------------------------------
+ /// Checks if there is a currently running read thread.
+ ///
+ /// @return
+ /// \b True if the read thread is running, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ReadThreadIsRunning();
+
+ //------------------------------------------------------------------
+ /// The static read thread function. This function will call
+ /// the "DoRead" function continuously and wait for data to become
+ /// available. When data is received it will append the available
+ /// data to the internal cache and broadcast a
+ /// \b eBroadcastBitReadThreadGotBytes event.
+ ///
+ /// @param[in] comm_ptr
+ /// A pointer to an instance of this class.
+ ///
+ /// @return
+ /// \b NULL.
+ ///
+ /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
+ //------------------------------------------------------------------
+ static lldb::thread_result_t ReadThread(lldb::thread_arg_t comm_ptr);
+
+ void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
+ void *callback_baton);
+
+ //------------------------------------------------------------------
+ /// Wait for the read thread to process all outstanding data.
+ ///
+ /// After this function returns, the read thread has processed all data that
+ /// has been waiting in the Connection queue.
+ ///
+ //------------------------------------------------------------------
+ void SynchronizeWithReadThread();
+
+ static const char *ConnectionStatusAsCString(lldb::ConnectionStatus status);
+
+ bool GetCloseOnEOF() const { return m_close_on_eof; }
+
+ void SetCloseOnEOF(bool b) { m_close_on_eof = b; }
+
+ static ConstString &GetStaticBroadcasterClass();
+
+ ConstString &GetBroadcasterClass() const override {
+ return GetStaticBroadcasterClass();
+ }
protected:
- lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class.
- HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
- std::atomic<bool> m_read_thread_enabled;
- std::atomic<bool> m_read_thread_did_exit;
- std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
- std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.
- std::mutex m_write_mutex; ///< Don't let multiple threads write at the same time...
- std::mutex m_synchronize_mutex;
- ReadThreadBytesReceived m_callback;
- void *m_callback_baton;
- bool m_close_on_eof;
-
- size_t
- ReadFromConnection (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr);
-
- //------------------------------------------------------------------
- /// Append new bytes that get read from the read thread into the
- /// internal object byte cache. This will cause a \b
- /// eBroadcastBitReadThreadGotBytes event to be broadcast if \a
- /// broadcast is true.
- ///
- /// Subclasses can override this function in order to inspect the
- /// received data and check if a packet is available.
- ///
- /// Subclasses can also still call this function from the
- /// overridden method to allow the caching to correctly happen and
- /// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes
- /// event by setting \a broadcast to false.
- ///
- /// @param[in] src
- /// A source buffer that must be at least \a src_len bytes
- /// long.
- ///
- /// @param[in] src_len
- /// The number of bytes to append to the cache.
- //------------------------------------------------------------------
- virtual void
- AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status);
-
- //------------------------------------------------------------------
- /// Get any available bytes from our data cache. If this call
- /// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event
- /// will be reset to signify no more bytes are available.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read from the cache,
- /// and also the max number of bytes that can be placed into
- /// \a dst.
- ///
- /// @return
- /// The number of bytes extracted from the data cache.
- //------------------------------------------------------------------
- size_t
- GetCachedBytes (void *dst, size_t dst_len);
+ lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use
+ ///by this communications class.
+ HostThread m_read_thread; ///< The read thread handle in case we need to
+ ///cancel the thread.
+ std::atomic<bool> m_read_thread_enabled;
+ std::atomic<bool> m_read_thread_did_exit;
+ std::string
+ m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
+ std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded
+ ///access to the cached bytes.
+ std::mutex
+ m_write_mutex; ///< Don't let multiple threads write at the same time...
+ std::mutex m_synchronize_mutex;
+ ReadThreadBytesReceived m_callback;
+ void *m_callback_baton;
+ bool m_close_on_eof;
+
+ size_t ReadFromConnection(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status, Error *error_ptr);
+
+ //------------------------------------------------------------------
+ /// Append new bytes that get read from the read thread into the
+ /// internal object byte cache. This will cause a \b
+ /// eBroadcastBitReadThreadGotBytes event to be broadcast if \a
+ /// broadcast is true.
+ ///
+ /// Subclasses can override this function in order to inspect the
+ /// received data and check if a packet is available.
+ ///
+ /// Subclasses can also still call this function from the
+ /// overridden method to allow the caching to correctly happen and
+ /// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes
+ /// event by setting \a broadcast to false.
+ ///
+ /// @param[in] src
+ /// A source buffer that must be at least \a src_len bytes
+ /// long.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to append to the cache.
+ //------------------------------------------------------------------
+ virtual void AppendBytesToCache(const uint8_t *src, size_t src_len,
+ bool broadcast,
+ lldb::ConnectionStatus status);
+
+ //------------------------------------------------------------------
+ /// Get any available bytes from our data cache. If this call
+ /// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event
+ /// will be reset to signify no more bytes are available.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read from the cache,
+ /// and also the max number of bytes that can be placed into
+ /// \a dst.
+ ///
+ /// @return
+ /// The number of bytes extracted from the data cache.
+ //------------------------------------------------------------------
+ size_t GetCachedBytes(void *dst, size_t dst_len);
private:
- DISALLOW_COPY_AND_ASSIGN (Communication);
+ DISALLOW_COPY_AND_ASSIGN(Communication);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Connection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Connection.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Connection.h (original)
+++ lldb/trunk/include/lldb/Core/Connection.h Tue Sep 6 15:57:50 2016
@@ -32,182 +32,170 @@ namespace lldb_private {
/// Communication class to perform communications where clients can
/// listen for broadcasts, and perform other higher level communications.
//----------------------------------------------------------------------
-class Connection
-{
+class Connection {
public:
- //------------------------------------------------------------------
- /// Default constructor
- //------------------------------------------------------------------
- Connection ();
-
- //------------------------------------------------------------------
- /// Virtual destructor since this class gets subclassed and handed
- /// to a Communication object.
- //------------------------------------------------------------------
- virtual
- ~Connection ();
-
- static Connection *CreateDefaultConnection(const char *url);
-
- //------------------------------------------------------------------
- /// Connect using the connect string \a url.
- ///
- /// @param[in] url
- /// A string that contains all information needed by the
- /// subclass to connect to another client.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns false. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// \b True if the connect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- //------------------------------------------------------------------
- virtual lldb::ConnectionStatus
- Connect (const char *url, Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Disconnect the communications connection if one is currently
- /// connected.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns false. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// \b True if the disconnect succeeded, \b false otherwise. The
- /// internal error object should be filled in with an
- /// appropriate value based on the result of this function.
- ///
- /// @see Error& Communication::GetError ();
- //------------------------------------------------------------------
- virtual lldb::ConnectionStatus
- Disconnect (Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Check if the connection is valid.
- ///
- /// @return
- /// \b True if this object is currently connected, \b false
- /// otherwise.
- //------------------------------------------------------------------
- virtual bool
- IsConnected () const = 0;
-
- //------------------------------------------------------------------
- /// The read function that attempts to read from the connection.
- ///
- /// @param[in] dst
- /// A destination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to read, and also the max
- /// number of bytes that can be placed into \a dst.
- ///
- /// @param[in] timeout_usec
- /// The number of microseconds to wait for the data.
- ///
- /// @param[out] status
- /// On return, indicates whether the call was successful or terminated
- /// due to some error condition.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns zero. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// The number of bytes actually read.
- ///
- /// @see size_t Communication::Read (void *, size_t, uint32_t);
- //------------------------------------------------------------------
- virtual size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// The actual write function that attempts to write to the
- /// communications protocol.
- ///
- /// Subclasses must override this function.
- ///
- /// @param[in] dst
- /// A desination buffer that must be at least \a dst_len bytes
- /// long.
- ///
- /// @param[in] dst_len
- /// The number of bytes to attempt to write, and also the
- /// number of bytes are currently available in \a dst.
- ///
- /// @param[out] error_ptr
- /// A pointer to an error object that should be given an
- /// appropriate error value if this method returns zero. This
- /// value can be NULL if the error value should be ignored.
- ///
- /// @return
- /// The number of bytes actually Written.
- //------------------------------------------------------------------
- virtual size_t
- Write (const void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr) = 0;
-
- //------------------------------------------------------------------
- /// Returns a URI that describes this connection object
- ///
- /// Subclasses may override this function.
- ///
- /// @return
- /// Returns URI or an empty string if disconnecteds
- //------------------------------------------------------------------
- virtual std::string
- GetURI() = 0;
-
- //------------------------------------------------------------------
- /// Interrupts an ongoing Read() operation.
- ///
- /// If there is an ongoing read operation in another thread, this operation
- /// return with status == eConnectionStatusInterrupted. Note that if there
- /// data waiting to be read and an interrupt request is issued, the Read()
- /// function will return the data immediately without processing the
- /// interrupt request (which will remain queued for the next Read()
- /// operation).
- ///
- /// @return
- /// Returns true is the interrupt request was successful.
- //------------------------------------------------------------------
- virtual bool
- InterruptRead() = 0;
-
- //------------------------------------------------------------------
- /// Returns the underlying IOObject used by the Connection.
- ///
- /// The IOObject can be used to wait for data to become available
- /// on the connection. If the Connection does not use IOObjects (and
- /// hence does not support waiting) this function should return a
- /// null pointer.
- ///
- /// @return
- /// The underlying IOObject used for reading.
- //------------------------------------------------------------------
- virtual lldb::IOObjectSP
- GetReadObject() { return lldb::IOObjectSP(); }
+ //------------------------------------------------------------------
+ /// Default constructor
+ //------------------------------------------------------------------
+ Connection();
+
+ //------------------------------------------------------------------
+ /// Virtual destructor since this class gets subclassed and handed
+ /// to a Communication object.
+ //------------------------------------------------------------------
+ virtual ~Connection();
+
+ static Connection *CreateDefaultConnection(const char *url);
+
+ //------------------------------------------------------------------
+ /// Connect using the connect string \a url.
+ ///
+ /// @param[in] url
+ /// A string that contains all information needed by the
+ /// subclass to connect to another client.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns false. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// \b True if the connect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ //------------------------------------------------------------------
+ virtual lldb::ConnectionStatus Connect(const char *url, Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Disconnect the communications connection if one is currently
+ /// connected.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns false. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// \b True if the disconnect succeeded, \b false otherwise. The
+ /// internal error object should be filled in with an
+ /// appropriate value based on the result of this function.
+ ///
+ /// @see Error& Communication::GetError ();
+ //------------------------------------------------------------------
+ virtual lldb::ConnectionStatus Disconnect(Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Check if the connection is valid.
+ ///
+ /// @return
+ /// \b True if this object is currently connected, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ virtual bool IsConnected() const = 0;
+
+ //------------------------------------------------------------------
+ /// The read function that attempts to read from the connection.
+ ///
+ /// @param[in] dst
+ /// A destination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to read, and also the max
+ /// number of bytes that can be placed into \a dst.
+ ///
+ /// @param[in] timeout_usec
+ /// The number of microseconds to wait for the data.
+ ///
+ /// @param[out] status
+ /// On return, indicates whether the call was successful or terminated
+ /// due to some error condition.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns zero. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// The number of bytes actually read.
+ ///
+ /// @see size_t Communication::Read (void *, size_t, uint32_t);
+ //------------------------------------------------------------------
+ virtual size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status, Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// The actual write function that attempts to write to the
+ /// communications protocol.
+ ///
+ /// Subclasses must override this function.
+ ///
+ /// @param[in] dst
+ /// A desination buffer that must be at least \a dst_len bytes
+ /// long.
+ ///
+ /// @param[in] dst_len
+ /// The number of bytes to attempt to write, and also the
+ /// number of bytes are currently available in \a dst.
+ ///
+ /// @param[out] error_ptr
+ /// A pointer to an error object that should be given an
+ /// appropriate error value if this method returns zero. This
+ /// value can be NULL if the error value should be ignored.
+ ///
+ /// @return
+ /// The number of bytes actually Written.
+ //------------------------------------------------------------------
+ virtual size_t Write(const void *dst, size_t dst_len,
+ lldb::ConnectionStatus &status, Error *error_ptr) = 0;
+
+ //------------------------------------------------------------------
+ /// Returns a URI that describes this connection object
+ ///
+ /// Subclasses may override this function.
+ ///
+ /// @return
+ /// Returns URI or an empty string if disconnecteds
+ //------------------------------------------------------------------
+ virtual std::string GetURI() = 0;
+
+ //------------------------------------------------------------------
+ /// Interrupts an ongoing Read() operation.
+ ///
+ /// If there is an ongoing read operation in another thread, this operation
+ /// return with status == eConnectionStatusInterrupted. Note that if there
+ /// data waiting to be read and an interrupt request is issued, the Read()
+ /// function will return the data immediately without processing the
+ /// interrupt request (which will remain queued for the next Read()
+ /// operation).
+ ///
+ /// @return
+ /// Returns true is the interrupt request was successful.
+ //------------------------------------------------------------------
+ virtual bool InterruptRead() = 0;
+
+ //------------------------------------------------------------------
+ /// Returns the underlying IOObject used by the Connection.
+ ///
+ /// The IOObject can be used to wait for data to become available
+ /// on the connection. If the Connection does not use IOObjects (and
+ /// hence does not support waiting) this function should return a
+ /// null pointer.
+ ///
+ /// @return
+ /// The underlying IOObject used for reading.
+ //------------------------------------------------------------------
+ virtual lldb::IOObjectSP GetReadObject() { return lldb::IOObjectSP(); }
private:
- //------------------------------------------------------------------
- // For Connection only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Connection);
+ //------------------------------------------------------------------
+ // For Connection only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Connection);
};
} // namespace lldb_private
-#endif // liblldb_Connection_h_
+#endif // liblldb_Connection_h_
Modified: lldb/trunk/include/lldb/Core/ConnectionMachPort.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionMachPort.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionMachPort.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionMachPort.h Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
#define liblldb_ConnectionMachPort_h_
// C Includes
-#include <mach/port.h>
#include <mach/kern_return.h>
+#include <mach/port.h>
// C++ Includes
#include <string>
@@ -22,76 +22,58 @@
// Project includes
#include "lldb/Core/Connection.h"
-class ConnectionMachPort :
- public lldb_private::Connection
-{
+class ConnectionMachPort : public lldb_private::Connection {
public:
- ConnectionMachPort ();
+ ConnectionMachPort();
- virtual
- ~ConnectionMachPort ();
+ virtual ~ConnectionMachPort();
- virtual bool
- IsConnected () const;
+ virtual bool IsConnected() const;
- virtual lldb::ConnectionStatus
- BytesAvailable (uint32_t timeout_usec, lldb_private::Error *error_ptr);
+ virtual lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec,
+ lldb_private::Error *error_ptr);
- virtual lldb::ConnectionStatus
- Connect (const char *s, lldb_private::Error *error_ptr);
+ virtual lldb::ConnectionStatus Connect(const char *s,
+ lldb_private::Error *error_ptr);
- virtual lldb::ConnectionStatus
- Disconnect (lldb_private::Error *error_ptr);
+ virtual lldb::ConnectionStatus Disconnect(lldb_private::Error *error_ptr);
- virtual size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- lldb_private::Error *error_ptr);
+ virtual size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status,
+ lldb_private::Error *error_ptr);
- virtual size_t
- Write (const void *src,
- size_t src_len,
- lldb::ConnectionStatus &status,
- lldb_private::Error *error_ptr);
+ virtual size_t Write(const void *src, size_t src_len,
+ lldb::ConnectionStatus &status,
+ lldb_private::Error *error_ptr);
- virtual std::string
- GetURI();
+ virtual std::string GetURI();
- lldb::ConnectionStatus
- BootstrapCheckIn (const char *port_name,
- lldb_private::Error *error_ptr);
+ lldb::ConnectionStatus BootstrapCheckIn(const char *port_name,
+ lldb_private::Error *error_ptr);
+
+ lldb::ConnectionStatus BootstrapLookup(const char *port_name,
+ lldb_private::Error *error_ptr);
+
+ struct PayloadType {
+ uint32_t command;
+ uint32_t data_length;
+ uint8_t data[32];
+ };
+
+ kern_return_t Send(const PayloadType &payload);
- lldb::ConnectionStatus
- BootstrapLookup (const char *port_name,
- lldb_private::Error *error_ptr);
-
- struct PayloadType
- {
- uint32_t command;
- uint32_t data_length;
- uint8_t data[32];
- };
-
- kern_return_t
- Send (const PayloadType &payload);
-
- kern_return_t
- Receive (PayloadType &payload);
-
+ kern_return_t Receive(PayloadType &payload);
protected:
- mach_port_t m_task;
- mach_port_t m_port;
+ mach_port_t m_task;
+ mach_port_t m_port;
private:
- std::string m_uri;
-
+ std::string m_uri;
- DISALLOW_COPY_AND_ASSIGN (ConnectionMachPort);
+ DISALLOW_COPY_AND_ASSIGN(ConnectionMachPort);
};
-#endif // liblldb_ConnectionMachPort_h_
+#endif // liblldb_ConnectionMachPort_h_
#endif // #if defined(__APPLE__)
Modified: lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h Tue Sep 6 15:57:50 2016
@@ -21,52 +21,39 @@
namespace lldb_private {
-class ConnectionSharedMemory :
- public Connection
-{
+class ConnectionSharedMemory : public Connection {
public:
+ ConnectionSharedMemory();
- ConnectionSharedMemory ();
+ ~ConnectionSharedMemory() override;
- ~ConnectionSharedMemory () override;
+ bool IsConnected() const override;
- bool
- IsConnected () const override;
+ virtual lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec,
+ Error *error_ptr);
- virtual lldb::ConnectionStatus
- BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
+ lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override;
- lldb::ConnectionStatus
- Connect (const char *s, Error *error_ptr) override;
+ lldb::ConnectionStatus Disconnect(Error *error_ptr) override;
- lldb::ConnectionStatus
- Disconnect (Error *error_ptr) override;
+ size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
+ lldb::ConnectionStatus &status, Error *error_ptr) override;
- size_t
- Read (void *dst,
- size_t dst_len,
- uint32_t timeout_usec,
- lldb::ConnectionStatus &status,
- Error *error_ptr) override;
+ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
+ Error *error_ptr) override;
- size_t
- Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override;
+ std::string GetURI() override;
- std::string
- GetURI() override;
-
- lldb::ConnectionStatus
- Open (bool create, const char *name, size_t size, Error *error_ptr);
+ lldb::ConnectionStatus Open(bool create, const char *name, size_t size,
+ Error *error_ptr);
protected:
-
- std::string m_name;
- int m_fd; // One buffer that contains all we need
- DataBufferMemoryMap m_mmap;
+ std::string m_name;
+ int m_fd; // One buffer that contains all we need
+ DataBufferMemoryMap m_mmap;
private:
-
- DISALLOW_COPY_AND_ASSIGN (ConnectionSharedMemory);
+ DISALLOW_COPY_AND_ASSIGN(ConnectionSharedMemory);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ConstString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConstString.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConstString.h (original)
+++ lldb/trunk/include/lldb/Core/ConstString.h Tue Sep 6 15:57:50 2016
@@ -25,503 +25,454 @@ namespace lldb_private {
/// @brief A uniqued constant string class.
///
/// Provides an efficient way to store strings as uniqued strings. After
-/// the strings are uniqued, finding strings that are equal to one
-/// another is very fast as just the pointers need to be compared. It
+/// the strings are uniqued, finding strings that are equal to one
+/// another is very fast as just the pointers need to be compared. It
/// also allows for many common strings from many different sources to
/// be shared to keep the memory footprint low.
///
-/// No reference counting is done on strings that are added to the
+/// No reference counting is done on strings that are added to the
/// string pool, once strings are added they are in the string pool for
/// the life of the program.
//----------------------------------------------------------------------
-class ConstString
-{
+class ConstString {
public:
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// Initializes the string to an empty string.
- //------------------------------------------------------------------
- ConstString():
- m_string(nullptr)
- {
- }
-
- //------------------------------------------------------------------
- /// Copy constructor
- ///
- /// Copies the string value in \a rhs into this object.
- ///
- /// @param[in] rhs
- /// Another string object to copy.
- //------------------------------------------------------------------
- ConstString (const ConstString& rhs) :
- m_string (rhs.m_string)
- {
- }
-
- explicit ConstString (const llvm::StringRef &s);
-
- //------------------------------------------------------------------
- /// Construct with C String value
- ///
- /// Constructs this object with a C string by looking to see if the
- /// C string already exists in the global string pool. If it doesn't
- /// exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- //------------------------------------------------------------------
- explicit ConstString (const char *cstr);
-
- //------------------------------------------------------------------
- /// Construct with C String value with max length
- ///
- /// Constructs this object with a C string with a length. If
- /// \a max_cstr_len is greater than the actual length of the string,
- /// the string length will be truncated. This allows substrings to
- /// be created without the need to NULL terminate the string as it
- /// is passed into this function.
- ///
- /// @param[in] cstr
- /// A pointer to the first character in the C string. The C
- /// string can be NULL terminated in a buffer that contains
- /// more characters than the length of the string, or the
- /// string can be part of another string and a new substring
- /// can be created.
- ///
- /// @param[in] max_cstr_len
- /// The max length of \a cstr. If the string length of \a cstr
- /// is less than \a max_cstr_len, then the string will be
- /// truncated. If the string length of \a cstr is greater than
- /// \a max_cstr_len, then only max_cstr_len bytes will be used
- /// from \a cstr.
- //------------------------------------------------------------------
- explicit ConstString (const char *cstr, size_t max_cstr_len);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// Since constant string values are currently not reference counted,
- /// there isn't much to do here.
- //------------------------------------------------------------------
- ~ConstString() = default;
-
- //----------------------------------------------------------------------
- /// C string equality binary predicate function object for ConstString
- /// objects.
- //----------------------------------------------------------------------
- struct StringIsEqual
- {
- //--------------------------------------------------------------
- /// C equality test.
- ///
- /// Two C strings are equal when they are contained in ConstString
- /// objects when their pointer values are equal to each other.
- ///
- /// @return
- /// Returns \b true if the C string in \a lhs is equal to
- /// the C string value in \a rhs, \b false otherwise.
- //--------------------------------------------------------------
- bool operator()(const char* lhs, const char* rhs) const
- {
- return lhs == rhs;
- }
- };
-
- //------------------------------------------------------------------
- /// Convert to bool operator.
- ///
- /// This allows code to check a ConstString object to see if it
- /// contains a valid string using code such as:
- ///
- /// @code
- /// ConstString str(...);
- /// if (str)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// /b True this object contains a valid non-empty C string, \b
- /// false otherwise.
- //------------------------------------------------------------------
- explicit operator bool() const
- {
- return m_string && m_string[0];
- }
-
- //------------------------------------------------------------------
- /// Assignment operator
- ///
- /// Assigns the string in this object with the value from \a rhs.
- ///
- /// @param[in] rhs
- /// Another string object to copy into this object.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ConstString&
- operator = (const ConstString& rhs)
- {
- m_string = rhs.m_string;
- return *this;
- }
-
- //------------------------------------------------------------------
- /// Equal to operator
- ///
- /// Returns true if this string is equal to the string in \a rhs.
- /// This operation is very fast as it results in a pointer
- /// comparison since all strings are in a uniqued in a global string
- /// pool.
- ///
- /// @param[in] rhs
- /// Another string object to compare this object to.
- ///
- /// @return
- /// @li \b true if this object is equal to \a rhs.
- /// @li \b false if this object is not equal to \a rhs.
- //------------------------------------------------------------------
- bool
- operator == (const ConstString& rhs) const
- {
- // We can do a pointer compare to compare these strings since they
- // must come from the same pool in order to be equal.
- return m_string == rhs.m_string;
- }
-
- //------------------------------------------------------------------
- /// Not equal to operator
- ///
- /// Returns true if this string is not equal to the string in \a rhs.
- /// This operation is very fast as it results in a pointer
- /// comparison since all strings are in a uniqued in a global string
- /// pool.
- ///
- /// @param[in] rhs
- /// Another string object to compare this object to.
- ///
- /// @return
- /// @li \b true if this object is not equal to \a rhs.
- /// @li \b false if this object is equal to \a rhs.
- //------------------------------------------------------------------
- bool
- operator != (const ConstString& rhs) const
- {
- return m_string != rhs.m_string;
- }
-
- bool
- operator < (const ConstString& rhs) const;
-
- //------------------------------------------------------------------
- /// Get the string value as a C string.
- ///
- /// Get the value of the contained string as a NULL terminated C
- /// string value.
- ///
- /// If \a value_if_empty is nullptr, then nullptr will be returned.
- ///
- /// @return
- /// Returns \a value_if_empty if the string is empty, otherwise
- /// the C string value contained in this object.
- //------------------------------------------------------------------
- const char *
- AsCString(const char *value_if_empty = nullptr) const
- {
- return (IsEmpty() ? value_if_empty : m_string);
- }
-
- //------------------------------------------------------------------
- /// Get the string value as a llvm::StringRef
- ///
- /// @return
- /// Returns a new llvm::StringRef object filled in with the
- /// needed data.
- //------------------------------------------------------------------
- llvm::StringRef
- GetStringRef () const
- {
- return llvm::StringRef (m_string, GetLength());
- }
-
- //------------------------------------------------------------------
- /// Get the string value as a C string.
- ///
- /// Get the value of the contained string as a NULL terminated C
- /// string value. Similar to the ConstString::AsCString() function,
- /// yet this function will always return nullptr if the string is not
- /// valid. So this function is a direct accessor to the string
- /// pointer value.
- ///
- /// @return
- /// Returns nullptr the string is invalid, otherwise the C string
- /// value contained in this object.
- //------------------------------------------------------------------
- const char *
- GetCString () const
- {
- return m_string;
- }
-
- //------------------------------------------------------------------
- /// Get the length in bytes of string value.
- ///
- /// The string pool stores the length of the string, so we can avoid
- /// calling strlen() on the pointer value with this function.
- ///
- /// @return
- /// Returns the number of bytes that this string occupies in
- /// memory, not including the NULL termination byte.
- //------------------------------------------------------------------
- size_t
- GetLength () const;
-
- //------------------------------------------------------------------
- /// Clear this object's state.
- ///
- /// Clear any contained string and reset the value to the an empty
- /// string value.
- //------------------------------------------------------------------
- void
- Clear ()
- {
- m_string = nullptr;
- }
-
- //------------------------------------------------------------------
- /// Equal to operator
- ///
- /// Returns true if this string is equal to the string in \a rhs.
- /// If case sensitive equality is tested, this operation is very
- /// fast as it results in a pointer comparison since all strings
- /// are in a uniqued in a global string pool.
- ///
- /// @param[in] rhs
- /// The Left Hand Side const ConstString object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const ConstString object reference.
- ///
- /// @param[in] case_sensitive
- /// Case sensitivity. If true, case sensitive equality
- /// will be tested, otherwise character case will be ignored
- ///
- /// @return
- /// @li \b true if this object is equal to \a rhs.
- /// @li \b false if this object is not equal to \a rhs.
- //------------------------------------------------------------------
- static bool
- Equals(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive = true);
-
- //------------------------------------------------------------------
- /// Compare two string objects.
- ///
- /// Compares the C string values contained in \a lhs and \a rhs and
- /// returns an integer result.
- ///
- /// NOTE: only call this function when you want a true string
- /// comparison. If you want string equality use the, use the ==
- /// operator as it is much more efficient. Also if you want string
- /// inequality, use the != operator for the same reasons.
- ///
- /// @param[in] lhs
- /// The Left Hand Side const ConstString object reference.
- ///
- /// @param[in] rhs
- /// The Right Hand Side const ConstString object reference.
- ///
- /// @param[in] case_sensitive
- /// Case sensitivity of compare. If true, case sensitive compare
- /// will be performed, otherwise character case will be ignored
- ///
- /// @return
- /// @li -1 if lhs < rhs
- /// @li 0 if lhs == rhs
- /// @li 1 if lhs > rhs
- //------------------------------------------------------------------
- static int
- Compare(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive = true);
-
- //------------------------------------------------------------------
- /// Dump the object description to a stream.
- ///
- /// Dump the string value to the stream \a s. If the contained string
- /// is empty, print \a value_if_empty to the stream instead. If
- /// \a value_if_empty is nullptr, then nothing will be dumped to the
- /// stream.
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- ///
- /// @param[in] value_if_empty
- /// The value to dump if the string is empty. If nullptr, nothing
- /// will be output to the stream.
- //------------------------------------------------------------------
- void
- Dump(Stream *s, const char *value_if_empty = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dump the object debug description to a stream.
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- //------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
-
- //------------------------------------------------------------------
- /// Test for empty string.
- ///
- /// @return
- /// @li \b true if the contained string is empty.
- /// @li \b false if the contained string is not empty.
- //------------------------------------------------------------------
- bool
- IsEmpty () const
- {
- return m_string == nullptr || m_string[0] == '\0';
- }
-
- //------------------------------------------------------------------
- /// Set the C string value.
- ///
- /// Set the string value in the object by uniquing the \a cstr
- /// string value in our global string pool.
- ///
- /// If the C string already exists in the global string pool, it
- /// finds the current entry and returns the existing value. If it
- /// doesn't exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- //------------------------------------------------------------------
- void
- SetCString (const char *cstr);
-
- void
- SetString (const llvm::StringRef &s);
-
- //------------------------------------------------------------------
- /// Set the C string value and its mangled counterpart.
- ///
- /// Object files and debug symbols often use mangled string to
- /// represent the linkage name for a symbol, function or global.
- /// The string pool can efficiently store these values and their
- /// counterparts so when we run into another instance of a mangled
- /// name, we can avoid calling the name demangler over and over on
- /// the same strings and then trying to unique them.
- ///
- /// @param[in] demangled
- /// The demangled C string to correlate with the \a mangled
- /// name.
- ///
- /// @param[in] mangled
- /// The already uniqued mangled ConstString to correlate the
- /// soon to be uniqued version of \a demangled.
- //------------------------------------------------------------------
- void
- SetCStringWithMangledCounterpart (const char *demangled,
- const ConstString &mangled);
-
- //------------------------------------------------------------------
- /// Retrieve the mangled or demangled counterpart for a mangled
- /// or demangled ConstString.
- ///
- /// Object files and debug symbols often use mangled string to
- /// represent the linkage name for a symbol, function or global.
- /// The string pool can efficiently store these values and their
- /// counterparts so when we run into another instance of a mangled
- /// name, we can avoid calling the name demangler over and over on
- /// the same strings and then trying to unique them.
- ///
- /// @param[in] counterpart
- /// A reference to a ConstString object that might get filled in
- /// with the demangled/mangled counterpart.
- ///
- /// @return
- /// /b True if \a counterpart was filled in with the counterpart
- /// /b false otherwise.
- //------------------------------------------------------------------
- bool
- GetMangledCounterpart (ConstString &counterpart) const;
-
- //------------------------------------------------------------------
- /// Set the C string value with length.
- ///
- /// Set the string value in the object by uniquing \a cstr_len bytes
- /// starting at the \a cstr string value in our global string pool.
- /// If trim is true, then \a cstr_len indicates a maximum length of
- /// the CString and if the actual length of the string is less, then
- /// it will be trimmed.
- ///
- /// If the C string already exists in the global string pool, it
- /// finds the current entry and returns the existing value. If it
- /// doesn't exist, it is added to the string pool.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string to add to the string pool.
- ///
- /// @param[in] cstr_len
- /// The maximum length of the C string.
- //------------------------------------------------------------------
- void
- SetCStringWithLength (const char *cstr, size_t cstr_len);
-
- //------------------------------------------------------------------
- /// Set the C string value with the minimum length between
- /// \a fixed_cstr_len and the actual length of the C string. This
- /// can be used for data structures that have a fixed length to
- /// store a C string where the string might not be NULL terminated
- /// if the string takes the entire buffer.
- //------------------------------------------------------------------
- void
- SetTrimmedCStringWithLength (const char *cstr, size_t fixed_cstr_len);
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, which does not include
- /// any the shared string values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const
- {
- return sizeof(ConstString);
- }
-
- //------------------------------------------------------------------
- /// Get the size in bytes of the current global string pool.
- ///
- /// Reports the size in bytes of all shared C string values,
- /// containers and any other values as a byte size for the
- /// entire string pool.
- ///
- /// @return
- /// The number of bytes that the global string pool occupies
- /// in memory.
- //------------------------------------------------------------------
- static size_t
- StaticMemorySize ();
+ //------------------------------------------------------------------
+ /// Default constructor
+ ///
+ /// Initializes the string to an empty string.
+ //------------------------------------------------------------------
+ ConstString() : m_string(nullptr) {}
+
+ //------------------------------------------------------------------
+ /// Copy constructor
+ ///
+ /// Copies the string value in \a rhs into this object.
+ ///
+ /// @param[in] rhs
+ /// Another string object to copy.
+ //------------------------------------------------------------------
+ ConstString(const ConstString &rhs) : m_string(rhs.m_string) {}
+
+ explicit ConstString(const llvm::StringRef &s);
+
+ //------------------------------------------------------------------
+ /// Construct with C String value
+ ///
+ /// Constructs this object with a C string by looking to see if the
+ /// C string already exists in the global string pool. If it doesn't
+ /// exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ //------------------------------------------------------------------
+ explicit ConstString(const char *cstr);
+
+ //------------------------------------------------------------------
+ /// Construct with C String value with max length
+ ///
+ /// Constructs this object with a C string with a length. If
+ /// \a max_cstr_len is greater than the actual length of the string,
+ /// the string length will be truncated. This allows substrings to
+ /// be created without the need to NULL terminate the string as it
+ /// is passed into this function.
+ ///
+ /// @param[in] cstr
+ /// A pointer to the first character in the C string. The C
+ /// string can be NULL terminated in a buffer that contains
+ /// more characters than the length of the string, or the
+ /// string can be part of another string and a new substring
+ /// can be created.
+ ///
+ /// @param[in] max_cstr_len
+ /// The max length of \a cstr. If the string length of \a cstr
+ /// is less than \a max_cstr_len, then the string will be
+ /// truncated. If the string length of \a cstr is greater than
+ /// \a max_cstr_len, then only max_cstr_len bytes will be used
+ /// from \a cstr.
+ //------------------------------------------------------------------
+ explicit ConstString(const char *cstr, size_t max_cstr_len);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// Since constant string values are currently not reference counted,
+ /// there isn't much to do here.
+ //------------------------------------------------------------------
+ ~ConstString() = default;
+
+ //----------------------------------------------------------------------
+ /// C string equality binary predicate function object for ConstString
+ /// objects.
+ //----------------------------------------------------------------------
+ struct StringIsEqual {
+ //--------------------------------------------------------------
+ /// C equality test.
+ ///
+ /// Two C strings are equal when they are contained in ConstString
+ /// objects when their pointer values are equal to each other.
+ ///
+ /// @return
+ /// Returns \b true if the C string in \a lhs is equal to
+ /// the C string value in \a rhs, \b false otherwise.
+ //--------------------------------------------------------------
+ bool operator()(const char *lhs, const char *rhs) const {
+ return lhs == rhs;
+ }
+ };
+
+ //------------------------------------------------------------------
+ /// Convert to bool operator.
+ ///
+ /// This allows code to check a ConstString object to see if it
+ /// contains a valid string using code such as:
+ ///
+ /// @code
+ /// ConstString str(...);
+ /// if (str)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// /b True this object contains a valid non-empty C string, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ explicit operator bool() const { return m_string && m_string[0]; }
+
+ //------------------------------------------------------------------
+ /// Assignment operator
+ ///
+ /// Assigns the string in this object with the value from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// Another string object to copy into this object.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ConstString &operator=(const ConstString &rhs) {
+ m_string = rhs.m_string;
+ return *this;
+ }
+
+ //------------------------------------------------------------------
+ /// Equal to operator
+ ///
+ /// Returns true if this string is equal to the string in \a rhs.
+ /// This operation is very fast as it results in a pointer
+ /// comparison since all strings are in a uniqued in a global string
+ /// pool.
+ ///
+ /// @param[in] rhs
+ /// Another string object to compare this object to.
+ ///
+ /// @return
+ /// @li \b true if this object is equal to \a rhs.
+ /// @li \b false if this object is not equal to \a rhs.
+ //------------------------------------------------------------------
+ bool operator==(const ConstString &rhs) const {
+ // We can do a pointer compare to compare these strings since they
+ // must come from the same pool in order to be equal.
+ return m_string == rhs.m_string;
+ }
+
+ //------------------------------------------------------------------
+ /// Not equal to operator
+ ///
+ /// Returns true if this string is not equal to the string in \a rhs.
+ /// This operation is very fast as it results in a pointer
+ /// comparison since all strings are in a uniqued in a global string
+ /// pool.
+ ///
+ /// @param[in] rhs
+ /// Another string object to compare this object to.
+ ///
+ /// @return
+ /// @li \b true if this object is not equal to \a rhs.
+ /// @li \b false if this object is equal to \a rhs.
+ //------------------------------------------------------------------
+ bool operator!=(const ConstString &rhs) const {
+ return m_string != rhs.m_string;
+ }
+
+ bool operator<(const ConstString &rhs) const;
+
+ //------------------------------------------------------------------
+ /// Get the string value as a C string.
+ ///
+ /// Get the value of the contained string as a NULL terminated C
+ /// string value.
+ ///
+ /// If \a value_if_empty is nullptr, then nullptr will be returned.
+ ///
+ /// @return
+ /// Returns \a value_if_empty if the string is empty, otherwise
+ /// the C string value contained in this object.
+ //------------------------------------------------------------------
+ const char *AsCString(const char *value_if_empty = nullptr) const {
+ return (IsEmpty() ? value_if_empty : m_string);
+ }
+
+ //------------------------------------------------------------------
+ /// Get the string value as a llvm::StringRef
+ ///
+ /// @return
+ /// Returns a new llvm::StringRef object filled in with the
+ /// needed data.
+ //------------------------------------------------------------------
+ llvm::StringRef GetStringRef() const {
+ return llvm::StringRef(m_string, GetLength());
+ }
+
+ //------------------------------------------------------------------
+ /// Get the string value as a C string.
+ ///
+ /// Get the value of the contained string as a NULL terminated C
+ /// string value. Similar to the ConstString::AsCString() function,
+ /// yet this function will always return nullptr if the string is not
+ /// valid. So this function is a direct accessor to the string
+ /// pointer value.
+ ///
+ /// @return
+ /// Returns nullptr the string is invalid, otherwise the C string
+ /// value contained in this object.
+ //------------------------------------------------------------------
+ const char *GetCString() const { return m_string; }
+
+ //------------------------------------------------------------------
+ /// Get the length in bytes of string value.
+ ///
+ /// The string pool stores the length of the string, so we can avoid
+ /// calling strlen() on the pointer value with this function.
+ ///
+ /// @return
+ /// Returns the number of bytes that this string occupies in
+ /// memory, not including the NULL termination byte.
+ //------------------------------------------------------------------
+ size_t GetLength() const;
+
+ //------------------------------------------------------------------
+ /// Clear this object's state.
+ ///
+ /// Clear any contained string and reset the value to the an empty
+ /// string value.
+ //------------------------------------------------------------------
+ void Clear() { m_string = nullptr; }
+
+ //------------------------------------------------------------------
+ /// Equal to operator
+ ///
+ /// Returns true if this string is equal to the string in \a rhs.
+ /// If case sensitive equality is tested, this operation is very
+ /// fast as it results in a pointer comparison since all strings
+ /// are in a uniqued in a global string pool.
+ ///
+ /// @param[in] rhs
+ /// The Left Hand Side const ConstString object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const ConstString object reference.
+ ///
+ /// @param[in] case_sensitive
+ /// Case sensitivity. If true, case sensitive equality
+ /// will be tested, otherwise character case will be ignored
+ ///
+ /// @return
+ /// @li \b true if this object is equal to \a rhs.
+ /// @li \b false if this object is not equal to \a rhs.
+ //------------------------------------------------------------------
+ static bool Equals(const ConstString &lhs, const ConstString &rhs,
+ const bool case_sensitive = true);
+
+ //------------------------------------------------------------------
+ /// Compare two string objects.
+ ///
+ /// Compares the C string values contained in \a lhs and \a rhs and
+ /// returns an integer result.
+ ///
+ /// NOTE: only call this function when you want a true string
+ /// comparison. If you want string equality use the, use the ==
+ /// operator as it is much more efficient. Also if you want string
+ /// inequality, use the != operator for the same reasons.
+ ///
+ /// @param[in] lhs
+ /// The Left Hand Side const ConstString object reference.
+ ///
+ /// @param[in] rhs
+ /// The Right Hand Side const ConstString object reference.
+ ///
+ /// @param[in] case_sensitive
+ /// Case sensitivity of compare. If true, case sensitive compare
+ /// will be performed, otherwise character case will be ignored
+ ///
+ /// @return
+ /// @li -1 if lhs < rhs
+ /// @li 0 if lhs == rhs
+ /// @li 1 if lhs > rhs
+ //------------------------------------------------------------------
+ static int Compare(const ConstString &lhs, const ConstString &rhs,
+ const bool case_sensitive = true);
+
+ //------------------------------------------------------------------
+ /// Dump the object description to a stream.
+ ///
+ /// Dump the string value to the stream \a s. If the contained string
+ /// is empty, print \a value_if_empty to the stream instead. If
+ /// \a value_if_empty is nullptr, then nothing will be dumped to the
+ /// stream.
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ ///
+ /// @param[in] value_if_empty
+ /// The value to dump if the string is empty. If nullptr, nothing
+ /// will be output to the stream.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, const char *value_if_empty = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dump the object debug description to a stream.
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ //------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
+
+ //------------------------------------------------------------------
+ /// Test for empty string.
+ ///
+ /// @return
+ /// @li \b true if the contained string is empty.
+ /// @li \b false if the contained string is not empty.
+ //------------------------------------------------------------------
+ bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; }
+
+ //------------------------------------------------------------------
+ /// Set the C string value.
+ ///
+ /// Set the string value in the object by uniquing the \a cstr
+ /// string value in our global string pool.
+ ///
+ /// If the C string already exists in the global string pool, it
+ /// finds the current entry and returns the existing value. If it
+ /// doesn't exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ //------------------------------------------------------------------
+ void SetCString(const char *cstr);
+
+ void SetString(const llvm::StringRef &s);
+
+ //------------------------------------------------------------------
+ /// Set the C string value and its mangled counterpart.
+ ///
+ /// Object files and debug symbols often use mangled string to
+ /// represent the linkage name for a symbol, function or global.
+ /// The string pool can efficiently store these values and their
+ /// counterparts so when we run into another instance of a mangled
+ /// name, we can avoid calling the name demangler over and over on
+ /// the same strings and then trying to unique them.
+ ///
+ /// @param[in] demangled
+ /// The demangled C string to correlate with the \a mangled
+ /// name.
+ ///
+ /// @param[in] mangled
+ /// The already uniqued mangled ConstString to correlate the
+ /// soon to be uniqued version of \a demangled.
+ //------------------------------------------------------------------
+ void SetCStringWithMangledCounterpart(const char *demangled,
+ const ConstString &mangled);
+
+ //------------------------------------------------------------------
+ /// Retrieve the mangled or demangled counterpart for a mangled
+ /// or demangled ConstString.
+ ///
+ /// Object files and debug symbols often use mangled string to
+ /// represent the linkage name for a symbol, function or global.
+ /// The string pool can efficiently store these values and their
+ /// counterparts so when we run into another instance of a mangled
+ /// name, we can avoid calling the name demangler over and over on
+ /// the same strings and then trying to unique them.
+ ///
+ /// @param[in] counterpart
+ /// A reference to a ConstString object that might get filled in
+ /// with the demangled/mangled counterpart.
+ ///
+ /// @return
+ /// /b True if \a counterpart was filled in with the counterpart
+ /// /b false otherwise.
+ //------------------------------------------------------------------
+ bool GetMangledCounterpart(ConstString &counterpart) const;
+
+ //------------------------------------------------------------------
+ /// Set the C string value with length.
+ ///
+ /// Set the string value in the object by uniquing \a cstr_len bytes
+ /// starting at the \a cstr string value in our global string pool.
+ /// If trim is true, then \a cstr_len indicates a maximum length of
+ /// the CString and if the actual length of the string is less, then
+ /// it will be trimmed.
+ ///
+ /// If the C string already exists in the global string pool, it
+ /// finds the current entry and returns the existing value. If it
+ /// doesn't exist, it is added to the string pool.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string to add to the string pool.
+ ///
+ /// @param[in] cstr_len
+ /// The maximum length of the C string.
+ //------------------------------------------------------------------
+ void SetCStringWithLength(const char *cstr, size_t cstr_len);
+
+ //------------------------------------------------------------------
+ /// Set the C string value with the minimum length between
+ /// \a fixed_cstr_len and the actual length of the C string. This
+ /// can be used for data structures that have a fixed length to
+ /// store a C string where the string might not be NULL terminated
+ /// if the string takes the entire buffer.
+ //------------------------------------------------------------------
+ void SetTrimmedCStringWithLength(const char *cstr, size_t fixed_cstr_len);
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, which does not include
+ /// any the shared string values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const { return sizeof(ConstString); }
+
+ //------------------------------------------------------------------
+ /// Get the size in bytes of the current global string pool.
+ ///
+ /// Reports the size in bytes of all shared C string values,
+ /// containers and any other values as a byte size for the
+ /// entire string pool.
+ ///
+ /// @return
+ /// The number of bytes that the global string pool occupies
+ /// in memory.
+ //------------------------------------------------------------------
+ static size_t StaticMemorySize();
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- const char *m_string;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ const char *m_string;
};
//------------------------------------------------------------------
/// Stream the string value \a str to the stream \a s
//------------------------------------------------------------------
-Stream& operator << (Stream& s, const ConstString& str);
+Stream &operator<<(Stream &s, const ConstString &str);
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/CxaDemangle.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/CxaDemangle.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/CxaDemangle.h (original)
+++ lldb/trunk/include/lldb/Core/CxaDemangle.h Tue Sep 6 15:57:50 2016
@@ -10,12 +10,10 @@
#ifndef liblldb_CxaDemangle_h_
#define liblldb_CxaDemangle_h_
-namespace lldb_private
-{
-
- char*
- __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status);
+namespace lldb_private {
+char *__cxa_demangle(const char *mangled_name, char *buf, size_t *n,
+ int *status);
}
#endif
Modified: lldb/trunk/include/lldb/Core/DataBuffer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataBuffer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataBuffer.h (original)
+++ lldb/trunk/include/lldb/Core/DataBuffer.h Tue Sep 6 15:57:50 2016
@@ -45,64 +45,55 @@ namespace lldb_private {
/// data on demand with some extra function calls to load the data
/// before it gets accessed.
//----------------------------------------------------------------------
-class DataBuffer
-{
+class DataBuffer {
public:
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// The destructor is virtual as other classes will inherit from
- /// this class and be downcast to the DataBuffer pure virtual
- /// interface. The virtual destructor ensures that destructing the
- /// base class will destruct the class that inherited from it
- /// correctly.
- //------------------------------------------------------------------
- virtual
- ~DataBuffer()
- {
- }
-
- //------------------------------------------------------------------
- /// Get a pointer to the data.
- ///
- /// @return
- /// A pointer to the bytes owned by this object, or NULL if the
- /// object contains no bytes.
- //------------------------------------------------------------------
- virtual uint8_t *
- GetBytes () = 0;
-
- //------------------------------------------------------------------
- /// Get a const pointer to the data.
- ///
- /// @return
- /// A const pointer to the bytes owned by this object, or NULL
- /// if the object contains no bytes.
- //------------------------------------------------------------------
- virtual const uint8_t *
- GetBytes () const = 0;
-
- //------------------------------------------------------------------
- /// Get the number of bytes in the data buffer.
- ///
- /// @return
- /// The number of bytes this object currently contains.
- //------------------------------------------------------------------
- virtual lldb::offset_t
- GetByteSize() const = 0;
-
- llvm::ArrayRef<uint8_t> GetData() const
- {
- return llvm::ArrayRef<uint8_t>(GetBytes(), GetByteSize());
- }
-
- llvm::MutableArrayRef<uint8_t> GetData()
- {
- return llvm::MutableArrayRef<uint8_t>(GetBytes(), GetByteSize());
- }
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// The destructor is virtual as other classes will inherit from
+ /// this class and be downcast to the DataBuffer pure virtual
+ /// interface. The virtual destructor ensures that destructing the
+ /// base class will destruct the class that inherited from it
+ /// correctly.
+ //------------------------------------------------------------------
+ virtual ~DataBuffer() {}
+
+ //------------------------------------------------------------------
+ /// Get a pointer to the data.
+ ///
+ /// @return
+ /// A pointer to the bytes owned by this object, or NULL if the
+ /// object contains no bytes.
+ //------------------------------------------------------------------
+ virtual uint8_t *GetBytes() = 0;
+
+ //------------------------------------------------------------------
+ /// Get a const pointer to the data.
+ ///
+ /// @return
+ /// A const pointer to the bytes owned by this object, or NULL
+ /// if the object contains no bytes.
+ //------------------------------------------------------------------
+ virtual const uint8_t *GetBytes() const = 0;
+
+ //------------------------------------------------------------------
+ /// Get the number of bytes in the data buffer.
+ ///
+ /// @return
+ /// The number of bytes this object currently contains.
+ //------------------------------------------------------------------
+ virtual lldb::offset_t GetByteSize() const = 0;
+
+ llvm::ArrayRef<uint8_t> GetData() const {
+ return llvm::ArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
+
+ llvm::MutableArrayRef<uint8_t> GetData() {
+ return llvm::MutableArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
};
} // namespace lldb_private
-#endif /// #if defined(__cplusplus)
-#endif /// lldb_DataBuffer_h_
+#endif /// #if defined(__cplusplus)
+#endif /// lldb_DataBuffer_h_
Modified: lldb/trunk/include/lldb/Core/DataBufferHeap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataBufferHeap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataBufferHeap.h (original)
+++ lldb/trunk/include/lldb/Core/DataBufferHeap.h Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
#include <vector>
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -27,111 +27,103 @@ namespace lldb_private {
/// fault new data pages in. Large amounts of data that comes from files
/// should probably use the DataBufferMemoryMap class.
//----------------------------------------------------------------------
-class DataBufferHeap : public DataBuffer
-{
+class DataBufferHeap : public DataBuffer {
public:
- //------------------------------------------------------------------
- /// Default constructor
- ///
- /// Initializes the heap based buffer with no bytes.
- //------------------------------------------------------------------
- DataBufferHeap ();
-
- //------------------------------------------------------------------
- /// Construct with size \a n and fill with \a ch.
- ///
- /// Initialize this class with \a n bytes and fills the buffer with
- /// \a ch.
- ///
- /// @param[in] n
- /// The number of bytes that heap based buffer should contain.
- ///
- /// @param[in] ch
- /// The character to use when filling the buffer initially.
- //------------------------------------------------------------------
- DataBufferHeap (lldb::offset_t n, uint8_t ch);
-
- //------------------------------------------------------------------
- /// Construct by making a copy of \a src_len bytes from \a src.
- ///
- /// @param[in] src
- /// A pointer to the data to copy.
- ///
- /// @param[in] src_len
- /// The number of bytes in \a src to copy.
- //------------------------------------------------------------------
- DataBufferHeap (const void *src, lldb::offset_t src_len);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Virtual destructor since this class inherits from a pure virtual
- /// base class #DataBuffer.
- //------------------------------------------------------------------
- ~DataBufferHeap() override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes()
- //------------------------------------------------------------------
- uint8_t *
- GetBytes () override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
- const uint8_t *
- GetBytes () const override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
- lldb::offset_t
- GetByteSize () const override;
-
- //------------------------------------------------------------------
- /// Set the number of bytes in the data buffer.
- ///
- /// Sets the number of bytes that this object should be able to
- /// contain. This can be used prior to copying data into the buffer.
- ///
- /// @param[in] byte_size
- /// The new size in bytes that this data buffer should attempt
- /// to resize itself to.
- ///
- /// @return
- /// The size in bytes after that this heap buffer was
- /// successfully resized to.
- //------------------------------------------------------------------
- lldb::offset_t
- SetByteSize (lldb::offset_t byte_size);
-
- //------------------------------------------------------------------
- /// Makes a copy of the \a src_len bytes in \a src.
- ///
- /// Copies the data in \a src into an internal buffer.
- ///
- /// @param[in] src
- /// A pointer to the data to copy.
- ///
- /// @param[in] src_len
- /// The number of bytes in \a src to copy.
- //------------------------------------------------------------------
- void
- CopyData (const void *src, lldb::offset_t src_len);
+ //------------------------------------------------------------------
+ /// Default constructor
+ ///
+ /// Initializes the heap based buffer with no bytes.
+ //------------------------------------------------------------------
+ DataBufferHeap();
+
+ //------------------------------------------------------------------
+ /// Construct with size \a n and fill with \a ch.
+ ///
+ /// Initialize this class with \a n bytes and fills the buffer with
+ /// \a ch.
+ ///
+ /// @param[in] n
+ /// The number of bytes that heap based buffer should contain.
+ ///
+ /// @param[in] ch
+ /// The character to use when filling the buffer initially.
+ //------------------------------------------------------------------
+ DataBufferHeap(lldb::offset_t n, uint8_t ch);
+
+ //------------------------------------------------------------------
+ /// Construct by making a copy of \a src_len bytes from \a src.
+ ///
+ /// @param[in] src
+ /// A pointer to the data to copy.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes in \a src to copy.
+ //------------------------------------------------------------------
+ DataBufferHeap(const void *src, lldb::offset_t src_len);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Virtual destructor since this class inherits from a pure virtual
+ /// base class #DataBuffer.
+ //------------------------------------------------------------------
+ ~DataBufferHeap() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes()
+ //------------------------------------------------------------------
+ uint8_t *GetBytes() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes() const
+ //------------------------------------------------------------------
+ const uint8_t *GetBytes() const override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetByteSize() const
+ //------------------------------------------------------------------
+ lldb::offset_t GetByteSize() const override;
+
+ //------------------------------------------------------------------
+ /// Set the number of bytes in the data buffer.
+ ///
+ /// Sets the number of bytes that this object should be able to
+ /// contain. This can be used prior to copying data into the buffer.
+ ///
+ /// @param[in] byte_size
+ /// The new size in bytes that this data buffer should attempt
+ /// to resize itself to.
+ ///
+ /// @return
+ /// The size in bytes after that this heap buffer was
+ /// successfully resized to.
+ //------------------------------------------------------------------
+ lldb::offset_t SetByteSize(lldb::offset_t byte_size);
+
+ //------------------------------------------------------------------
+ /// Makes a copy of the \a src_len bytes in \a src.
+ ///
+ /// Copies the data in \a src into an internal buffer.
+ ///
+ /// @param[in] src
+ /// A pointer to the data to copy.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes in \a src to copy.
+ //------------------------------------------------------------------
+ void CopyData(const void *src, lldb::offset_t src_len);
- void
- AppendData (const void *src, uint64_t src_len);
+ void AppendData(const void *src, uint64_t src_len);
- void
- Clear();
+ void Clear();
private:
- //------------------------------------------------------------------
- // This object uses a std::vector<uint8_t> to store its data. This
- // takes care of free the data when the object is deleted.
- //------------------------------------------------------------------
- typedef std::vector<uint8_t> buffer_t; ///< Buffer type
- buffer_t m_data; ///< The heap based buffer where data is stored
+ //------------------------------------------------------------------
+ // This object uses a std::vector<uint8_t> to store its data. This
+ // takes care of free the data when the object is deleted.
+ //------------------------------------------------------------------
+ typedef std::vector<uint8_t> buffer_t; ///< Buffer type
+ buffer_t m_data; ///< The heap based buffer where data is stored
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h (original)
+++ lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h Tue Sep 6 15:57:50 2016
@@ -10,15 +10,16 @@
#ifndef liblldb_DataBufferMemoryMap_h_
#define liblldb_DataBufferMemoryMap_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private.h"
#include <string>
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class DataBufferMemoryMap DataBufferMemoryMap.h "lldb/Core/DataBufferMemoryMap.h"
+/// @class DataBufferMemoryMap DataBufferMemoryMap.h
+/// "lldb/Core/DataBufferMemoryMap.h"
/// @brief A subclass of DataBuffer that memory maps data.
///
/// This class memory maps data and stores any needed data for the
@@ -29,131 +30,123 @@ namespace lldb_private {
/// This class is designed to allow pages to be faulted in as needed and
/// works well data from large files that won't be accessed all at once.
//----------------------------------------------------------------------
-class DataBufferMemoryMap : public DataBuffer
-{
+class DataBufferMemoryMap : public DataBuffer {
public:
- //------------------------------------------------------------------
- /// Default Constructor
- //------------------------------------------------------------------
- DataBufferMemoryMap ();
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Virtual destructor since this class inherits from a pure virtual
- /// base class #DataBuffer.
- //------------------------------------------------------------------
- ~DataBufferMemoryMap () override;
-
- //------------------------------------------------------------------
- /// Reverts this object to an empty state by unmapping any memory
- /// that is currently owned.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes()
- //------------------------------------------------------------------
- uint8_t *
- GetBytes () override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
- const uint8_t *
- GetBytes () const override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
- lldb::offset_t
- GetByteSize () const override;
-
- //------------------------------------------------------------------
- /// Error get accessor.
- ///
- /// @return
- /// A const reference to Error object in case memory mapping
- /// fails.
- //------------------------------------------------------------------
- const Error &
- GetError() const;
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from \a file starting \a offset
- /// bytes into the file. If \a length is set to \c SIZE_MAX,
- /// then map as many bytes as possible.
- ///
- /// @param[in] file
- /// The file specification from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible. Even though it may be possible
- /// for a 32-bit host debugger to debug a 64-bit target, size_t
- /// still dictates the maximum possible size that can be mapped
- /// into this process. For this kind of cross-arch debugging
- /// scenario, mappings and views should be managed at a higher
- /// level.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t
- MemoryMapFromFileSpec (const FileSpec* file,
- lldb::offset_t offset = 0,
- size_t length = SIZE_MAX,
- bool writeable = false);
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from an opened file descriptor \a fd
- /// starting \a offset bytes into the file. If \a length is set to
- /// \c SIZE_MAX, then map as many bytes as possible.
- ///
- /// @param[in] fd
- /// The posix file descriptor for an already opened file
- /// from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t
- MemoryMapFromFileDescriptor (int fd,
- lldb::offset_t offset,
- size_t length,
- bool write,
- bool fd_is_file);
+ //------------------------------------------------------------------
+ /// Default Constructor
+ //------------------------------------------------------------------
+ DataBufferMemoryMap();
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Virtual destructor since this class inherits from a pure virtual
+ /// base class #DataBuffer.
+ //------------------------------------------------------------------
+ ~DataBufferMemoryMap() override;
+
+ //------------------------------------------------------------------
+ /// Reverts this object to an empty state by unmapping any memory
+ /// that is currently owned.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes()
+ //------------------------------------------------------------------
+ uint8_t *GetBytes() override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetBytes() const
+ //------------------------------------------------------------------
+ const uint8_t *GetBytes() const override;
+
+ //------------------------------------------------------------------
+ /// @copydoc DataBuffer::GetByteSize() const
+ //------------------------------------------------------------------
+ lldb::offset_t GetByteSize() const override;
+
+ //------------------------------------------------------------------
+ /// Error get accessor.
+ ///
+ /// @return
+ /// A const reference to Error object in case memory mapping
+ /// fails.
+ //------------------------------------------------------------------
+ const Error &GetError() const;
+
+ //------------------------------------------------------------------
+ /// Memory map all or part of a file.
+ ///
+ /// Memory map \a length bytes from \a file starting \a offset
+ /// bytes into the file. If \a length is set to \c SIZE_MAX,
+ /// then map as many bytes as possible.
+ ///
+ /// @param[in] file
+ /// The file specification from which to map data.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible. Even though it may be possible
+ /// for a 32-bit host debugger to debug a 64-bit target, size_t
+ /// still dictates the maximum possible size that can be mapped
+ /// into this process. For this kind of cross-arch debugging
+ /// scenario, mappings and views should be managed at a higher
+ /// level.
+ ///
+ /// @return
+ /// The number of bytes mapped starting from the \a offset.
+ //------------------------------------------------------------------
+ size_t MemoryMapFromFileSpec(const FileSpec *file, lldb::offset_t offset = 0,
+ size_t length = SIZE_MAX,
+ bool writeable = false);
+
+ //------------------------------------------------------------------
+ /// Memory map all or part of a file.
+ ///
+ /// Memory map \a length bytes from an opened file descriptor \a fd
+ /// starting \a offset bytes into the file. If \a length is set to
+ /// \c SIZE_MAX, then map as many bytes as possible.
+ ///
+ /// @param[in] fd
+ /// The posix file descriptor for an already opened file
+ /// from which to map data.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes from the beginning of the file where
+ /// memory mapping should begin.
+ ///
+ /// @param[in] length
+ /// The size in bytes that should be mapped starting \a offset
+ /// bytes into the file. If \a length is \c SIZE_MAX, map
+ /// as many bytes as possible.
+ ///
+ /// @return
+ /// The number of bytes mapped starting from the \a offset.
+ //------------------------------------------------------------------
+ size_t MemoryMapFromFileDescriptor(int fd, lldb::offset_t offset,
+ size_t length, bool write,
+ bool fd_is_file);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from DataBufferMemoryMap can see and modify these
- //------------------------------------------------------------------
- uint8_t * m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
- size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c mmap() was called
- uint8_t *m_data; ///< The data the user requested somewhere within the memory mapped data.
- lldb::offset_t m_size; ///< The size of the data the user got when data was requested
+ //------------------------------------------------------------------
+ // Classes that inherit from DataBufferMemoryMap can see and modify these
+ //------------------------------------------------------------------
+ uint8_t *m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
+ size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c
+ ///mmap() was called
+ uint8_t *m_data; ///< The data the user requested somewhere within the memory
+ ///mapped data.
+ lldb::offset_t
+ m_size; ///< The size of the data the user got when data was requested
private:
- DISALLOW_COPY_AND_ASSIGN (DataBufferMemoryMap);
+ DISALLOW_COPY_AND_ASSIGN(DataBufferMemoryMap);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/DataEncoder.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataEncoder.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataEncoder.h (original)
+++ lldb/trunk/include/lldb/Core/DataEncoder.h Tue Sep 6 15:57:50 2016
@@ -10,7 +10,7 @@
#ifndef liblldb_DataEncoder_h_
#define liblldb_DataEncoder_h_
-#if defined (__cplusplus)
+#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include <limits.h>
@@ -25,435 +25,374 @@ namespace lldb_private {
/// DataEncoder is a class that can encode binary data (swapping if needed)
/// to a data buffer. The data buffer can be caller owned, or can be
/// shared data that can be shared between multiple DataEncoder or
-/// DataEncoder instances.
+/// DataEncoder instances.
///
/// @see DataBuffer
//----------------------------------------------------------------------
-class DataEncoder
-{
+class DataEncoder {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all members to a default empty state.
- //------------------------------------------------------------------
- DataEncoder ();
-
- //------------------------------------------------------------------
- /// Construct with a buffer that is owned by the caller.
- ///
- /// This constructor allows us to use data that is owned by the
- /// caller. The data must stay around as long as this object is
- /// valid.
- ///
- /// @param[in] data
- /// A pointer to caller owned data.
- ///
- /// @param[in] data_length
- /// The length in bytes of \a data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- //------------------------------------------------------------------
- DataEncoder (void* data, uint32_t data_length, lldb::ByteOrder byte_order, uint8_t addr_size);
-
- //------------------------------------------------------------------
- /// Construct with shared data.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- //------------------------------------------------------------------
- DataEncoder (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint8_t addr_size);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// If this object contains a valid shared data reference, the
- /// reference count on the data will be decremented, and if zero,
- /// the data will be freed.
- //------------------------------------------------------------------
- ~DataEncoder ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state, and
- /// release any references to shared data that this object may
- /// contain.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Get the current address size.
- ///
- /// Return the size in bytes of any address values this object will
- /// extract.
- ///
- /// @return
- /// The size in bytes of address values that will be extracted.
- //------------------------------------------------------------------
- uint8_t
- GetAddressByteSize () const
- {
- return m_addr_size;
- }
-
-
- //------------------------------------------------------------------
- /// Get the number of bytes contained in this object.
- ///
- /// @return
- /// The total number of bytes of data this object refers to.
- //------------------------------------------------------------------
- size_t
- GetByteSize () const
- {
- return m_end - m_start;
- }
-
- //------------------------------------------------------------------
- /// Get the data end pointer.
- ///
- /// @return
- /// Returns a pointer to the next byte contained in this
- /// object's data, or NULL of there is no data in this object.
- //------------------------------------------------------------------
- uint8_t *
- GetDataEnd ()
- {
- return m_end;
- }
-
- const uint8_t *
- GetDataEnd () const
- {
- return m_end;
- }
-
- //------------------------------------------------------------------
- /// Get the shared data offset.
- ///
- /// Get the offset of the first byte of data in the shared data (if
- /// any).
- ///
- /// @return
- /// If this object contains shared data, this function returns
- /// the offset in bytes into that shared data, zero otherwise.
- //------------------------------------------------------------------
- size_t
- GetSharedDataOffset () const;
-
-
- //------------------------------------------------------------------
- /// Get the current byte order value.
- ///
- /// @return
- /// The current byte order value from this object's internal
- /// state.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const
- {
- return m_byte_order;
- }
-
- //------------------------------------------------------------------
- /// Get the data start pointer.
- ///
- /// @return
- /// Returns a pointer to the first byte contained in this
- /// object's data, or NULL of there is no data in this object.
- //------------------------------------------------------------------
- uint8_t *
- GetDataStart ()
- {
- return m_start;
- }
-
- const uint8_t *
- GetDataStart () const
- {
- return m_start;
- }
-
- //------------------------------------------------------------------
- /// Encode unsigned integer values into the data at \a offset.
- ///
- /// @param[in] offset
- /// The offset within the contained data at which to put the
- /// data.
- ///
- /// @param[in] value
- /// The value to encode into the data.
- ///
- /// @return
- /// The next offset in the bytes of this data if the data
- /// was successfully encoded, UINT32_MAX if the encoding failed.
- //------------------------------------------------------------------
- uint32_t
- PutU8 (uint32_t offset, uint8_t value);
-
- uint32_t
- PutU16 (uint32_t offset, uint16_t value);
-
- uint32_t
- PutU32 (uint32_t offset, uint32_t value);
-
- uint32_t
- PutU64 (uint32_t offset, uint64_t value);
-
- //------------------------------------------------------------------
- /// Encode an unsigned integer of size \a byte_size to \a offset.
- ///
- /// Encode a single integer value at \a offset and return the offset
- /// that follows the newly encoded integer when the data is successfully
- /// encoded into the existing data. There must be enough room in the
- /// data, else UINT32_MAX will be returned to indicate that encoding
- /// failed.
- ///
- /// @param[in] offset
- /// The offset within the contained data at which to put the
- /// encoded integer.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to encode.
- ///
- /// @param[in] value
- /// The integer value to write. The least significant bytes of
- /// the integer value will be written if the size is less than
- /// 8 bytes.
- ///
- /// @return
- /// The next offset in the bytes of this data if the integer
- /// was successfully encoded, UINT32_MAX if the encoding failed.
- //------------------------------------------------------------------
- uint32_t
- PutMaxU64 (uint32_t offset, uint32_t byte_size, uint64_t value);
-
- //------------------------------------------------------------------
- /// Encode an arbitrary number of bytes.
- ///
- /// @param[in] offset
- /// The offset in bytes into the contained data at which to
- /// start encoding.
- ///
- /// @param[in] src
- /// The buffer that contains the bytes to encode.
- ///
- /// @param[in] src_len
- /// The number of bytes to encode.
- ///
- /// @return
- /// The next valid offset within data if the put operation
- /// was successful, else UINT32_MAX to indicate the put failed.
- //------------------------------------------------------------------
- uint32_t
- PutData (uint32_t offset,
- const void *src,
- uint32_t src_len);
-
- //------------------------------------------------------------------
- /// Encode an address in the existing buffer at \a offset bytes into
- /// the buffer.
- ///
- /// Encode a single address (honoring the m_addr_size member) to
- /// the data and return the next offset where subsequent data would
- /// go.
- /// pointed to by \a offset_ptr. The size of the extracted address
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any address values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The next valid offset within data if the put operation
- /// was successful, else UINT32_MAX to indicate the put failed.
- //------------------------------------------------------------------
- uint32_t
- PutAddress (uint32_t offset, lldb::addr_t addr);
-
- //------------------------------------------------------------------
- /// Put a C string to \a offset.
- ///
- /// Encodes a C string into the existing data including the
- /// terminating
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the C string is out of bounds,
- /// NULL will be returned.
- //------------------------------------------------------------------
- uint32_t
- PutCString (uint32_t offset_ptr, const char *cstr);
-
- lldb::DataBufferSP &
- GetSharedDataBuffer ()
- {
- return m_data_sp;
- }
-
- //------------------------------------------------------------------
- /// Set the address byte size.
- ///
- /// Set the size in bytes that will be used when extracting any
- /// address and pointer values from data contained in this object.
- ///
- /// @param[in] addr_size
- /// The size in bytes to use when extracting addresses.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint8_t addr_size)
- {
- m_addr_size = addr_size;
- }
-
- //------------------------------------------------------------------
- /// Set data with a buffer that is caller owned.
- ///
- /// Use data that is owned by the caller when extracting values.
- /// The data must stay around as long as this object, or any object
- /// that copies a subset of this object's data, is valid. If \a
- /// bytes is NULL, or \a length is zero, this object will contain
- /// no data.
- ///
- /// @param[in] bytes
- /// A pointer to caller owned data.
- ///
- /// @param[in] length
- /// The length in bytes of \a bytes.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- uint32_t
- SetData (void *bytes, uint32_t length, lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Adopt a subset of shared data in \a data_sp.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp. The byte order
- /// and address byte size settings remain the same. If
- /// \a offset is not a valid offset in \a data_sp, then no reference
- /// to the shared data will be added. If there are not \a length
- /// bytes available in \a data starting at \a offset, the length
- /// will be truncated to contains as many bytes as possible.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] offset
- /// The offset into \a data_sp at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data_sp.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- uint32_t
- SetData (const lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
-
- //------------------------------------------------------------------
- /// Test the validity of \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset into the data in this
- /// object, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffset (uint32_t offset) const
- {
- return offset < GetByteSize();
- }
-
- //------------------------------------------------------------------
- /// Test the availability of \a length bytes of data from \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset and there are \a
- /// length bytes available at that offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
- {
- return length <= BytesLeft (offset);
- }
-
- uint32_t
- BytesLeft (uint32_t offset) const
- {
- const uint32_t size = GetByteSize();
- if (size > offset)
- return size - offset;
- return 0;
- }
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all members to a default empty state.
+ //------------------------------------------------------------------
+ DataEncoder();
+
+ //------------------------------------------------------------------
+ /// Construct with a buffer that is owned by the caller.
+ ///
+ /// This constructor allows us to use data that is owned by the
+ /// caller. The data must stay around as long as this object is
+ /// valid.
+ ///
+ /// @param[in] data
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] data_length
+ /// The length in bytes of \a data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ //------------------------------------------------------------------
+ DataEncoder(void *data, uint32_t data_length, lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Construct with shared data.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ //------------------------------------------------------------------
+ DataEncoder(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// If this object contains a valid shared data reference, the
+ /// reference count on the data will be decremented, and if zero,
+ /// the data will be freed.
+ //------------------------------------------------------------------
+ ~DataEncoder();
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state, and
+ /// release any references to shared data that this object may
+ /// contain.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Get the current address size.
+ ///
+ /// Return the size in bytes of any address values this object will
+ /// extract.
+ ///
+ /// @return
+ /// The size in bytes of address values that will be extracted.
+ //------------------------------------------------------------------
+ uint8_t GetAddressByteSize() const { return m_addr_size; }
+
+ //------------------------------------------------------------------
+ /// Get the number of bytes contained in this object.
+ ///
+ /// @return
+ /// The total number of bytes of data this object refers to.
+ //------------------------------------------------------------------
+ size_t GetByteSize() const { return m_end - m_start; }
+
+ //------------------------------------------------------------------
+ /// Get the data end pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the next byte contained in this
+ /// object's data, or NULL of there is no data in this object.
+ //------------------------------------------------------------------
+ uint8_t *GetDataEnd() { return m_end; }
+
+ const uint8_t *GetDataEnd() const { return m_end; }
+
+ //------------------------------------------------------------------
+ /// Get the shared data offset.
+ ///
+ /// Get the offset of the first byte of data in the shared data (if
+ /// any).
+ ///
+ /// @return
+ /// If this object contains shared data, this function returns
+ /// the offset in bytes into that shared data, zero otherwise.
+ //------------------------------------------------------------------
+ size_t GetSharedDataOffset() const;
+
+ //------------------------------------------------------------------
+ /// Get the current byte order value.
+ ///
+ /// @return
+ /// The current byte order value from this object's internal
+ /// state.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const { return m_byte_order; }
+
+ //------------------------------------------------------------------
+ /// Get the data start pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the first byte contained in this
+ /// object's data, or NULL of there is no data in this object.
+ //------------------------------------------------------------------
+ uint8_t *GetDataStart() { return m_start; }
+
+ const uint8_t *GetDataStart() const { return m_start; }
+
+ //------------------------------------------------------------------
+ /// Encode unsigned integer values into the data at \a offset.
+ ///
+ /// @param[in] offset
+ /// The offset within the contained data at which to put the
+ /// data.
+ ///
+ /// @param[in] value
+ /// The value to encode into the data.
+ ///
+ /// @return
+ /// The next offset in the bytes of this data if the data
+ /// was successfully encoded, UINT32_MAX if the encoding failed.
+ //------------------------------------------------------------------
+ uint32_t PutU8(uint32_t offset, uint8_t value);
+
+ uint32_t PutU16(uint32_t offset, uint16_t value);
+
+ uint32_t PutU32(uint32_t offset, uint32_t value);
+
+ uint32_t PutU64(uint32_t offset, uint64_t value);
+
+ //------------------------------------------------------------------
+ /// Encode an unsigned integer of size \a byte_size to \a offset.
+ ///
+ /// Encode a single integer value at \a offset and return the offset
+ /// that follows the newly encoded integer when the data is successfully
+ /// encoded into the existing data. There must be enough room in the
+ /// data, else UINT32_MAX will be returned to indicate that encoding
+ /// failed.
+ ///
+ /// @param[in] offset
+ /// The offset within the contained data at which to put the
+ /// encoded integer.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to encode.
+ ///
+ /// @param[in] value
+ /// The integer value to write. The least significant bytes of
+ /// the integer value will be written if the size is less than
+ /// 8 bytes.
+ ///
+ /// @return
+ /// The next offset in the bytes of this data if the integer
+ /// was successfully encoded, UINT32_MAX if the encoding failed.
+ //------------------------------------------------------------------
+ uint32_t PutMaxU64(uint32_t offset, uint32_t byte_size, uint64_t value);
+
+ //------------------------------------------------------------------
+ /// Encode an arbitrary number of bytes.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into the contained data at which to
+ /// start encoding.
+ ///
+ /// @param[in] src
+ /// The buffer that contains the bytes to encode.
+ ///
+ /// @param[in] src_len
+ /// The number of bytes to encode.
+ ///
+ /// @return
+ /// The next valid offset within data if the put operation
+ /// was successful, else UINT32_MAX to indicate the put failed.
+ //------------------------------------------------------------------
+ uint32_t PutData(uint32_t offset, const void *src, uint32_t src_len);
+
+ //------------------------------------------------------------------
+ /// Encode an address in the existing buffer at \a offset bytes into
+ /// the buffer.
+ ///
+ /// Encode a single address (honoring the m_addr_size member) to
+ /// the data and return the next offset where subsequent data would
+ /// go.
+ /// pointed to by \a offset_ptr. The size of the extracted address
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any address values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The next valid offset within data if the put operation
+ /// was successful, else UINT32_MAX to indicate the put failed.
+ //------------------------------------------------------------------
+ uint32_t PutAddress(uint32_t offset, lldb::addr_t addr);
+
+ //------------------------------------------------------------------
+ /// Put a C string to \a offset.
+ ///
+ /// Encodes a C string into the existing data including the
+ /// terminating
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the C string is out of bounds,
+ /// NULL will be returned.
+ //------------------------------------------------------------------
+ uint32_t PutCString(uint32_t offset_ptr, const char *cstr);
+
+ lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; }
+
+ //------------------------------------------------------------------
+ /// Set the address byte size.
+ ///
+ /// Set the size in bytes that will be used when extracting any
+ /// address and pointer values from data contained in this object.
+ ///
+ /// @param[in] addr_size
+ /// The size in bytes to use when extracting addresses.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint8_t addr_size) { m_addr_size = addr_size; }
+
+ //------------------------------------------------------------------
+ /// Set data with a buffer that is caller owned.
+ ///
+ /// Use data that is owned by the caller when extracting values.
+ /// The data must stay around as long as this object, or any object
+ /// that copies a subset of this object's data, is valid. If \a
+ /// bytes is NULL, or \a length is zero, this object will contain
+ /// no data.
+ ///
+ /// @param[in] bytes
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] length
+ /// The length in bytes of \a bytes.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ uint32_t SetData(void *bytes, uint32_t length, lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of shared data in \a data_sp.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp. The byte order
+ /// and address byte size settings remain the same. If
+ /// \a offset is not a valid offset in \a data_sp, then no reference
+ /// to the shared data will be added. If there are not \a length
+ /// bytes available in \a data starting at \a offset, the length
+ /// will be truncated to contains as many bytes as possible.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data_sp at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data_sp.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ uint32_t SetData(const lldb::DataBufferSP &data_sp, uint32_t offset = 0,
+ uint32_t length = UINT32_MAX);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ //------------------------------------------------------------------
+ /// Test the validity of \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset into the data in this
+ /// object, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffset(uint32_t offset) const { return offset < GetByteSize(); }
+
+ //------------------------------------------------------------------
+ /// Test the availability of \a length bytes of data from \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset and there are \a
+ /// length bytes available at that offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const {
+ return length <= BytesLeft(offset);
+ }
+
+ uint32_t BytesLeft(uint32_t offset) const {
+ const uint32_t size = GetByteSize();
+ if (size > offset)
+ return size - offset;
+ return 0;
+ }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- uint8_t *m_start; ///< A pointer to the first byte of data.
- uint8_t *m_end; ///< A pointer to the byte that is past the end of the data.
- lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from.
- uint8_t m_addr_size; ///< The address size to use when extracting pointers or addresses
- mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multiple instances
-
-private:
- DISALLOW_COPY_AND_ASSIGN (DataEncoder);
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ uint8_t *m_start; ///< A pointer to the first byte of data.
+ uint8_t *m_end; ///< A pointer to the byte that is past the end of the data.
+ lldb::ByteOrder
+ m_byte_order; ///< The byte order of the data we are extracting from.
+ uint8_t m_addr_size; ///< The address size to use when extracting pointers or
+ ///addresses
+ mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
+ ///be shared among multiple instances
+private:
+ DISALLOW_COPY_AND_ASSIGN(DataEncoder);
};
} // namespace lldb_private
-#endif // #if defined (__cplusplus)
-#endif // #ifndef liblldb_DataEncoder_h_
+#endif // #if defined (__cplusplus)
+#endif // #ifndef liblldb_DataEncoder_h_
Modified: lldb/trunk/include/lldb/Core/DataExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataExtractor.h (original)
+++ lldb/trunk/include/lldb/Core/DataExtractor.h Tue Sep 6 15:57:50 2016
@@ -38,1305 +38,1215 @@ namespace lldb_private {
///
/// @see DataBuffer
//----------------------------------------------------------------------
-class DataExtractor
-{
+class DataExtractor {
public:
- //------------------------------------------------------------------
- /// @typedef DataExtractor::Type
- /// @brief Type enumerations used in the dump routines.
- /// @see DataExtractor::Dump()
- /// @see DataExtractor::DumpRawHexBytes()
- //------------------------------------------------------------------
- typedef enum
- {
- TypeUInt8, ///< Format output as unsigned 8 bit integers
- TypeChar, ///< Format output as characters
- TypeUInt16, ///< Format output as unsigned 16 bit integers
- TypeUInt32, ///< Format output as unsigned 32 bit integers
- TypeUInt64, ///< Format output as unsigned 64 bit integers
- TypePointer, ///< Format output as pointers
- TypeULEB128, ///< Format output as ULEB128 numbers
- TypeSLEB128 ///< Format output as SLEB128 numbers
- } Type;
-
- static void
- DumpHexBytes (Stream *s,
- const void *src,
- size_t src_len,
- uint32_t bytes_per_line,
- lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize all members to a default empty state.
- //------------------------------------------------------------------
- DataExtractor ();
-
- //------------------------------------------------------------------
- /// Construct with a buffer that is owned by the caller.
- ///
- /// This constructor allows us to use data that is owned by the
- /// caller. The data must stay around as long as this object is
- /// valid.
- ///
- /// @param[in] data
- /// A pointer to caller owned data.
- ///
- /// @param[in] data_length
- /// The length in bytes of \a data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
-
- //------------------------------------------------------------------
- /// Construct with shared data.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @param[in] addr_size
- /// A new address byte size value.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
-
- //------------------------------------------------------------------
- /// Construct with a subset of \a data.
- ///
- /// Initialize this object with a subset of the data bytes in \a
- /// data. If \a data contains shared data, then a reference to the
- /// shared data will be added to ensure the shared data stays around
- /// as long as any objects have references to the shared data. The
- /// byte order value and the address size settings are copied from \a
- /// data. If \a offset is not a valid offset in \a data, then no
- /// reference to the shared data will be added. If there are not
- /// \a length bytes available in \a data starting at \a offset,
- /// the length will be truncated to contain as many bytes as
- /// possible.
- ///
- /// @param[in] data
- /// Another DataExtractor object that contains data.
- ///
- /// @param[in] offset
- /// The offset into \a data at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of data.
- ///
- /// @param[in] target_byte_size
- /// A size of a target byte in 8-bit host bytes
- //------------------------------------------------------------------
- DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1);
-
- DataExtractor (const DataExtractor& rhs);
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies all data, byte order and address size settings from \a rhs into
- /// this object. If \a rhs contains shared data, a reference to that
- /// shared data will be added.
- ///
- /// @param[in] rhs
- /// Another DataExtractor object to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const DataExtractor&
- operator= (const DataExtractor& rhs);
-
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// If this object contains a valid shared data reference, the
- /// reference count on the data will be decremented, and if zero,
- /// the data will be freed.
- //------------------------------------------------------------------
- ~DataExtractor ();
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state, and
- /// release any references to shared data that this object may
- /// contain.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Dumps the binary data as \a type objects to stream \a s (or to
- /// Log() if \a s is nullptr) starting \a offset bytes into the data
- /// and stopping after dumping \a length bytes. The offset into the
- /// data is displayed at the beginning of each line and can be
- /// offset by base address \a base_addr. \a num_per_line objects
- /// will be displayed on each line.
- ///
- /// @param[in] s
- /// The stream to dump the output to. If nullptr the output will
- /// be dumped to Log().
- ///
- /// @param[in] offset
- /// The offset into the data at which to start dumping.
- ///
- /// @param[in] length
- /// The number of bytes to dump.
- ///
- /// @param[in] base_addr
- /// The base address that gets added to the offset displayed on
- /// each line.
- ///
- /// @param[in] num_per_line
- /// The number of \a type objects to display on each line.
- ///
- /// @param[in] type
- /// The type of objects to use when dumping data from this
- /// object. See DataExtractor::Type.
- ///
- /// @param[in] type_format
- /// The optional format to use for the \a type objects. If this
- /// is nullptr, the default format for the \a type will be used.
- ///
- /// @return
- /// The offset at which dumping ended.
- //------------------------------------------------------------------
- lldb::offset_t
- PutToLog(Log *log,
- lldb::offset_t offset,
- lldb::offset_t length,
- uint64_t base_addr,
- uint32_t num_per_line,
- Type type,
- const char *type_format = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dumps \a item_count objects into the stream \a s.
- ///
- /// Dumps \a item_count objects using \a item_format, each of which
- /// are \a item_byte_size bytes long starting at offset \a offset
- /// bytes into the contained data, into the stream \a s. \a
- /// num_per_line objects will be dumped on each line before a new
- /// line will be output. If \a base_addr is a valid address, then
- /// each new line of output will be preceded by the address value
- /// plus appropriate offset, and a colon and space. Bitfield values
- /// can be dumped by calling this function multiple times with the
- /// same start offset, format and size, yet differing \a
- /// item_bit_size and \a item_bit_offset values.
- ///
- /// @param[in] s
- /// The stream to dump the output to. This value can not be nullptr.
- ///
- /// @param[in] offset
- /// The offset into the data at which to start dumping.
- ///
- /// @param[in] item_format
- /// The format to use when dumping each item.
- ///
- /// @param[in] item_byte_size
- /// The byte size of each item.
- ///
- /// @param[in] item_count
- /// The number of items to dump.
- ///
- /// @param[in] num_per_line
- /// The number of items to display on each line.
- ///
- /// @param[in] base_addr
- /// The base address that gets added to the offset displayed on
- /// each line if the value is valid. Is \a base_addr is
- /// LLDB_INVALID_ADDRESS then no address values will be prepended
- /// to any lines.
- ///
- /// @param[in] item_bit_size
- /// If the value to display is a bitfield, this value should
- /// be the number of bits that the bitfield item has within the
- /// item's byte size value. This function will need to be called
- /// multiple times with identical \a offset and \a item_byte_size
- /// values in order to display multiple bitfield values that
- /// exist within the same integer value. If the items being
- /// displayed are not bitfields, this value should be zero.
- ///
- /// @param[in] item_bit_offset
- /// If the value to display is a bitfield, this value should
- /// be the offset in bits, or shift right amount, that the
- /// bitfield item occupies within the item's byte size value.
- /// This function will need to be called multiple times with
- /// identical \a offset and \a item_byte_size values in order
- /// to display multiple bitfield values that exist within the
- /// same integer value. If the items being displayed are not
- /// bitfields, this value should be zero.
- ///
- /// @return
- /// The offset at which dumping ended.
- //------------------------------------------------------------------
- lldb::offset_t
- Dump(Stream *s,
- lldb::offset_t offset,
- lldb::Format item_format,
- size_t item_byte_size,
- size_t item_count,
- size_t num_per_line,
- uint64_t base_addr,
- uint32_t item_bit_size,
- uint32_t item_bit_offset,
- ExecutionContextScope *exe_scope = nullptr) const;
-
- //------------------------------------------------------------------
- /// Dump a UUID value at \a offset.
- ///
- /// Dump a UUID starting at \a offset bytes into this object's data.
- /// If the stream \a s is nullptr, the output will be sent to Log().
- ///
- /// @param[in] s
- /// The stream to dump the output to. If nullptr the output will
- /// be dumped to Log().
- ///
- /// @param[in] offset
- /// The offset into the data at which to extract and dump a
- /// UUID value.
- //------------------------------------------------------------------
- void
- DumpUUID (Stream *s, lldb::offset_t offset) const;
-
- //------------------------------------------------------------------
- /// Extract an arbitrary number of bytes in the specified byte
- /// order.
- ///
- /// Attemps to extract \a length bytes starting at \a offset bytes
- /// into this data in the requested byte order (\a dst_byte_order)
- /// and place the results in \a dst. \a dst must be at least \a
- /// length bytes long.
- ///
- /// @param[in] offset
- /// The offset in bytes into the contained data at which to
- /// start extracting.
- ///
- /// @param[in] length
- /// The number of bytes to extract.
- ///
- /// @param[in] dst_byte_order
- /// A byte order of the data that we want when the value in
- /// copied to \a dst.
- ///
- /// @param[out] dst
- /// The buffer that will receive the extracted value if there
- /// are enough bytes available in the current data.
- ///
- /// @return
- /// The number of bytes that were extracted which will be \a
- /// length when the value is successfully extracted, or zero
- /// if there aren't enough bytes at the specified offset.
- //------------------------------------------------------------------
- size_t
- ExtractBytes (lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const;
-
- //------------------------------------------------------------------
- /// Extract an address from \a *offset_ptr.
- ///
- /// Extract a single address from the data and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted address
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any address values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted address value.
- //------------------------------------------------------------------
- uint64_t
- GetAddress (lldb::offset_t *offset_ptr) const;
-
- uint64_t
- GetAddress_unchecked (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Get the current address size.
- ///
- /// Return the size in bytes of any address values this object will
- /// extract.
- ///
- /// @return
- /// The size in bytes of address values that will be extracted.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const
- {
- return m_addr_size;
- }
-
- //------------------------------------------------------------------
- /// Get the number of bytes contained in this object.
- ///
- /// @return
- /// The total number of bytes of data this object refers to.
- //------------------------------------------------------------------
- uint64_t
- GetByteSize () const
- {
- return m_end - m_start;
- }
-
- //------------------------------------------------------------------
- /// Extract a C string from \a *offset_ptr.
- ///
- /// Returns a pointer to a C String from the data at the offset
- /// pointed to by \a offset_ptr. A variable length NULL terminated C
- /// string will be extracted and the \a offset_ptr will be
- /// updated with the offset of the byte that follows the NULL
- /// terminator byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the C string is out of bounds,
- /// nullptr will be returned.
- //------------------------------------------------------------------
- const char *
- GetCStr (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a C string from \a *offset_ptr with field size \a len.
- ///
- /// Returns a pointer to a C String from the data at the offset
- /// pointed to by \a offset_ptr, with a field length of \a len.
- /// A NULL terminated C string will be extracted and the \a offset_ptr
- /// will be updated with the offset of the byte that follows the fixed
- /// length field.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// A pointer to the C string value in the data. If the offset
- /// pointed to by \a offset_ptr is out of bounds, or if the
- /// offset plus the length of the field is out of bounds, or if
- /// the field does not contain a NULL terminator byte, nullptr will
- /// be returned.
- const char *
- GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const;
-
- //------------------------------------------------------------------
- /// Extract \a length bytes from \a *offset_ptr.
- ///
- /// Returns a pointer to a bytes in this object's data at the offset
- /// pointed to by \a offset_ptr. If \a length is zero or too large,
- /// then the offset pointed to by \a offset_ptr will not be updated
- /// and nullptr will be returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] length
- /// The optional length of a string to extract. If the value is
- /// zero, a NULL terminated C string will be extracted.
- ///
- /// @return
- /// A pointer to the bytes in this object's data if the offset
- /// and length are valid, or nullptr otherwise.
- //------------------------------------------------------------------
- const void*
- GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const
- {
- const uint8_t *ptr = PeekData (*offset_ptr, length);
- if (ptr)
- *offset_ptr += length;
- return ptr;
- }
-
- //------------------------------------------------------------------
- /// Copy \a length bytes from \a *offset, without swapping bytes.
- ///
- /// @param[in] offset
- /// The offset into this data from which to start copying
- ///
- /// @param[in] length
- /// The length of the data to copy from this object
- ///
- /// @param[out] dst
- /// The buffer to place the output data.
- ///
- /// @return
- /// Returns the number of bytes that were copied, or zero if
- /// anything goes wrong.
- //------------------------------------------------------------------
- lldb::offset_t
- CopyData (lldb::offset_t offset,
- lldb::offset_t length,
- void *dst) const;
-
- //------------------------------------------------------------------
- /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied
- /// data is treated as a value that can be swapped to match the
- /// specified byte order.
- ///
- /// For values that are larger than the supported integer sizes,
- /// this function can be used to extract data in a specified byte
- /// order. It can also be used to copy a smaller integer value from
- /// to a larger value. The extra bytes left over will be padded
- /// correctly according to the byte order of this object and the
- /// \a dst_byte_order. This can be very handy when say copying a
- /// partial data value into a register.
- ///
- /// @param[in] src_offset
- /// The offset into this data from which to start copying an
- /// endian entity
- ///
- /// @param[in] src_len
- /// The length of the endian data to copy from this object
- /// into the \a dst object
- ///
- /// @param[out] dst
- /// The buffer where to place the endian data. The data might
- /// need to be byte swapped (and appropriately padded with
- /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order
- /// does not match the byte order in this object.
- ///
- /// @param[in] dst_len
- /// The length number of bytes that the endian value will
- /// occupy is \a dst.
- ///
- /// @param[in] byte_order
- /// The byte order that the endian value should be in the \a dst
- /// buffer.
- ///
- /// @return
- /// Returns the number of bytes that were copied, or zero if
- /// anything goes wrong.
- //------------------------------------------------------------------
- lldb::offset_t
- CopyByteOrderedData (lldb::offset_t src_offset,
- lldb::offset_t src_len,
- void *dst,
- lldb::offset_t dst_len,
- lldb::ByteOrder dst_byte_order) const;
-
- //------------------------------------------------------------------
- /// Get the data end pointer.
- ///
- /// @return
- /// Returns a pointer to the next byte contained in this
- /// object's data, or nullptr of there is no data in this object.
- //------------------------------------------------------------------
- const uint8_t *
- GetDataEnd () const
- {
- return m_end;
- }
-
- //------------------------------------------------------------------
- /// Get the shared data offset.
- ///
- /// Get the offset of the first byte of data in the shared data (if
- /// any).
- ///
- /// @return
- /// If this object contains shared data, this function returns
- /// the offset in bytes into that shared data, zero otherwise.
- //------------------------------------------------------------------
- size_t
- GetSharedDataOffset () const;
-
- //------------------------------------------------------------------
- /// Get the data start pointer.
- ///
- /// @return
- /// Returns a pointer to the first byte contained in this
- /// object's data, or nullptr of there is no data in this object.
- //------------------------------------------------------------------
- const uint8_t *
- GetDataStart () const
- {
- return m_start;
- }
-
- //------------------------------------------------------------------
- /// Extract a float from \a *offset_ptr.
- ///
- /// Extract a single float value.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The floating value that was extracted, or zero on failure.
- //------------------------------------------------------------------
- float
- GetFloat (lldb::offset_t *offset_ptr) const;
-
- double
- GetDouble (lldb::offset_t *offset_ptr) const;
-
- long double
- GetLongDouble (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a GNU encoded pointer value from \a *offset_ptr.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] eh_ptr_enc
- /// The GNU pointer encoding type.
- ///
- /// @param[in] pc_rel_addr
- /// The PC relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_pcrel.
- ///
- /// @param[in] text_addr
- /// The text (code) relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_textrel.
- ///
- /// @param[in] data_addr
- /// The data relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_datarel.
- ///
- /// @return
- /// The extracted GNU encoded pointer value.
- //------------------------------------------------------------------
- uint64_t
- GetGNUEHPointer (lldb::offset_t *offset_ptr,
- uint32_t eh_ptr_enc,
- lldb::addr_t pc_rel_addr,
- lldb::addr_t text_addr,
- lldb::addr_t data_addr);
-
- //------------------------------------------------------------------
- /// Extract an integer of size \a byte_size from \a *offset_ptr.
- ///
- /// Extract a single integer value and update the offset pointed to
- /// by \a offset_ptr. The size of the extracted integer is specified
- /// by the \a byte_size argument. \a byte_size should have a value
- /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
- /// \a byte_size values less than 1 or greater than 4 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The integer value that was extracted, or zero on failure.
- //------------------------------------------------------------------
- uint32_t
- GetMaxU32 (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- //------------------------------------------------------------------
- /// Extract an unsigned integer of size \a byte_size from \a
- /// *offset_ptr.
- ///
- /// Extract a single unsigned integer value and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
- /// have a value greater than or equal to one and less than or equal
- /// to eight since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The unsigned integer value that was extracted, or zero on
- /// failure.
- //------------------------------------------------------------------
- uint64_t
- GetMaxU64 (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- uint64_t
- GetMaxU64_unchecked (lldb::offset_t *offset_ptr, size_t byte_size) const;
-
- //------------------------------------------------------------------
- /// Extract an signed integer of size \a byte_size from \a *offset_ptr.
- ///
- /// Extract a single signed integer value (sign extending if required)
- /// and update the offset pointed to by \a offset_ptr. The size of
- /// the extracted integer is specified by the \a byte_size argument.
- /// \a byte_size should have a value greater than or equal to one
- /// and less than or equal to eight since the return value is 64
- /// bits wide. Any \a byte_size values less than 1 or greater than
- /// 8 will result in nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @return
- /// The sign extended signed integer value that was extracted,
- /// or zero on failure.
- //------------------------------------------------------------------
- int64_t
- GetMaxS64 (lldb::offset_t *offset_ptr, size_t size) const;
-
- //------------------------------------------------------------------
- /// Extract an unsigned integer of size \a byte_size from \a
- /// *offset_ptr, then extract the bitfield from this value if
- /// \a bitfield_bit_size is non-zero.
- ///
- /// Extract a single unsigned integer value and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
- /// have a value greater than or equal to one and less than or equal
- /// to 8 since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in byte of the integer to extract.
- ///
- /// @param[in] bitfield_bit_size
- /// The size in bits of the bitfield value to extract, or zero
- /// to just extract the entire integer value.
- ///
- /// @param[in] bitfield_bit_offset
- /// The bit offset of the bitfield value in the extracted
- /// integer. For little-endian data, this is the offset of
- /// the LSB of the bitfield from the LSB of the integer.
- /// For big-endian data, this is the offset of the MSB of the
- /// bitfield from the MSB of the integer.
- ///
- /// @return
- /// The unsigned bitfield integer value that was extracted, or
- /// zero on failure.
- //------------------------------------------------------------------
- uint64_t
- GetMaxU64Bitfield (lldb::offset_t *offset_ptr,
- size_t size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset) const;
-
- //------------------------------------------------------------------
- /// Extract an signed integer of size \a byte_size from \a
- /// *offset_ptr, then extract and signe extend the bitfield from
- /// this value if \a bitfield_bit_size is non-zero.
- ///
- /// Extract a single signed integer value (sign extending if required)
- /// and update the offset pointed to by \a offset_ptr. The size of
- /// the extracted integer is specified by the \a byte_size argument.
- /// \a byte_size should have a value greater than or equal to one
- /// and less than or equal to eight since the return value is 64
- /// bits wide. Any \a byte_size values less than 1 or greater than
- /// 8 will result in nothing being extracted, and zero being returned.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] byte_size
- /// The size in bytes of the integer to extract.
- ///
- /// @param[in] bitfield_bit_size
- /// The size in bits of the bitfield value to extract, or zero
- /// to just extract the entire integer value.
- ///
- /// @param[in] bitfield_bit_offset
- /// The bit offset of the bitfield value in the extracted
- /// integer. For little-endian data, this is the offset of
- /// the LSB of the bitfield from the LSB of the integer.
- /// For big-endian data, this is the offset of the MSB of the
- /// bitfield from the MSB of the integer.
- ///
- /// @return
- /// The signed bitfield integer value that was extracted, or
- /// zero on failure.
- //------------------------------------------------------------------
- int64_t
- GetMaxS64Bitfield (lldb::offset_t *offset_ptr,
- size_t size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset) const;
-
- //------------------------------------------------------------------
- /// Extract an pointer from \a *offset_ptr.
- ///
- /// Extract a single pointer from the data and update the offset
- /// pointed to by \a offset_ptr. The size of the extracted pointer
- /// comes from the \a m_addr_size member variable and should be
- /// set correctly prior to extracting any pointer values.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted pointer value as a 64 integer.
- //------------------------------------------------------------------
- uint64_t
- GetPointer (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Get the current byte order value.
- ///
- /// @return
- /// The current byte order value from this object's internal
- /// state.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const
- {
- return m_byte_order;
- }
-
- //------------------------------------------------------------------
- /// Extract a uint8_t value from \a *offset_ptr.
- ///
- /// Extract a single uint8_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and advance the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint8_t value.
- //------------------------------------------------------------------
- uint8_t
- GetU8 ( lldb::offset_t *offset_ptr) const;
-
- uint8_t
- GetU8_unchecked (lldb::offset_t *offset_ptr) const
- {
- uint8_t val = m_start[*offset_ptr];
- *offset_ptr += 1;
- return val;
- }
-
- uint16_t
- GetU16_unchecked (lldb::offset_t *offset_ptr) const;
-
- uint32_t
- GetU32_unchecked (lldb::offset_t *offset_ptr) const;
-
- uint64_t
- GetU64_unchecked (lldb::offset_t *offset_ptr) const;
- //------------------------------------------------------------------
- /// Extract \a count uint8_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint8_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint8_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint8_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint16_t value from \a *offset_ptr.
- ///
- /// Extract a single uint16_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint16_t value.
- //------------------------------------------------------------------
- uint16_t
- GetU16 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint16_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint16_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint16_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint16_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint32_t value from \a *offset_ptr.
- ///
- /// Extract a single uint32_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint32_t value.
- //------------------------------------------------------------------
- uint32_t
- GetU32 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint32_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint32_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint32_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint32_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a uint64_t value from \a *offset_ptr.
- ///
- /// Extract a single uint64_t from the binary data at the offset
- /// pointed to by \a offset_ptr, and update the offset on success.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted uint64_t value.
- //------------------------------------------------------------------
- uint64_t
- GetU64 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract \a count uint64_t values from \a *offset_ptr.
- ///
- /// Extract \a count uint64_t values from the binary data at the
- /// offset pointed to by \a offset_ptr, and advance the offset on
- /// success. The extracted values are copied into \a dst.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[out] dst
- /// A buffer to copy \a count uint64_t values into. \a dst must
- /// be large enough to hold all requested data.
- ///
- /// @param[in] count
- /// The number of uint64_t values to extract.
- ///
- /// @return
- /// \a dst if all values were properly extracted and copied,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- void *
- GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
-
- //------------------------------------------------------------------
- /// Extract a signed LEB128 value from \a *offset_ptr.
- ///
- /// Extracts an signed LEB128 number from this object's data
- /// starting at the offset pointed to by \a offset_ptr. The offset
- /// pointed to by \a offset_ptr will be updated with the offset of
- /// the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted signed integer value.
- //------------------------------------------------------------------
- int64_t
- GetSLEB128 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Extract a unsigned LEB128 value from \a *offset_ptr.
- ///
- /// Extracts an unsigned LEB128 number from this object's data
- /// starting at the offset pointed to by \a offset_ptr. The offset
- /// pointed to by \a offset_ptr will be updated with the offset of
- /// the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- /// The extracted unsigned integer value.
- //------------------------------------------------------------------
- uint64_t
- GetULEB128 (lldb::offset_t *offset_ptr) const;
-
- lldb::DataBufferSP &
- GetSharedDataBuffer ()
- {
- return m_data_sp;
- }
-
- //------------------------------------------------------------------
- /// Peek at a C string at \a offset.
- ///
- /// Peeks at a string in the contained data. No verification is done
- /// to make sure the entire string lies within the bounds of this
- /// object's data, only \a offset is verified to be a valid offset.
- ///
- /// @param[in] offset
- /// An offset into the data.
- ///
- /// @return
- /// A non-nullptr C string pointer if \a offset is a valid offset,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- const char *
- PeekCStr (lldb::offset_t offset) const;
-
- //------------------------------------------------------------------
- /// Peek at a bytes at \a offset.
- ///
- /// Returns a pointer to \a length bytes at \a offset as long as
- /// there are \a length bytes available starting at \a offset.
- ///
- /// @return
- /// A non-nullptr data pointer if \a offset is a valid offset and
- /// there are \a length bytes available at that offset, nullptr
- /// otherwise.
- //------------------------------------------------------------------
- const uint8_t*
- PeekData (lldb::offset_t offset, lldb::offset_t length) const
- {
- if (ValidOffsetForDataOfSize(offset, length))
- return m_start + offset;
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Set the address byte size.
- ///
- /// Set the size in bytes that will be used when extracting any
- /// address and pointer values from data contained in this object.
- ///
- /// @param[in] addr_size
- /// The size in bytes to use when extracting addresses.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint32_t addr_size)
- {
+ //------------------------------------------------------------------
+ /// @typedef DataExtractor::Type
+ /// @brief Type enumerations used in the dump routines.
+ /// @see DataExtractor::Dump()
+ /// @see DataExtractor::DumpRawHexBytes()
+ //------------------------------------------------------------------
+ typedef enum {
+ TypeUInt8, ///< Format output as unsigned 8 bit integers
+ TypeChar, ///< Format output as characters
+ TypeUInt16, ///< Format output as unsigned 16 bit integers
+ TypeUInt32, ///< Format output as unsigned 32 bit integers
+ TypeUInt64, ///< Format output as unsigned 64 bit integers
+ TypePointer, ///< Format output as pointers
+ TypeULEB128, ///< Format output as ULEB128 numbers
+ TypeSLEB128 ///< Format output as SLEB128 numbers
+ } Type;
+
+ static void DumpHexBytes(Stream *s, const void *src, size_t src_len,
+ uint32_t bytes_per_line,
+ lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS
+ // to not show address at
+ // start of line
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize all members to a default empty state.
+ //------------------------------------------------------------------
+ DataExtractor();
+
+ //------------------------------------------------------------------
+ /// Construct with a buffer that is owned by the caller.
+ ///
+ /// This constructor allows us to use data that is owned by the
+ /// caller. The data must stay around as long as this object is
+ /// valid.
+ ///
+ /// @param[in] data
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] data_length
+ /// The length in bytes of \a data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const void *data, lldb::offset_t data_length,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ uint32_t target_byte_size = 1);
+
+ //------------------------------------------------------------------
+ /// Construct with shared data.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @param[in] addr_size
+ /// A new address byte size value.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order,
+ uint32_t addr_size, uint32_t target_byte_size = 1);
+
+ //------------------------------------------------------------------
+ /// Construct with a subset of \a data.
+ ///
+ /// Initialize this object with a subset of the data bytes in \a
+ /// data. If \a data contains shared data, then a reference to the
+ /// shared data will be added to ensure the shared data stays around
+ /// as long as any objects have references to the shared data. The
+ /// byte order value and the address size settings are copied from \a
+ /// data. If \a offset is not a valid offset in \a data, then no
+ /// reference to the shared data will be added. If there are not
+ /// \a length bytes available in \a data starting at \a offset,
+ /// the length will be truncated to contain as many bytes as
+ /// possible.
+ ///
+ /// @param[in] data
+ /// Another DataExtractor object that contains data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of data.
+ ///
+ /// @param[in] target_byte_size
+ /// A size of a target byte in 8-bit host bytes
+ //------------------------------------------------------------------
+ DataExtractor(const DataExtractor &data, lldb::offset_t offset,
+ lldb::offset_t length, uint32_t target_byte_size = 1);
+
+ DataExtractor(const DataExtractor &rhs);
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Copies all data, byte order and address size settings from \a rhs into
+ /// this object. If \a rhs contains shared data, a reference to that
+ /// shared data will be added.
+ ///
+ /// @param[in] rhs
+ /// Another DataExtractor object to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const DataExtractor &operator=(const DataExtractor &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// If this object contains a valid shared data reference, the
+ /// reference count on the data will be decremented, and if zero,
+ /// the data will be freed.
+ //------------------------------------------------------------------
+ ~DataExtractor();
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state, and
+ /// release any references to shared data that this object may
+ /// contain.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dumps the binary data as \a type objects to stream \a s (or to
+ /// Log() if \a s is nullptr) starting \a offset bytes into the data
+ /// and stopping after dumping \a length bytes. The offset into the
+ /// data is displayed at the beginning of each line and can be
+ /// offset by base address \a base_addr. \a num_per_line objects
+ /// will be displayed on each line.
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. If nullptr the output will
+ /// be dumped to Log().
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to start dumping.
+ ///
+ /// @param[in] length
+ /// The number of bytes to dump.
+ ///
+ /// @param[in] base_addr
+ /// The base address that gets added to the offset displayed on
+ /// each line.
+ ///
+ /// @param[in] num_per_line
+ /// The number of \a type objects to display on each line.
+ ///
+ /// @param[in] type
+ /// The type of objects to use when dumping data from this
+ /// object. See DataExtractor::Type.
+ ///
+ /// @param[in] type_format
+ /// The optional format to use for the \a type objects. If this
+ /// is nullptr, the default format for the \a type will be used.
+ ///
+ /// @return
+ /// The offset at which dumping ended.
+ //------------------------------------------------------------------
+ lldb::offset_t PutToLog(Log *log, lldb::offset_t offset,
+ lldb::offset_t length, uint64_t base_addr,
+ uint32_t num_per_line, Type type,
+ const char *type_format = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dumps \a item_count objects into the stream \a s.
+ ///
+ /// Dumps \a item_count objects using \a item_format, each of which
+ /// are \a item_byte_size bytes long starting at offset \a offset
+ /// bytes into the contained data, into the stream \a s. \a
+ /// num_per_line objects will be dumped on each line before a new
+ /// line will be output. If \a base_addr is a valid address, then
+ /// each new line of output will be preceded by the address value
+ /// plus appropriate offset, and a colon and space. Bitfield values
+ /// can be dumped by calling this function multiple times with the
+ /// same start offset, format and size, yet differing \a
+ /// item_bit_size and \a item_bit_offset values.
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. This value can not be nullptr.
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to start dumping.
+ ///
+ /// @param[in] item_format
+ /// The format to use when dumping each item.
+ ///
+ /// @param[in] item_byte_size
+ /// The byte size of each item.
+ ///
+ /// @param[in] item_count
+ /// The number of items to dump.
+ ///
+ /// @param[in] num_per_line
+ /// The number of items to display on each line.
+ ///
+ /// @param[in] base_addr
+ /// The base address that gets added to the offset displayed on
+ /// each line if the value is valid. Is \a base_addr is
+ /// LLDB_INVALID_ADDRESS then no address values will be prepended
+ /// to any lines.
+ ///
+ /// @param[in] item_bit_size
+ /// If the value to display is a bitfield, this value should
+ /// be the number of bits that the bitfield item has within the
+ /// item's byte size value. This function will need to be called
+ /// multiple times with identical \a offset and \a item_byte_size
+ /// values in order to display multiple bitfield values that
+ /// exist within the same integer value. If the items being
+ /// displayed are not bitfields, this value should be zero.
+ ///
+ /// @param[in] item_bit_offset
+ /// If the value to display is a bitfield, this value should
+ /// be the offset in bits, or shift right amount, that the
+ /// bitfield item occupies within the item's byte size value.
+ /// This function will need to be called multiple times with
+ /// identical \a offset and \a item_byte_size values in order
+ /// to display multiple bitfield values that exist within the
+ /// same integer value. If the items being displayed are not
+ /// bitfields, this value should be zero.
+ ///
+ /// @return
+ /// The offset at which dumping ended.
+ //------------------------------------------------------------------
+ lldb::offset_t Dump(Stream *s, lldb::offset_t offset,
+ lldb::Format item_format, size_t item_byte_size,
+ size_t item_count, size_t num_per_line,
+ uint64_t base_addr, uint32_t item_bit_size,
+ uint32_t item_bit_offset,
+ ExecutionContextScope *exe_scope = nullptr) const;
+
+ //------------------------------------------------------------------
+ /// Dump a UUID value at \a offset.
+ ///
+ /// Dump a UUID starting at \a offset bytes into this object's data.
+ /// If the stream \a s is nullptr, the output will be sent to Log().
+ ///
+ /// @param[in] s
+ /// The stream to dump the output to. If nullptr the output will
+ /// be dumped to Log().
+ ///
+ /// @param[in] offset
+ /// The offset into the data at which to extract and dump a
+ /// UUID value.
+ //------------------------------------------------------------------
+ void DumpUUID(Stream *s, lldb::offset_t offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an arbitrary number of bytes in the specified byte
+ /// order.
+ ///
+ /// Attemps to extract \a length bytes starting at \a offset bytes
+ /// into this data in the requested byte order (\a dst_byte_order)
+ /// and place the results in \a dst. \a dst must be at least \a
+ /// length bytes long.
+ ///
+ /// @param[in] offset
+ /// The offset in bytes into the contained data at which to
+ /// start extracting.
+ ///
+ /// @param[in] length
+ /// The number of bytes to extract.
+ ///
+ /// @param[in] dst_byte_order
+ /// A byte order of the data that we want when the value in
+ /// copied to \a dst.
+ ///
+ /// @param[out] dst
+ /// The buffer that will receive the extracted value if there
+ /// are enough bytes available in the current data.
+ ///
+ /// @return
+ /// The number of bytes that were extracted which will be \a
+ /// length when the value is successfully extracted, or zero
+ /// if there aren't enough bytes at the specified offset.
+ //------------------------------------------------------------------
+ size_t ExtractBytes(lldb::offset_t offset, lldb::offset_t length,
+ lldb::ByteOrder dst_byte_order, void *dst) const;
+
+ //------------------------------------------------------------------
+ /// Extract an address from \a *offset_ptr.
+ ///
+ /// Extract a single address from the data and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted address
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any address values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted address value.
+ //------------------------------------------------------------------
+ uint64_t GetAddress(lldb::offset_t *offset_ptr) const;
+
+ uint64_t GetAddress_unchecked(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Get the current address size.
+ ///
+ /// Return the size in bytes of any address values this object will
+ /// extract.
+ ///
+ /// @return
+ /// The size in bytes of address values that will be extracted.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const { return m_addr_size; }
+
+ //------------------------------------------------------------------
+ /// Get the number of bytes contained in this object.
+ ///
+ /// @return
+ /// The total number of bytes of data this object refers to.
+ //------------------------------------------------------------------
+ uint64_t GetByteSize() const { return m_end - m_start; }
+
+ //------------------------------------------------------------------
+ /// Extract a C string from \a *offset_ptr.
+ ///
+ /// Returns a pointer to a C String from the data at the offset
+ /// pointed to by \a offset_ptr. A variable length NULL terminated C
+ /// string will be extracted and the \a offset_ptr will be
+ /// updated with the offset of the byte that follows the NULL
+ /// terminator byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the C string is out of bounds,
+ /// nullptr will be returned.
+ //------------------------------------------------------------------
+ const char *GetCStr(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a C string from \a *offset_ptr with field size \a len.
+ ///
+ /// Returns a pointer to a C String from the data at the offset
+ /// pointed to by \a offset_ptr, with a field length of \a len.
+ /// A NULL terminated C string will be extracted and the \a offset_ptr
+ /// will be updated with the offset of the byte that follows the fixed
+ /// length field.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// A pointer to the C string value in the data. If the offset
+ /// pointed to by \a offset_ptr is out of bounds, or if the
+ /// offset plus the length of the field is out of bounds, or if
+ /// the field does not contain a NULL terminator byte, nullptr will
+ /// be returned.
+ const char *GetCStr(lldb::offset_t *offset_ptr, lldb::offset_t len) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a length bytes from \a *offset_ptr.
+ ///
+ /// Returns a pointer to a bytes in this object's data at the offset
+ /// pointed to by \a offset_ptr. If \a length is zero or too large,
+ /// then the offset pointed to by \a offset_ptr will not be updated
+ /// and nullptr will be returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] length
+ /// The optional length of a string to extract. If the value is
+ /// zero, a NULL terminated C string will be extracted.
+ ///
+ /// @return
+ /// A pointer to the bytes in this object's data if the offset
+ /// and length are valid, or nullptr otherwise.
+ //------------------------------------------------------------------
+ const void *GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const {
+ const uint8_t *ptr = PeekData(*offset_ptr, length);
+ if (ptr)
+ *offset_ptr += length;
+ return ptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Copy \a length bytes from \a *offset, without swapping bytes.
+ ///
+ /// @param[in] offset
+ /// The offset into this data from which to start copying
+ ///
+ /// @param[in] length
+ /// The length of the data to copy from this object
+ ///
+ /// @param[out] dst
+ /// The buffer to place the output data.
+ ///
+ /// @return
+ /// Returns the number of bytes that were copied, or zero if
+ /// anything goes wrong.
+ //------------------------------------------------------------------
+ lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length,
+ void *dst) const;
+
+ //------------------------------------------------------------------
+ /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied
+ /// data is treated as a value that can be swapped to match the
+ /// specified byte order.
+ ///
+ /// For values that are larger than the supported integer sizes,
+ /// this function can be used to extract data in a specified byte
+ /// order. It can also be used to copy a smaller integer value from
+ /// to a larger value. The extra bytes left over will be padded
+ /// correctly according to the byte order of this object and the
+ /// \a dst_byte_order. This can be very handy when say copying a
+ /// partial data value into a register.
+ ///
+ /// @param[in] src_offset
+ /// The offset into this data from which to start copying an
+ /// endian entity
+ ///
+ /// @param[in] src_len
+ /// The length of the endian data to copy from this object
+ /// into the \a dst object
+ ///
+ /// @param[out] dst
+ /// The buffer where to place the endian data. The data might
+ /// need to be byte swapped (and appropriately padded with
+ /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order
+ /// does not match the byte order in this object.
+ ///
+ /// @param[in] dst_len
+ /// The length number of bytes that the endian value will
+ /// occupy is \a dst.
+ ///
+ /// @param[in] byte_order
+ /// The byte order that the endian value should be in the \a dst
+ /// buffer.
+ ///
+ /// @return
+ /// Returns the number of bytes that were copied, or zero if
+ /// anything goes wrong.
+ //------------------------------------------------------------------
+ lldb::offset_t CopyByteOrderedData(lldb::offset_t src_offset,
+ lldb::offset_t src_len, void *dst,
+ lldb::offset_t dst_len,
+ lldb::ByteOrder dst_byte_order) const;
+
+ //------------------------------------------------------------------
+ /// Get the data end pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the next byte contained in this
+ /// object's data, or nullptr of there is no data in this object.
+ //------------------------------------------------------------------
+ const uint8_t *GetDataEnd() const { return m_end; }
+
+ //------------------------------------------------------------------
+ /// Get the shared data offset.
+ ///
+ /// Get the offset of the first byte of data in the shared data (if
+ /// any).
+ ///
+ /// @return
+ /// If this object contains shared data, this function returns
+ /// the offset in bytes into that shared data, zero otherwise.
+ //------------------------------------------------------------------
+ size_t GetSharedDataOffset() const;
+
+ //------------------------------------------------------------------
+ /// Get the data start pointer.
+ ///
+ /// @return
+ /// Returns a pointer to the first byte contained in this
+ /// object's data, or nullptr of there is no data in this object.
+ //------------------------------------------------------------------
+ const uint8_t *GetDataStart() const { return m_start; }
+
+ //------------------------------------------------------------------
+ /// Extract a float from \a *offset_ptr.
+ ///
+ /// Extract a single float value.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The floating value that was extracted, or zero on failure.
+ //------------------------------------------------------------------
+ float GetFloat(lldb::offset_t *offset_ptr) const;
+
+ double GetDouble(lldb::offset_t *offset_ptr) const;
+
+ long double GetLongDouble(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a GNU encoded pointer value from \a *offset_ptr.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] eh_ptr_enc
+ /// The GNU pointer encoding type.
+ ///
+ /// @param[in] pc_rel_addr
+ /// The PC relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_pcrel.
+ ///
+ /// @param[in] text_addr
+ /// The text (code) relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_textrel.
+ ///
+ /// @param[in] data_addr
+ /// The data relative address to use when the encoding is
+ /// \c DW_GNU_EH_PE_datarel.
+ ///
+ /// @return
+ /// The extracted GNU encoded pointer value.
+ //------------------------------------------------------------------
+ uint64_t GetGNUEHPointer(lldb::offset_t *offset_ptr, uint32_t eh_ptr_enc,
+ lldb::addr_t pc_rel_addr, lldb::addr_t text_addr,
+ lldb::addr_t data_addr);
+
+ //------------------------------------------------------------------
+ /// Extract an integer of size \a byte_size from \a *offset_ptr.
+ ///
+ /// Extract a single integer value and update the offset pointed to
+ /// by \a offset_ptr. The size of the extracted integer is specified
+ /// by the \a byte_size argument. \a byte_size should have a value
+ /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 4 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The integer value that was extracted, or zero on failure.
+ //------------------------------------------------------------------
+ uint32_t GetMaxU32(lldb::offset_t *offset_ptr, size_t byte_size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an unsigned integer of size \a byte_size from \a
+ /// *offset_ptr.
+ ///
+ /// Extract a single unsigned integer value and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted integer
+ /// is specified by the \a byte_size argument. \a byte_size should
+ /// have a value greater than or equal to one and less than or equal
+ /// to eight since the return value is 64 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 8 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The unsigned integer value that was extracted, or zero on
+ /// failure.
+ //------------------------------------------------------------------
+ uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const;
+
+ uint64_t GetMaxU64_unchecked(lldb::offset_t *offset_ptr,
+ size_t byte_size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an signed integer of size \a byte_size from \a *offset_ptr.
+ ///
+ /// Extract a single signed integer value (sign extending if required)
+ /// and update the offset pointed to by \a offset_ptr. The size of
+ /// the extracted integer is specified by the \a byte_size argument.
+ /// \a byte_size should have a value greater than or equal to one
+ /// and less than or equal to eight since the return value is 64
+ /// bits wide. Any \a byte_size values less than 1 or greater than
+ /// 8 will result in nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @return
+ /// The sign extended signed integer value that was extracted,
+ /// or zero on failure.
+ //------------------------------------------------------------------
+ int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t size) const;
+
+ //------------------------------------------------------------------
+ /// Extract an unsigned integer of size \a byte_size from \a
+ /// *offset_ptr, then extract the bitfield from this value if
+ /// \a bitfield_bit_size is non-zero.
+ ///
+ /// Extract a single unsigned integer value and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted integer
+ /// is specified by the \a byte_size argument. \a byte_size should
+ /// have a value greater than or equal to one and less than or equal
+ /// to 8 since the return value is 64 bits wide. Any
+ /// \a byte_size values less than 1 or greater than 8 will result in
+ /// nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in byte of the integer to extract.
+ ///
+ /// @param[in] bitfield_bit_size
+ /// The size in bits of the bitfield value to extract, or zero
+ /// to just extract the entire integer value.
+ ///
+ /// @param[in] bitfield_bit_offset
+ /// The bit offset of the bitfield value in the extracted
+ /// integer. For little-endian data, this is the offset of
+ /// the LSB of the bitfield from the LSB of the integer.
+ /// For big-endian data, this is the offset of the MSB of the
+ /// bitfield from the MSB of the integer.
+ ///
+ /// @return
+ /// The unsigned bitfield integer value that was extracted, or
+ /// zero on failure.
+ //------------------------------------------------------------------
+ uint64_t GetMaxU64Bitfield(lldb::offset_t *offset_ptr, size_t size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an signed integer of size \a byte_size from \a
+ /// *offset_ptr, then extract and signe extend the bitfield from
+ /// this value if \a bitfield_bit_size is non-zero.
+ ///
+ /// Extract a single signed integer value (sign extending if required)
+ /// and update the offset pointed to by \a offset_ptr. The size of
+ /// the extracted integer is specified by the \a byte_size argument.
+ /// \a byte_size should have a value greater than or equal to one
+ /// and less than or equal to eight since the return value is 64
+ /// bits wide. Any \a byte_size values less than 1 or greater than
+ /// 8 will result in nothing being extracted, and zero being returned.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[in] byte_size
+ /// The size in bytes of the integer to extract.
+ ///
+ /// @param[in] bitfield_bit_size
+ /// The size in bits of the bitfield value to extract, or zero
+ /// to just extract the entire integer value.
+ ///
+ /// @param[in] bitfield_bit_offset
+ /// The bit offset of the bitfield value in the extracted
+ /// integer. For little-endian data, this is the offset of
+ /// the LSB of the bitfield from the LSB of the integer.
+ /// For big-endian data, this is the offset of the MSB of the
+ /// bitfield from the MSB of the integer.
+ ///
+ /// @return
+ /// The signed bitfield integer value that was extracted, or
+ /// zero on failure.
+ //------------------------------------------------------------------
+ int64_t GetMaxS64Bitfield(lldb::offset_t *offset_ptr, size_t size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset) const;
+
+ //------------------------------------------------------------------
+ /// Extract an pointer from \a *offset_ptr.
+ ///
+ /// Extract a single pointer from the data and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted pointer
+ /// comes from the \a m_addr_size member variable and should be
+ /// set correctly prior to extracting any pointer values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted pointer value as a 64 integer.
+ //------------------------------------------------------------------
+ uint64_t GetPointer(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Get the current byte order value.
+ ///
+ /// @return
+ /// The current byte order value from this object's internal
+ /// state.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const { return m_byte_order; }
+
+ //------------------------------------------------------------------
+ /// Extract a uint8_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint8_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and advance the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint8_t value.
+ //------------------------------------------------------------------
+ uint8_t GetU8(lldb::offset_t *offset_ptr) const;
+
+ uint8_t GetU8_unchecked(lldb::offset_t *offset_ptr) const {
+ uint8_t val = m_start[*offset_ptr];
+ *offset_ptr += 1;
+ return val;
+ }
+
+ uint16_t GetU16_unchecked(lldb::offset_t *offset_ptr) const;
+
+ uint32_t GetU32_unchecked(lldb::offset_t *offset_ptr) const;
+
+ uint64_t GetU64_unchecked(lldb::offset_t *offset_ptr) const;
+ //------------------------------------------------------------------
+ /// Extract \a count uint8_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint8_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint8_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint8_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU8(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint16_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint16_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint16_t value.
+ //------------------------------------------------------------------
+ uint16_t GetU16(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint16_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint16_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint16_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint16_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU16(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint32_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint32_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint32_t value.
+ //------------------------------------------------------------------
+ uint32_t GetU32(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint32_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint32_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint32_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint32_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU32(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a uint64_t value from \a *offset_ptr.
+ ///
+ /// Extract a single uint64_t from the binary data at the offset
+ /// pointed to by \a offset_ptr, and update the offset on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted uint64_t value.
+ //------------------------------------------------------------------
+ uint64_t GetU64(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract \a count uint64_t values from \a *offset_ptr.
+ ///
+ /// Extract \a count uint64_t values from the binary data at the
+ /// offset pointed to by \a offset_ptr, and advance the offset on
+ /// success. The extracted values are copied into \a dst.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @param[out] dst
+ /// A buffer to copy \a count uint64_t values into. \a dst must
+ /// be large enough to hold all requested data.
+ ///
+ /// @param[in] count
+ /// The number of uint64_t values to extract.
+ ///
+ /// @return
+ /// \a dst if all values were properly extracted and copied,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ void *GetU64(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;
+
+ //------------------------------------------------------------------
+ /// Extract a signed LEB128 value from \a *offset_ptr.
+ ///
+ /// Extracts an signed LEB128 number from this object's data
+ /// starting at the offset pointed to by \a offset_ptr. The offset
+ /// pointed to by \a offset_ptr will be updated with the offset of
+ /// the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted signed integer value.
+ //------------------------------------------------------------------
+ int64_t GetSLEB128(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Extract a unsigned LEB128 value from \a *offset_ptr.
+ ///
+ /// Extracts an unsigned LEB128 number from this object's data
+ /// starting at the offset pointed to by \a offset_ptr. The offset
+ /// pointed to by \a offset_ptr will be updated with the offset of
+ /// the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted unsigned integer value.
+ //------------------------------------------------------------------
+ uint64_t GetULEB128(lldb::offset_t *offset_ptr) const;
+
+ lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; }
+
+ //------------------------------------------------------------------
+ /// Peek at a C string at \a offset.
+ ///
+ /// Peeks at a string in the contained data. No verification is done
+ /// to make sure the entire string lies within the bounds of this
+ /// object's data, only \a offset is verified to be a valid offset.
+ ///
+ /// @param[in] offset
+ /// An offset into the data.
+ ///
+ /// @return
+ /// A non-nullptr C string pointer if \a offset is a valid offset,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ const char *PeekCStr(lldb::offset_t offset) const;
+
+ //------------------------------------------------------------------
+ /// Peek at a bytes at \a offset.
+ ///
+ /// Returns a pointer to \a length bytes at \a offset as long as
+ /// there are \a length bytes available starting at \a offset.
+ ///
+ /// @return
+ /// A non-nullptr data pointer if \a offset is a valid offset and
+ /// there are \a length bytes available at that offset, nullptr
+ /// otherwise.
+ //------------------------------------------------------------------
+ const uint8_t *PeekData(lldb::offset_t offset, lldb::offset_t length) const {
+ if (ValidOffsetForDataOfSize(offset, length))
+ return m_start + offset;
+ return nullptr;
+ }
+
+ //------------------------------------------------------------------
+ /// Set the address byte size.
+ ///
+ /// Set the size in bytes that will be used when extracting any
+ /// address and pointer values from data contained in this object.
+ ///
+ /// @param[in] addr_size
+ /// The size in bytes to use when extracting addresses.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint32_t addr_size) {
#ifdef LLDB_CONFIGURATION_DEBUG
- assert (addr_size == 4 || addr_size == 8);
+ assert(addr_size == 4 || addr_size == 8);
#endif
- m_addr_size = addr_size;
- }
+ m_addr_size = addr_size;
+ }
- //------------------------------------------------------------------
- /// Set data with a buffer that is caller owned.
- ///
- /// Use data that is owned by the caller when extracting values.
- /// The data must stay around as long as this object, or any object
- /// that copies a subset of this object's data, is valid. If \a
- /// bytes is nullptr, or \a length is zero, this object will contain
- /// no data.
- ///
- /// @param[in] bytes
- /// A pointer to caller owned data.
- ///
- /// @param[in] length
- /// The length in bytes of \a bytes.
- ///
- /// @param[in] byte_order
- /// A byte order of the data that we are extracting from.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Adopt a subset of \a data.
- ///
- /// Set this object's data to be a subset of the data bytes in \a
- /// data. If \a data contains shared data, then a reference to the
- /// shared data will be added to ensure the shared data stays around
- /// as long as any objects have references to the shared data. The
- /// byte order and the address size settings are copied from \a
- /// data. If \a offset is not a valid offset in \a data, then no
- /// reference to the shared data will be added. If there are not
- /// \a length bytes available in \a data starting at \a offset,
- /// the length will be truncated to contains as many bytes as
- /// possible.
- ///
- /// @param[in] data
- /// Another DataExtractor object that contains data.
- ///
- /// @param[in] offset
- /// The offset into \a data at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length);
-
- //------------------------------------------------------------------
- /// Adopt a subset of shared data in \a data_sp.
- ///
- /// Copies the data shared pointer which adds a reference to the
- /// contained in \a data_sp. The shared data reference is reference
- /// counted to ensure the data lives as long as anyone still has a
- /// valid shared pointer to the data in \a data_sp. The byte order
- /// and address byte size settings remain the same. If
- /// \a offset is not a valid offset in \a data_sp, then no reference
- /// to the shared data will be added. If there are not \a length
- /// bytes available in \a data starting at \a offset, the length
- /// will be truncated to contains as many bytes as possible.
- ///
- /// @param[in] data_sp
- /// A shared pointer to data.
- ///
- /// @param[in] offset
- /// The offset into \a data_sp at which the subset starts.
- ///
- /// @param[in] length
- /// The length in bytes of the subset of \a data_sp.
- ///
- /// @return
- /// The number of bytes that this object now contains.
- //------------------------------------------------------------------
- lldb::offset_t
- SetData (const lldb::DataBufferSP& data_sp, lldb::offset_t offset = 0, lldb::offset_t length = LLDB_INVALID_OFFSET);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- //------------------------------------------------------------------
- void
- SetByteOrder (lldb::ByteOrder byte_order)
- {
- m_byte_order = byte_order;
- }
-
- //------------------------------------------------------------------
- /// Skip an LEB128 number at \a *offset_ptr.
- ///
- /// Skips a LEB128 number (signed or unsigned) from this object's
- /// data starting at the offset pointed to by \a offset_ptr. The
- /// offset pointed to by \a offset_ptr will be updated with the
- /// offset of the byte following the last extracted byte.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @return
- // The number of bytes consumed during the extraction.
- //------------------------------------------------------------------
- uint32_t
- Skip_LEB128 (lldb::offset_t *offset_ptr) const;
-
- //------------------------------------------------------------------
- /// Test the validity of \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset into the data in this
- /// object, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffset (lldb::offset_t offset) const
- {
- return offset < GetByteSize();
- }
-
- //------------------------------------------------------------------
- /// Test the availability of \a length bytes of data from \a offset.
- ///
- /// @return
- /// \b true if \a offset is a valid offset and there are \a
- /// length bytes available at that offset, \b false otherwise.
- //------------------------------------------------------------------
- bool
- ValidOffsetForDataOfSize (lldb::offset_t offset, lldb::offset_t length) const
- {
- return length <= BytesLeft (offset);
- }
-
- size_t
- Copy (DataExtractor& dest_data) const;
-
- bool
- Append (DataExtractor& rhs);
-
- bool
- Append (void* bytes, lldb::offset_t length);
-
- lldb::offset_t
- BytesLeft (lldb::offset_t offset) const
- {
- const lldb::offset_t size = GetByteSize();
- if (size > offset)
- return size - offset;
- return 0;
- }
-
- void
- Checksum (llvm::SmallVectorImpl<uint8_t> &dest,
- uint64_t max_data = 0);
+ //------------------------------------------------------------------
+ /// Set data with a buffer that is caller owned.
+ ///
+ /// Use data that is owned by the caller when extracting values.
+ /// The data must stay around as long as this object, or any object
+ /// that copies a subset of this object's data, is valid. If \a
+ /// bytes is nullptr, or \a length is zero, this object will contain
+ /// no data.
+ ///
+ /// @param[in] bytes
+ /// A pointer to caller owned data.
+ ///
+ /// @param[in] length
+ /// The length in bytes of \a bytes.
+ ///
+ /// @param[in] byte_order
+ /// A byte order of the data that we are extracting from.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const void *bytes, lldb::offset_t length,
+ lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of \a data.
+ ///
+ /// Set this object's data to be a subset of the data bytes in \a
+ /// data. If \a data contains shared data, then a reference to the
+ /// shared data will be added to ensure the shared data stays around
+ /// as long as any objects have references to the shared data. The
+ /// byte order and the address size settings are copied from \a
+ /// data. If \a offset is not a valid offset in \a data, then no
+ /// reference to the shared data will be added. If there are not
+ /// \a length bytes available in \a data starting at \a offset,
+ /// the length will be truncated to contains as many bytes as
+ /// possible.
+ ///
+ /// @param[in] data
+ /// Another DataExtractor object that contains data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const DataExtractor &data, lldb::offset_t offset,
+ lldb::offset_t length);
+
+ //------------------------------------------------------------------
+ /// Adopt a subset of shared data in \a data_sp.
+ ///
+ /// Copies the data shared pointer which adds a reference to the
+ /// contained in \a data_sp. The shared data reference is reference
+ /// counted to ensure the data lives as long as anyone still has a
+ /// valid shared pointer to the data in \a data_sp. The byte order
+ /// and address byte size settings remain the same. If
+ /// \a offset is not a valid offset in \a data_sp, then no reference
+ /// to the shared data will be added. If there are not \a length
+ /// bytes available in \a data starting at \a offset, the length
+ /// will be truncated to contains as many bytes as possible.
+ ///
+ /// @param[in] data_sp
+ /// A shared pointer to data.
+ ///
+ /// @param[in] offset
+ /// The offset into \a data_sp at which the subset starts.
+ ///
+ /// @param[in] length
+ /// The length in bytes of the subset of \a data_sp.
+ ///
+ /// @return
+ /// The number of bytes that this object now contains.
+ //------------------------------------------------------------------
+ lldb::offset_t SetData(const lldb::DataBufferSP &data_sp,
+ lldb::offset_t offset = 0,
+ lldb::offset_t length = LLDB_INVALID_OFFSET);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ //------------------------------------------------------------------
+ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
+
+ //------------------------------------------------------------------
+ /// Skip an LEB128 number at \a *offset_ptr.
+ ///
+ /// Skips a LEB128 number (signed or unsigned) from this object's
+ /// data starting at the offset pointed to by \a offset_ptr. The
+ /// offset pointed to by \a offset_ptr will be updated with the
+ /// offset of the byte following the last extracted byte.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ // The number of bytes consumed during the extraction.
+ //------------------------------------------------------------------
+ uint32_t Skip_LEB128(lldb::offset_t *offset_ptr) const;
+
+ //------------------------------------------------------------------
+ /// Test the validity of \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset into the data in this
+ /// object, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffset(lldb::offset_t offset) const {
+ return offset < GetByteSize();
+ }
+
+ //------------------------------------------------------------------
+ /// Test the availability of \a length bytes of data from \a offset.
+ ///
+ /// @return
+ /// \b true if \a offset is a valid offset and there are \a
+ /// length bytes available at that offset, \b false otherwise.
+ //------------------------------------------------------------------
+ bool ValidOffsetForDataOfSize(lldb::offset_t offset,
+ lldb::offset_t length) const {
+ return length <= BytesLeft(offset);
+ }
+
+ size_t Copy(DataExtractor &dest_data) const;
+
+ bool Append(DataExtractor &rhs);
+
+ bool Append(void *bytes, lldb::offset_t length);
+
+ lldb::offset_t BytesLeft(lldb::offset_t offset) const {
+ const lldb::offset_t size = GetByteSize();
+ if (size > offset)
+ return size - offset;
+ return 0;
+ }
+
+ void Checksum(llvm::SmallVectorImpl<uint8_t> &dest, uint64_t max_data = 0);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- const uint8_t * m_start; ///< A pointer to the first byte of data.
- const uint8_t * m_end; ///< A pointer to the byte that is past the end of the data.
- lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from.
- uint32_t m_addr_size; ///< The address size to use when extracting pointers or addresses
- mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multiple instances
- const uint32_t m_target_byte_size;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ const uint8_t *m_start; ///< A pointer to the first byte of data.
+ const uint8_t
+ *m_end; ///< A pointer to the byte that is past the end of the data.
+ lldb::ByteOrder
+ m_byte_order; ///< The byte order of the data we are extracting from.
+ uint32_t m_addr_size; ///< The address size to use when extracting pointers or
+ ///addresses
+ mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
+ ///be shared among multiple instances
+ const uint32_t m_target_byte_size;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Tue Sep 6 15:57:50 2016
@@ -14,14 +14,13 @@
#include <stdint.h>
// C++ Includes
-#include <memory>
#include <map>
+#include <memory>
#include <mutex>
#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/IOHandler.h"
@@ -33,11 +32,10 @@
#include "lldb/Host/Terminal.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/lldb-public.h"
-namespace llvm
-{
-namespace sys
-{
+namespace llvm {
+namespace sys {
class DynamicLibrary;
} // namespace sys
} // namespace llvm
@@ -51,454 +49,337 @@ namespace lldb_private {
/// Provides a global root objects for the debugger core.
//----------------------------------------------------------------------
-class Debugger :
- public std::enable_shared_from_this<Debugger>,
- public UserID,
- public Properties
-{
-friend class SourceManager; // For GetSourceFileCache.
+class Debugger : public std::enable_shared_from_this<Debugger>,
+ public UserID,
+ public Properties {
+ friend class SourceManager; // For GetSourceFileCache.
public:
- ~Debugger() override;
+ ~Debugger() override;
+
+ static lldb::DebuggerSP
+ CreateInstance(lldb::LogOutputCallback log_callback = nullptr,
+ void *baton = nullptr);
+
+ static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid);
+
+ static lldb::TargetSP FindTargetWithProcess(Process *process);
+
+ static void Initialize(LoadPluginCallbackType load_plugin_callback);
+
+ static void Terminate();
+
+ static void SettingsInitialize();
+
+ static void SettingsTerminate();
+
+ static void Destroy(lldb::DebuggerSP &debugger_sp);
+
+ static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id);
+
+ static lldb::DebuggerSP
+ FindDebuggerWithInstanceName(const ConstString &instance_name);
+
+ static size_t GetNumDebuggers();
+
+ static lldb::DebuggerSP GetDebuggerAtIndex(size_t index);
+
+ static bool FormatDisassemblerAddress(const FormatEntity::Entry *format,
+ const SymbolContext *sc,
+ const SymbolContext *prev_sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, Stream &s);
+
+ void Clear();
+
+ bool GetAsyncExecution();
+
+ void SetAsyncExecution(bool async);
+
+ lldb::StreamFileSP GetInputFile() { return m_input_file_sp; }
+
+ lldb::StreamFileSP GetOutputFile() { return m_output_file_sp; }
+
+ lldb::StreamFileSP GetErrorFile() { return m_error_file_sp; }
+
+ void SetInputFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SetOutputFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SetErrorFileHandle(FILE *fh, bool tranfer_ownership);
+
+ void SaveInputTerminalState();
+
+ void RestoreInputTerminalState();
+
+ lldb::StreamSP GetAsyncOutputStream();
+
+ lldb::StreamSP GetAsyncErrorStream();
+
+ CommandInterpreter &GetCommandInterpreter() {
+ assert(m_command_interpreter_ap.get());
+ return *m_command_interpreter_ap;
+ }
+
+ lldb::ListenerSP GetListener() { return m_listener_sp; }
+
+ // This returns the Debugger's scratch source manager. It won't be able to
+ // look up files in debug
+ // information, but it can look up files by absolute path and display them to
+ // you.
+ // To get the target's source manager, call GetSourceManager on the target
+ // instead.
+ SourceManager &GetSourceManager();
+
+ lldb::TargetSP GetSelectedTarget() {
+ return m_target_list.GetSelectedTarget();
+ }
+
+ ExecutionContext GetSelectedExecutionContext();
+ //------------------------------------------------------------------
+ /// Get accessor for the target list.
+ ///
+ /// The target list is part of the global debugger object. This
+ /// the single debugger shared instance to control where targets
+ /// get created and to allow for tracking and searching for targets
+ /// based on certain criteria.
+ ///
+ /// @return
+ /// A global shared target list.
+ //------------------------------------------------------------------
+ TargetList &GetTargetList() { return m_target_list; }
+
+ PlatformList &GetPlatformList() { return m_platform_list; }
+
+ void DispatchInputInterrupt();
+
+ void DispatchInputEndOfFile();
+
+ //------------------------------------------------------------------
+ // If any of the streams are not set, set them to the in/out/err
+ // stream of the top most input reader to ensure they at least have
+ // something
+ //------------------------------------------------------------------
+ void AdoptTopIOHandlerFilesIfInvalid(lldb::StreamFileSP &in,
+ lldb::StreamFileSP &out,
+ lldb::StreamFileSP &err);
+
+ void PushIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ // Synchronously run an input reader until it is done
+ void RunIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
+
+ bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
+ IOHandler::Type second_top_type);
+
+ void PrintAsync(const char *s, size_t len, bool is_stdout);
+
+ ConstString GetTopIOHandlerControlSequence(char ch);
+
+ const char *GetIOHandlerCommandPrefix();
+
+ const char *GetIOHandlerHelpPrologue();
+
+ void ClearIOHandlers();
+
+ bool GetCloseInputOnEOF() const;
+
+ void SetCloseInputOnEOF(bool b);
+
+ bool EnableLog(const char *channel, const char **categories,
+ const char *log_file, uint32_t log_options,
+ Stream &error_stream);
+
+ void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
+
+ //----------------------------------------------------------------------
+ // Properties Functions
+ //----------------------------------------------------------------------
+ enum StopDisassemblyType {
+ eStopDisassemblyTypeNever = 0,
+ eStopDisassemblyTypeNoDebugInfo,
+ eStopDisassemblyTypeNoSource,
+ eStopDisassemblyTypeAlways
+ };
- static lldb::DebuggerSP
- CreateInstance(lldb::LogOutputCallback log_callback = nullptr, void *baton = nullptr);
+ Error SetPropertyValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op, const char *property_path,
+ const char *value) override;
- static lldb::TargetSP
- FindTargetWithProcessID (lldb::pid_t pid);
-
- static lldb::TargetSP
- FindTargetWithProcess (Process *process);
-
- static void
- Initialize(LoadPluginCallbackType load_plugin_callback);
-
- static void
- Terminate();
-
- static void
- SettingsInitialize ();
-
- static void
- SettingsTerminate ();
-
- static void
- Destroy (lldb::DebuggerSP &debugger_sp);
-
- static lldb::DebuggerSP
- FindDebuggerWithID(lldb::user_id_t id);
-
- static lldb::DebuggerSP
- FindDebuggerWithInstanceName(const ConstString &instance_name);
-
- static size_t
- GetNumDebuggers();
-
- static lldb::DebuggerSP
- GetDebuggerAtIndex(size_t index);
-
- static bool
- FormatDisassemblerAddress(const FormatEntity::Entry *format,
- const SymbolContext *sc,
- const SymbolContext *prev_sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- Stream &s);
-
- void Clear();
-
- bool
- GetAsyncExecution ();
-
- void
- SetAsyncExecution (bool async);
-
- lldb::StreamFileSP
- GetInputFile ()
- {
- return m_input_file_sp;
- }
-
- lldb::StreamFileSP
- GetOutputFile ()
- {
- return m_output_file_sp;
- }
-
- lldb::StreamFileSP
- GetErrorFile ()
- {
- return m_error_file_sp;
- }
-
- void
- SetInputFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SetOutputFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SetErrorFileHandle (FILE *fh, bool tranfer_ownership);
-
- void
- SaveInputTerminalState();
-
- void
- RestoreInputTerminalState();
-
- lldb::StreamSP
- GetAsyncOutputStream ();
-
- lldb::StreamSP
- GetAsyncErrorStream ();
-
- CommandInterpreter &
- GetCommandInterpreter ()
- {
- assert (m_command_interpreter_ap.get());
- return *m_command_interpreter_ap;
- }
-
- lldb::ListenerSP
- GetListener ()
- {
- return m_listener_sp;
- }
-
- // This returns the Debugger's scratch source manager. It won't be able to look up files in debug
- // information, but it can look up files by absolute path and display them to you.
- // To get the target's source manager, call GetSourceManager on the target instead.
- SourceManager &
- GetSourceManager ();
-
- lldb::TargetSP
- GetSelectedTarget ()
- {
- return m_target_list.GetSelectedTarget ();
- }
-
- ExecutionContext
- GetSelectedExecutionContext();
- //------------------------------------------------------------------
- /// Get accessor for the target list.
- ///
- /// The target list is part of the global debugger object. This
- /// the single debugger shared instance to control where targets
- /// get created and to allow for tracking and searching for targets
- /// based on certain criteria.
- ///
- /// @return
- /// A global shared target list.
- //------------------------------------------------------------------
- TargetList &
- GetTargetList ()
- {
- return m_target_list;
- }
-
- PlatformList &
- GetPlatformList ()
- {
- return m_platform_list;
- }
-
- void
- DispatchInputInterrupt ();
-
- void
- DispatchInputEndOfFile ();
-
- //------------------------------------------------------------------
- // If any of the streams are not set, set them to the in/out/err
- // stream of the top most input reader to ensure they at least have
- // something
- //------------------------------------------------------------------
- void
- AdoptTopIOHandlerFilesIfInvalid (lldb::StreamFileSP &in,
- lldb::StreamFileSP &out,
- lldb::StreamFileSP &err);
-
- void
- PushIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- PopIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- // Synchronously run an input reader until it is done
- void
- RunIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- IsTopIOHandler (const lldb::IOHandlerSP& reader_sp);
-
- bool
- CheckTopIOHandlerTypes (IOHandler::Type top_type,
- IOHandler::Type second_top_type);
-
- void
- PrintAsync (const char *s, size_t len, bool is_stdout);
-
- ConstString
- GetTopIOHandlerControlSequence(char ch);
-
- const char *
- GetIOHandlerCommandPrefix();
-
- const char *
- GetIOHandlerHelpPrologue();
-
- void
- ClearIOHandlers ();
-
- bool
- GetCloseInputOnEOF () const;
-
- void
- SetCloseInputOnEOF (bool b);
-
- bool
- EnableLog (const char *channel, const char **categories, const char *log_file, uint32_t log_options, Stream &error_stream);
-
- void
- SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
-
- //----------------------------------------------------------------------
- // Properties Functions
- //----------------------------------------------------------------------
- enum StopDisassemblyType
- {
- eStopDisassemblyTypeNever = 0,
- eStopDisassemblyTypeNoDebugInfo,
- eStopDisassemblyTypeNoSource,
- eStopDisassemblyTypeAlways
- };
-
- Error
- SetPropertyValue(const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *property_path,
- const char *value) override;
-
- bool
- GetAutoConfirm () const;
-
- const FormatEntity::Entry *
- GetDisassemblyFormat() const;
-
- const FormatEntity::Entry *
- GetFrameFormat() const;
-
- const FormatEntity::Entry *
- GetThreadFormat() const;
-
- lldb::ScriptLanguage
- GetScriptLanguage() const;
-
- bool
- SetScriptLanguage (lldb::ScriptLanguage script_lang);
-
- uint32_t
- GetTerminalWidth () const;
-
- bool
- SetTerminalWidth (uint32_t term_width);
-
- const char *
- GetPrompt() const;
-
- void
- SetPrompt(const char *p);
-
- bool
- GetUseExternalEditor () const;
-
- bool
- SetUseExternalEditor (bool use_external_editor_p);
-
- bool
- GetUseColor () const;
-
- bool
- SetUseColor (bool use_color);
-
- uint32_t
- GetStopSourceLineCount (bool before) const;
-
- StopDisassemblyType
- GetStopDisassemblyDisplay () const;
-
- uint32_t
- GetDisassemblyLineCount () const;
-
- bool
- GetAutoOneLineSummaries () const;
-
- bool
- GetAutoIndent () const;
-
- bool
- SetAutoIndent (bool b);
-
- bool
- GetPrintDecls () const;
-
- bool
- SetPrintDecls (bool b);
-
- uint32_t
- GetTabSize () const;
-
- bool
- SetTabSize (uint32_t tab_size);
-
- bool
- GetEscapeNonPrintables () const;
-
- bool
- GetNotifyVoid () const;
-
- const ConstString &
- GetInstanceName()
- {
- return m_instance_name;
- }
-
- bool
- LoadPlugin (const FileSpec& spec, Error& error);
-
- void
- ExecuteIOHandlers();
-
- bool
- IsForwardingEvents ();
-
- void
- EnableForwardEvents (const lldb::ListenerSP &listener_sp);
-
- void
- CancelForwardEvents (const lldb::ListenerSP &listener_sp);
-
- bool
- IsHandlingEvents () const
- {
- return m_event_handler_thread.IsJoinable();
- }
-
- Error
- RunREPL (lldb::LanguageType language, const char *repl_options);
-
- // This is for use in the command interpreter, when you either want the selected target, or if no target
- // is present you want to prime the dummy target with entities that will be copied over to new targets.
- Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
- Target *GetDummyTarget();
-
- lldb::BroadcasterManagerSP
- GetBroadcasterManager()
- {
- return m_broadcaster_manager_sp;
- }
+ bool GetAutoConfirm() const;
+
+ const FormatEntity::Entry *GetDisassemblyFormat() const;
+
+ const FormatEntity::Entry *GetFrameFormat() const;
+
+ const FormatEntity::Entry *GetThreadFormat() const;
+
+ lldb::ScriptLanguage GetScriptLanguage() const;
+
+ bool SetScriptLanguage(lldb::ScriptLanguage script_lang);
+
+ uint32_t GetTerminalWidth() const;
+
+ bool SetTerminalWidth(uint32_t term_width);
+
+ const char *GetPrompt() const;
+
+ void SetPrompt(const char *p);
+
+ bool GetUseExternalEditor() const;
+
+ bool SetUseExternalEditor(bool use_external_editor_p);
+
+ bool GetUseColor() const;
+
+ bool SetUseColor(bool use_color);
+
+ uint32_t GetStopSourceLineCount(bool before) const;
+
+ StopDisassemblyType GetStopDisassemblyDisplay() const;
+
+ uint32_t GetDisassemblyLineCount() const;
+
+ bool GetAutoOneLineSummaries() const;
+
+ bool GetAutoIndent() const;
+
+ bool SetAutoIndent(bool b);
+
+ bool GetPrintDecls() const;
+
+ bool SetPrintDecls(bool b);
+
+ uint32_t GetTabSize() const;
+
+ bool SetTabSize(uint32_t tab_size);
+
+ bool GetEscapeNonPrintables() const;
+
+ bool GetNotifyVoid() const;
+
+ const ConstString &GetInstanceName() { return m_instance_name; }
+
+ bool LoadPlugin(const FileSpec &spec, Error &error);
+
+ void ExecuteIOHandlers();
+
+ bool IsForwardingEvents();
+
+ void EnableForwardEvents(const lldb::ListenerSP &listener_sp);
+
+ void CancelForwardEvents(const lldb::ListenerSP &listener_sp);
+
+ bool IsHandlingEvents() const { return m_event_handler_thread.IsJoinable(); }
+
+ Error RunREPL(lldb::LanguageType language, const char *repl_options);
+
+ // This is for use in the command interpreter, when you either want the
+ // selected target, or if no target
+ // is present you want to prime the dummy target with entities that will be
+ // copied over to new targets.
+ Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
+ Target *GetDummyTarget();
+
+ lldb::BroadcasterManagerSP GetBroadcasterManager() {
+ return m_broadcaster_manager_sp;
+ }
protected:
- friend class CommandInterpreter;
- friend class REPL;
+ friend class CommandInterpreter;
+ friend class REPL;
+
+ bool StartEventHandlerThread();
+
+ void StopEventHandlerThread();
+
+ static lldb::thread_result_t EventHandlerThread(lldb::thread_arg_t arg);
+
+ bool HasIOHandlerThread();
+
+ bool StartIOHandlerThread();
+
+ void StopIOHandlerThread();
+
+ void JoinIOHandlerThread();
+
+ static lldb::thread_result_t IOHandlerThread(lldb::thread_arg_t arg);
+
+ void DefaultEventHandler();
+
+ void HandleBreakpointEvent(const lldb::EventSP &event_sp);
+
+ void HandleProcessEvent(const lldb::EventSP &event_sp);
+
+ void HandleThreadEvent(const lldb::EventSP &event_sp);
+
+ size_t GetProcessSTDOUT(Process *process, Stream *stream);
+
+ size_t GetProcessSTDERR(Process *process, Stream *stream);
+
+ SourceManager::SourceFileCache &GetSourceFileCache() {
+ return m_source_file_cache;
+ }
+
+ void InstanceInitialize();
+
+ lldb::StreamFileSP m_input_file_sp;
+ lldb::StreamFileSP m_output_file_sp;
+ lldb::StreamFileSP m_error_file_sp;
+
+ lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a
+ // broadcaster manager of
+ // last resort.
+ // It needs to get constructed before the target_list or any other
+ // member that might want to broadcast through the debugger.
+
+ TerminalState m_terminal_state;
+ TargetList m_target_list;
- bool
- StartEventHandlerThread();
+ PlatformList m_platform_list;
+ lldb::ListenerSP m_listener_sp;
+ std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch
+ // source manager that we
+ // return if we have no
+ // targets.
+ SourceManager::SourceFileCache m_source_file_cache; // All the source managers
+ // for targets created in
+ // this debugger used this
+ // shared
+ // source file cache.
+ std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
- void
- StopEventHandlerThread();
+ IOHandlerStack m_input_reader_stack;
+ typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
+ LogStreamMap m_log_streams;
+ lldb::StreamSP m_log_callback_stream_sp;
+ ConstString m_instance_name;
+ static LoadPluginCallbackType g_load_plugin_callback;
+ typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
+ LoadedPluginsList m_loaded_plugins;
+ HostThread m_event_handler_thread;
+ HostThread m_io_handler_thread;
+ Broadcaster m_sync_broadcaster;
+ lldb::ListenerSP m_forward_listener_sp;
+ std::once_flag m_clear_once;
- static lldb::thread_result_t
- EventHandlerThread (lldb::thread_arg_t arg);
-
- bool
- HasIOHandlerThread();
-
- bool
- StartIOHandlerThread();
-
- void
- StopIOHandlerThread();
-
- void
- JoinIOHandlerThread();
-
- static lldb::thread_result_t
- IOHandlerThread (lldb::thread_arg_t arg);
-
- void
- DefaultEventHandler();
-
- void
- HandleBreakpointEvent (const lldb::EventSP &event_sp);
-
- void
- HandleProcessEvent (const lldb::EventSP &event_sp);
-
- void
- HandleThreadEvent (const lldb::EventSP &event_sp);
-
- size_t
- GetProcessSTDOUT (Process *process, Stream *stream);
-
- size_t
- GetProcessSTDERR (Process *process, Stream *stream);
-
- SourceManager::SourceFileCache &
- GetSourceFileCache ()
- {
- return m_source_file_cache;
- }
-
- void
- InstanceInitialize ();
-
- lldb::StreamFileSP m_input_file_sp;
- lldb::StreamFileSP m_output_file_sp;
- lldb::StreamFileSP m_error_file_sp;
-
- lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a broadcaster manager of last resort.
- // It needs to get constructed before the target_list or any other
- // member that might want to broadcast through the debugger.
-
- TerminalState m_terminal_state;
- TargetList m_target_list;
-
- PlatformList m_platform_list;
- lldb::ListenerSP m_listener_sp;
- std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch source manager that we return if we have no targets.
- SourceManager::SourceFileCache m_source_file_cache; // All the source managers for targets created in this debugger used this shared
- // source file cache.
- std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
-
- IOHandlerStack m_input_reader_stack;
- typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
- LogStreamMap m_log_streams;
- lldb::StreamSP m_log_callback_stream_sp;
- ConstString m_instance_name;
- static LoadPluginCallbackType g_load_plugin_callback;
- typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
- LoadedPluginsList m_loaded_plugins;
- HostThread m_event_handler_thread;
- HostThread m_io_handler_thread;
- Broadcaster m_sync_broadcaster;
- lldb::ListenerSP m_forward_listener_sp;
- std::once_flag m_clear_once;
-
- //----------------------------------------------------------------------
- // Events for m_sync_broadcaster
- //----------------------------------------------------------------------
- enum
- {
- eBroadcastBitEventThreadIsListening = (1 << 0),
- };
+ //----------------------------------------------------------------------
+ // Events for m_sync_broadcaster
+ //----------------------------------------------------------------------
+ enum {
+ eBroadcastBitEventThreadIsListening = (1 << 0),
+ };
private:
- // Use Debugger::CreateInstance() to get a shared pointer to a new
- // debugger object
- Debugger (lldb::LogOutputCallback m_log_callback, void *baton);
+ // Use Debugger::CreateInstance() to get a shared pointer to a new
+ // debugger object
+ Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
- DISALLOW_COPY_AND_ASSIGN (Debugger);
+ DISALLOW_COPY_AND_ASSIGN(Debugger);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Disassembler.h (original)
+++ lldb/trunk/include/lldb/Core/Disassembler.h Tue Sep 6 15:57:50 2016
@@ -12,503 +12,395 @@
// C Includes
// C++ Includes
-#include <vector>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Instruction
-{
+class Instruction {
public:
- Instruction (const Address &address,
- lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+ Instruction(const Address &address,
+ lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
- virtual
- ~Instruction();
+ virtual ~Instruction();
- const Address &
- GetAddress () const
- {
- return m_address;
- }
-
- const char *
- GetMnemonic (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_opcode_name.c_str();
- }
-
- const char *
- GetOperands (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_mnemonics.c_str();
- }
-
- const char *
- GetComment (const ExecutionContext* exe_ctx)
- {
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
- return m_comment.c_str();
- }
+ const Address &GetAddress() const { return m_address; }
- virtual void
- CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx) = 0;
-
- lldb::AddressClass
- GetAddressClass ();
-
- void
- SetAddress (const Address &addr)
- {
- // Invalidate the address class to lazily discover
- // it if we need to.
- m_address_class = lldb::eAddressClassInvalid;
- m_address = addr;
- }
+ const char *GetMnemonic(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_opcode_name.c_str();
+ }
+
+ const char *GetOperands(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_mnemonics.c_str();
+ }
+
+ const char *GetComment(const ExecutionContext *exe_ctx) {
+ CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
+ return m_comment.c_str();
+ }
+
+ virtual void
+ CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx) = 0;
+
+ lldb::AddressClass GetAddressClass();
+
+ void SetAddress(const Address &addr) {
+ // Invalidate the address class to lazily discover
+ // it if we need to.
+ m_address_class = lldb::eAddressClassInvalid;
+ m_address = addr;
+ }
+
+ //------------------------------------------------------------------
+ /// Dump the text representation of this Instruction to a Stream
+ ///
+ /// Print the (optional) address, (optional) bytes, opcode,
+ /// operands, and instruction comments to a stream.
+ ///
+ /// @param[in] s
+ /// The Stream to add the text to.
+ ///
+ /// @param[in] show_address
+ /// Whether the address (using disassembly_addr_format_spec formatting)
+ /// should be printed.
+ ///
+ /// @param[in] show_bytes
+ /// Whether the bytes of the assembly instruction should be printed.
+ ///
+ /// @param[in] max_opcode_byte_size
+ /// The size (in bytes) of the largest instruction in the list that
+ /// we are printing (for text justification/alignment purposes)
+ /// Only needed if show_bytes is true.
+ ///
+ /// @param[in] exe_ctx
+ /// The current execution context, if available. May be used in
+ /// the assembling of the operands+comments for this instruction.
+ /// Pass NULL if not applicable.
+ ///
+ /// @param[in] sym_ctx
+ /// The SymbolContext for this instruction.
+ /// Pass NULL if not available/computed.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] prev_sym_ctx
+ /// The SymbolContext for the previous instruction. Depending on
+ /// the disassembly address format specification, a change in
+ /// Symbol / Function may mean that a line is printed with the new
+ /// symbol/function name.
+ /// Pass NULL if unavailable, or if this is the first instruction of
+ /// the InstructionList.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] disassembly_addr_format
+ /// The format specification for how addresses are printed.
+ /// Only needed if show_address is true.
+ ///
+ /// @param[in] max_address_text_size
+ /// The length of the longest address string at the start of the
+ /// disassembly line that will be printed (the
+ /// Debugger::FormatDisassemblerAddress() string)
+ /// so this method can properly align the instruction opcodes.
+ /// May be 0 to indicate no indentation/alignment of the opcodes.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s, uint32_t max_opcode_byte_size, bool show_address,
+ bool show_bytes, const ExecutionContext *exe_ctx,
+ const SymbolContext *sym_ctx,
+ const SymbolContext *prev_sym_ctx,
+ const FormatEntity::Entry *disassembly_addr_format,
+ size_t max_address_text_size);
+
+ virtual bool DoesBranch() = 0;
+
+ virtual bool HasDelaySlot();
+
+ virtual size_t Decode(const Disassembler &disassembler,
+ const DataExtractor &data,
+ lldb::offset_t data_offset) = 0;
+
+ virtual void SetDescription(const char *) {
+ } // May be overridden in sub-classes that have descriptions.
+
+ lldb::OptionValueSP ReadArray(FILE *in_file, Stream *out_stream,
+ OptionValue::Type data_type);
+
+ lldb::OptionValueSP ReadDictionary(FILE *in_file, Stream *out_stream);
+
+ bool DumpEmulation(const ArchSpec &arch);
+
+ virtual bool TestEmulation(Stream *stream, const char *test_file_name);
+
+ bool Emulate(const ArchSpec &arch, uint32_t evaluate_options, void *baton,
+ EmulateInstruction::ReadMemoryCallback read_mem_callback,
+ EmulateInstruction::WriteMemoryCallback write_mem_calback,
+ EmulateInstruction::ReadRegisterCallback read_reg_callback,
+ EmulateInstruction::WriteRegisterCallback write_reg_callback);
+
+ const Opcode &GetOpcode() const { return m_opcode; }
+
+ uint32_t GetData(DataExtractor &data);
+
+ struct Operand {
+ enum class Type {
+ Invalid = 0,
+ Register,
+ Immediate,
+ Dereference,
+ Sum,
+ Product
+ } m_type = Type::Invalid;
+ std::vector<Operand> m_children;
+ lldb::addr_t m_immediate = 0;
+ ConstString m_register;
+ bool m_negative = false;
+ bool m_clobbered = false;
+
+ bool IsValid() { return m_type != Type::Invalid; }
+ };
+
+ virtual bool ParseOperands(llvm::SmallVectorImpl<Operand> &operands) {
+ return false;
+ }
- //------------------------------------------------------------------
- /// Dump the text representation of this Instruction to a Stream
- ///
- /// Print the (optional) address, (optional) bytes, opcode,
- /// operands, and instruction comments to a stream.
- ///
- /// @param[in] s
- /// The Stream to add the text to.
- ///
- /// @param[in] show_address
- /// Whether the address (using disassembly_addr_format_spec formatting)
- /// should be printed.
- ///
- /// @param[in] show_bytes
- /// Whether the bytes of the assembly instruction should be printed.
- ///
- /// @param[in] max_opcode_byte_size
- /// The size (in bytes) of the largest instruction in the list that
- /// we are printing (for text justification/alignment purposes)
- /// Only needed if show_bytes is true.
- ///
- /// @param[in] exe_ctx
- /// The current execution context, if available. May be used in
- /// the assembling of the operands+comments for this instruction.
- /// Pass NULL if not applicable.
- ///
- /// @param[in] sym_ctx
- /// The SymbolContext for this instruction.
- /// Pass NULL if not available/computed.
- /// Only needed if show_address is true.
- ///
- /// @param[in] prev_sym_ctx
- /// The SymbolContext for the previous instruction. Depending on
- /// the disassembly address format specification, a change in
- /// Symbol / Function may mean that a line is printed with the new
- /// symbol/function name.
- /// Pass NULL if unavailable, or if this is the first instruction of
- /// the InstructionList.
- /// Only needed if show_address is true.
- ///
- /// @param[in] disassembly_addr_format
- /// The format specification for how addresses are printed.
- /// Only needed if show_address is true.
- ///
- /// @param[in] max_address_text_size
- /// The length of the longest address string at the start of the
- /// disassembly line that will be printed (the Debugger::FormatDisassemblerAddress() string)
- /// so this method can properly align the instruction opcodes.
- /// May be 0 to indicate no indentation/alignment of the opcodes.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx,
- const SymbolContext *sym_ctx,
- const SymbolContext *prev_sym_ctx,
- const FormatEntity::Entry *disassembly_addr_format,
- size_t max_address_text_size);
-
- virtual bool
- DoesBranch () = 0;
-
- virtual bool
- HasDelaySlot ();
-
- virtual size_t
- Decode (const Disassembler &disassembler,
- const DataExtractor& data,
- lldb::offset_t data_offset) = 0;
-
- virtual void
- SetDescription (const char *) {} // May be overridden in sub-classes that have descriptions.
-
- lldb::OptionValueSP
- ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type data_type);
-
- lldb::OptionValueSP
- ReadDictionary (FILE *in_file, Stream *out_stream);
-
- bool
- DumpEmulation (const ArchSpec &arch);
-
- virtual bool
- TestEmulation (Stream *stream, const char *test_file_name);
-
- bool
- Emulate (const ArchSpec &arch,
- uint32_t evaluate_options,
- void *baton,
- EmulateInstruction::ReadMemoryCallback read_mem_callback,
- EmulateInstruction::WriteMemoryCallback write_mem_calback,
- EmulateInstruction::ReadRegisterCallback read_reg_callback,
- EmulateInstruction::WriteRegisterCallback write_reg_callback);
-
- const Opcode &
- GetOpcode () const
- {
- return m_opcode;
- }
-
- uint32_t
- GetData (DataExtractor &data);
-
- struct Operand
- {
- enum class Type {
- Invalid = 0,
- Register,
- Immediate,
- Dereference,
- Sum,
- Product
- } m_type = Type::Invalid;
- std::vector<Operand> m_children;
- lldb::addr_t m_immediate = 0;
- ConstString m_register;
- bool m_negative = false;
- bool m_clobbered = false;
-
- bool IsValid() { return m_type != Type::Invalid; }
- };
-
- virtual bool
- ParseOperands (llvm::SmallVectorImpl<Operand> &operands)
- {
- return false;
- }
-
- virtual bool
- IsCall ()
- {
- return false;
- }
+ virtual bool IsCall() { return false; }
protected:
- Address m_address; // The section offset address of this instruction
- // We include an address class in the Instruction class to
- // allow the instruction specify the eAddressClassCodeAlternateISA
- // (currently used for thumb), and also to specify data (eAddressClassData).
- // The usual value will be eAddressClassCode, but often when
- // disassembling memory, you might run into data. This can
- // help us to disassemble appropriately.
+ Address m_address; // The section offset address of this instruction
+ // We include an address class in the Instruction class to
+ // allow the instruction specify the eAddressClassCodeAlternateISA
+ // (currently used for thumb), and also to specify data (eAddressClassData).
+ // The usual value will be eAddressClassCode, but often when
+ // disassembling memory, you might run into data. This can
+ // help us to disassemble appropriately.
private:
- lldb::AddressClass m_address_class; // Use GetAddressClass () accessor function!
+ lldb::AddressClass
+ m_address_class; // Use GetAddressClass () accessor function!
protected:
- Opcode m_opcode; // The opcode for this instruction
- std::string m_opcode_name;
- std::string m_mnemonics;
- std::string m_comment;
- bool m_calculated_strings;
-
- void
- CalculateMnemonicOperandsAndCommentIfNeeded (const ExecutionContext* exe_ctx)
- {
- if (!m_calculated_strings)
- {
- m_calculated_strings = true;
- CalculateMnemonicOperandsAndComment(exe_ctx);
- }
+ Opcode m_opcode; // The opcode for this instruction
+ std::string m_opcode_name;
+ std::string m_mnemonics;
+ std::string m_comment;
+ bool m_calculated_strings;
+
+ void
+ CalculateMnemonicOperandsAndCommentIfNeeded(const ExecutionContext *exe_ctx) {
+ if (!m_calculated_strings) {
+ m_calculated_strings = true;
+ CalculateMnemonicOperandsAndComment(exe_ctx);
}
+ }
};
-class InstructionList
-{
+class InstructionList {
public:
- InstructionList();
- ~InstructionList();
+ InstructionList();
+ ~InstructionList();
+
+ size_t GetSize() const;
+
+ uint32_t GetMaxOpcocdeByteSize() const;
+
+ lldb::InstructionSP GetInstructionAtIndex(size_t idx) const;
+
+ uint32_t GetIndexOfNextBranchInstruction(uint32_t start,
+ Target &target) const;
+
+ uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr,
+ Target &target);
- size_t
- GetSize() const;
-
- uint32_t
- GetMaxOpcocdeByteSize () const;
-
- lldb::InstructionSP
- GetInstructionAtIndex (size_t idx) const;
-
- uint32_t
- GetIndexOfNextBranchInstruction(uint32_t start, Target &target) const;
-
- uint32_t
- GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target);
-
- uint32_t
- GetIndexOfInstructionAtAddress (const Address &addr);
-
- void
- Clear();
-
- void
- Append (lldb::InstructionSP &inst_sp);
-
- void
- Dump (Stream *s,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx);
+ uint32_t GetIndexOfInstructionAtAddress(const Address &addr);
+
+ void Clear();
+
+ void Append(lldb::InstructionSP &inst_sp);
+
+ void Dump(Stream *s, bool show_address, bool show_bytes,
+ const ExecutionContext *exe_ctx);
private:
- typedef std::vector<lldb::InstructionSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::vector<lldb::InstructionSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- collection m_instructions;
+ collection m_instructions;
};
-class PseudoInstruction :
- public Instruction
-{
+class PseudoInstruction : public Instruction {
public:
+ PseudoInstruction();
+
+ ~PseudoInstruction() override;
+
+ bool DoesBranch() override;
+
+ bool HasDelaySlot() override;
+
+ void CalculateMnemonicOperandsAndComment(
+ const ExecutionContext *exe_ctx) override {
+ // TODO: fill this in and put opcode name into Instruction::m_opcode_name,
+ // mnemonic into Instruction::m_mnemonics, and any comment into
+ // Instruction::m_comment
+ }
+
+ size_t Decode(const Disassembler &disassembler, const DataExtractor &data,
+ lldb::offset_t data_offset) override;
+
+ void SetOpcode(size_t opcode_size, void *opcode_data);
+
+ void SetDescription(const char *description) override;
- PseudoInstruction ();
-
- ~PseudoInstruction() override;
-
- bool
- DoesBranch() override;
-
- bool
- HasDelaySlot() override;
-
- void
- CalculateMnemonicOperandsAndComment(const ExecutionContext* exe_ctx) override
- {
- // TODO: fill this in and put opcode name into Instruction::m_opcode_name,
- // mnemonic into Instruction::m_mnemonics, and any comment into
- // Instruction::m_comment
- }
-
- size_t
- Decode(const Disassembler &disassembler,
- const DataExtractor &data,
- lldb::offset_t data_offset) override;
-
- void
- SetOpcode (size_t opcode_size, void *opcode_data);
-
- void
- SetDescription(const char *description) override;
-
protected:
- std::string m_description;
-
- DISALLOW_COPY_AND_ASSIGN (PseudoInstruction);
+ std::string m_description;
+
+ DISALLOW_COPY_AND_ASSIGN(PseudoInstruction);
};
-class Disassembler :
- public std::enable_shared_from_this<Disassembler>,
- public PluginInterface
-{
+class Disassembler : public std::enable_shared_from_this<Disassembler>,
+ public PluginInterface {
public:
+ enum {
+ eOptionNone = 0u,
+ eOptionShowBytes = (1u << 0),
+ eOptionRawOuput = (1u << 1),
+ eOptionMarkPCSourceLine = (1u << 2), // Mark the source line that contains
+ // the current PC (mixed mode only)
+ eOptionMarkPCAddress =
+ (1u << 3) // Mark the disassembly line the contains the PC
+ };
+
+ enum HexImmediateStyle {
+ eHexStyleC,
+ eHexStyleAsm,
+ };
+
+ // FindPlugin should be lax about the flavor string (it is too annoying to
+ // have various internal uses of the
+ // disassembler fail because the global flavor string gets set wrong.
+ // Instead, if you get a flavor string you
+ // don't understand, use the default. Folks who care to check can use the
+ // FlavorValidForArchSpec method on the
+ // disassembler they got back.
+ static lldb::DisassemblerSP
+ FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name);
+
+ // This version will use the value in the Target settings if flavor is NULL;
+ static lldb::DisassemblerSP
+ FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch,
+ const char *flavor, const char *plugin_name);
+
+ static lldb::DisassemblerSP
+ DisassembleRange(const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ const AddressRange &disasm_range, bool prefer_file_cache);
+
+ static lldb::DisassemblerSP
+ DisassembleBytes(const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const Address &start, const void *bytes,
+ size_t length, uint32_t max_num_instructions,
+ bool data_from_file);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const AddressRange &range, uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx, const Address &start,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ static size_t
+ Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx,
+ SymbolContextList &sc_list, uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options, Stream &strm);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const ConstString &name, Module *module,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
+ const char *plugin_name, const char *flavor,
+ const ExecutionContext &exe_ctx,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Disassembler(const ArchSpec &arch, const char *flavor);
+ ~Disassembler() override;
+
+ typedef const char *(*SummaryCallback)(const Instruction &inst,
+ ExecutionContext *exe_context,
+ void *user_data);
+
+ static bool PrintInstructions(Disassembler *disasm_ptr, Debugger &debugger,
+ const ArchSpec &arch,
+ const ExecutionContext &exe_ctx,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options, Stream &strm);
+
+ size_t ParseInstructions(const ExecutionContext *exe_ctx,
+ const AddressRange &range, Stream *error_strm_ptr,
+ bool prefer_file_cache);
+
+ size_t ParseInstructions(const ExecutionContext *exe_ctx,
+ const Address &range, uint32_t num_instructions,
+ bool prefer_file_cache);
+
+ virtual size_t DecodeInstructions(const Address &base_addr,
+ const DataExtractor &data,
+ lldb::offset_t data_offset,
+ size_t num_instructions, bool append,
+ bool data_from_file) = 0;
+
+ InstructionList &GetInstructionList();
- enum
- {
- eOptionNone = 0u,
- eOptionShowBytes = (1u << 0),
- eOptionRawOuput = (1u << 1),
- eOptionMarkPCSourceLine = (1u << 2), // Mark the source line that contains the current PC (mixed mode only)
- eOptionMarkPCAddress = (1u << 3) // Mark the disassembly line the contains the PC
- };
-
- enum HexImmediateStyle
- {
- eHexStyleC,
- eHexStyleAsm,
- };
-
- // FindPlugin should be lax about the flavor string (it is too annoying to have various internal uses of the
- // disassembler fail because the global flavor string gets set wrong. Instead, if you get a flavor string you
- // don't understand, use the default. Folks who care to check can use the FlavorValidForArchSpec method on the
- // disassembler they got back.
- static lldb::DisassemblerSP
- FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name);
-
- // This version will use the value in the Target settings if flavor is NULL;
- static lldb::DisassemblerSP
- FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name);
-
- static lldb::DisassemblerSP
- DisassembleRange (const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &disasm_range,
- bool prefer_file_cache);
-
- static lldb::DisassemblerSP
- DisassembleBytes (const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const Address &start,
- const void *bytes,
- size_t length,
- uint32_t max_num_instructions,
- bool data_from_file);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &range,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const Address &start,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static size_t
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- SymbolContextList &sc_list,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const ConstString &name,
- Module *module,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- static bool
- Disassemble (Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Disassembler(const ArchSpec &arch, const char *flavor);
- ~Disassembler() override;
-
- typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data);
-
- static bool
- PrintInstructions (Disassembler *disasm_ptr,
- Debugger &debugger,
- const ArchSpec &arch,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm);
-
- size_t
- ParseInstructions (const ExecutionContext *exe_ctx,
- const AddressRange &range,
- Stream *error_strm_ptr,
- bool prefer_file_cache);
-
- size_t
- ParseInstructions (const ExecutionContext *exe_ctx,
- const Address &range,
- uint32_t num_instructions,
- bool prefer_file_cache);
-
- virtual size_t
- DecodeInstructions (const Address &base_addr,
- const DataExtractor& data,
- lldb::offset_t data_offset,
- size_t num_instructions,
- bool append,
- bool data_from_file) = 0;
-
- InstructionList &
- GetInstructionList ();
-
- const InstructionList &
- GetInstructionList () const;
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
-
- const char *
- GetFlavor () const
- {
- return m_flavor.c_str();
- }
-
- virtual bool
- FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor) = 0;
+ const InstructionList &GetInstructionList() const;
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ const char *GetFlavor() const { return m_flavor.c_str(); }
+
+ virtual bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch,
+ const char *flavor) = 0;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from Disassembler can see and modify these
- //------------------------------------------------------------------
- ArchSpec m_arch;
- InstructionList m_instruction_list;
- lldb::addr_t m_base_addr;
- std::string m_flavor;
+ //------------------------------------------------------------------
+ // Classes that inherit from Disassembler can see and modify these
+ //------------------------------------------------------------------
+ ArchSpec m_arch;
+ InstructionList m_instruction_list;
+ lldb::addr_t m_base_addr;
+ std::string m_flavor;
private:
- //------------------------------------------------------------------
- // For Disassembler only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Disassembler);
+ //------------------------------------------------------------------
+ // For Disassembler only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Disassembler);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original)
+++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Sep 6 15:57:50 2016
@@ -12,24 +12,25 @@
#include <string>
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-public.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/Opcode.h"
+#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h"
+/// @class EmulateInstruction EmulateInstruction.h
+/// "lldb/Core/EmulateInstruction.h"
/// @brief A class that allows emulation of CPU opcodes.
///
-/// This class is a plug-in interface that is accessed through the
+/// This class is a plug-in interface that is accessed through the
/// standard static FindPlugin function call in the EmulateInstruction
/// class. The FindPlugin takes a target triple and returns a new object
/// if there is a plug-in that supports the architecture and OS. Four
-/// callbacks and a baton are provided. The four callbacks are read
+/// callbacks and a baton are provided. The four callbacks are read
/// register, write register, read memory and write memory.
///
/// This class is currently designed for these main use cases:
@@ -38,13 +39,13 @@ namespace lldb_private {
/// - Emulating instructions for breakpoint traps
///
/// Objects can be asked to read an instruction which will cause a call
-/// to the read register callback to get the PC, followed by a read
-/// memory call to read the opcode. If ReadInstruction () returns true,
-/// then a call to EmulateInstruction::EvaluateInstruction () can be
+/// to the read register callback to get the PC, followed by a read
+/// memory call to read the opcode. If ReadInstruction () returns true,
+/// then a call to EmulateInstruction::EvaluateInstruction () can be
/// made. At this point the EmulateInstruction subclass will use all of
/// the callbacks to emulate an instruction.
///
-/// Clients that provide the callbacks can either do the read/write
+/// Clients that provide the callbacks can either do the read/write
/// registers/memory to actually emulate the instruction on a real or
/// virtual CPU, or watch for the EmulateInstruction::Context which
/// is context for the read/write register/memory which explains why
@@ -54,15 +55,15 @@ namespace lldb_private {
/// CFI information from assembly code without having to actually do
/// the read/write register/memory.
///
-/// Clients must be prepared that not all instructions for an
-/// Instruction Set Architecture (ISA) will be emulated.
+/// Clients must be prepared that not all instructions for an
+/// Instruction Set Architecture (ISA) will be emulated.
///
/// Subclasses at the very least should implement the instructions that
/// save and restore registers onto the stack and adjustment to the stack
/// pointer. By just implementing a few instructions for an ISA that are
-/// the typical prologue opcodes, you can then generate CFI using a
+/// the typical prologue opcodes, you can then generate CFI using a
/// class that will soon be available.
-///
+///
/// Implementing all of the instructions that affect the PC can then
/// allow single step prediction support.
///
@@ -73,571 +74,431 @@ namespace lldb_private {
/// hitting software breakpoints we must disable the breakpoint by
/// restoring the original breakpoint opcode, single stepping and
/// restoring the breakpoint trap. If all threads were allowed to run
-/// then other threads could miss the breakpoint.
+/// then other threads could miss the breakpoint.
///
-/// This class centralizes the code that usually is done in separate
+/// This class centralizes the code that usually is done in separate
/// code paths in a debugger (single step prediction, finding save
/// restore locations of registers for unwinding stack frame variables)
/// and emulating the instruction is just a bonus.
//----------------------------------------------------------------------
-class EmulateInstruction :
- public PluginInterface
-{
+class EmulateInstruction : public PluginInterface {
public:
+ static EmulateInstruction *FindPlugin(const ArchSpec &arch,
+ InstructionType supported_inst_type,
+ const char *plugin_name);
+
+ enum ContextType {
+ eContextInvalid = 0,
+ // Read an instruction opcode from memory
+ eContextReadOpcode,
+
+ // Usually used for writing a register value whose source value is an
+ // immediate
+ eContextImmediate,
+
+ // Exclusively used when saving a register to the stack as part of the
+ // prologue
+ eContextPushRegisterOnStack,
+
+ // Exclusively used when restoring a register off the stack as part of
+ // the epilogue
+ eContextPopRegisterOffStack,
+
+ // Add or subtract a value from the stack
+ eContextAdjustStackPointer,
+
+ // Adjust the frame pointer for the current frame
+ eContextSetFramePointer,
+
+ // Add or subtract a value from a base address register (other than SP)
+ eContextAdjustBaseRegister,
+
+ // Add or subtract a value from the PC or store a value to the PC.
+ eContextAdjustPC,
+
+ // Used in WriteRegister callbacks to indicate where the
+ eContextRegisterPlusOffset,
+
+ // Used in WriteMemory callback to indicate where the data came from
+ eContextRegisterStore,
+
+ eContextRegisterLoad,
+
+ // Used when performing a PC-relative branch where the
+ eContextRelativeBranchImmediate,
+
+ // Used when performing an absolute branch where the
+ eContextAbsoluteBranchRegister,
+
+ // Used when performing a supervisor call to an operating system to
+ // provide a service:
+ eContextSupervisorCall,
+
+ // Used when performing a MemU operation to read the PC-relative offset
+ // from an address.
+ eContextTableBranchReadMemory,
+
+ // Used when random bits are written into a register
+ eContextWriteRegisterRandomBits,
+
+ // Used when random bits are written to memory
+ eContextWriteMemoryRandomBits,
+
+ eContextArithmetic,
+
+ eContextAdvancePC,
+
+ eContextReturnFromException
+ };
+
+ enum InfoType {
+ eInfoTypeRegisterPlusOffset,
+ eInfoTypeRegisterPlusIndirectOffset,
+ eInfoTypeRegisterToRegisterPlusOffset,
+ eInfoTypeRegisterToRegisterPlusIndirectOffset,
+ eInfoTypeRegisterRegisterOperands,
+ eInfoTypeOffset,
+ eInfoTypeRegister,
+ eInfoTypeImmediate,
+ eInfoTypeImmediateSigned,
+ eInfoTypeAddress,
+ eInfoTypeISAAndImmediate,
+ eInfoTypeISAAndImmediateSigned,
+ eInfoTypeISA,
+ eInfoTypeNoArgs
+ } InfoType;
+
+ struct Context {
+ ContextType type;
+ enum InfoType info_type;
+ union {
+ struct RegisterPlusOffset {
+ RegisterInfo reg; // base register
+ int64_t signed_offset; // signed offset added to base register
+ } RegisterPlusOffset;
+
+ struct RegisterPlusIndirectOffset {
+ RegisterInfo base_reg; // base register number
+ RegisterInfo offset_reg; // offset register kind
+ } RegisterPlusIndirectOffset;
+
+ struct RegisterToRegisterPlusOffset {
+ RegisterInfo data_reg; // source/target register for data
+ RegisterInfo base_reg; // base register for address calculation
+ int64_t offset; // offset for address calculation
+ } RegisterToRegisterPlusOffset;
+
+ struct RegisterToRegisterPlusIndirectOffset {
+ RegisterInfo base_reg; // base register for address calculation
+ RegisterInfo offset_reg; // offset register for address calculation
+ RegisterInfo data_reg; // source/target register for data
+ } RegisterToRegisterPlusIndirectOffset;
+
+ struct RegisterRegisterOperands {
+ RegisterInfo
+ operand1; // register containing first operand for binary op
+ RegisterInfo
+ operand2; // register containing second operand for binary op
+ } RegisterRegisterOperands;
+
+ int64_t signed_offset; // signed offset by which to adjust self (for
+ // registers only)
+
+ RegisterInfo reg; // plain register
+
+ uint64_t unsigned_immediate; // unsigned immediate value
+ int64_t signed_immediate; // signed immediate value
+
+ lldb::addr_t address; // direct address
+
+ struct ISAAndImmediate {
+ uint32_t isa;
+ uint32_t unsigned_data32; // immediate data
+ } ISAAndImmediate;
+
+ struct ISAAndImmediateSigned {
+ uint32_t isa;
+ int32_t signed_data32; // signed immediate data
+ } ISAAndImmediateSigned;
+
+ uint32_t isa;
+ } info;
+
+ Context() : type(eContextInvalid), info_type(eInfoTypeNoArgs) {}
+
+ void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset) {
+ info_type = eInfoTypeRegisterPlusOffset;
+ info.RegisterPlusOffset.reg = base_reg;
+ info.RegisterPlusOffset.signed_offset = signed_offset;
+ }
- static EmulateInstruction*
- FindPlugin (const ArchSpec &arch,
- InstructionType supported_inst_type,
- const char *plugin_name);
-
- enum ContextType
- {
- eContextInvalid = 0,
- // Read an instruction opcode from memory
- eContextReadOpcode,
-
- // Usually used for writing a register value whose source value is an
- // immediate
- eContextImmediate,
-
- // Exclusively used when saving a register to the stack as part of the
- // prologue
- eContextPushRegisterOnStack,
-
- // Exclusively used when restoring a register off the stack as part of
- // the epilogue
- eContextPopRegisterOffStack,
-
- // Add or subtract a value from the stack
- eContextAdjustStackPointer,
-
- // Adjust the frame pointer for the current frame
- eContextSetFramePointer,
-
- // Add or subtract a value from a base address register (other than SP)
- eContextAdjustBaseRegister,
-
- // Add or subtract a value from the PC or store a value to the PC.
- eContextAdjustPC,
-
- // Used in WriteRegister callbacks to indicate where the
- eContextRegisterPlusOffset,
-
- // Used in WriteMemory callback to indicate where the data came from
- eContextRegisterStore,
-
- eContextRegisterLoad,
-
- // Used when performing a PC-relative branch where the
- eContextRelativeBranchImmediate,
-
- // Used when performing an absolute branch where the
- eContextAbsoluteBranchRegister,
-
- // Used when performing a supervisor call to an operating system to
- // provide a service:
- eContextSupervisorCall,
-
- // Used when performing a MemU operation to read the PC-relative offset
- // from an address.
- eContextTableBranchReadMemory,
-
- // Used when random bits are written into a register
- eContextWriteRegisterRandomBits,
-
- // Used when random bits are written to memory
- eContextWriteMemoryRandomBits,
-
- eContextArithmetic,
-
- eContextAdvancePC,
-
- eContextReturnFromException
- };
-
- enum InfoType {
- eInfoTypeRegisterPlusOffset,
- eInfoTypeRegisterPlusIndirectOffset,
- eInfoTypeRegisterToRegisterPlusOffset,
- eInfoTypeRegisterToRegisterPlusIndirectOffset,
- eInfoTypeRegisterRegisterOperands,
- eInfoTypeOffset,
- eInfoTypeRegister,
- eInfoTypeImmediate,
- eInfoTypeImmediateSigned,
- eInfoTypeAddress,
- eInfoTypeISAAndImmediate,
- eInfoTypeISAAndImmediateSigned,
- eInfoTypeISA,
- eInfoTypeNoArgs
- } InfoType;
-
- struct Context
- {
- ContextType type;
- enum InfoType info_type;
- union
- {
- struct RegisterPlusOffset
- {
- RegisterInfo reg; // base register
- int64_t signed_offset; // signed offset added to base register
- } RegisterPlusOffset;
-
- struct RegisterPlusIndirectOffset
- {
- RegisterInfo base_reg; // base register number
- RegisterInfo offset_reg; // offset register kind
- } RegisterPlusIndirectOffset;
-
- struct RegisterToRegisterPlusOffset
- {
- RegisterInfo data_reg; // source/target register for data
- RegisterInfo base_reg; // base register for address calculation
- int64_t offset; // offset for address calculation
- } RegisterToRegisterPlusOffset;
-
- struct RegisterToRegisterPlusIndirectOffset
- {
- RegisterInfo base_reg; // base register for address calculation
- RegisterInfo offset_reg; // offset register for address calculation
- RegisterInfo data_reg; // source/target register for data
- } RegisterToRegisterPlusIndirectOffset;
-
- struct RegisterRegisterOperands
- {
- RegisterInfo operand1; // register containing first operand for binary op
- RegisterInfo operand2; // register containing second operand for binary op
- } RegisterRegisterOperands;
-
- int64_t signed_offset; // signed offset by which to adjust self (for registers only)
-
- RegisterInfo reg; // plain register
-
- uint64_t unsigned_immediate;// unsigned immediate value
- int64_t signed_immediate; // signed immediate value
-
- lldb::addr_t address; // direct address
-
- struct ISAAndImmediate
- {
- uint32_t isa;
- uint32_t unsigned_data32; // immediate data
- } ISAAndImmediate;
-
- struct ISAAndImmediateSigned
- {
- uint32_t isa;
- int32_t signed_data32; // signed immediate data
- } ISAAndImmediateSigned;
-
- uint32_t isa;
- } info;
-
- Context () :
- type (eContextInvalid),
- info_type (eInfoTypeNoArgs)
- {
- }
-
- void
- SetRegisterPlusOffset (RegisterInfo base_reg,
- int64_t signed_offset)
- {
- info_type = eInfoTypeRegisterPlusOffset;
- info.RegisterPlusOffset.reg = base_reg;
- info.RegisterPlusOffset.signed_offset = signed_offset;
- }
-
- void
- SetRegisterPlusIndirectOffset (RegisterInfo base_reg,
- RegisterInfo offset_reg)
- {
- info_type = eInfoTypeRegisterPlusIndirectOffset;
- info.RegisterPlusIndirectOffset.base_reg = base_reg;
- info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
- }
-
- void
- SetRegisterToRegisterPlusOffset (RegisterInfo data_reg,
+ void SetRegisterPlusIndirectOffset(RegisterInfo base_reg,
+ RegisterInfo offset_reg) {
+ info_type = eInfoTypeRegisterPlusIndirectOffset;
+ info.RegisterPlusIndirectOffset.base_reg = base_reg;
+ info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
+ }
+
+ void SetRegisterToRegisterPlusOffset(RegisterInfo data_reg,
RegisterInfo base_reg,
- int64_t offset)
- {
- info_type = eInfoTypeRegisterToRegisterPlusOffset;
- info.RegisterToRegisterPlusOffset.data_reg = data_reg;
- info.RegisterToRegisterPlusOffset.base_reg = base_reg;
- info.RegisterToRegisterPlusOffset.offset = offset;
- }
-
- void
- SetRegisterToRegisterPlusIndirectOffset (RegisterInfo base_reg,
+ int64_t offset) {
+ info_type = eInfoTypeRegisterToRegisterPlusOffset;
+ info.RegisterToRegisterPlusOffset.data_reg = data_reg;
+ info.RegisterToRegisterPlusOffset.base_reg = base_reg;
+ info.RegisterToRegisterPlusOffset.offset = offset;
+ }
+
+ void SetRegisterToRegisterPlusIndirectOffset(RegisterInfo base_reg,
RegisterInfo offset_reg,
- RegisterInfo data_reg)
- {
- info_type = eInfoTypeRegisterToRegisterPlusIndirectOffset;
- info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
- info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
- info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
- }
-
- void
- SetRegisterRegisterOperands (RegisterInfo op1_reg,
- RegisterInfo op2_reg)
- {
- info_type = eInfoTypeRegisterRegisterOperands;
- info.RegisterRegisterOperands.operand1 = op1_reg;
- info.RegisterRegisterOperands.operand2 = op2_reg;
- }
-
- void
- SetOffset (int64_t signed_offset)
- {
- info_type = eInfoTypeOffset;
- info.signed_offset = signed_offset;
- }
-
- void
- SetRegister (RegisterInfo reg)
- {
- info_type = eInfoTypeRegister;
- info.reg = reg;
- }
-
- void
- SetImmediate (uint64_t immediate)
- {
- info_type = eInfoTypeImmediate;
- info.unsigned_immediate = immediate;
- }
-
- void
- SetImmediateSigned (int64_t signed_immediate)
- {
- info_type = eInfoTypeImmediateSigned;
- info.signed_immediate = signed_immediate;
- }
-
- void
- SetAddress (lldb::addr_t address)
- {
- info_type = eInfoTypeAddress;
- info.address = address;
- }
- void
- SetISAAndImmediate (uint32_t isa, uint32_t data)
- {
- info_type = eInfoTypeISAAndImmediate;
- info.ISAAndImmediate.isa = isa;
- info.ISAAndImmediate.unsigned_data32 = data;
- }
-
- void
- SetISAAndImmediateSigned (uint32_t isa, int32_t data)
- {
- info_type = eInfoTypeISAAndImmediateSigned;
- info.ISAAndImmediateSigned.isa = isa;
- info.ISAAndImmediateSigned.signed_data32 = data;
- }
-
- void
- SetISA (uint32_t isa)
- {
- info_type = eInfoTypeISA;
- info.isa = isa;
- }
-
- void
- SetNoArgs ()
- {
- info_type = eInfoTypeNoArgs;
- }
-
- void
- Dump (Stream &s,
- EmulateInstruction *instruction) const;
-
- };
-
- typedef size_t (*ReadMemoryCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- typedef size_t (*WriteMemoryCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- typedef bool (*ReadRegisterCallback) (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue ®_value);
-
- typedef bool (*WriteRegisterCallback) (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue ®_value);
-
- // Type to represent the condition of an instruction. The UINT32 value is reserved for the
- // unconditional case and all other value can be used in an architecture dependent way.
- typedef uint32_t InstructionCondition;
- static const InstructionCondition UnconditionalCondition = UINT32_MAX;
-
- EmulateInstruction (const ArchSpec &arch);
-
- ~EmulateInstruction() override = default;
-
- //----------------------------------------------------------------------
- // Mandatory overrides
- //----------------------------------------------------------------------
- virtual bool
- SupportsEmulatingInstructionsOfType (InstructionType inst_type) = 0;
-
- virtual bool
- SetTargetTriple (const ArchSpec &arch) = 0;
-
- virtual bool
- ReadInstruction () = 0;
-
- virtual bool
- EvaluateInstruction (uint32_t evaluate_options) = 0;
-
- virtual InstructionCondition
- GetInstructionCondition() { return UnconditionalCondition; }
-
- virtual bool
- TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0;
-
- virtual bool
- GetRegisterInfo (lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo ®_info) = 0;
-
- //----------------------------------------------------------------------
- // Optional overrides
- //----------------------------------------------------------------------
- virtual bool
- SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target);
-
- virtual bool
- CreateFunctionEntryUnwind (UnwindPlan &unwind_plan);
-
- static const char *
- TranslateRegister (lldb::RegisterKind reg_kind, uint32_t reg_num, std::string ®_name);
-
- //----------------------------------------------------------------------
- // RegisterInfo variants
- //----------------------------------------------------------------------
- bool
- ReadRegister (const RegisterInfo *reg_info,
- RegisterValue& reg_value);
-
- uint64_t
- ReadRegisterUnsigned (const RegisterInfo *reg_info,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteRegister (const Context &context,
- const RegisterInfo *ref_info,
- const RegisterValue& reg_value);
-
- bool
- WriteRegisterUnsigned (const Context &context,
- const RegisterInfo *reg_info,
- uint64_t reg_value);
-
- //----------------------------------------------------------------------
- // Register kind and number variants
- //----------------------------------------------------------------------
- bool
- ReadRegister (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- RegisterValue& reg_value);
-
- bool
- WriteRegister (const Context &context,
- lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- const RegisterValue& reg_value);
-
- uint64_t
- ReadRegisterUnsigned (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteRegisterUnsigned (const Context &context,
- lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- uint64_t reg_value);
-
-
- size_t
- ReadMemory (const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t dst_len);
-
- uint64_t
- ReadMemoryUnsigned (const Context &context,
- lldb::addr_t addr,
- size_t byte_size,
- uint64_t fail_value,
- bool *success_ptr);
-
- bool
- WriteMemory (const Context &context,
- lldb::addr_t addr,
- const void *src,
- size_t src_len);
-
- bool
- WriteMemoryUnsigned (const Context &context,
- lldb::addr_t addr,
- uint64_t uval,
- size_t uval_byte_size);
-
- uint32_t
- GetAddressByteSize () const
- {
- return m_arch.GetAddressByteSize();
- }
-
- lldb::ByteOrder
- GetByteOrder () const
- {
- return m_arch.GetByteOrder();
- }
-
- const Opcode &
- GetOpcode () const
- {
- return m_opcode;
- }
-
- lldb::addr_t
- GetAddress () const
- {
- return m_addr;
- }
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
-
- static size_t
- ReadMemoryFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- static size_t
- WriteMemoryFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- static bool
- ReadRegisterFrame (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue ®_value);
-
-
- static bool
- WriteRegisterFrame (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue ®_value);
-
- static size_t
- ReadMemoryDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- static size_t
- WriteMemoryDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- static bool
- ReadRegisterDefault (EmulateInstruction *instruction,
- void *baton,
- const RegisterInfo *reg_info,
- RegisterValue ®_value);
-
-
- static bool
- WriteRegisterDefault (EmulateInstruction *instruction,
- void *baton,
- const Context &context,
- const RegisterInfo *reg_info,
- const RegisterValue ®_value);
-
- void
- SetBaton (void *baton);
-
- void
- SetCallbacks (ReadMemoryCallback read_mem_callback,
- WriteMemoryCallback write_mem_callback,
- ReadRegisterCallback read_reg_callback,
- WriteRegisterCallback write_reg_callback);
-
- void
- SetReadMemCallback (ReadMemoryCallback read_mem_callback);
-
- void
- SetWriteMemCallback (WriteMemoryCallback write_mem_callback);
-
- void
- SetReadRegCallback (ReadRegisterCallback read_reg_callback);
-
- void
- SetWriteRegCallback (WriteRegisterCallback write_reg_callback);
-
- static bool
- GetBestRegisterKindAndNumber (const RegisterInfo *reg_info,
- lldb::RegisterKind ®_kind,
- uint32_t ®_num);
-
- static uint32_t
- GetInternalRegisterNumber (RegisterContext *reg_ctx,
- const RegisterInfo ®_info);
+ RegisterInfo data_reg) {
+ info_type = eInfoTypeRegisterToRegisterPlusIndirectOffset;
+ info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
+ info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
+ info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
+ }
+
+ void SetRegisterRegisterOperands(RegisterInfo op1_reg,
+ RegisterInfo op2_reg) {
+ info_type = eInfoTypeRegisterRegisterOperands;
+ info.RegisterRegisterOperands.operand1 = op1_reg;
+ info.RegisterRegisterOperands.operand2 = op2_reg;
+ }
+
+ void SetOffset(int64_t signed_offset) {
+ info_type = eInfoTypeOffset;
+ info.signed_offset = signed_offset;
+ }
+
+ void SetRegister(RegisterInfo reg) {
+ info_type = eInfoTypeRegister;
+ info.reg = reg;
+ }
+
+ void SetImmediate(uint64_t immediate) {
+ info_type = eInfoTypeImmediate;
+ info.unsigned_immediate = immediate;
+ }
+
+ void SetImmediateSigned(int64_t signed_immediate) {
+ info_type = eInfoTypeImmediateSigned;
+ info.signed_immediate = signed_immediate;
+ }
+
+ void SetAddress(lldb::addr_t address) {
+ info_type = eInfoTypeAddress;
+ info.address = address;
+ }
+ void SetISAAndImmediate(uint32_t isa, uint32_t data) {
+ info_type = eInfoTypeISAAndImmediate;
+ info.ISAAndImmediate.isa = isa;
+ info.ISAAndImmediate.unsigned_data32 = data;
+ }
+
+ void SetISAAndImmediateSigned(uint32_t isa, int32_t data) {
+ info_type = eInfoTypeISAAndImmediateSigned;
+ info.ISAAndImmediateSigned.isa = isa;
+ info.ISAAndImmediateSigned.signed_data32 = data;
+ }
+
+ void SetISA(uint32_t isa) {
+ info_type = eInfoTypeISA;
+ info.isa = isa;
+ }
+
+ void SetNoArgs() { info_type = eInfoTypeNoArgs; }
+
+ void Dump(Stream &s, EmulateInstruction *instruction) const;
+ };
+
+ typedef size_t (*ReadMemoryCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ lldb::addr_t addr, void *dst,
+ size_t length);
+
+ typedef size_t (*WriteMemoryCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ lldb::addr_t addr, const void *dst,
+ size_t length);
+
+ typedef bool (*ReadRegisterCallback)(EmulateInstruction *instruction,
+ void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue ®_value);
+
+ typedef bool (*WriteRegisterCallback)(EmulateInstruction *instruction,
+ void *baton, const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue ®_value);
+
+ // Type to represent the condition of an instruction. The UINT32 value is
+ // reserved for the
+ // unconditional case and all other value can be used in an architecture
+ // dependent way.
+ typedef uint32_t InstructionCondition;
+ static const InstructionCondition UnconditionalCondition = UINT32_MAX;
+
+ EmulateInstruction(const ArchSpec &arch);
+
+ ~EmulateInstruction() override = default;
+
+ //----------------------------------------------------------------------
+ // Mandatory overrides
+ //----------------------------------------------------------------------
+ virtual bool
+ SupportsEmulatingInstructionsOfType(InstructionType inst_type) = 0;
+
+ virtual bool SetTargetTriple(const ArchSpec &arch) = 0;
+
+ virtual bool ReadInstruction() = 0;
+
+ virtual bool EvaluateInstruction(uint32_t evaluate_options) = 0;
+
+ virtual InstructionCondition GetInstructionCondition() {
+ return UnconditionalCondition;
+ }
+
+ virtual bool TestEmulation(Stream *out_stream, ArchSpec &arch,
+ OptionValueDictionary *test_data) = 0;
+
+ virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ RegisterInfo ®_info) = 0;
+
+ //----------------------------------------------------------------------
+ // Optional overrides
+ //----------------------------------------------------------------------
+ virtual bool SetInstruction(const Opcode &insn_opcode,
+ const Address &inst_addr, Target *target);
+
+ virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan);
+
+ static const char *TranslateRegister(lldb::RegisterKind reg_kind,
+ uint32_t reg_num, std::string ®_name);
+
+ //----------------------------------------------------------------------
+ // RegisterInfo variants
+ //----------------------------------------------------------------------
+ bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value);
+
+ uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info,
+ uint64_t fail_value, bool *success_ptr);
+
+ bool WriteRegister(const Context &context, const RegisterInfo *ref_info,
+ const RegisterValue ®_value);
+
+ bool WriteRegisterUnsigned(const Context &context,
+ const RegisterInfo *reg_info, uint64_t reg_value);
+
+ //----------------------------------------------------------------------
+ // Register kind and number variants
+ //----------------------------------------------------------------------
+ bool ReadRegister(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ RegisterValue ®_value);
+
+ bool WriteRegister(const Context &context, lldb::RegisterKind reg_kind,
+ uint32_t reg_num, const RegisterValue ®_value);
+
+ uint64_t ReadRegisterUnsigned(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ uint64_t fail_value, bool *success_ptr);
+
+ bool WriteRegisterUnsigned(const Context &context,
+ lldb::RegisterKind reg_kind, uint32_t reg_num,
+ uint64_t reg_value);
+
+ size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst,
+ size_t dst_len);
+
+ uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr,
+ size_t byte_size, uint64_t fail_value,
+ bool *success_ptr);
+
+ bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src,
+ size_t src_len);
+
+ bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr,
+ uint64_t uval, size_t uval_byte_size);
+
+ uint32_t GetAddressByteSize() const { return m_arch.GetAddressByteSize(); }
+
+ lldb::ByteOrder GetByteOrder() const { return m_arch.GetByteOrder(); }
+
+ const Opcode &GetOpcode() const { return m_opcode; }
+
+ lldb::addr_t GetAddress() const { return m_addr; }
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ static size_t ReadMemoryFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ void *dst, size_t length);
+
+ static size_t WriteMemoryFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ const void *dst, size_t length);
+
+ static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue ®_value);
+
+ static bool WriteRegisterFrame(EmulateInstruction *instruction, void *baton,
+ const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue ®_value);
+
+ static size_t ReadMemoryDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ void *dst, size_t length);
+
+ static size_t WriteMemoryDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context, lldb::addr_t addr,
+ const void *dst, size_t length);
+
+ static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue ®_value);
+
+ static bool WriteRegisterDefault(EmulateInstruction *instruction, void *baton,
+ const Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue ®_value);
+
+ void SetBaton(void *baton);
+
+ void SetCallbacks(ReadMemoryCallback read_mem_callback,
+ WriteMemoryCallback write_mem_callback,
+ ReadRegisterCallback read_reg_callback,
+ WriteRegisterCallback write_reg_callback);
+
+ void SetReadMemCallback(ReadMemoryCallback read_mem_callback);
+
+ void SetWriteMemCallback(WriteMemoryCallback write_mem_callback);
+
+ void SetReadRegCallback(ReadRegisterCallback read_reg_callback);
+
+ void SetWriteRegCallback(WriteRegisterCallback write_reg_callback);
+
+ static bool GetBestRegisterKindAndNumber(const RegisterInfo *reg_info,
+ lldb::RegisterKind ®_kind,
+ uint32_t ®_num);
+
+ static uint32_t GetInternalRegisterNumber(RegisterContext *reg_ctx,
+ const RegisterInfo ®_info);
protected:
- ArchSpec m_arch;
- void * m_baton;
- ReadMemoryCallback m_read_mem_callback;
- WriteMemoryCallback m_write_mem_callback;
- ReadRegisterCallback m_read_reg_callback;
- WriteRegisterCallback m_write_reg_callback;
- lldb::addr_t m_addr;
- Opcode m_opcode;
-
+ ArchSpec m_arch;
+ void *m_baton;
+ ReadMemoryCallback m_read_mem_callback;
+ WriteMemoryCallback m_write_mem_callback;
+ ReadRegisterCallback m_read_reg_callback;
+ WriteRegisterCallback m_write_reg_callback;
+ lldb::addr_t m_addr;
+ Opcode m_opcode;
+
private:
- //------------------------------------------------------------------
- // For EmulateInstruction only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (EmulateInstruction);
+ //------------------------------------------------------------------
+ // For EmulateInstruction only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(EmulateInstruction);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Error.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Error.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Error.h (original)
+++ lldb/trunk/include/lldb/Core/Error.h Tue Sep 6 15:57:50 2016
@@ -43,276 +43,255 @@ class Log;
/// be cached until the error is cleared of the value of the error
/// changes.
//----------------------------------------------------------------------
-class Error
-{
+class Error {
public:
- //------------------------------------------------------------------
- /// Every error value that this object can contain needs to be able
- /// to fit into ValueType.
- //------------------------------------------------------------------
- typedef uint32_t ValueType;
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize the error object with a generic success value.
- ///
- /// @param[in] err
- /// An error code.
- ///
- /// @param[in] type
- /// The type for \a err.
- //------------------------------------------------------------------
- Error ();
-
- explicit
- Error (ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric);
-
- explicit
- Error (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- Error (const Error &rhs);
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] err
- /// An error code.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const Error&
- operator = (const Error& rhs);
-
-
- //------------------------------------------------------------------
- /// Assignment operator from a kern_return_t.
- ///
- /// Sets the type to \c MachKernel and the error code to \a err.
- ///
- /// @param[in] err
- /// A mach error code.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const Error&
- operator = (uint32_t err);
-
- ~Error();
-
- //------------------------------------------------------------------
- /// Get the error string associated with the current error.
- //
- /// Gets the error value as a NULL terminated C string. The error
- /// string will be fetched and cached on demand. The error string
- /// will be retrieved from a callback that is appropriate for the
- /// type of the error and will be cached until the error value is
- /// changed or cleared.
- ///
- /// @return
- /// The error as a NULL terminated C string value if the error
- /// is valid and is able to be converted to a string value,
- /// NULL otherwise.
- //------------------------------------------------------------------
- const char *
- AsCString (const char *default_error_str = "unknown error") const;
-
- //------------------------------------------------------------------
- /// Clear the object state.
- ///
- /// Reverts the state of this object to contain a generic success
- /// value and frees any cached error string value.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Test for error condition.
- ///
- /// @return
- /// \b true if this object contains an error, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool
- Fail () const;
-
- //------------------------------------------------------------------
- /// Access the error value.
- ///
- /// @return
- /// The error value.
- //------------------------------------------------------------------
- ValueType
- GetError () const;
-
- //------------------------------------------------------------------
- /// Access the error type.
- ///
- /// @return
- /// The error type enumeration value.
- //------------------------------------------------------------------
- lldb::ErrorType
- GetType () const;
-
- //------------------------------------------------------------------
- /// Log an error to Log().
- ///
- /// Log the error given a formatted string \a format. If the this
- /// object contains an error code, update the error string to
- /// contain the prefix "error: ", followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object. Logging always occurs
- /// even when the error code contains a non-error value.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void
- PutToLog (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- //------------------------------------------------------------------
- /// Log an error to Log() if the error value is an error.
- ///
- /// Log the error given a formatted string \a format only if the
- /// error value in this object describes an error condition. If the
- /// this object contains an error, update the error string to
- /// contain the prefix "error: " followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void
- LogIfError (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- //------------------------------------------------------------------
- /// Set accessor from a kern_return_t.
- ///
- /// Set accesssor for the error value to \a err and the error type
- /// to \c MachKernel.
- ///
- /// @param[in] err
- /// A mach error code.
- //------------------------------------------------------------------
- void
- SetMachError (uint32_t err);
-
-
- void
- SetExpressionError (lldb::ExpressionResults, const char *mssg);
-
- int
- SetExpressionErrorWithFormat (lldb::ExpressionResults, const char *format, ...) __attribute__ ((format (printf, 3,4)));
-
- //------------------------------------------------------------------
- /// Set accesssor with an error value and type.
- ///
- /// Set accesssor for the error value to \a err and the error type
- /// to \a type.
- ///
- /// @param[in] err
- /// A mach error code.
- ///
- /// @param[in] type
- /// The type for \a err.
- //------------------------------------------------------------------
- void
- SetError (ValueType err, lldb::ErrorType type);
-
- //------------------------------------------------------------------
- /// Set the current error to errno.
- ///
- /// Update the error value to be \c errno and update the type to
- /// be \c Error::POSIX.
- //------------------------------------------------------------------
- void
- SetErrorToErrno ();
-
- //------------------------------------------------------------------
- /// Set the current error to a generic error.
- ///
- /// Update the error value to be \c LLDB_GENERIC_ERROR and update the
- /// type to be \c Error::Generic.
- //------------------------------------------------------------------
- void
- SetErrorToGenericError ();
-
- //------------------------------------------------------------------
- /// Set the current error string to \a err_str.
- ///
- /// Set accessor for the error string value for a generic errors,
- /// or to supply additional details above and beyond the standard
- /// error strings that the standard type callbacks typically
- /// provide. This allows custom strings to be supplied as an
- /// error explanation. The error string value will remain until the
- /// error value is cleared or a new error value/type is assigned.
- ///
- /// @param err_str
- /// The new custom error string to copy and cache.
- //------------------------------------------------------------------
- void
- SetErrorString (const char *err_str);
-
- //------------------------------------------------------------------
- /// Set the current error string to a formatted error string.
- ///
- /// @param format
- /// A printf style format string
- //------------------------------------------------------------------
- int
- SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- int
- SetErrorStringWithVarArg (const char *format, va_list args);
-
- //------------------------------------------------------------------
- /// Test for success condition.
- ///
- /// Returns true if the error code in this object is considered a
- /// successful return value.
- ///
- /// @return
- /// \b true if this object contains an value that describes
- /// success (non-erro), \b false otherwise.
- //------------------------------------------------------------------
- bool
- Success () const;
-
- //------------------------------------------------------------------
- /// Test for a failure due to a generic interrupt.
- ///
- /// Returns true if the error code in this object was caused by an interrupt.
- /// At present only supports Posix EINTR.
- ///
- /// @return
- /// \b true if this object contains an value that describes
- /// failure due to interrupt, \b false otherwise.
- //------------------------------------------------------------------
- bool
- WasInterrupted() const;
+ //------------------------------------------------------------------
+ /// Every error value that this object can contain needs to be able
+ /// to fit into ValueType.
+ //------------------------------------------------------------------
+ typedef uint32_t ValueType;
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize the error object with a generic success value.
+ ///
+ /// @param[in] err
+ /// An error code.
+ ///
+ /// @param[in] type
+ /// The type for \a err.
+ //------------------------------------------------------------------
+ Error();
+
+ explicit Error(ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric);
+
+ explicit Error(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ Error(const Error &rhs);
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] err
+ /// An error code.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const Error &operator=(const Error &rhs);
+
+ //------------------------------------------------------------------
+ /// Assignment operator from a kern_return_t.
+ ///
+ /// Sets the type to \c MachKernel and the error code to \a err.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const Error &operator=(uint32_t err);
+
+ ~Error();
+
+ //------------------------------------------------------------------
+ /// Get the error string associated with the current error.
+ //
+ /// Gets the error value as a NULL terminated C string. The error
+ /// string will be fetched and cached on demand. The error string
+ /// will be retrieved from a callback that is appropriate for the
+ /// type of the error and will be cached until the error value is
+ /// changed or cleared.
+ ///
+ /// @return
+ /// The error as a NULL terminated C string value if the error
+ /// is valid and is able to be converted to a string value,
+ /// NULL otherwise.
+ //------------------------------------------------------------------
+ const char *AsCString(const char *default_error_str = "unknown error") const;
+
+ //------------------------------------------------------------------
+ /// Clear the object state.
+ ///
+ /// Reverts the state of this object to contain a generic success
+ /// value and frees any cached error string value.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Test for error condition.
+ ///
+ /// @return
+ /// \b true if this object contains an error, \b false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool Fail() const;
+
+ //------------------------------------------------------------------
+ /// Access the error value.
+ ///
+ /// @return
+ /// The error value.
+ //------------------------------------------------------------------
+ ValueType GetError() const;
+
+ //------------------------------------------------------------------
+ /// Access the error type.
+ ///
+ /// @return
+ /// The error type enumeration value.
+ //------------------------------------------------------------------
+ lldb::ErrorType GetType() const;
+
+ //------------------------------------------------------------------
+ /// Log an error to Log().
+ ///
+ /// Log the error given a formatted string \a format. If the this
+ /// object contains an error code, update the error string to
+ /// contain the prefix "error: ", followed by the formatted string,
+ /// followed by the error value and any string that describes the
+ /// error value. This allows more context to be given to an error
+ /// string that remains cached in this object. Logging always occurs
+ /// even when the error code contains a non-error value.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ void PutToLog(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Log an error to Log() if the error value is an error.
+ ///
+ /// Log the error given a formatted string \a format only if the
+ /// error value in this object describes an error condition. If the
+ /// this object contains an error, update the error string to
+ /// contain the prefix "error: " followed by the formatted string,
+ /// followed by the error value and any string that describes the
+ /// error value. This allows more context to be given to an error
+ /// string that remains cached in this object.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ void LogIfError(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Set accessor from a kern_return_t.
+ ///
+ /// Set accesssor for the error value to \a err and the error type
+ /// to \c MachKernel.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ //------------------------------------------------------------------
+ void SetMachError(uint32_t err);
+
+ void SetExpressionError(lldb::ExpressionResults, const char *mssg);
+
+ int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format,
+ ...) __attribute__((format(printf, 3, 4)));
+
+ //------------------------------------------------------------------
+ /// Set accesssor with an error value and type.
+ ///
+ /// Set accesssor for the error value to \a err and the error type
+ /// to \a type.
+ ///
+ /// @param[in] err
+ /// A mach error code.
+ ///
+ /// @param[in] type
+ /// The type for \a err.
+ //------------------------------------------------------------------
+ void SetError(ValueType err, lldb::ErrorType type);
+
+ //------------------------------------------------------------------
+ /// Set the current error to errno.
+ ///
+ /// Update the error value to be \c errno and update the type to
+ /// be \c Error::POSIX.
+ //------------------------------------------------------------------
+ void SetErrorToErrno();
+
+ //------------------------------------------------------------------
+ /// Set the current error to a generic error.
+ ///
+ /// Update the error value to be \c LLDB_GENERIC_ERROR and update the
+ /// type to be \c Error::Generic.
+ //------------------------------------------------------------------
+ void SetErrorToGenericError();
+
+ //------------------------------------------------------------------
+ /// Set the current error string to \a err_str.
+ ///
+ /// Set accessor for the error string value for a generic errors,
+ /// or to supply additional details above and beyond the standard
+ /// error strings that the standard type callbacks typically
+ /// provide. This allows custom strings to be supplied as an
+ /// error explanation. The error string value will remain until the
+ /// error value is cleared or a new error value/type is assigned.
+ ///
+ /// @param err_str
+ /// The new custom error string to copy and cache.
+ //------------------------------------------------------------------
+ void SetErrorString(const char *err_str);
+
+ //------------------------------------------------------------------
+ /// Set the current error string to a formatted error string.
+ ///
+ /// @param format
+ /// A printf style format string
+ //------------------------------------------------------------------
+ int SetErrorStringWithFormat(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ int SetErrorStringWithVarArg(const char *format, va_list args);
+
+ //------------------------------------------------------------------
+ /// Test for success condition.
+ ///
+ /// Returns true if the error code in this object is considered a
+ /// successful return value.
+ ///
+ /// @return
+ /// \b true if this object contains an value that describes
+ /// success (non-erro), \b false otherwise.
+ //------------------------------------------------------------------
+ bool Success() const;
+
+ //------------------------------------------------------------------
+ /// Test for a failure due to a generic interrupt.
+ ///
+ /// Returns true if the error code in this object was caused by an interrupt.
+ /// At present only supports Posix EINTR.
+ ///
+ /// @return
+ /// \b true if this object contains an value that describes
+ /// failure due to interrupt, \b false otherwise.
+ //------------------------------------------------------------------
+ bool WasInterrupted() const;
protected:
- //------------------------------------------------------------------
- /// Member variables
- //------------------------------------------------------------------
- ValueType m_code; ///< Error code as an integer value.
- lldb::ErrorType m_type; ///< The type of the above error code.
- mutable std::string m_string; ///< A string representation of the error code.
+ //------------------------------------------------------------------
+ /// Member variables
+ //------------------------------------------------------------------
+ ValueType m_code; ///< Error code as an integer value.
+ lldb::ErrorType m_type; ///< The type of the above error code.
+ mutable std::string m_string; ///< A string representation of the error code.
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // #ifndef __DCError_h__
+#endif // #if defined(__cplusplus)
+#endif // #ifndef __DCError_h__
Modified: lldb/trunk/include/lldb/Core/Event.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Event.h (original)
+++ lldb/trunk/include/lldb/Core/Event.h Tue Sep 6 15:57:50 2016
@@ -18,145 +18,110 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/Predicate.h"
-#include "lldb/Core/Broadcaster.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// lldb::EventData
//----------------------------------------------------------------------
-class EventData
-{
- friend class Event;
+class EventData {
+ friend class Event;
public:
- EventData ();
+ EventData();
- virtual
- ~EventData();
+ virtual ~EventData();
- virtual const ConstString &
- GetFlavor () const = 0;
+ virtual const ConstString &GetFlavor() const = 0;
- virtual void
- Dump (Stream *s) const;
+ virtual void Dump(Stream *s) const;
private:
- virtual void
- DoOnRemoval (Event *event_ptr)
- {
- }
+ virtual void DoOnRemoval(Event *event_ptr) {}
- DISALLOW_COPY_AND_ASSIGN (EventData);
+ DISALLOW_COPY_AND_ASSIGN(EventData);
};
//----------------------------------------------------------------------
// lldb::EventDataBytes
//----------------------------------------------------------------------
-class EventDataBytes : public EventData
-{
+class EventDataBytes : public EventData {
public:
- //------------------------------------------------------------------
- // Constructors
- //------------------------------------------------------------------
- EventDataBytes ();
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ EventDataBytes();
+
+ EventDataBytes(const char *cstr);
- EventDataBytes (const char *cstr);
+ EventDataBytes(const void *src, size_t src_len);
- EventDataBytes (const void *src, size_t src_len);
+ ~EventDataBytes() override;
- ~EventDataBytes() override;
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ const ConstString &GetFlavor() const override;
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- const ConstString &
- GetFlavor () const override;
+ void Dump(Stream *s) const override;
- void
- Dump (Stream *s) const override;
+ const void *GetBytes() const;
- const void *
- GetBytes() const;
+ size_t GetByteSize() const;
- size_t
- GetByteSize() const;
+ void SetBytes(const void *src, size_t src_len);
- void
- SetBytes (const void *src, size_t src_len);
-
- void
- SwapBytes (std::string &new_bytes);
+ void SwapBytes(std::string &new_bytes);
- void
- SetBytesFromCString (const char *cstr);
+ void SetBytesFromCString(const char *cstr);
- //------------------------------------------------------------------
- // Static functions
- //------------------------------------------------------------------
- static const EventDataBytes *
- GetEventDataFromEvent (const Event *event_ptr);
+ //------------------------------------------------------------------
+ // Static functions
+ //------------------------------------------------------------------
+ static const EventDataBytes *GetEventDataFromEvent(const Event *event_ptr);
- static const void *
- GetBytesFromEvent (const Event *event_ptr);
+ static const void *GetBytesFromEvent(const Event *event_ptr);
- static size_t
- GetByteSizeFromEvent (const Event *event_ptr);
+ static size_t GetByteSizeFromEvent(const Event *event_ptr);
- static const ConstString &
- GetFlavorString ();
+ static const ConstString &GetFlavorString();
private:
- std::string m_bytes;
+ std::string m_bytes;
- DISALLOW_COPY_AND_ASSIGN (EventDataBytes);
+ DISALLOW_COPY_AND_ASSIGN(EventDataBytes);
};
-class EventDataReceipt : public EventData
-{
+class EventDataReceipt : public EventData {
public:
- EventDataReceipt() :
- EventData(),
- m_predicate(false)
- {
- }
-
- ~EventDataReceipt() override
- {
- }
-
- static const ConstString &
- GetFlavorString ()
- {
- static ConstString g_flavor("Process::ProcessEventData");
- return g_flavor;
- }
-
- const ConstString &
- GetFlavor () const override
- {
- return GetFlavorString();
- }
-
- bool
- WaitForEventReceived(const std::chrono::microseconds &abstime = std::chrono::microseconds(0),
- bool *timed_out = nullptr)
- {
- return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
- }
+ EventDataReceipt() : EventData(), m_predicate(false) {}
+
+ ~EventDataReceipt() override {}
+
+ static const ConstString &GetFlavorString() {
+ static ConstString g_flavor("Process::ProcessEventData");
+ return g_flavor;
+ }
+
+ const ConstString &GetFlavor() const override { return GetFlavorString(); }
+
+ bool WaitForEventReceived(
+ const std::chrono::microseconds &abstime = std::chrono::microseconds(0),
+ bool *timed_out = nullptr) {
+ return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
+ }
private:
- Predicate<bool> m_predicate;
-
- void
- DoOnRemoval (Event *event_ptr) override
- {
- m_predicate.SetValue(true, eBroadcastAlways);
- }
+ Predicate<bool> m_predicate;
+
+ void DoOnRemoval(Event *event_ptr) override {
+ m_predicate.SetValue(true, eBroadcastAlways);
+ }
};
//----------------------------------------------------------------------
@@ -164,178 +129,135 @@ private:
/// that are raised for structured data events.
//----------------------------------------------------------------------
-class EventDataStructuredData : public EventData
-{
+class EventDataStructuredData : public EventData {
public:
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ EventDataStructuredData();
- //------------------------------------------------------------------
- // Constructors
- //------------------------------------------------------------------
- EventDataStructuredData();
+ EventDataStructuredData(const lldb::ProcessSP &process_sp,
+ const StructuredData::ObjectSP &object_sp,
+ const lldb::StructuredDataPluginSP &plugin_sp);
- EventDataStructuredData(const lldb::ProcessSP &process_sp,
- const StructuredData::ObjectSP &object_sp,
- const lldb::StructuredDataPluginSP &plugin_sp);
+ ~EventDataStructuredData() override;
- ~EventDataStructuredData() override;
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ const ConstString &GetFlavor() const override;
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- const ConstString &
- GetFlavor() const override;
+ void Dump(Stream *s) const override;
- void
- Dump(Stream *s) const override;
+ const lldb::ProcessSP &GetProcess() const;
- const lldb::ProcessSP&
- GetProcess() const;
+ const StructuredData::ObjectSP &GetObject() const;
- const StructuredData::ObjectSP&
- GetObject() const;
+ const lldb::StructuredDataPluginSP &GetStructuredDataPlugin() const;
- const lldb::StructuredDataPluginSP&
- GetStructuredDataPlugin() const;
+ void SetProcess(const lldb::ProcessSP &process_sp);
- void
- SetProcess(const lldb::ProcessSP &process_sp);
+ void SetObject(const StructuredData::ObjectSP &object_sp);
- void
- SetObject(const StructuredData::ObjectSP &object_sp);
+ void SetStructuredDataPlugin(const lldb::StructuredDataPluginSP &plugin_sp);
- void
- SetStructuredDataPlugin(const lldb::StructuredDataPluginSP &plugin_sp);
+ //------------------------------------------------------------------
+ // Static functions
+ //------------------------------------------------------------------
+ static const EventDataStructuredData *
+ GetEventDataFromEvent(const Event *event_ptr);
- //------------------------------------------------------------------
- // Static functions
- //------------------------------------------------------------------
- static const EventDataStructuredData*
- GetEventDataFromEvent(const Event *event_ptr);
+ static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr);
- static lldb::ProcessSP
- GetProcessFromEvent(const Event *event_ptr);
+ static StructuredData::ObjectSP GetObjectFromEvent(const Event *event_ptr);
- static StructuredData::ObjectSP
- GetObjectFromEvent(const Event *event_ptr);
+ static lldb::StructuredDataPluginSP
+ GetPluginFromEvent(const Event *event_ptr);
- static lldb::StructuredDataPluginSP
- GetPluginFromEvent(const Event *event_ptr);
-
- static const ConstString &
- GetFlavorString ();
+ static const ConstString &GetFlavorString();
private:
+ lldb::ProcessSP m_process_sp;
+ StructuredData::ObjectSP m_object_sp;
+ lldb::StructuredDataPluginSP m_plugin_sp;
- lldb::ProcessSP m_process_sp;
- StructuredData::ObjectSP m_object_sp;
- lldb::StructuredDataPluginSP m_plugin_sp;
-
- DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData);
+ DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData);
};
//----------------------------------------------------------------------
// lldb::Event
//----------------------------------------------------------------------
-class Event
-{
- friend class Listener;
- friend class EventData;
- friend class Broadcaster::BroadcasterImpl;
+class Event {
+ friend class Listener;
+ friend class EventData;
+ friend class Broadcaster::BroadcasterImpl;
public:
- Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data = nullptr);
+ Event(Broadcaster *broadcaster, uint32_t event_type,
+ EventData *data = nullptr);
- Event(Broadcaster *broadcaster, uint32_t event_type, const lldb::EventDataSP &event_data_sp);
+ Event(Broadcaster *broadcaster, uint32_t event_type,
+ const lldb::EventDataSP &event_data_sp);
- Event(uint32_t event_type, EventData *data = nullptr);
+ Event(uint32_t event_type, EventData *data = nullptr);
- Event(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
+ Event(uint32_t event_type, const lldb::EventDataSP &event_data_sp);
- ~Event ();
-
- void
- Dump (Stream *s) const;
-
- EventData *
- GetData ()
- {
- return m_data_sp.get();
- }
-
- const EventData *
- GetData () const
- {
- return m_data_sp.get();
- }
-
- void
- SetData (EventData *new_data)
- {
- m_data_sp.reset (new_data);
- }
-
- uint32_t
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (uint32_t new_type)
- {
- m_type = new_type;
- }
-
- Broadcaster *
- GetBroadcaster () const
- {
- Broadcaster::BroadcasterImplSP broadcaster_impl_sp = m_broadcaster_wp.lock();
- if (broadcaster_impl_sp)
- return broadcaster_impl_sp->GetBroadcaster();
- else
- return nullptr;
- }
-
- bool
- BroadcasterIs (Broadcaster *broadcaster)
- {
- Broadcaster::BroadcasterImplSP broadcaster_impl_sp = m_broadcaster_wp.lock();
- if (broadcaster_impl_sp)
- return broadcaster_impl_sp->GetBroadcaster() == broadcaster;
- else
- return false;
- }
-
- void
- Clear()
- {
- m_data_sp.reset();
- }
+ ~Event();
-private:
- // This is only called by Listener when it pops an event off the queue for
- // the listener. It calls the Event Data's DoOnRemoval() method, which is
- // virtual and can be overridden by the specific data classes.
-
- void
- DoOnRemoval ();
-
- // Called by Broadcaster::BroadcastEvent prior to letting all the listeners
- // know about it update the contained broadcaster so that events can be
- // popped off one queue and re-broadcast to others.
- void
- SetBroadcaster (Broadcaster *broadcaster)
- {
- m_broadcaster_wp = broadcaster->GetBroadcasterImpl();
- }
-
- Broadcaster::BroadcasterImplWP m_broadcaster_wp; // The broadcaster that sent this event
- uint32_t m_type; // The bit describing this event
- lldb::EventDataSP m_data_sp; // User specific data for this event
+ void Dump(Stream *s) const;
+
+ EventData *GetData() { return m_data_sp.get(); }
+
+ const EventData *GetData() const { return m_data_sp.get(); }
+
+ void SetData(EventData *new_data) { m_data_sp.reset(new_data); }
+
+ uint32_t GetType() const { return m_type; }
+ void SetType(uint32_t new_type) { m_type = new_type; }
+
+ Broadcaster *GetBroadcaster() const {
+ Broadcaster::BroadcasterImplSP broadcaster_impl_sp =
+ m_broadcaster_wp.lock();
+ if (broadcaster_impl_sp)
+ return broadcaster_impl_sp->GetBroadcaster();
+ else
+ return nullptr;
+ }
+
+ bool BroadcasterIs(Broadcaster *broadcaster) {
+ Broadcaster::BroadcasterImplSP broadcaster_impl_sp =
+ m_broadcaster_wp.lock();
+ if (broadcaster_impl_sp)
+ return broadcaster_impl_sp->GetBroadcaster() == broadcaster;
+ else
+ return false;
+ }
+
+ void Clear() { m_data_sp.reset(); }
+
+private:
+ // This is only called by Listener when it pops an event off the queue for
+ // the listener. It calls the Event Data's DoOnRemoval() method, which is
+ // virtual and can be overridden by the specific data classes.
+
+ void DoOnRemoval();
+
+ // Called by Broadcaster::BroadcastEvent prior to letting all the listeners
+ // know about it update the contained broadcaster so that events can be
+ // popped off one queue and re-broadcast to others.
+ void SetBroadcaster(Broadcaster *broadcaster) {
+ m_broadcaster_wp = broadcaster->GetBroadcasterImpl();
+ }
+
+ Broadcaster::BroadcasterImplWP
+ m_broadcaster_wp; // The broadcaster that sent this event
+ uint32_t m_type; // The bit describing this event
+ lldb::EventDataSP m_data_sp; // User specific data for this event
- DISALLOW_COPY_AND_ASSIGN (Event);
- Event(); // Disallow default constructor
+ DISALLOW_COPY_AND_ASSIGN(Event);
+ Event(); // Disallow default constructor
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/FastDemangle.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FastDemangle.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FastDemangle.h (original)
+++ lldb/trunk/include/lldb/Core/FastDemangle.h Tue Sep 6 15:57:50 2016
@@ -10,15 +10,11 @@
#ifndef liblldb_FastDemangle_h_
#define liblldb_FastDemangle_h_
-namespace lldb_private
-{
+namespace lldb_private {
- char *
- FastDemangle(const char *mangled_name);
-
- char *
- FastDemangle(const char *mangled_name, long mangled_name_length);
+char *FastDemangle(const char *mangled_name);
+char *FastDemangle(const char *mangled_name, long mangled_name_length);
}
#endif
Modified: lldb/trunk/include/lldb/Core/FileLineResolver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileLineResolver.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FileLineResolver.h (original)
+++ lldb/trunk/include/lldb/Core/FileLineResolver.h Tue Sep 6 15:57:50 2016
@@ -18,61 +18,46 @@ namespace lldb_private {
//----------------------------------------------------------------------
/// @class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h"
-/// @brief This class finds address for source file and line. Optionally, it will look for inlined
+/// @brief This class finds address for source file and line. Optionally, it
+/// will look for inlined
/// instances of the file and line specification.
//----------------------------------------------------------------------
-class FileLineResolver :
- public Searcher
-{
+class FileLineResolver : public Searcher {
public:
- FileLineResolver () :
- m_file_spec(),
+ FileLineResolver()
+ : m_file_spec(),
m_line_number(UINT32_MAX), // Set this to zero for all lines in a file
- m_sc_list (),
- m_inlines (true)
- {
- }
-
- FileLineResolver (const FileSpec &resolver,
- uint32_t line_no,
- bool check_inlines);
-
- ~FileLineResolver () override;
-
- Searcher::CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing) override;
-
- Searcher::Depth
- GetDepth () override;
-
- void
- GetDescription (Stream *s) override;
-
- const SymbolContextList &
- GetFileLineMatches()
- {
- return m_sc_list;
- }
-
- void
- Clear();
-
- void
- Reset (const FileSpec &file_spec,
- uint32_t line,
- bool check_inlines);
-protected:
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
- SymbolContextList m_sc_list;
- bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
+ m_sc_list(), m_inlines(true) {}
+
+ FileLineResolver(const FileSpec &resolver, uint32_t line_no,
+ bool check_inlines);
+
+ ~FileLineResolver() override;
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) override;
+
+ Searcher::Depth GetDepth() override;
+
+ void GetDescription(Stream *s) override;
+
+ const SymbolContextList &GetFileLineMatches() { return m_sc_list; }
+
+ void Clear();
+
+ void Reset(const FileSpec &file_spec, uint32_t line, bool check_inlines);
+
+protected:
+ FileSpec m_file_spec; // This is the file spec we are looking for.
+ uint32_t m_line_number; // This is the line number that we are looking for.
+ SymbolContextList m_sc_list;
+ bool m_inlines; // This determines whether the resolver looks for inlined
+ // functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(FileLineResolver);
+ DISALLOW_COPY_AND_ASSIGN(FileLineResolver);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/FileSpecList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpecList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FileSpecList.h (original)
+++ lldb/trunk/include/lldb/Core/FileSpecList.h Tue Sep 6 15:57:50 2016
@@ -11,8 +11,8 @@
#define liblldb_FileSpecList_h_
#if defined(__cplusplus)
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
#include <vector>
namespace lldb_private {
@@ -23,224 +23,201 @@ namespace lldb_private {
///
/// A class that contains a mutable list of FileSpec objects.
//----------------------------------------------------------------------
-class FileSpecList
-{
+class FileSpecList {
public:
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize this object with an empty file list.
- //------------------------------------------------------------------
- FileSpecList ();
-
- //------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// Initialize this object with a copy of the file list from \a rhs.
- ///
- /// @param[in] rhs
- /// A const reference to another file list object.
- //------------------------------------------------------------------
- FileSpecList (const FileSpecList &rhs);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~FileSpecList ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Replace the file list in this object with the file list from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// A file list object to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const FileSpecList&
- operator= (const FileSpecList &rhs);
-
- //------------------------------------------------------------------
- /// Append a FileSpec object to the list.
- ///
- /// Appends \a file to the end of the file list.
- ///
- /// @param[in] file
- /// A new file to append to this file list.
- //------------------------------------------------------------------
- void
- Append (const FileSpec &file);
-
- //------------------------------------------------------------------
- /// Append a FileSpec object if unique.
- ///
- /// Appends \a file to the end of the file list if it doesn't
- /// already exist in the file list.
- ///
- /// @param[in] file
- /// A new file to append to this file list.
- ///
- /// @return
- /// \b true if the file was appended, \b false otherwise.
- //------------------------------------------------------------------
- bool
- AppendIfUnique (const FileSpec &file);
-
- //------------------------------------------------------------------
- /// Clears the file list.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Dumps the file list to the supplied stream pointer "s".
- ///
- /// @param[in] s
- /// The stream that will be used to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s, const char *separator_cstr = "\n") const;
-
- //------------------------------------------------------------------
- /// Find a file index.
- ///
- /// Find the index of the file in the file spec list that matches
- /// \a file starting \a idx entries into the file spec list.
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @param[in] file
- /// The file specification to search for.
- ///
- /// @param[in] full
- /// Should FileSpec::Equal be called with "full" true or false.
- ///
- /// @param[in] remove_backup_dots
- /// Should FileSpec::Equal be called with "remove_backup_dots" true or false.
- ///
- /// @return
- /// The index of the file that matches \a file if it is found,
- /// else UINT32_MAX is returned.
- //------------------------------------------------------------------
- size_t
- FindFileIndex (size_t idx, const FileSpec &file, bool full, bool remove_backup_dots = false) const;
-
- //------------------------------------------------------------------
- /// Get file at index.
- ///
- /// Gets a file from the file list. If \a idx is not a valid index,
- /// an empty FileSpec object will be returned. The file objects
- /// that are returned can be tested using
- /// FileSpec::operator void*().
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @return
- /// A copy of the FileSpec object at index \a idx. If \a idx
- /// is out of range, then an empty FileSpec object will be
- /// returned.
- //------------------------------------------------------------------
- const FileSpec &
- GetFileSpecAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get file specification pointer at index.
- ///
- /// Gets a file from the file list. The file objects that are
- /// returned can be tested using FileSpec::operator void*().
- ///
- /// @param[in] idx
- /// An index into the file list.
- ///
- /// @return
- /// A pointer to a contained FileSpec object at index \a idx.
- /// If \a idx is out of range, then an NULL is returned.
- //------------------------------------------------------------------
- const FileSpec *
- GetFileSpecPointerAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, not any shared string
- /// values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- bool
- IsEmpty() const
- {
- return m_files.empty();
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize this object with an empty file list.
+ //------------------------------------------------------------------
+ FileSpecList();
+
+ //------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// Initialize this object with a copy of the file list from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const reference to another file list object.
+ //------------------------------------------------------------------
+ FileSpecList(const FileSpecList &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~FileSpecList();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Replace the file list in this object with the file list from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A file list object to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const FileSpecList &operator=(const FileSpecList &rhs);
+
+ //------------------------------------------------------------------
+ /// Append a FileSpec object to the list.
+ ///
+ /// Appends \a file to the end of the file list.
+ ///
+ /// @param[in] file
+ /// A new file to append to this file list.
+ //------------------------------------------------------------------
+ void Append(const FileSpec &file);
+
+ //------------------------------------------------------------------
+ /// Append a FileSpec object if unique.
+ ///
+ /// Appends \a file to the end of the file list if it doesn't
+ /// already exist in the file list.
+ ///
+ /// @param[in] file
+ /// A new file to append to this file list.
+ ///
+ /// @return
+ /// \b true if the file was appended, \b false otherwise.
+ //------------------------------------------------------------------
+ bool AppendIfUnique(const FileSpec &file);
+
+ //------------------------------------------------------------------
+ /// Clears the file list.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Dumps the file list to the supplied stream pointer "s".
+ ///
+ /// @param[in] s
+ /// The stream that will be used to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s, const char *separator_cstr = "\n") const;
+
+ //------------------------------------------------------------------
+ /// Find a file index.
+ ///
+ /// Find the index of the file in the file spec list that matches
+ /// \a file starting \a idx entries into the file spec list.
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @param[in] file
+ /// The file specification to search for.
+ ///
+ /// @param[in] full
+ /// Should FileSpec::Equal be called with "full" true or false.
+ ///
+ /// @param[in] remove_backup_dots
+ /// Should FileSpec::Equal be called with "remove_backup_dots" true or
+ /// false.
+ ///
+ /// @return
+ /// The index of the file that matches \a file if it is found,
+ /// else UINT32_MAX is returned.
+ //------------------------------------------------------------------
+ size_t FindFileIndex(size_t idx, const FileSpec &file, bool full,
+ bool remove_backup_dots = false) const;
+
+ //------------------------------------------------------------------
+ /// Get file at index.
+ ///
+ /// Gets a file from the file list. If \a idx is not a valid index,
+ /// an empty FileSpec object will be returned. The file objects
+ /// that are returned can be tested using
+ /// FileSpec::operator void*().
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @return
+ /// A copy of the FileSpec object at index \a idx. If \a idx
+ /// is out of range, then an empty FileSpec object will be
+ /// returned.
+ //------------------------------------------------------------------
+ const FileSpec &GetFileSpecAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get file specification pointer at index.
+ ///
+ /// Gets a file from the file list. The file objects that are
+ /// returned can be tested using FileSpec::operator void*().
+ ///
+ /// @param[in] idx
+ /// An index into the file list.
+ ///
+ /// @return
+ /// A pointer to a contained FileSpec object at index \a idx.
+ /// If \a idx is out of range, then an NULL is returned.
+ //------------------------------------------------------------------
+ const FileSpec *GetFileSpecPointerAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, not any shared string
+ /// values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ bool IsEmpty() const { return m_files.empty(); }
+
+ //------------------------------------------------------------------
+ /// Get the number of files in the file list.
+ ///
+ /// @return
+ /// The number of files in the file spec list.
+ //------------------------------------------------------------------
+ size_t GetSize() const;
+
+ bool Insert(size_t idx, const FileSpec &file) {
+ if (idx < m_files.size()) {
+ m_files.insert(m_files.begin() + idx, file);
+ return true;
+ } else if (idx == m_files.size()) {
+ m_files.push_back(file);
+ return true;
}
+ return false;
+ }
- //------------------------------------------------------------------
- /// Get the number of files in the file list.
- ///
- /// @return
- /// The number of files in the file spec list.
- //------------------------------------------------------------------
- size_t
- GetSize () const;
-
- bool
- Insert (size_t idx, const FileSpec &file)
- {
- if (idx < m_files.size())
- {
- m_files.insert(m_files.begin() + idx, file);
- return true;
- }
- else if (idx == m_files.size())
- {
- m_files.push_back(file);
- return true;
- }
- return false;
+ bool Replace(size_t idx, const FileSpec &file) {
+ if (idx < m_files.size()) {
+ m_files[idx] = file;
+ return true;
}
+ return false;
+ }
- bool
- Replace (size_t idx, const FileSpec &file)
- {
- if (idx < m_files.size())
- {
- m_files[idx] = file;
- return true;
- }
- return false;
+ bool Remove(size_t idx) {
+ if (idx < m_files.size()) {
+ m_files.erase(m_files.begin() + idx);
+ return true;
}
+ return false;
+ }
- bool
- Remove (size_t idx)
- {
- if (idx < m_files.size())
- {
- m_files.erase(m_files.begin() + idx);
- return true;
- }
- return false;
- }
-
- static size_t GetFilesMatchingPartialPath (const char *path, bool dir_okay, FileSpecList &matches);
+ static size_t GetFilesMatchingPartialPath(const char *path, bool dir_okay,
+ FileSpecList &matches);
protected:
- typedef std::vector<FileSpec> collection; ///< The collection type for the file list.
- collection m_files; ///< A collection of FileSpec objects.
+ typedef std::vector<FileSpec>
+ collection; ///< The collection type for the file list.
+ collection m_files; ///< A collection of FileSpec objects.
};
} // namespace lldb_private
-
-#endif // #if defined(__cplusplus)
-#endif // liblldb_FileSpecList_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_FileSpecList_h_
Modified: lldb/trunk/include/lldb/Core/Flags.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Flags.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Flags.h (original)
+++ lldb/trunk/include/lldb/Core/Flags.h Tue Sep 6 15:57:50 2016
@@ -19,232 +19,175 @@ namespace lldb_private {
/// @class Flags Flags.h "lldb/Core/Flags.h"
/// @brief A class to manage flags.
///
-/// The Flags class managed flag bits and allows testing and
+/// The Flags class managed flag bits and allows testing and
/// modification of individual or multiple flag bits.
//----------------------------------------------------------------------
-class Flags
-{
+class Flags {
public:
- //----------------------------------------------------------------------
- /// The value type for flags is a 32 bit unsigned integer type.
- //----------------------------------------------------------------------
- typedef uint32_t ValueType;
-
- //----------------------------------------------------------------------
- /// Construct with initial flag bit values.
- ///
- /// Constructs this object with \a mask as the initial value for all
- /// of the flags.
- ///
- /// @param[in] mask
- /// The initial value for all flags.
- //----------------------------------------------------------------------
- Flags (ValueType flags = 0) :
- m_flags (flags)
- {
- }
-
- //----------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// Construct and copy the flags from \a rhs.
- ///
- /// @param[in] rhs
- /// A const Flags object reference to copy.
- //----------------------------------------------------------------------
- Flags (const Flags& rhs) :
- m_flags(rhs.m_flags)
- {
- }
-
- //----------------------------------------------------------------------
- /// Destructor.
- //----------------------------------------------------------------------
- ~Flags ()
- {
- }
-
- //----------------------------------------------------------------------
- /// Get accessor for all flags.
- ///
- /// @return
- /// Returns all of the flags as a Flags::ValueType.
- //----------------------------------------------------------------------
- ValueType
- Get () const
- {
- return m_flags;
- }
-
- //----------------------------------------------------------------------
- /// Return the number of flags that can be represented in this
- /// object.
- ///
- /// @return
- /// The maximum number bits in this flag object.
- //----------------------------------------------------------------------
- size_t
- GetBitSize() const
- {
- return sizeof (ValueType) * 8;
- }
-
- //----------------------------------------------------------------------
- /// Set accessor for all flags.
- ///
- /// @param[in] flags
- /// The bits with which to replace all of the current flags.
- //----------------------------------------------------------------------
- void
- Reset (ValueType flags)
- {
- m_flags = flags;
- }
-
- //----------------------------------------------------------------------
- /// Clear one or more flags.
- ///
- /// @param[in] mask
- /// A bitfield containing one or more flags.
- ///
- /// @return
- /// The new flags after clearing all bits from \a mask.
- //----------------------------------------------------------------------
- ValueType
- Clear (ValueType mask = ~(ValueType)0)
- {
- m_flags &= ~mask;
- return m_flags;
- }
-
-
- //----------------------------------------------------------------------
- /// Set one or more flags by logical OR'ing \a mask with the current
- /// flags.
- ///
- /// @param[in] mask
- /// A bitfield containing one or more flags.
- ///
- /// @return
- /// The new flags after setting all bits from \a mask.
- //----------------------------------------------------------------------
- ValueType
- Set (ValueType mask)
- {
- m_flags |= mask;
- return m_flags;
- }
-
-
- //----------------------------------------------------------------------
- /// Test if all bits in \a mask are 1 in the current flags
- ///
- /// @return
- /// \b true if all flags in \a mask are 1, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AllSet (ValueType mask) const
- {
- return (m_flags & mask) == mask;
- }
-
- //----------------------------------------------------------------------
- /// Test one or more flags.
- ///
- /// @return
- /// \b true if any flags in \a mask are 1, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AnySet (ValueType mask) const
- {
- return (m_flags & mask) != 0;
- }
-
- //----------------------------------------------------------------------
- /// Test a single flag bit.
- ///
- /// @return
- /// \b true if \a bit is set, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- Test (ValueType bit) const
- {
- return (m_flags & bit) != 0;
- }
-
- //----------------------------------------------------------------------
- /// Test if all bits in \a mask are clear.
- ///
- /// @return
- /// \b true if \b all flags in \a mask are clear, \b false
- /// otherwise.
- //----------------------------------------------------------------------
- bool
- AllClear (ValueType mask) const
- {
- return (m_flags & mask) == 0;
- }
-
- bool
- AnyClear (ValueType mask) const
- {
- return (m_flags & mask) != mask;
- }
-
- //----------------------------------------------------------------------
- /// Test a single flag bit to see if it is clear (zero).
- ///
- /// @return
- /// \b true if \a bit is 0, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- IsClear (ValueType bit) const
- {
- return (m_flags & bit) == 0;
- }
-
- //----------------------------------------------------------------------
- /// Get the number of zero bits in \a m_flags.
- ///
- /// @return
- /// The number of bits that are set to 0 in the current flags.
- //----------------------------------------------------------------------
- size_t
- ClearCount () const
- {
- size_t count = 0;
- for (ValueType shift = 0; shift < sizeof(ValueType)*8; ++shift)
- {
- if ((m_flags & (1u << shift)) == 0)
- ++count;
- }
- return count;
- }
-
- //----------------------------------------------------------------------
- /// Get the number of one bits in \a m_flags.
- ///
- /// @return
- /// The number of bits that are set to 1 in the current flags.
- //----------------------------------------------------------------------
- size_t
- SetCount () const
- {
- size_t count = 0;
- for (ValueType mask = m_flags; mask; mask >>= 1)
- {
- if (mask & 1u)
- ++count;
- }
- return count;
+ //----------------------------------------------------------------------
+ /// The value type for flags is a 32 bit unsigned integer type.
+ //----------------------------------------------------------------------
+ typedef uint32_t ValueType;
+
+ //----------------------------------------------------------------------
+ /// Construct with initial flag bit values.
+ ///
+ /// Constructs this object with \a mask as the initial value for all
+ /// of the flags.
+ ///
+ /// @param[in] mask
+ /// The initial value for all flags.
+ //----------------------------------------------------------------------
+ Flags(ValueType flags = 0) : m_flags(flags) {}
+
+ //----------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// Construct and copy the flags from \a rhs.
+ ///
+ /// @param[in] rhs
+ /// A const Flags object reference to copy.
+ //----------------------------------------------------------------------
+ Flags(const Flags &rhs) : m_flags(rhs.m_flags) {}
+
+ //----------------------------------------------------------------------
+ /// Destructor.
+ //----------------------------------------------------------------------
+ ~Flags() {}
+
+ //----------------------------------------------------------------------
+ /// Get accessor for all flags.
+ ///
+ /// @return
+ /// Returns all of the flags as a Flags::ValueType.
+ //----------------------------------------------------------------------
+ ValueType Get() const { return m_flags; }
+
+ //----------------------------------------------------------------------
+ /// Return the number of flags that can be represented in this
+ /// object.
+ ///
+ /// @return
+ /// The maximum number bits in this flag object.
+ //----------------------------------------------------------------------
+ size_t GetBitSize() const { return sizeof(ValueType) * 8; }
+
+ //----------------------------------------------------------------------
+ /// Set accessor for all flags.
+ ///
+ /// @param[in] flags
+ /// The bits with which to replace all of the current flags.
+ //----------------------------------------------------------------------
+ void Reset(ValueType flags) { m_flags = flags; }
+
+ //----------------------------------------------------------------------
+ /// Clear one or more flags.
+ ///
+ /// @param[in] mask
+ /// A bitfield containing one or more flags.
+ ///
+ /// @return
+ /// The new flags after clearing all bits from \a mask.
+ //----------------------------------------------------------------------
+ ValueType Clear(ValueType mask = ~(ValueType)0) {
+ m_flags &= ~mask;
+ return m_flags;
+ }
+
+ //----------------------------------------------------------------------
+ /// Set one or more flags by logical OR'ing \a mask with the current
+ /// flags.
+ ///
+ /// @param[in] mask
+ /// A bitfield containing one or more flags.
+ ///
+ /// @return
+ /// The new flags after setting all bits from \a mask.
+ //----------------------------------------------------------------------
+ ValueType Set(ValueType mask) {
+ m_flags |= mask;
+ return m_flags;
+ }
+
+ //----------------------------------------------------------------------
+ /// Test if all bits in \a mask are 1 in the current flags
+ ///
+ /// @return
+ /// \b true if all flags in \a mask are 1, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AllSet(ValueType mask) const { return (m_flags & mask) == mask; }
+
+ //----------------------------------------------------------------------
+ /// Test one or more flags.
+ ///
+ /// @return
+ /// \b true if any flags in \a mask are 1, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AnySet(ValueType mask) const { return (m_flags & mask) != 0; }
+
+ //----------------------------------------------------------------------
+ /// Test a single flag bit.
+ ///
+ /// @return
+ /// \b true if \a bit is set, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool Test(ValueType bit) const { return (m_flags & bit) != 0; }
+
+ //----------------------------------------------------------------------
+ /// Test if all bits in \a mask are clear.
+ ///
+ /// @return
+ /// \b true if \b all flags in \a mask are clear, \b false
+ /// otherwise.
+ //----------------------------------------------------------------------
+ bool AllClear(ValueType mask) const { return (m_flags & mask) == 0; }
+
+ bool AnyClear(ValueType mask) const { return (m_flags & mask) != mask; }
+
+ //----------------------------------------------------------------------
+ /// Test a single flag bit to see if it is clear (zero).
+ ///
+ /// @return
+ /// \b true if \a bit is 0, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool IsClear(ValueType bit) const { return (m_flags & bit) == 0; }
+
+ //----------------------------------------------------------------------
+ /// Get the number of zero bits in \a m_flags.
+ ///
+ /// @return
+ /// The number of bits that are set to 0 in the current flags.
+ //----------------------------------------------------------------------
+ size_t ClearCount() const {
+ size_t count = 0;
+ for (ValueType shift = 0; shift < sizeof(ValueType) * 8; ++shift) {
+ if ((m_flags & (1u << shift)) == 0)
+ ++count;
+ }
+ return count;
+ }
+
+ //----------------------------------------------------------------------
+ /// Get the number of one bits in \a m_flags.
+ ///
+ /// @return
+ /// The number of bits that are set to 1 in the current flags.
+ //----------------------------------------------------------------------
+ size_t SetCount() const {
+ size_t count = 0;
+ for (ValueType mask = m_flags; mask; mask >>= 1) {
+ if (mask & 1u)
+ ++count;
}
+ return count;
+ }
protected:
- ValueType m_flags; ///< The flags.
+ ValueType m_flags; ///< The flags.
};
} // namespace lldb_private
-#endif // liblldb_Flags_h_
+#endif // liblldb_Flags_h_
Modified: lldb/trunk/include/lldb/Core/FormatEntity.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatEntity.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatEntity.h (original)
+++ lldb/trunk/include/lldb/Core/FormatEntity.h Tue Sep 6 15:57:50 2016
@@ -17,249 +17,200 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Error.h"
+#include "lldb/lldb-private.h"
-namespace llvm
-{
- class StringRef;
+namespace llvm {
+class StringRef;
} // namespace llvm
-namespace lldb_private
-{
- class FormatEntity
- {
- public:
- struct Entry
- {
- enum class Type {
- Invalid,
- ParentNumber,
- ParentString,
- InsertString,
- Root,
- String,
- Scope,
- Variable,
- VariableSynthetic,
- ScriptVariable,
- ScriptVariableSynthetic,
- AddressLoad,
- AddressFile,
- AddressLoadOrFile,
- ProcessID,
- ProcessFile,
- ScriptProcess,
- ThreadID,
- ThreadProtocolID,
- ThreadIndexID,
- ThreadName,
- ThreadQueue,
- ThreadStopReason,
- ThreadReturnValue,
- ThreadCompletedExpression,
- ScriptThread,
- ThreadInfo,
- TargetArch,
- ScriptTarget,
- ModuleFile,
- File,
- Lang,
- FrameIndex,
- FrameRegisterPC,
- FrameRegisterSP,
- FrameRegisterFP,
- FrameRegisterFlags,
- FrameRegisterByName,
- ScriptFrame,
- FunctionID,
- FunctionDidChange,
- FunctionInitialFunction,
- FunctionName,
- FunctionNameWithArgs,
- FunctionNameNoArgs,
- FunctionAddrOffset,
- FunctionAddrOffsetConcrete,
- FunctionLineOffset,
- FunctionPCOffset,
- FunctionInitial,
- FunctionChanged,
- FunctionIsOptimized,
- LineEntryFile,
- LineEntryLineNumber,
- LineEntryStartAddress,
- LineEntryEndAddress,
- CurrentPCArrow
- };
-
- enum FormatType
- {
- None,
- UInt32,
- UInt64,
- CString
- };
-
- struct Definition
- {
- const char *name;
- const char *string; // Insert this exact string into the output
- Entry::Type type;
- FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can be formatted by printf or lldb::Format
- uint64_t data;
- uint32_t num_children;
- Definition *children; // An array of "num_children" Definition entries,
- bool keep_separator;
- };
-
- Entry(Type t = Type::Invalid,
- const char *s = nullptr,
- const char *f = nullptr) :
- string (s ? s : ""),
- printf_format (f ? f : ""),
- children (),
- definition (nullptr),
- type (t),
- fmt (lldb::eFormatDefault),
- number (0),
- deref (false)
- {
- }
-
- Entry (llvm::StringRef s);
- Entry (char ch);
-
- void
- AppendChar (char ch);
-
- void
- AppendText (const llvm::StringRef &s);
-
- void
- AppendText (const char *cstr);
-
- void
- AppendEntry (const Entry &&entry)
- {
- children.push_back(entry);
- }
-
- void
- Clear ()
- {
- string.clear();
- printf_format.clear();
- children.clear();
- definition = nullptr;
- type = Type::Invalid;
- fmt = lldb::eFormatDefault;
- number = 0;
- deref = false;
- }
-
- static const char *
- TypeToCString (Type t);
-
- void
- Dump (Stream &s, int depth = 0) const;
-
- bool
- operator == (const Entry &rhs) const
- {
- if (string != rhs.string)
- return false;
- if (printf_format != rhs.printf_format)
- return false;
- const size_t n = children.size();
- const size_t m = rhs.children.size();
- for (size_t i=0; i < std::min<size_t>(n, m); ++i)
- {
- if (!(children[i] == rhs.children[i]))
- return false;
- }
- if (children != rhs.children)
- return false;
- if (definition != rhs.definition)
- return false;
- if (type != rhs.type)
- return false;
- if (fmt != rhs.fmt)
- return false;
- if (deref != rhs.deref)
- return false;
- return true;
- }
-
- std::string string;
- std::string printf_format;
- std::vector<Entry> children;
- Definition *definition;
- Type type;
- lldb::Format fmt;
- lldb::addr_t number;
- bool deref;
- };
-
- static bool
- Format (const Entry &entry,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static bool
- FormatStringRef (const llvm::StringRef &format,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static bool
- FormatCString (const char *format,
- Stream &s,
- const SymbolContext *sc,
- const ExecutionContext *exe_ctx,
- const Address *addr,
- ValueObject* valobj,
- bool function_changed,
- bool initial_function);
-
- static Error
- Parse (const llvm::StringRef &format, Entry &entry);
-
- static Error
- ExtractVariableInfo (llvm::StringRef &format_str,
- llvm::StringRef &variable_name,
- llvm::StringRef &variable_format);
-
- static size_t
- AutoComplete (const char *s,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches);
-
- //----------------------------------------------------------------------
- // Format the current elements into the stream \a s.
- //
- // The root element will be stripped off and the format str passed in
- // will be either an empty string (print a description of this object),
- // or contain a . separated series like a domain name that identifies
- // further sub elements to display.
- //----------------------------------------------------------------------
- static bool
- FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
- protected:
- static Error
- ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
+namespace lldb_private {
+class FormatEntity {
+public:
+ struct Entry {
+ enum class Type {
+ Invalid,
+ ParentNumber,
+ ParentString,
+ InsertString,
+ Root,
+ String,
+ Scope,
+ Variable,
+ VariableSynthetic,
+ ScriptVariable,
+ ScriptVariableSynthetic,
+ AddressLoad,
+ AddressFile,
+ AddressLoadOrFile,
+ ProcessID,
+ ProcessFile,
+ ScriptProcess,
+ ThreadID,
+ ThreadProtocolID,
+ ThreadIndexID,
+ ThreadName,
+ ThreadQueue,
+ ThreadStopReason,
+ ThreadReturnValue,
+ ThreadCompletedExpression,
+ ScriptThread,
+ ThreadInfo,
+ TargetArch,
+ ScriptTarget,
+ ModuleFile,
+ File,
+ Lang,
+ FrameIndex,
+ FrameRegisterPC,
+ FrameRegisterSP,
+ FrameRegisterFP,
+ FrameRegisterFlags,
+ FrameRegisterByName,
+ ScriptFrame,
+ FunctionID,
+ FunctionDidChange,
+ FunctionInitialFunction,
+ FunctionName,
+ FunctionNameWithArgs,
+ FunctionNameNoArgs,
+ FunctionAddrOffset,
+ FunctionAddrOffsetConcrete,
+ FunctionLineOffset,
+ FunctionPCOffset,
+ FunctionInitial,
+ FunctionChanged,
+ FunctionIsOptimized,
+ LineEntryFile,
+ LineEntryLineNumber,
+ LineEntryStartAddress,
+ LineEntryEndAddress,
+ CurrentPCArrow
+ };
+ enum FormatType { None, UInt32, UInt64, CString };
+
+ struct Definition {
+ const char *name;
+ const char *string; // Insert this exact string into the output
+ Entry::Type type;
+ FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can
+ // be formatted by printf or lldb::Format
+ uint64_t data;
+ uint32_t num_children;
+ Definition *children; // An array of "num_children" Definition entries,
+ bool keep_separator;
};
+
+ Entry(Type t = Type::Invalid, const char *s = nullptr,
+ const char *f = nullptr)
+ : string(s ? s : ""), printf_format(f ? f : ""), children(),
+ definition(nullptr), type(t), fmt(lldb::eFormatDefault), number(0),
+ deref(false) {}
+
+ Entry(llvm::StringRef s);
+ Entry(char ch);
+
+ void AppendChar(char ch);
+
+ void AppendText(const llvm::StringRef &s);
+
+ void AppendText(const char *cstr);
+
+ void AppendEntry(const Entry &&entry) { children.push_back(entry); }
+
+ void Clear() {
+ string.clear();
+ printf_format.clear();
+ children.clear();
+ definition = nullptr;
+ type = Type::Invalid;
+ fmt = lldb::eFormatDefault;
+ number = 0;
+ deref = false;
+ }
+
+ static const char *TypeToCString(Type t);
+
+ void Dump(Stream &s, int depth = 0) const;
+
+ bool operator==(const Entry &rhs) const {
+ if (string != rhs.string)
+ return false;
+ if (printf_format != rhs.printf_format)
+ return false;
+ const size_t n = children.size();
+ const size_t m = rhs.children.size();
+ for (size_t i = 0; i < std::min<size_t>(n, m); ++i) {
+ if (!(children[i] == rhs.children[i]))
+ return false;
+ }
+ if (children != rhs.children)
+ return false;
+ if (definition != rhs.definition)
+ return false;
+ if (type != rhs.type)
+ return false;
+ if (fmt != rhs.fmt)
+ return false;
+ if (deref != rhs.deref)
+ return false;
+ return true;
+ }
+
+ std::string string;
+ std::string printf_format;
+ std::vector<Entry> children;
+ Definition *definition;
+ Type type;
+ lldb::Format fmt;
+ lldb::addr_t number;
+ bool deref;
+ };
+
+ static bool Format(const Entry &entry, Stream &s, const SymbolContext *sc,
+ const ExecutionContext *exe_ctx, const Address *addr,
+ ValueObject *valobj, bool function_changed,
+ bool initial_function);
+
+ static bool FormatStringRef(const llvm::StringRef &format, Stream &s,
+ const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, ValueObject *valobj,
+ bool function_changed, bool initial_function);
+
+ static bool FormatCString(const char *format, Stream &s,
+ const SymbolContext *sc,
+ const ExecutionContext *exe_ctx,
+ const Address *addr, ValueObject *valobj,
+ bool function_changed, bool initial_function);
+
+ static Error Parse(const llvm::StringRef &format, Entry &entry);
+
+ static Error ExtractVariableInfo(llvm::StringRef &format_str,
+ llvm::StringRef &variable_name,
+ llvm::StringRef &variable_format);
+
+ static size_t AutoComplete(const char *s, int match_start_point,
+ int max_return_elements, bool &word_complete,
+ StringList &matches);
+
+ //----------------------------------------------------------------------
+ // Format the current elements into the stream \a s.
+ //
+ // The root element will be stripped off and the format str passed in
+ // will be either an empty string (print a description of this object),
+ // or contain a . separated series like a domain name that identifies
+ // further sub elements to display.
+ //----------------------------------------------------------------------
+ static bool FormatFileSpec(const FileSpec &file, Stream &s,
+ llvm::StringRef elements,
+ llvm::StringRef element_format);
+
+protected:
+ static Error ParseInternal(llvm::StringRef &format, Entry &parent_entry,
+ uint32_t depth);
+};
} // namespace lldb_private
#endif // liblldb_FormatEntity_h_
Modified: lldb/trunk/include/lldb/Core/History.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/History.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/History.h (original)
+++ lldb/trunk/include/lldb/Core/History.h Tue Sep 6 15:57:50 2016
@@ -28,141 +28,105 @@ namespace lldb_private {
/// @class HistorySource History.h "lldb/Core/History.h"
/// @brief A class that defines history events.
//----------------------------------------------------------------------
-
-class HistorySource
-{
+
+class HistorySource {
public:
- typedef const void * HistoryEvent;
+ typedef const void *HistoryEvent;
- HistorySource() : m_mutex(), m_events() {}
+ HistorySource() : m_mutex(), m_events() {}
- virtual
- ~HistorySource()
- {
- }
+ virtual ~HistorySource() {}
- // Create a new history event. Subclasses should use any data or members
- // in the subclass of this class to produce a history event and push it
- // onto the end of the history stack.
+ // Create a new history event. Subclasses should use any data or members
+ // in the subclass of this class to produce a history event and push it
+ // onto the end of the history stack.
- virtual HistoryEvent
- CreateHistoryEvent () = 0;
+ virtual HistoryEvent CreateHistoryEvent() = 0;
- virtual void
- DeleteHistoryEvent (HistoryEvent event) = 0;
+ virtual void DeleteHistoryEvent(HistoryEvent event) = 0;
- virtual void
- DumpHistoryEvent (Stream &strm, HistoryEvent event) = 0;
+ virtual void DumpHistoryEvent(Stream &strm, HistoryEvent event) = 0;
- virtual size_t
- GetHistoryEventCount() = 0;
+ virtual size_t GetHistoryEventCount() = 0;
- virtual HistoryEvent
- GetHistoryEventAtIndex (uint32_t idx) = 0;
+ virtual HistoryEvent GetHistoryEventAtIndex(uint32_t idx) = 0;
- virtual HistoryEvent
- GetCurrentHistoryEvent () = 0;
+ virtual HistoryEvent GetCurrentHistoryEvent() = 0;
- // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
- virtual int
- CompareHistoryEvents (const HistoryEvent lhs,
- const HistoryEvent rhs) = 0;
+ // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
+ virtual int CompareHistoryEvents(const HistoryEvent lhs,
+ const HistoryEvent rhs) = 0;
- virtual bool
- IsCurrentHistoryEvent (const HistoryEvent event) = 0;
+ virtual bool IsCurrentHistoryEvent(const HistoryEvent event) = 0;
private:
- typedef std::stack<HistoryEvent> collection;
+ typedef std::stack<HistoryEvent> collection;
- std::recursive_mutex m_mutex;
- collection m_events;
+ std::recursive_mutex m_mutex;
+ collection m_events;
- DISALLOW_COPY_AND_ASSIGN (HistorySource);
+ DISALLOW_COPY_AND_ASSIGN(HistorySource);
};
-
+
//----------------------------------------------------------------------
/// @class HistorySourceUInt History.h "lldb/Core/History.h"
/// @brief A class that defines history events that are represented by
/// unsigned integers.
///
-/// Any history event that is defined by a unique monotonically
+/// Any history event that is defined by a unique monotonically
/// increasing unsigned integer
//----------------------------------------------------------------------
-class HistorySourceUInt : public HistorySource
-{
- HistorySourceUInt (const char *id_name, uintptr_t start_value = 0u) :
- HistorySource(),
- m_name (id_name),
- m_curr_id (start_value)
- {
- }
-
- ~HistorySourceUInt() override
- {
- }
-
- // Create a new history event. Subclasses should use any data or members
- // in the subclass of this class to produce a history event and push it
- // onto the end of the history stack.
-
- HistoryEvent
- CreateHistoryEvent () override
- {
- ++m_curr_id;
- return (HistoryEvent)m_curr_id;
- }
-
- void
- DeleteHistoryEvent (HistoryEvent event) override
- {
- // Nothing to delete, the event contains the integer
- }
-
- void
- DumpHistoryEvent (Stream &strm, HistoryEvent event) override;
-
- size_t
- GetHistoryEventCount() override
- {
- return m_curr_id;
- }
-
- HistoryEvent
- GetHistoryEventAtIndex (uint32_t idx) override
- {
- return (HistoryEvent)((uintptr_t)idx);
- }
-
- HistoryEvent
- GetCurrentHistoryEvent () override
- {
- return (HistoryEvent)m_curr_id;
- }
-
- // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
- int
- CompareHistoryEvents (const HistoryEvent lhs,
- const HistoryEvent rhs) override
- {
- uintptr_t lhs_uint = (uintptr_t)lhs;
- uintptr_t rhs_uint = (uintptr_t)rhs;
- if (lhs_uint < rhs_uint)
- return -1;
- if (lhs_uint > rhs_uint)
- return +1;
- return 0;
- }
-
- bool
- IsCurrentHistoryEvent (const HistoryEvent event) override
- {
- return (uintptr_t)event == m_curr_id;
- }
+class HistorySourceUInt : public HistorySource {
+ HistorySourceUInt(const char *id_name, uintptr_t start_value = 0u)
+ : HistorySource(), m_name(id_name), m_curr_id(start_value) {}
+
+ ~HistorySourceUInt() override {}
+
+ // Create a new history event. Subclasses should use any data or members
+ // in the subclass of this class to produce a history event and push it
+ // onto the end of the history stack.
+
+ HistoryEvent CreateHistoryEvent() override {
+ ++m_curr_id;
+ return (HistoryEvent)m_curr_id;
+ }
+
+ void DeleteHistoryEvent(HistoryEvent event) override {
+ // Nothing to delete, the event contains the integer
+ }
+
+ void DumpHistoryEvent(Stream &strm, HistoryEvent event) override;
+
+ size_t GetHistoryEventCount() override { return m_curr_id; }
+
+ HistoryEvent GetHistoryEventAtIndex(uint32_t idx) override {
+ return (HistoryEvent)((uintptr_t)idx);
+ }
+
+ HistoryEvent GetCurrentHistoryEvent() override {
+ return (HistoryEvent)m_curr_id;
+ }
+
+ // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs.
+ int CompareHistoryEvents(const HistoryEvent lhs,
+ const HistoryEvent rhs) override {
+ uintptr_t lhs_uint = (uintptr_t)lhs;
+ uintptr_t rhs_uint = (uintptr_t)rhs;
+ if (lhs_uint < rhs_uint)
+ return -1;
+ if (lhs_uint > rhs_uint)
+ return +1;
+ return 0;
+ }
+
+ bool IsCurrentHistoryEvent(const HistoryEvent event) override {
+ return (uintptr_t)event == m_curr_id;
+ }
protected:
- std::string m_name; // The name of the history unsigned integer
- uintptr_t m_curr_id; // The current value of the history unsigned unteger
+ std::string m_name; // The name of the history unsigned integer
+ uintptr_t m_curr_id; // The current value of the history unsigned unteger
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Tue Sep 6 15:57:50 2016
@@ -21,8 +21,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
@@ -30,794 +28,567 @@
#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Predicate.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
-namespace curses
-{
- class Application;
- typedef std::unique_ptr<Application> ApplicationAP;
+namespace curses {
+class Application;
+typedef std::unique_ptr<Application> ApplicationAP;
} // namespace curses
namespace lldb_private {
- class IOHandler
- {
- public:
- enum class Type {
- CommandInterpreter,
- CommandList,
- Confirm,
- Curses,
- Expression,
- REPL,
- ProcessIO,
- PythonInterpreter,
- PythonCode,
- Other
- };
-
- IOHandler (Debugger &debugger,
- IOHandler::Type type);
-
- IOHandler (Debugger &debugger,
- IOHandler::Type type,
- const lldb::StreamFileSP &input_sp,
- const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp,
- uint32_t flags);
-
- virtual
- ~IOHandler ();
-
- // Each IOHandler gets to run until it is done. It should read data
- // from the "in" and place output into "out" and "err and return
- // when done.
- virtual void
- Run () = 0;
-
- // Called when an input reader should relinquish its control so another
- // can be pushed onto the IO handler stack, or so the current IO
- // handler can pop itself off the stack
-
- virtual void
- Cancel () = 0;
-
- // Called when CTRL+C is pressed which usually causes
- // Debugger::DispatchInputInterrupt to be called.
-
- virtual bool
- Interrupt () = 0;
-
- virtual void
- GotEOF() = 0;
-
- virtual bool
- IsActive ()
- {
- return m_active && !m_done;
- }
-
- virtual void
- SetIsDone (bool b)
- {
- m_done = b;
- }
-
- virtual bool
- GetIsDone ()
- {
- return m_done;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- virtual void
- Activate ()
- {
- m_active = true;
- }
-
- virtual void
- Deactivate ()
- {
- m_active = false;
- }
-
- virtual const char *
- GetPrompt ()
- {
- // Prompt support isn't mandatory
- return nullptr;
- }
-
- virtual bool
- SetPrompt (const char *prompt)
- {
- // Prompt support isn't mandatory
- return false;
- }
-
- virtual ConstString
- GetControlSequence (char ch)
- {
- return ConstString();
- }
-
- virtual const char *
- GetCommandPrefix ()
- {
- return nullptr;
- }
-
- virtual const char *
- GetHelpPrologue()
- {
- return nullptr;
- }
-
- int
- GetInputFD();
-
- int
- GetOutputFD();
-
- int
- GetErrorFD();
-
- FILE *
- GetInputFILE();
-
- FILE *
- GetOutputFILE();
-
- FILE *
- GetErrorFILE();
-
- lldb::StreamFileSP &
- GetInputStreamFile();
-
- lldb::StreamFileSP &
- GetOutputStreamFile();
-
- lldb::StreamFileSP &
- GetErrorStreamFile();
-
- Debugger &
- GetDebugger()
- {
- return m_debugger;
- }
-
- void *
- GetUserData ()
- {
- return m_user_data;
- }
-
- void
- SetUserData (void *user_data)
- {
- m_user_data = user_data;
- }
-
- Flags &
- GetFlags ()
- {
- return m_flags;
- }
-
- const Flags &
- GetFlags () const
- {
- return m_flags;
- }
-
- //------------------------------------------------------------------
- /// Check if the input is being supplied interactively by a user
- ///
- /// This will return true if the input stream is a terminal (tty or
- /// pty) and can cause IO handlers to do different things (like
- /// for a confirmation when deleting all breakpoints).
- //------------------------------------------------------------------
- bool
- GetIsInteractive ();
-
- //------------------------------------------------------------------
- /// Check if the input is coming from a real terminal.
- ///
- /// A real terminal has a valid size with a certain number of rows
- /// and columns. If this function returns true, then terminal escape
- /// sequences are expected to work (cursor movement escape sequences,
- /// clearing lines, etc).
- //------------------------------------------------------------------
- bool
- GetIsRealTerminal ();
-
- void
- SetPopped (bool b);
-
- void
- WaitForPop ();
-
- virtual void
- PrintAsync (Stream *stream, const char *s, size_t len)
- {
- stream->Write (s, len);
- stream->Flush();
- }
-
- protected:
- Debugger &m_debugger;
- lldb::StreamFileSP m_input_sp;
- lldb::StreamFileSP m_output_sp;
- lldb::StreamFileSP m_error_sp;
- Predicate<bool> m_popped;
- Flags m_flags;
- Type m_type;
- void *m_user_data;
- bool m_done;
- bool m_active;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (IOHandler);
- };
-
- //------------------------------------------------------------------
- /// A delegate class for use with IOHandler subclasses.
- ///
- /// The IOHandler delegate is designed to be mixed into classes so
- /// they can use an IOHandler subclass to fetch input and notify the
- /// object that inherits from this delegate class when a token is
- /// received.
- //------------------------------------------------------------------
- class IOHandlerDelegate
- {
- public:
- enum class Completion {
- None,
- LLDBCommand,
- Expression
- };
-
- IOHandlerDelegate (Completion completion = Completion::None) :
- m_completion(completion),
- m_io_handler_done (false)
- {
- }
-
- virtual
- ~IOHandlerDelegate() = default;
-
- virtual void
- IOHandlerActivated (IOHandler &io_handler)
- {
- }
-
- virtual void
- IOHandlerDeactivated (IOHandler &io_handler)
- {
- }
-
- virtual int
- IOHandlerComplete (IOHandler &io_handler,
- const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches);
-
- virtual const char *
- IOHandlerGetFixIndentationCharacters ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- /// Called when a new line is created or one of an identified set of
- /// indentation characters is typed.
- ///
- /// This function determines how much indentation should be added
- /// or removed to match the recommended amount for the final line.
- ///
- /// @param[in] io_handler
- /// The IOHandler that responsible for input.
- ///
- /// @param[in] lines
- /// The current input up to the line to be corrected. Lines
- /// following the line containing the cursor are not included.
- ///
- /// @param[in] cursor_position
- /// The number of characters preceding the cursor on the final
- /// line at the time.
- ///
- /// @return
- /// Returns an integer describing the number of spaces needed
- /// to correct the indentation level. Positive values indicate
- /// that spaces should be added, while negative values represent
- /// spaces that should be removed.
- //------------------------------------------------------------------
- virtual int
- IOHandlerFixIndentation (IOHandler &io_handler,
- const StringList &lines,
- int cursor_position)
- {
- return 0;
- }
-
- //------------------------------------------------------------------
- /// Called when a line or lines have been retrieved.
- ///
- /// This function can handle the current line and possibly call
- /// IOHandler::SetIsDone(true) when the IO handler is done like when
- /// "quit" is entered as a command, of when an empty line is
- /// received. It is up to the delegate to determine when a line
- /// should cause a IOHandler to exit.
- //------------------------------------------------------------------
- virtual void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data) = 0;
-
- virtual void
- IOHandlerInputInterrupted (IOHandler &io_handler, std::string &data)
- {
- }
-
- //------------------------------------------------------------------
- /// Called to determine whether typing enter after the last line in
- /// \a lines should end input. This function will not be called on
- /// IOHandler objects that are getting single lines.
- /// @param[in] io_handler
- /// The IOHandler that responsible for updating the lines.
- ///
- /// @param[in] lines
- /// The current multi-line content. May be altered to provide
- /// alternative input when complete.
- ///
- /// @return
- /// Return an boolean to indicate whether input is complete,
- /// true indicates that no additional input is necessary, while
- /// false indicates that more input is required.
- //------------------------------------------------------------------
- virtual bool
- IOHandlerIsInputComplete (IOHandler &io_handler,
- StringList &lines)
- {
- // Impose no requirements for input to be considered
- // complete. subclasses should do something more intelligent.
- return true;
- }
-
- virtual ConstString
- IOHandlerGetControlSequence (char ch)
- {
- return ConstString();
- }
-
- virtual const char *
- IOHandlerGetCommandPrefix ()
- {
- return nullptr;
- }
-
- virtual const char *
- IOHandlerGetHelpPrologue ()
- {
- return nullptr;
- }
-
- //------------------------------------------------------------------
- // Intercept the IOHandler::Interrupt() calls and do something.
- //
- // Return true if the interrupt was handled, false if the IOHandler
- // should continue to try handle the interrupt itself.
- //------------------------------------------------------------------
- virtual bool
- IOHandlerInterrupt (IOHandler &io_handler)
- {
- return false;
- }
-
- protected:
- Completion m_completion; // Support for common builtin completions
- bool m_io_handler_done;
- };
-
- //----------------------------------------------------------------------
- // IOHandlerDelegateMultiline
- //
- // A IOHandlerDelegate that handles terminating multi-line input when
- // the last line is equal to "end_line" which is specified in the
- // constructor.
- //----------------------------------------------------------------------
- class IOHandlerDelegateMultiline :
- public IOHandlerDelegate
- {
- public:
- IOHandlerDelegateMultiline (const char *end_line,
- Completion completion = Completion::None) :
- IOHandlerDelegate (completion),
- m_end_line((end_line && end_line[0]) ? end_line : "")
- {
- }
-
- ~IOHandlerDelegateMultiline() override = default;
-
- ConstString
- IOHandlerGetControlSequence (char ch) override
- {
- if (ch == 'd')
- return ConstString (m_end_line + "\n");
- return ConstString();
- }
-
- bool
- IOHandlerIsInputComplete (IOHandler &io_handler,
- StringList &lines) override
- {
- // Determine whether the end of input signal has been entered
- const size_t num_lines = lines.GetSize();
- if (num_lines > 0 && lines[num_lines - 1] == m_end_line)
- {
- // Remove the terminal line from "lines" so it doesn't appear in
- // the resulting input and return true to indicate we are done
- // getting lines
- lines.PopBack();
- return true;
- }
- return false;
- }
-
- protected:
- const std::string m_end_line;
- };
-
- class IOHandlerEditline : public IOHandler
- {
- public:
- IOHandlerEditline (Debugger &debugger,
- IOHandler::Type type,
- const char *editline_name, // Used for saving history files
- const char *prompt,
- const char *continuation_prompt,
- bool multi_line,
- bool color_prompts,
- uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
- IOHandlerDelegate &delegate);
-
- IOHandlerEditline (Debugger &debugger,
- IOHandler::Type type,
- const lldb::StreamFileSP &input_sp,
- const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp,
- uint32_t flags,
- const char *editline_name, // Used for saving history files
- const char *prompt,
- const char *continuation_prompt,
- bool multi_line,
- bool color_prompts,
- uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
- IOHandlerDelegate &delegate);
-
- ~IOHandlerEditline() override;
-
- void
- Run () override;
-
- void
- Cancel () override;
-
- bool
- Interrupt () override;
-
- void
- GotEOF() override;
-
- void
- Activate () override;
-
- void
- Deactivate () override;
-
- ConstString
- GetControlSequence (char ch) override
- {
- return m_delegate.IOHandlerGetControlSequence (ch);
- }
-
- const char *
- GetCommandPrefix () override
- {
- return m_delegate.IOHandlerGetCommandPrefix ();
- }
-
- const char *
- GetHelpPrologue () override
- {
- return m_delegate.IOHandlerGetHelpPrologue ();
- }
-
- const char *
- GetPrompt () override;
-
- bool
- SetPrompt (const char *prompt) override;
-
- const char *
- GetContinuationPrompt ();
-
- void
- SetContinuationPrompt (const char *prompt);
-
- bool
- GetLine (std::string &line, bool &interrupted);
-
- bool
- GetLines (StringList &lines, bool &interrupted);
-
- void
- SetBaseLineNumber (uint32_t line);
-
- bool
- GetInterruptExits ()
- {
- return m_interrupt_exits;
- }
-
- void
- SetInterruptExits (bool b)
- {
- m_interrupt_exits = b;
- }
-
- const StringList *
- GetCurrentLines () const
- {
- return m_current_lines_ptr;
- }
-
- uint32_t
- GetCurrentLineIndex () const;
+class IOHandler {
+public:
+ enum class Type {
+ CommandInterpreter,
+ CommandList,
+ Confirm,
+ Curses,
+ Expression,
+ REPL,
+ ProcessIO,
+ PythonInterpreter,
+ PythonCode,
+ Other
+ };
+
+ IOHandler(Debugger &debugger, IOHandler::Type type);
+
+ IOHandler(Debugger &debugger, IOHandler::Type type,
+ const lldb::StreamFileSP &input_sp,
+ const lldb::StreamFileSP &output_sp,
+ const lldb::StreamFileSP &error_sp, uint32_t flags);
+
+ virtual ~IOHandler();
+
+ // Each IOHandler gets to run until it is done. It should read data
+ // from the "in" and place output into "out" and "err and return
+ // when done.
+ virtual void Run() = 0;
+
+ // Called when an input reader should relinquish its control so another
+ // can be pushed onto the IO handler stack, or so the current IO
+ // handler can pop itself off the stack
+
+ virtual void Cancel() = 0;
+
+ // Called when CTRL+C is pressed which usually causes
+ // Debugger::DispatchInputInterrupt to be called.
+
+ virtual bool Interrupt() = 0;
+
+ virtual void GotEOF() = 0;
+
+ virtual bool IsActive() { return m_active && !m_done; }
+
+ virtual void SetIsDone(bool b) { m_done = b; }
+
+ virtual bool GetIsDone() { return m_done; }
+
+ Type GetType() const { return m_type; }
+
+ virtual void Activate() { m_active = true; }
+
+ virtual void Deactivate() { m_active = false; }
+
+ virtual const char *GetPrompt() {
+ // Prompt support isn't mandatory
+ return nullptr;
+ }
+
+ virtual bool SetPrompt(const char *prompt) {
+ // Prompt support isn't mandatory
+ return false;
+ }
+
+ virtual ConstString GetControlSequence(char ch) { return ConstString(); }
+
+ virtual const char *GetCommandPrefix() { return nullptr; }
+
+ virtual const char *GetHelpPrologue() { return nullptr; }
+
+ int GetInputFD();
+
+ int GetOutputFD();
+
+ int GetErrorFD();
+
+ FILE *GetInputFILE();
+
+ FILE *GetOutputFILE();
+
+ FILE *GetErrorFILE();
+
+ lldb::StreamFileSP &GetInputStreamFile();
+
+ lldb::StreamFileSP &GetOutputStreamFile();
+
+ lldb::StreamFileSP &GetErrorStreamFile();
+
+ Debugger &GetDebugger() { return m_debugger; }
+
+ void *GetUserData() { return m_user_data; }
+
+ void SetUserData(void *user_data) { m_user_data = user_data; }
+
+ Flags &GetFlags() { return m_flags; }
+
+ const Flags &GetFlags() const { return m_flags; }
+
+ //------------------------------------------------------------------
+ /// Check if the input is being supplied interactively by a user
+ ///
+ /// This will return true if the input stream is a terminal (tty or
+ /// pty) and can cause IO handlers to do different things (like
+ /// for a confirmation when deleting all breakpoints).
+ //------------------------------------------------------------------
+ bool GetIsInteractive();
+
+ //------------------------------------------------------------------
+ /// Check if the input is coming from a real terminal.
+ ///
+ /// A real terminal has a valid size with a certain number of rows
+ /// and columns. If this function returns true, then terminal escape
+ /// sequences are expected to work (cursor movement escape sequences,
+ /// clearing lines, etc).
+ //------------------------------------------------------------------
+ bool GetIsRealTerminal();
+
+ void SetPopped(bool b);
+
+ void WaitForPop();
+
+ virtual void PrintAsync(Stream *stream, const char *s, size_t len) {
+ stream->Write(s, len);
+ stream->Flush();
+ }
+
+protected:
+ Debugger &m_debugger;
+ lldb::StreamFileSP m_input_sp;
+ lldb::StreamFileSP m_output_sp;
+ lldb::StreamFileSP m_error_sp;
+ Predicate<bool> m_popped;
+ Flags m_flags;
+ Type m_type;
+ void *m_user_data;
+ bool m_done;
+ bool m_active;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(IOHandler);
+};
+
+//------------------------------------------------------------------
+/// A delegate class for use with IOHandler subclasses.
+///
+/// The IOHandler delegate is designed to be mixed into classes so
+/// they can use an IOHandler subclass to fetch input and notify the
+/// object that inherits from this delegate class when a token is
+/// received.
+//------------------------------------------------------------------
+class IOHandlerDelegate {
+public:
+ enum class Completion { None, LLDBCommand, Expression };
+
+ IOHandlerDelegate(Completion completion = Completion::None)
+ : m_completion(completion), m_io_handler_done(false) {}
+
+ virtual ~IOHandlerDelegate() = default;
+
+ virtual void IOHandlerActivated(IOHandler &io_handler) {}
+
+ virtual void IOHandlerDeactivated(IOHandler &io_handler) {}
+
+ virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches);
+
+ virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; }
+
+ //------------------------------------------------------------------
+ /// Called when a new line is created or one of an identified set of
+ /// indentation characters is typed.
+ ///
+ /// This function determines how much indentation should be added
+ /// or removed to match the recommended amount for the final line.
+ ///
+ /// @param[in] io_handler
+ /// The IOHandler that responsible for input.
+ ///
+ /// @param[in] lines
+ /// The current input up to the line to be corrected. Lines
+ /// following the line containing the cursor are not included.
+ ///
+ /// @param[in] cursor_position
+ /// The number of characters preceding the cursor on the final
+ /// line at the time.
+ ///
+ /// @return
+ /// Returns an integer describing the number of spaces needed
+ /// to correct the indentation level. Positive values indicate
+ /// that spaces should be added, while negative values represent
+ /// spaces that should be removed.
+ //------------------------------------------------------------------
+ virtual int IOHandlerFixIndentation(IOHandler &io_handler,
+ const StringList &lines,
+ int cursor_position) {
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ /// Called when a line or lines have been retrieved.
+ ///
+ /// This function can handle the current line and possibly call
+ /// IOHandler::SetIsDone(true) when the IO handler is done like when
+ /// "quit" is entered as a command, of when an empty line is
+ /// received. It is up to the delegate to determine when a line
+ /// should cause a IOHandler to exit.
+ //------------------------------------------------------------------
+ virtual void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) = 0;
+
+ virtual void IOHandlerInputInterrupted(IOHandler &io_handler,
+ std::string &data) {}
+
+ //------------------------------------------------------------------
+ /// Called to determine whether typing enter after the last line in
+ /// \a lines should end input. This function will not be called on
+ /// IOHandler objects that are getting single lines.
+ /// @param[in] io_handler
+ /// The IOHandler that responsible for updating the lines.
+ ///
+ /// @param[in] lines
+ /// The current multi-line content. May be altered to provide
+ /// alternative input when complete.
+ ///
+ /// @return
+ /// Return an boolean to indicate whether input is complete,
+ /// true indicates that no additional input is necessary, while
+ /// false indicates that more input is required.
+ //------------------------------------------------------------------
+ virtual bool IOHandlerIsInputComplete(IOHandler &io_handler,
+ StringList &lines) {
+ // Impose no requirements for input to be considered
+ // complete. subclasses should do something more intelligent.
+ return true;
+ }
+
+ virtual ConstString IOHandlerGetControlSequence(char ch) {
+ return ConstString();
+ }
+
+ virtual const char *IOHandlerGetCommandPrefix() { return nullptr; }
+
+ virtual const char *IOHandlerGetHelpPrologue() { return nullptr; }
+
+ //------------------------------------------------------------------
+ // Intercept the IOHandler::Interrupt() calls and do something.
+ //
+ // Return true if the interrupt was handled, false if the IOHandler
+ // should continue to try handle the interrupt itself.
+ //------------------------------------------------------------------
+ virtual bool IOHandlerInterrupt(IOHandler &io_handler) { return false; }
+
+protected:
+ Completion m_completion; // Support for common builtin completions
+ bool m_io_handler_done;
+};
+
+//----------------------------------------------------------------------
+// IOHandlerDelegateMultiline
+//
+// A IOHandlerDelegate that handles terminating multi-line input when
+// the last line is equal to "end_line" which is specified in the
+// constructor.
+//----------------------------------------------------------------------
+class IOHandlerDelegateMultiline : public IOHandlerDelegate {
+public:
+ IOHandlerDelegateMultiline(const char *end_line,
+ Completion completion = Completion::None)
+ : IOHandlerDelegate(completion),
+ m_end_line((end_line && end_line[0]) ? end_line : "") {}
+
+ ~IOHandlerDelegateMultiline() override = default;
+
+ ConstString IOHandlerGetControlSequence(char ch) override {
+ if (ch == 'd')
+ return ConstString(m_end_line + "\n");
+ return ConstString();
+ }
+
+ bool IOHandlerIsInputComplete(IOHandler &io_handler,
+ StringList &lines) override {
+ // Determine whether the end of input signal has been entered
+ const size_t num_lines = lines.GetSize();
+ if (num_lines > 0 && lines[num_lines - 1] == m_end_line) {
+ // Remove the terminal line from "lines" so it doesn't appear in
+ // the resulting input and return true to indicate we are done
+ // getting lines
+ lines.PopBack();
+ return true;
+ }
+ return false;
+ }
+
+protected:
+ const std::string m_end_line;
+};
+
+class IOHandlerEditline : public IOHandler {
+public:
+ IOHandlerEditline(Debugger &debugger, IOHandler::Type type,
+ const char *editline_name, // Used for saving history files
+ const char *prompt, const char *continuation_prompt,
+ bool multi_line, bool color_prompts,
+ uint32_t line_number_start, // If non-zero show line numbers
+ // starting at
+ // 'line_number_start'
+ IOHandlerDelegate &delegate);
+
+ IOHandlerEditline(Debugger &debugger, IOHandler::Type type,
+ const lldb::StreamFileSP &input_sp,
+ const lldb::StreamFileSP &output_sp,
+ const lldb::StreamFileSP &error_sp, uint32_t flags,
+ const char *editline_name, // Used for saving history files
+ const char *prompt, const char *continuation_prompt,
+ bool multi_line, bool color_prompts,
+ uint32_t line_number_start, // If non-zero show line numbers
+ // starting at
+ // 'line_number_start'
+ IOHandlerDelegate &delegate);
+
+ ~IOHandlerEditline() override;
+
+ void Run() override;
+
+ void Cancel() override;
+
+ bool Interrupt() override;
+
+ void GotEOF() override;
+
+ void Activate() override;
+
+ void Deactivate() override;
+
+ ConstString GetControlSequence(char ch) override {
+ return m_delegate.IOHandlerGetControlSequence(ch);
+ }
+
+ const char *GetCommandPrefix() override {
+ return m_delegate.IOHandlerGetCommandPrefix();
+ }
+
+ const char *GetHelpPrologue() override {
+ return m_delegate.IOHandlerGetHelpPrologue();
+ }
+
+ const char *GetPrompt() override;
+
+ bool SetPrompt(const char *prompt) override;
+
+ const char *GetContinuationPrompt();
+
+ void SetContinuationPrompt(const char *prompt);
+
+ bool GetLine(std::string &line, bool &interrupted);
+
+ bool GetLines(StringList &lines, bool &interrupted);
+
+ void SetBaseLineNumber(uint32_t line);
+
+ bool GetInterruptExits() { return m_interrupt_exits; }
+
+ void SetInterruptExits(bool b) { m_interrupt_exits = b; }
+
+ const StringList *GetCurrentLines() const { return m_current_lines_ptr; }
+
+ uint32_t GetCurrentLineIndex() const;
- void
- PrintAsync (Stream *stream, const char *s, size_t len) override;
+ void PrintAsync(Stream *stream, const char *s, size_t len) override;
- private:
+private:
#ifndef LLDB_DISABLE_LIBEDIT
- static bool
- IsInputCompleteCallback (Editline *editline,
- StringList &lines,
- void *baton);
-
- static int
- FixIndentationCallback (Editline *editline,
- const StringList &lines,
- int cursor_position,
- void *baton);
-
- static int AutoCompleteCallback (const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches,
- void *baton);
+ static bool IsInputCompleteCallback(Editline *editline, StringList &lines,
+ void *baton);
+
+ static int FixIndentationCallback(Editline *editline, const StringList &lines,
+ int cursor_position, void *baton);
+
+ static int AutoCompleteCallback(const char *current_line, const char *cursor,
+ const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches, void *baton);
#endif
- protected:
+protected:
#ifndef LLDB_DISABLE_LIBEDIT
- std::unique_ptr<Editline> m_editline_ap;
+ std::unique_ptr<Editline> m_editline_ap;
#endif
- IOHandlerDelegate &m_delegate;
- std::string m_prompt;
- std::string m_continuation_prompt;
- StringList *m_current_lines_ptr;
- uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
- uint32_t m_curr_line_idx;
- bool m_multi_line;
- bool m_color_prompts;
- bool m_interrupt_exits;
- bool m_editing; // Set to true when fetching a line manually (not using libedit)
- };
-
- // The order of base classes is important. Look at the constructor of IOHandlerConfirm
- // to see how.
- class IOHandlerConfirm :
- public IOHandlerDelegate,
- public IOHandlerEditline
- {
- public:
- IOHandlerConfirm (Debugger &debugger,
- const char *prompt,
- bool default_response);
-
- ~IOHandlerConfirm() override;
-
- bool
- GetResponse () const
- {
- return m_user_response;
- }
-
- int
- IOHandlerComplete (IOHandler &io_handler,
- const char *current_line,
- const char *cursor,
- const char *last_char,
- int skip_first_n_matches,
- int max_matches,
- StringList &matches) override;
-
- void
- IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override;
-
- protected:
- const bool m_default_response;
- bool m_user_response;
- };
+ IOHandlerDelegate &m_delegate;
+ std::string m_prompt;
+ std::string m_continuation_prompt;
+ StringList *m_current_lines_ptr;
+ uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
+ uint32_t m_curr_line_idx;
+ bool m_multi_line;
+ bool m_color_prompts;
+ bool m_interrupt_exits;
+ bool m_editing; // Set to true when fetching a line manually (not using
+ // libedit)
+};
- class IOHandlerCursesGUI :
- public IOHandler
- {
- public:
- IOHandlerCursesGUI (Debugger &debugger);
-
- ~IOHandlerCursesGUI () override;
-
- void
- Run () override;
-
- void
- Cancel () override;
-
- bool
- Interrupt () override;
-
- void
- GotEOF() override;
-
- void
- Activate () override;
-
- void
- Deactivate () override;
-
- protected:
- curses::ApplicationAP m_app_ap;
- };
+// The order of base classes is important. Look at the constructor of
+// IOHandlerConfirm
+// to see how.
+class IOHandlerConfirm : public IOHandlerDelegate, public IOHandlerEditline {
+public:
+ IOHandlerConfirm(Debugger &debugger, const char *prompt,
+ bool default_response);
- class IOHandlerCursesValueObjectList :
- public IOHandler
- {
- public:
- IOHandlerCursesValueObjectList (Debugger &debugger, ValueObjectList &valobj_list);
-
- ~IOHandlerCursesValueObjectList() override;
-
- void
- Run () override;
-
- void
- GotEOF() override;
-
- protected:
- ValueObjectList m_valobj_list;
- };
+ ~IOHandlerConfirm() override;
- class IOHandlerStack
- {
- public:
- IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
+ bool GetResponse() const { return m_user_response; }
+
+ int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
+ const char *cursor, const char *last_char,
+ int skip_first_n_matches, int max_matches,
+ StringList &matches) override;
+
+ void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) override;
+
+protected:
+ const bool m_default_response;
+ bool m_user_response;
+};
- ~IOHandlerStack() = default;
+class IOHandlerCursesGUI : public IOHandler {
+public:
+ IOHandlerCursesGUI(Debugger &debugger);
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_stack.size();
- }
-
- void
- Push(const lldb::IOHandlerSP &sp)
- {
- if (sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- sp->SetPopped(false);
- m_stack.push_back(sp);
- // Set m_top the non-locking IsTop() call
- m_top = sp.get();
- }
- }
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_stack.empty();
- }
-
- lldb::IOHandlerSP
- Top()
- {
- lldb::IOHandlerSP sp;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_stack.empty())
- sp = m_stack.back();
- }
- return sp;
- }
-
- void
- Pop()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_stack.empty())
- {
- lldb::IOHandlerSP sp(m_stack.back());
- m_stack.pop_back();
- sp->SetPopped(true);
- }
- // Set m_top the non-locking IsTop() call
-
- m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
-
- bool
- IsTop (const lldb::IOHandlerSP &io_handler_sp) const
- {
- return m_top == io_handler_sp.get();
- }
-
- bool
- CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const size_t num_io_handlers = m_stack.size();
- return (num_io_handlers >= 2 && m_stack[num_io_handlers - 1]->GetType() == top_type &&
- m_stack[num_io_handlers - 2]->GetType() == second_top_type);
- }
-
- ConstString
- GetTopIOHandlerControlSequence (char ch)
- {
- return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString());
- }
-
- const char *
- GetTopIOHandlerCommandPrefix()
- {
- return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr);
- }
-
- const char *
- GetTopIOHandlerHelpPrologue()
- {
- return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr);
- }
-
- void
- PrintAsync (Stream *stream, const char *s, size_t len);
-
- protected:
- typedef std::vector<lldb::IOHandlerSP> collection;
- collection m_stack;
- mutable std::recursive_mutex m_mutex;
- IOHandler *m_top;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (IOHandlerStack);
- };
+ ~IOHandlerCursesGUI() override;
+
+ void Run() override;
+
+ void Cancel() override;
+
+ bool Interrupt() override;
+
+ void GotEOF() override;
+
+ void Activate() override;
+
+ void Deactivate() override;
+
+protected:
+ curses::ApplicationAP m_app_ap;
+};
+
+class IOHandlerCursesValueObjectList : public IOHandler {
+public:
+ IOHandlerCursesValueObjectList(Debugger &debugger,
+ ValueObjectList &valobj_list);
+
+ ~IOHandlerCursesValueObjectList() override;
+
+ void Run() override;
+
+ void GotEOF() override;
+
+protected:
+ ValueObjectList m_valobj_list;
+};
+
+class IOHandlerStack {
+public:
+ IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
+
+ ~IOHandlerStack() = default;
+
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_stack.size();
+ }
+
+ void Push(const lldb::IOHandlerSP &sp) {
+ if (sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ sp->SetPopped(false);
+ m_stack.push_back(sp);
+ // Set m_top the non-locking IsTop() call
+ m_top = sp.get();
+ }
+ }
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_stack.empty();
+ }
+
+ lldb::IOHandlerSP Top() {
+ lldb::IOHandlerSP sp;
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_stack.empty())
+ sp = m_stack.back();
+ }
+ return sp;
+ }
+
+ void Pop() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_stack.empty()) {
+ lldb::IOHandlerSP sp(m_stack.back());
+ m_stack.pop_back();
+ sp->SetPopped(true);
+ }
+ // Set m_top the non-locking IsTop() call
+
+ m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
+ }
+
+ std::recursive_mutex &GetMutex() { return m_mutex; }
+
+ bool IsTop(const lldb::IOHandlerSP &io_handler_sp) const {
+ return m_top == io_handler_sp.get();
+ }
+
+ bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
+ IOHandler::Type second_top_type) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const size_t num_io_handlers = m_stack.size();
+ return (num_io_handlers >= 2 &&
+ m_stack[num_io_handlers - 1]->GetType() == top_type &&
+ m_stack[num_io_handlers - 2]->GetType() == second_top_type);
+ }
+
+ ConstString GetTopIOHandlerControlSequence(char ch) {
+ return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString());
+ }
+
+ const char *GetTopIOHandlerCommandPrefix() {
+ return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr);
+ }
+
+ const char *GetTopIOHandlerHelpPrologue() {
+ return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr);
+ }
+
+ void PrintAsync(Stream *stream, const char *s, size_t len);
+
+protected:
+ typedef std::vector<lldb::IOHandlerSP> collection;
+ collection m_stack;
+ mutable std::recursive_mutex m_mutex;
+ IOHandler *m_top;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(IOHandlerStack);
+};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/IOStreamMacros.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOStreamMacros.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/IOStreamMacros.h (original)
+++ lldb/trunk/include/lldb/Core/IOStreamMacros.h Tue Sep 6 15:57:50 2016
@@ -13,26 +13,30 @@
#include <iomanip>
-#define RAW_HEXBASE std::setfill('0') << std::hex << std::right
-#define HEXBASE '0' << 'x' << RAW_HEXBASE
-#define RAWHEX8(x) RAW_HEXBASE << std::setw(2) << ((uint32_t)(x))
-#define RAWHEX16 RAW_HEXBASE << std::setw(4)
-#define RAWHEX32 RAW_HEXBASE << std::setw(8)
-#define RAWHEX64 RAW_HEXBASE << std::setw(16)
-#define HEX8(x) HEXBASE << std::setw(2) << ((uint32_t)(x))
-#define HEX16 HEXBASE << std::setw(4)
-#define HEX32 HEXBASE << std::setw(8)
-#define HEX64 HEXBASE << std::setw(16)
-#define RAW_HEX(x) RAW_HEXBASE << std::setw(sizeof(x)*2) << (x)
-#define HEX(x) HEXBASE << std::setw(sizeof(x)*2) << (x)
+#define RAW_HEXBASE std::setfill('0') << std::hex << std::right
+#define HEXBASE '0' << 'x' << RAW_HEXBASE
+#define RAWHEX8(x) RAW_HEXBASE << std::setw(2) << ((uint32_t)(x))
+#define RAWHEX16 RAW_HEXBASE << std::setw(4)
+#define RAWHEX32 RAW_HEXBASE << std::setw(8)
+#define RAWHEX64 RAW_HEXBASE << std::setw(16)
+#define HEX8(x) HEXBASE << std::setw(2) << ((uint32_t)(x))
+#define HEX16 HEXBASE << std::setw(4)
+#define HEX32 HEXBASE << std::setw(8)
+#define HEX64 HEXBASE << std::setw(16)
+#define RAW_HEX(x) RAW_HEXBASE << std::setw(sizeof(x) * 2) << (x)
+#define HEX(x) HEXBASE << std::setw(sizeof(x) * 2) << (x)
#define HEX_SIZE(x, sz) HEXBASE << std::setw((sz)) << (x)
#define STRING_WIDTH(w) std::setfill(' ') << std::setw(w)
-#define LEFT_STRING_WIDTH(s, w) std::left << std::setfill(' ') << std::setw(w) << (s) << std::right
-#define DECIMAL std::dec << std::setfill(' ')
+#define LEFT_STRING_WIDTH(s, w) \
+ std::left << std::setfill(' ') << std::setw(w) << (s) << std::right
+#define DECIMAL std::dec << std::setfill(' ')
#define DECIMAL_WIDTH(w) DECIMAL << std::setw(w)
-//#define FLOAT(n, d) std::setfill(' ') << std::setw((n)+(d)+1) << std::setprecision(d) << std::showpoint << std::fixed
-#define INDENT_WITH_SPACES(iword_idx) std::setfill(' ') << std::setw((iword_idx)) << ""
-#define INDENT_WITH_TABS(iword_idx) std::setfill('\t') << std::setw((iword_idx)) << ""
+//#define FLOAT(n, d) std::setfill(' ') << std::setw((n)+(d)+1) <<
+//std::setprecision(d) << std::showpoint << std::fixed
+#define INDENT_WITH_SPACES(iword_idx) \
+ std::setfill(' ') << std::setw((iword_idx)) << ""
+#define INDENT_WITH_TABS(iword_idx) \
+ std::setfill('\t') << std::setw((iword_idx)) << ""
-#endif // #if defined(__cplusplus)
-#endif // liblldb_IOStreamMacros_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_IOStreamMacros_h_
Modified: lldb/trunk/include/lldb/Core/Listener.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Listener.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Listener.h (original)
+++ lldb/trunk/include/lldb/Core/Listener.h Tue Sep 6 15:57:50 2016
@@ -21,173 +21,147 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Event.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Listener :
- public std::enable_shared_from_this<Listener>
-{
+class Listener : public std::enable_shared_from_this<Listener> {
public:
- typedef bool (*HandleBroadcastCallback) (lldb::EventSP &event_sp, void *baton);
+ typedef bool (*HandleBroadcastCallback)(lldb::EventSP &event_sp, void *baton);
- friend class Broadcaster;
- friend class BroadcasterManager;
+ friend class Broadcaster;
+ friend class BroadcasterManager;
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- //
- // Listeners have to be constructed into shared pointers - at least if you want them to listen to
- // Broadcasters,
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ //
+ // Listeners have to be constructed into shared pointers - at least if you
+ // want them to listen to
+ // Broadcasters,
protected:
- Listener (const char *name);
+ Listener(const char *name);
public:
- static lldb::ListenerSP
- MakeListener(const char *name);
-
- ~Listener ();
-
- void
- AddEvent (lldb::EventSP &event);
-
- void
- Clear ();
-
- const char *
- GetName ()
- {
- return m_name.c_str();
- }
+ static lldb::ListenerSP MakeListener(const char *name);
- uint32_t
- StartListeningForEventSpec (lldb::BroadcasterManagerSP manager_sp,
- const BroadcastEventSpec &event_spec);
-
- bool
- StopListeningForEventSpec (lldb::BroadcasterManagerSP manager_sp,
+ ~Listener();
+
+ void AddEvent(lldb::EventSP &event);
+
+ void Clear();
+
+ const char *GetName() { return m_name.c_str(); }
+
+ uint32_t StartListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
+ const BroadcastEventSpec &event_spec);
+
+ bool StopListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
const BroadcastEventSpec &event_spec);
-
- uint32_t
- StartListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask);
-
- uint32_t
- StartListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask,
- HandleBroadcastCallback callback,
- void *callback_user_data);
-
- bool
- StopListeningForEvents (Broadcaster* broadcaster,
- uint32_t event_mask);
-
- // Returns true if an event was received, false if we timed out.
- bool
- WaitForEvent(const std::chrono::microseconds &timeout, lldb::EventSP &event_sp);
-
- bool
- WaitForEventForBroadcaster(const std::chrono::microseconds &timeout, Broadcaster *broadcaster,
- lldb::EventSP &event_sp);
-
- bool
- WaitForEventForBroadcasterWithType(const std::chrono::microseconds &timeout, Broadcaster *broadcaster,
- uint32_t event_type_mask, lldb::EventSP &event_sp);
-
- Event *
- PeekAtNextEvent ();
-
- Event *
- PeekAtNextEventForBroadcaster (Broadcaster *broadcaster);
-
- Event *
- PeekAtNextEventForBroadcasterWithType (Broadcaster *broadcaster,
- uint32_t event_type_mask);
-
- bool
- GetNextEvent (lldb::EventSP &event_sp);
-
- bool
- GetNextEventForBroadcaster (Broadcaster *broadcaster,
- lldb::EventSP &event_sp);
-
- bool
- GetNextEventForBroadcasterWithType (Broadcaster *broadcaster,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
- size_t
- HandleBroadcastEvent (lldb::EventSP &event_sp);
+ uint32_t StartListeningForEvents(Broadcaster *broadcaster,
+ uint32_t event_mask);
+
+ uint32_t StartListeningForEvents(Broadcaster *broadcaster,
+ uint32_t event_mask,
+ HandleBroadcastCallback callback,
+ void *callback_user_data);
+
+ bool StopListeningForEvents(Broadcaster *broadcaster, uint32_t event_mask);
+
+ // Returns true if an event was received, false if we timed out.
+ bool WaitForEvent(const std::chrono::microseconds &timeout,
+ lldb::EventSP &event_sp);
+
+ bool WaitForEventForBroadcaster(const std::chrono::microseconds &timeout,
+ Broadcaster *broadcaster,
+ lldb::EventSP &event_sp);
+
+ bool WaitForEventForBroadcasterWithType(
+ const std::chrono::microseconds &timeout, Broadcaster *broadcaster,
+ uint32_t event_type_mask, lldb::EventSP &event_sp);
+
+ Event *PeekAtNextEvent();
+
+ Event *PeekAtNextEventForBroadcaster(Broadcaster *broadcaster);
+
+ Event *PeekAtNextEventForBroadcasterWithType(Broadcaster *broadcaster,
+ uint32_t event_type_mask);
+
+ bool GetNextEvent(lldb::EventSP &event_sp);
+
+ bool GetNextEventForBroadcaster(Broadcaster *broadcaster,
+ lldb::EventSP &event_sp);
+
+ bool GetNextEventForBroadcasterWithType(Broadcaster *broadcaster,
+ uint32_t event_type_mask,
+ lldb::EventSP &event_sp);
+
+ size_t HandleBroadcastEvent(lldb::EventSP &event_sp);
private:
- //------------------------------------------------------------------
- // Classes that inherit from Listener can see and modify these
- //------------------------------------------------------------------
- struct BroadcasterInfo
- {
- BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) :
- event_mask (mask),
- callback (cb),
- callback_user_data (ud)
- {
- }
-
- uint32_t event_mask;
- HandleBroadcastCallback callback;
- void *callback_user_data;
- };
-
- typedef std::multimap<Broadcaster::BroadcasterImplWP,
- BroadcasterInfo,
- std::owner_less<Broadcaster::BroadcasterImplWP>> broadcaster_collection;
- typedef std::list<lldb::EventSP> event_collection;
- typedef std::vector<lldb::BroadcasterManagerWP> broadcaster_manager_collection;
-
- bool
- FindNextEventInternal(std::unique_lock<std::mutex> &lock,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources, uint32_t event_type_mask, lldb::EventSP &event_sp, bool remove);
-
- bool
- GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources,
- uint32_t event_type_mask,
- lldb::EventSP &event_sp);
-
- bool
- WaitForEventsInternal(const std::chrono::microseconds &timeout,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources, uint32_t event_type_mask, lldb::EventSP &event_sp);
-
- std::string m_name;
- broadcaster_collection m_broadcasters;
- std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
- event_collection m_events;
- std::mutex m_events_mutex; // Protects m_broadcasters and m_events
- std::condition_variable m_events_condition;
- broadcaster_manager_collection m_broadcaster_managers;
-
- void
- BroadcasterWillDestruct (Broadcaster *);
-
- void
- BroadcasterManagerWillDestruct (lldb::BroadcasterManagerSP manager_sp);
-
-
-// broadcaster_collection::iterator
-// FindBroadcasterWithMask (Broadcaster *broadcaster,
-// uint32_t event_mask,
-// bool exact);
-
- //------------------------------------------------------------------
- // For Listener only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (Listener);
+ //------------------------------------------------------------------
+ // Classes that inherit from Listener can see and modify these
+ //------------------------------------------------------------------
+ struct BroadcasterInfo {
+ BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr,
+ void *ud = nullptr)
+ : event_mask(mask), callback(cb), callback_user_data(ud) {}
+
+ uint32_t event_mask;
+ HandleBroadcastCallback callback;
+ void *callback_user_data;
+ };
+
+ typedef std::multimap<Broadcaster::BroadcasterImplWP, BroadcasterInfo,
+ std::owner_less<Broadcaster::BroadcasterImplWP>>
+ broadcaster_collection;
+ typedef std::list<lldb::EventSP> event_collection;
+ typedef std::vector<lldb::BroadcasterManagerWP>
+ broadcaster_manager_collection;
+
+ bool
+ FindNextEventInternal(std::unique_lock<std::mutex> &lock,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources, uint32_t event_type_mask,
+ lldb::EventSP &event_sp, bool remove);
+
+ bool
+ GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources, uint32_t event_type_mask,
+ lldb::EventSP &event_sp);
+
+ bool
+ WaitForEventsInternal(const std::chrono::microseconds &timeout,
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ const ConstString *sources, // nullptr for any event
+ uint32_t num_sources, uint32_t event_type_mask,
+ lldb::EventSP &event_sp);
+
+ std::string m_name;
+ broadcaster_collection m_broadcasters;
+ std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
+ event_collection m_events;
+ std::mutex m_events_mutex; // Protects m_broadcasters and m_events
+ std::condition_variable m_events_condition;
+ broadcaster_manager_collection m_broadcaster_managers;
+
+ void BroadcasterWillDestruct(Broadcaster *);
+
+ void BroadcasterManagerWillDestruct(lldb::BroadcasterManagerSP manager_sp);
+
+ // broadcaster_collection::iterator
+ // FindBroadcasterWithMask (Broadcaster *broadcaster,
+ // uint32_t event_mask,
+ // bool exact);
+
+ //------------------------------------------------------------------
+ // For Listener only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(Listener);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h (original)
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h Tue Sep 6 15:57:50 2016
@@ -19,134 +19,101 @@
#include "lldb/lldb-private-forward.h"
namespace lldb_private {
-class LoadedModuleInfoList
-{
+class LoadedModuleInfoList {
public:
+ class LoadedModuleInfo {
+ public:
+ enum e_data_point {
+ e_has_name = 0,
+ e_has_base,
+ e_has_dynamic,
+ e_has_link_map,
+ e_num
+ };
- class LoadedModuleInfo
- {
- public:
-
- enum e_data_point
- {
- e_has_name = 0,
- e_has_base ,
- e_has_dynamic ,
- e_has_link_map ,
- e_num
- };
-
- LoadedModuleInfo ()
- {
- for (uint32_t i = 0; i < e_num; ++i)
- m_has[i] = false;
- };
-
- void set_name (const std::string & name)
- {
- m_name = name;
- m_has[e_has_name] = true;
- }
- bool get_name (std::string & out) const
- {
- out = m_name;
- return m_has[e_has_name];
- }
-
- void set_base (const lldb::addr_t base)
- {
- m_base = base;
- m_has[e_has_base] = true;
- }
- bool get_base (lldb::addr_t & out) const
- {
- out = m_base;
- return m_has[e_has_base];
- }
-
- void set_base_is_offset (bool is_offset)
- {
- m_base_is_offset = is_offset;
- }
- bool get_base_is_offset(bool & out) const
- {
- out = m_base_is_offset;
- return m_has[e_has_base];
- }
-
- void set_link_map (const lldb::addr_t addr)
- {
- m_link_map = addr;
- m_has[e_has_link_map] = true;
- }
- bool get_link_map (lldb::addr_t & out) const
- {
- out = m_link_map;
- return m_has[e_has_link_map];
- }
-
- void set_dynamic (const lldb::addr_t addr)
- {
- m_dynamic = addr;
- m_has[e_has_dynamic] = true;
- }
- bool get_dynamic (lldb::addr_t & out) const
- {
- out = m_dynamic;
- return m_has[e_has_dynamic];
- }
-
- bool has_info (e_data_point datum) const
- {
- assert (datum < e_num);
- return m_has[datum];
- }
-
- bool
- operator == (LoadedModuleInfo const &rhs) const
- {
- if (e_num != rhs.e_num)
- return false;
-
- for (size_t i = 0; i < e_num; ++i)
- {
- if (m_has[i] != rhs.m_has[i])
- return false;
- }
-
- return (m_base == rhs.m_base) &&
- (m_link_map == rhs.m_link_map) &&
- (m_dynamic == rhs.m_dynamic) &&
- (m_name == rhs.m_name);
- }
- protected:
-
- bool m_has[e_num];
- std::string m_name;
- lldb::addr_t m_link_map;
- lldb::addr_t m_base;
- bool m_base_is_offset;
- lldb::addr_t m_dynamic;
+ LoadedModuleInfo() {
+ for (uint32_t i = 0; i < e_num; ++i)
+ m_has[i] = false;
};
- LoadedModuleInfoList ()
- : m_list ()
- , m_link_map (LLDB_INVALID_ADDRESS)
- {}
+ void set_name(const std::string &name) {
+ m_name = name;
+ m_has[e_has_name] = true;
+ }
+ bool get_name(std::string &out) const {
+ out = m_name;
+ return m_has[e_has_name];
+ }
+
+ void set_base(const lldb::addr_t base) {
+ m_base = base;
+ m_has[e_has_base] = true;
+ }
+ bool get_base(lldb::addr_t &out) const {
+ out = m_base;
+ return m_has[e_has_base];
+ }
+
+ void set_base_is_offset(bool is_offset) { m_base_is_offset = is_offset; }
+ bool get_base_is_offset(bool &out) const {
+ out = m_base_is_offset;
+ return m_has[e_has_base];
+ }
- void add (const LoadedModuleInfo & mod)
- {
- m_list.push_back (mod);
+ void set_link_map(const lldb::addr_t addr) {
+ m_link_map = addr;
+ m_has[e_has_link_map] = true;
+ }
+ bool get_link_map(lldb::addr_t &out) const {
+ out = m_link_map;
+ return m_has[e_has_link_map];
}
- void clear ()
- {
- m_list.clear ();
+ void set_dynamic(const lldb::addr_t addr) {
+ m_dynamic = addr;
+ m_has[e_has_dynamic] = true;
+ }
+ bool get_dynamic(lldb::addr_t &out) const {
+ out = m_dynamic;
+ return m_has[e_has_dynamic];
}
- std::vector<LoadedModuleInfo> m_list;
+ bool has_info(e_data_point datum) const {
+ assert(datum < e_num);
+ return m_has[datum];
+ }
+
+ bool operator==(LoadedModuleInfo const &rhs) const {
+ if (e_num != rhs.e_num)
+ return false;
+
+ for (size_t i = 0; i < e_num; ++i) {
+ if (m_has[i] != rhs.m_has[i])
+ return false;
+ }
+
+ return (m_base == rhs.m_base) && (m_link_map == rhs.m_link_map) &&
+ (m_dynamic == rhs.m_dynamic) && (m_name == rhs.m_name);
+ }
+
+ protected:
+ bool m_has[e_num];
+ std::string m_name;
lldb::addr_t m_link_map;
+ lldb::addr_t m_base;
+ bool m_base_is_offset;
+ lldb::addr_t m_dynamic;
+ };
+
+ LoadedModuleInfoList() : m_list(), m_link_map(LLDB_INVALID_ADDRESS) {}
+
+ void add(const LoadedModuleInfo &mod) { m_list.push_back(mod); }
+
+ void clear() { m_list.clear(); }
+
+ std::vector<LoadedModuleInfo> m_list;
+ lldb::addr_t m_link_map;
};
} // namespace lldb_private
-#endif // liblldb_LoadedModuleInfoList_h_
+#endif // liblldb_LoadedModuleInfoList_h_
Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Tue Sep 6 15:57:50 2016
@@ -11,179 +11,159 @@
#define liblldb_Log_h_
// C Includes
+#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
-#include <signal.h>
#include <stdio.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Logging.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/lldb-private.h"
//----------------------------------------------------------------------
// Logging Options
//----------------------------------------------------------------------
-#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
-#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
-#define LLDB_LOG_OPTION_DEBUG (1u << 2)
-#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
-#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
+#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
+#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
+#define LLDB_LOG_OPTION_DEBUG (1u << 2)
+#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
+#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
-#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
-#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
-#define LLDB_LOG_OPTION_APPEND (1U << 8)
+#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
+#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
+#define LLDB_LOG_OPTION_APPEND (1U << 8)
//----------------------------------------------------------------------
// Logging Functions
//----------------------------------------------------------------------
namespace lldb_private {
-class Log
-{
+class Log {
public:
-
- //------------------------------------------------------------------
- // Callback definitions for abstracted plug-in log access.
- //------------------------------------------------------------------
- typedef void (*DisableCallback)(const char **categories, Stream *feedback_strm);
- typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories,
+ //------------------------------------------------------------------
+ // Callback definitions for abstracted plug-in log access.
+ //------------------------------------------------------------------
+ typedef void (*DisableCallback)(const char **categories,
+ Stream *feedback_strm);
+ typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char **categories,
Stream *feedback_strm);
typedef void (*ListCategoriesCallback)(Stream *strm);
- struct Callbacks
- {
- DisableCallback disable;
- EnableCallback enable;
- ListCategoriesCallback list_categories;
- };
+ struct Callbacks {
+ DisableCallback disable;
+ EnableCallback enable;
+ ListCategoriesCallback list_categories;
+ };
- //------------------------------------------------------------------
- // Static accessors for logging channels
- //------------------------------------------------------------------
- static void
- RegisterLogChannel(const ConstString &channel, const Log::Callbacks &log_callbacks);
+ //------------------------------------------------------------------
+ // Static accessors for logging channels
+ //------------------------------------------------------------------
+ static void RegisterLogChannel(const ConstString &channel,
+ const Log::Callbacks &log_callbacks);
- static bool
- UnregisterLogChannel(const ConstString &channel);
+ static bool UnregisterLogChannel(const ConstString &channel);
- static bool
- GetLogChannelCallbacks(const ConstString &channel, Log::Callbacks &log_callbacks);
+ static bool GetLogChannelCallbacks(const ConstString &channel,
+ Log::Callbacks &log_callbacks);
- static bool
- EnableLogChannel(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char *channel,
- const char **categories, Stream &error_stream);
+ static bool EnableLogChannel(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char *channel,
+ const char **categories, Stream &error_stream);
- static void
- EnableAllLogChannels(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories,
- Stream *feedback_strm);
+ static void EnableAllLogChannels(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options,
+ const char **categories,
+ Stream *feedback_strm);
- static void
- DisableAllLogChannels(Stream *feedback_strm);
+ static void DisableAllLogChannels(Stream *feedback_strm);
- static void
- ListAllLogChannels(Stream *strm);
+ static void ListAllLogChannels(Stream *strm);
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- //------------------------------------------------------------------
- // Auto completion
- //------------------------------------------------------------------
- static void
- AutoCompleteChannelName(const char *channel_name, StringList &matches);
+ //------------------------------------------------------------------
+ // Auto completion
+ //------------------------------------------------------------------
+ static void AutoCompleteChannelName(const char *channel_name,
+ StringList &matches);
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- Log();
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ Log();
- Log(const lldb::StreamSP &stream_sp);
+ Log(const lldb::StreamSP &stream_sp);
- virtual
- ~Log();
+ virtual ~Log();
- virtual void
- PutCString(const char *cstr);
+ virtual void PutCString(const char *cstr);
- virtual void
- Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+ virtual void Printf(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- VAPrintf(const char *format, va_list args);
+ virtual void VAPrintf(const char *format, va_list args);
- virtual void
- LogIf(uint32_t mask, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+ virtual void LogIf(uint32_t mask, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
- virtual void
- Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void Debug(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- DebugVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void DebugVerbose(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void Error(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- VAError(const char *format, va_list args);
+ virtual void VAError(const char *format, va_list args);
- virtual void
- FatalError(int err, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+ virtual void FatalError(int err, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
- virtual void
- Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void Verbose(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void Warning(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- virtual void
- WarningVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+ virtual void WarningVerbose(const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
- Flags &
- GetOptions();
+ Flags &GetOptions();
- const Flags &
- GetOptions() const;
+ const Flags &GetOptions() const;
- Flags &
- GetMask();
+ Flags &GetMask();
- const Flags &
- GetMask() const;
+ const Flags &GetMask() const;
- bool
- GetVerbose() const;
+ bool GetVerbose() const;
- bool
- GetDebug() const;
+ bool GetDebug() const;
- void
- SetStream(const lldb::StreamSP &stream_sp)
- {
- m_stream_sp = stream_sp;
- }
+ void SetStream(const lldb::StreamSP &stream_sp) { m_stream_sp = stream_sp; }
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::StreamSP m_stream_sp;
- Flags m_options;
- Flags m_mask_bits;
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::StreamSP m_stream_sp;
+ Flags m_options;
+ Flags m_mask_bits;
private:
DISALLOW_COPY_AND_ASSIGN(Log);
};
-class LogChannel : public PluginInterface
-{
+class LogChannel : public PluginInterface {
public:
LogChannel();
@@ -191,18 +171,20 @@ public:
static lldb::LogChannelSP FindPlugin(const char *plugin_name);
- // categories is an array of chars that ends with a NULL element.
+ // categories is an array of chars that ends with a NULL element.
virtual void Disable(const char **categories, Stream *feedback_strm) = 0;
- virtual bool Enable(
- lldb::StreamSP &log_stream_sp, uint32_t log_options,
- Stream *feedback_strm, // Feedback stream for argument errors etc
- const char **categories) = 0; // The categories to enable within this logging stream, if empty, enable default set
+ virtual bool
+ Enable(lldb::StreamSP &log_stream_sp, uint32_t log_options,
+ Stream *feedback_strm, // Feedback stream for argument errors etc
+ const char **categories) = 0; // The categories to enable within this
+ // logging stream, if empty, enable
+ // default set
virtual void ListCategories(Stream *strm) = 0;
protected:
- std::unique_ptr<Log> m_log_ap;
+ std::unique_ptr<Log> m_log_ap;
private:
DISALLOW_COPY_AND_ASSIGN(LogChannel);
Modified: lldb/trunk/include/lldb/Core/Logging.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Logging.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Logging.h (original)
+++ lldb/trunk/include/lldb/Core/Logging.h Tue Sep 6 15:57:50 2016
@@ -19,78 +19,65 @@
//----------------------------------------------------------------------
// Log Bits specific to logging in lldb
//----------------------------------------------------------------------
-#define LIBLLDB_LOG_VERBOSE (1u << 0)
-#define LIBLLDB_LOG_PROCESS (1u << 1)
-#define LIBLLDB_LOG_THREAD (1u << 2)
-#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
-#define LIBLLDB_LOG_EVENTS (1u << 4)
-#define LIBLLDB_LOG_BREAKPOINTS (1u << 5)
-#define LIBLLDB_LOG_WATCHPOINTS (1u << 6)
-#define LIBLLDB_LOG_STEP (1u << 7)
-#define LIBLLDB_LOG_EXPRESSIONS (1u << 8)
-#define LIBLLDB_LOG_TEMPORARY (1u << 9)
-#define LIBLLDB_LOG_STATE (1u << 10)
-#define LIBLLDB_LOG_OBJECT (1u << 11)
-#define LIBLLDB_LOG_COMMUNICATION (1u << 12)
-#define LIBLLDB_LOG_CONNECTION (1u << 13)
-#define LIBLLDB_LOG_HOST (1u << 14)
-#define LIBLLDB_LOG_UNWIND (1u << 15)
-#define LIBLLDB_LOG_API (1u << 16)
-#define LIBLLDB_LOG_SCRIPT (1u << 17)
-#define LIBLLDB_LOG_COMMANDS (1U << 18)
-#define LIBLLDB_LOG_TYPES (1u << 19)
-#define LIBLLDB_LOG_SYMBOLS (1u << 20)
-#define LIBLLDB_LOG_MODULES (1u << 21)
-#define LIBLLDB_LOG_TARGET (1u << 22)
-#define LIBLLDB_LOG_MMAP (1u << 23)
-#define LIBLLDB_LOG_OS (1u << 24)
-#define LIBLLDB_LOG_PLATFORM (1u << 25)
-#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
-#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
-#define LIBLLDB_LOG_LANGUAGE (1u << 28)
-#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
-#define LIBLLDB_LOG_DEMANGLE (1u << 30)
-#define LIBLLDB_LOG_ALL (UINT32_MAX)
-#define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\
- LIBLLDB_LOG_THREAD |\
- LIBLLDB_LOG_DYNAMIC_LOADER |\
- LIBLLDB_LOG_BREAKPOINTS |\
- LIBLLDB_LOG_WATCHPOINTS |\
- LIBLLDB_LOG_STEP |\
- LIBLLDB_LOG_STATE |\
- LIBLLDB_LOG_SYMBOLS |\
- LIBLLDB_LOG_TARGET |\
- LIBLLDB_LOG_COMMANDS)
+#define LIBLLDB_LOG_VERBOSE (1u << 0)
+#define LIBLLDB_LOG_PROCESS (1u << 1)
+#define LIBLLDB_LOG_THREAD (1u << 2)
+#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
+#define LIBLLDB_LOG_EVENTS (1u << 4)
+#define LIBLLDB_LOG_BREAKPOINTS (1u << 5)
+#define LIBLLDB_LOG_WATCHPOINTS (1u << 6)
+#define LIBLLDB_LOG_STEP (1u << 7)
+#define LIBLLDB_LOG_EXPRESSIONS (1u << 8)
+#define LIBLLDB_LOG_TEMPORARY (1u << 9)
+#define LIBLLDB_LOG_STATE (1u << 10)
+#define LIBLLDB_LOG_OBJECT (1u << 11)
+#define LIBLLDB_LOG_COMMUNICATION (1u << 12)
+#define LIBLLDB_LOG_CONNECTION (1u << 13)
+#define LIBLLDB_LOG_HOST (1u << 14)
+#define LIBLLDB_LOG_UNWIND (1u << 15)
+#define LIBLLDB_LOG_API (1u << 16)
+#define LIBLLDB_LOG_SCRIPT (1u << 17)
+#define LIBLLDB_LOG_COMMANDS (1U << 18)
+#define LIBLLDB_LOG_TYPES (1u << 19)
+#define LIBLLDB_LOG_SYMBOLS (1u << 20)
+#define LIBLLDB_LOG_MODULES (1u << 21)
+#define LIBLLDB_LOG_TARGET (1u << 22)
+#define LIBLLDB_LOG_MMAP (1u << 23)
+#define LIBLLDB_LOG_OS (1u << 24)
+#define LIBLLDB_LOG_PLATFORM (1u << 25)
+#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
+#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
+#define LIBLLDB_LOG_LANGUAGE (1u << 28)
+#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
+#define LIBLLDB_LOG_DEMANGLE (1u << 30)
+#define LIBLLDB_LOG_ALL (UINT32_MAX)
+#define LIBLLDB_LOG_DEFAULT \
+ (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \
+ LIBLLDB_LOG_BREAKPOINTS | LIBLLDB_LOG_WATCHPOINTS | LIBLLDB_LOG_STEP | \
+ LIBLLDB_LOG_STATE | LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_TARGET | \
+ LIBLLDB_LOG_COMMANDS)
namespace lldb_private {
-void
-LogIfAllCategoriesSet (uint32_t mask, const char *format, ...);
+void LogIfAllCategoriesSet(uint32_t mask, const char *format, ...);
-void
-LogIfAnyCategoriesSet (uint32_t mask, const char *format, ...);
+void LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...);
-Log *
-GetLogIfAllCategoriesSet (uint32_t mask);
+Log *GetLogIfAllCategoriesSet(uint32_t mask);
-Log *
-GetLogIfAnyCategoriesSet (uint32_t mask);
+Log *GetLogIfAnyCategoriesSet(uint32_t mask);
-uint32_t
-GetLogMask ();
+uint32_t GetLogMask();
-bool
-IsLogVerbose ();
+bool IsLogVerbose();
-void
-DisableLog (const char **categories, Stream *feedback_strm);
+void DisableLog(const char **categories, Stream *feedback_strm);
-Log *
-EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm);
+Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
+ const char **categories, Stream *feedback_strm);
-void
-ListLogCategories (Stream *strm);
+void ListLogCategories(Stream *strm);
} // namespace lldb_private
-#endif // liblldb_Core_Logging_h_
+#endif // liblldb_Core_Logging_h_
Modified: lldb/trunk/include/lldb/Core/Mangled.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Mangled.h (original)
+++ lldb/trunk/include/lldb/Core/Mangled.h Tue Sep 6 15:57:50 2016
@@ -11,9 +11,8 @@
#define liblldb_Mangled_h_
#if defined(__cplusplus)
-
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-private.h"
#include <vector>
namespace lldb_private {
@@ -30,313 +29,277 @@ namespace lldb_private {
/// string pools are used for the mangled, demangled, and token string
/// values to allow for faster comparisons and for efficient memory use.
//----------------------------------------------------------------------
-class Mangled
-{
+class Mangled {
public:
-
- enum NamePreference
- {
- ePreferMangled,
- ePreferDemangled,
- ePreferDemangledWithoutArguments
- };
-
- enum ManglingScheme
- {
- eManglingSchemeNone = 0,
- eManglingSchemeMSVC,
- eManglingSchemeItanium
- };
-
- //----------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Initialize with both mangled and demangled names empty.
- //----------------------------------------------------------------------
- Mangled ();
-
- //----------------------------------------------------------------------
- /// Construct with name.
- ///
- /// Constructor with an optional string and a boolean indicating if it is
- /// the mangled version.
- ///
- /// @param[in] name
- /// The already const name to copy into this object.
- ///
- /// @param[in] is_mangled
- /// If \b true then \a name is a mangled name, if \b false then
- /// \a name is demangled.
- //----------------------------------------------------------------------
- explicit
- Mangled (const ConstString &name, bool is_mangled);
-
- //----------------------------------------------------------------------
- /// Construct with name.
- ///
- /// Constructor with an optional string and auto-detect if \a name is
- /// mangled or not.
- ///
- /// @param[in] name
- /// The already const name to copy into this object.
- //----------------------------------------------------------------------
- explicit
- Mangled (const ConstString &name);
-
- //----------------------------------------------------------------------
- /// Destructor
- ///
- /// Releases its ref counts on the mangled and demangled strings that
- /// live in the global string pool.
- //----------------------------------------------------------------------
- ~Mangled ();
-
- //----------------------------------------------------------------------
- /// Convert to pointer operator.
- ///
- /// This allows code to check a Mangled object to see if it contains
- /// a valid mangled name using code such as:
- ///
- /// @code
- /// Mangled mangled(...);
- /// if (mangled)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// A pointer to this object if either the mangled or unmangled
- /// name is set, NULL otherwise.
- //----------------------------------------------------------------------
- operator
- void*() const;
-
- //----------------------------------------------------------------------
- /// Logical NOT operator.
- ///
- /// This allows code to check a Mangled object to see if it contains
- /// an empty mangled name using code such as:
- ///
- /// @code
- /// Mangled mangled(...);
- /// if (!mangled)
- /// { ...
- /// @endcode
- ///
- /// @return
- /// Returns \b true if the object has an empty mangled and
- /// unmangled name, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- operator!() const;
-
- //----------------------------------------------------------------------
- /// Clear the mangled and demangled values.
- //----------------------------------------------------------------------
- void
- Clear ();
-
- //----------------------------------------------------------------------
- /// Compare the mangled string values
- ///
- /// Compares the Mangled::GetName() string in \a lhs and \a rhs.
- ///
- /// @param[in] lhs
- /// A const reference to the Left Hand Side object to compare.
- ///
- /// @param[in] rhs
- /// A const reference to the Right Hand Side object to compare.
- ///
- /// @return
- /// @li -1 if \a lhs is less than \a rhs
- /// @li 0 if \a lhs is equal to \a rhs
- /// @li 1 if \a lhs is greater than \a rhs
- //----------------------------------------------------------------------
- static int
- Compare (const Mangled& lhs, const Mangled& rhs);
-
- //----------------------------------------------------------------------
- /// Dump a description of this object to a Stream \a s.
- ///
- /// Dump a Mangled object to stream \a s. We don't force our
- /// demangled name to be computed currently (we don't use the accessor).
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //----------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- //----------------------------------------------------------------------
- /// Dump a debug description of this object to a Stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //----------------------------------------------------------------------
- void
- DumpDebug (Stream *s) const;
-
- //----------------------------------------------------------------------
- /// Demangled name get accessor.
- ///
- /// @return
- /// A const reference to the demangled name string object.
- //----------------------------------------------------------------------
- const ConstString&
- GetDemangledName (lldb::LanguageType language) const;
-
- //----------------------------------------------------------------------
- /// Display demangled name get accessor.
- ///
- /// @return
- /// A const reference to the display demangled name string object.
- //----------------------------------------------------------------------
- ConstString
- GetDisplayDemangledName (lldb::LanguageType language) const;
-
- void
- SetDemangledName (const ConstString &name)
- {
- m_demangled = name;
- }
-
- void
- SetMangledName (const ConstString &name)
- {
- m_mangled = name;
- }
-
- //----------------------------------------------------------------------
- /// Mangled name get accessor.
- ///
- /// @return
- /// A reference to the mangled name string object.
- //----------------------------------------------------------------------
- ConstString&
- GetMangledName ()
- {
- return m_mangled;
- }
-
- //----------------------------------------------------------------------
- /// Mangled name get accessor.
- ///
- /// @return
- /// A const reference to the mangled name string object.
- //----------------------------------------------------------------------
- const ConstString&
- GetMangledName () const
- {
- return m_mangled;
- }
-
- //----------------------------------------------------------------------
- /// Best name get accessor.
- ///
- /// @param[in] preference
- /// Which name would you prefer to get?
- ///
- /// @return
- /// A const reference to the preferred name string object if this
- /// object has a valid name of that kind, else a const reference to the
- /// other name is returned.
- //----------------------------------------------------------------------
- ConstString
- GetName (lldb::LanguageType language, NamePreference preference = ePreferDemangled) const;
-
- //----------------------------------------------------------------------
- /// Check if "name" matches either the mangled or demangled name.
- ///
- /// @param[in] name
- /// A name to match against both strings.
- ///
- /// @return
- /// \b True if \a name matches either name, \b false otherwise.
- //----------------------------------------------------------------------
- bool
- NameMatches (const ConstString &name, lldb::LanguageType language) const
- {
- if (m_mangled == name)
- return true;
- return GetDemangledName (language) == name;
- }
-
- bool
- NameMatches (const RegularExpression& regex, lldb::LanguageType language) const;
-
- //----------------------------------------------------------------------
- /// Get the memory cost of this object.
- ///
- /// Return the size in bytes that this object takes in memory. This
- /// returns the size in bytes of this object, not any shared string
- /// values it may refer to.
- ///
- /// @return
- /// The number of bytes that this object occupies in memory.
- ///
- /// @see ConstString::StaticMemorySize ()
- //----------------------------------------------------------------------
- size_t
- MemorySize () const;
-
- //----------------------------------------------------------------------
- /// Set the string value in this object.
- ///
- /// If \a is_mangled is \b true, then the mangled named is set to \a
- /// name, else the demangled name is set to \a name.
- ///
- /// @param[in] name
- /// The already const version of the name for this object.
- ///
- /// @param[in] is_mangled
- /// If \b true then \a name is a mangled name, if \b false then
- /// \a name is demangled.
- //----------------------------------------------------------------------
- void
- SetValue (const ConstString &name, bool is_mangled);
-
- //----------------------------------------------------------------------
- /// Set the string value in this object.
- ///
- /// This version auto detects if the string is mangled by inspecting the
- /// string value and looking for common mangling prefixes.
- ///
- /// @param[in] name
- /// The already const version of the name for this object.
- //----------------------------------------------------------------------
- void
- SetValue (const ConstString &name);
-
- //----------------------------------------------------------------------
- /// Try to guess the language from the mangling.
- ///
- /// For a mangled name to have a language it must have both a mangled
- /// and a demangled name and it can be guessed from the mangling what
- /// the language is. Note: this will return C++ for any language that
- /// uses Itanium ABI mangling.
- ///
- /// Standard C function names will return eLanguageTypeUnknown because
- /// they aren't mangled and it isn't clear what language the name
- /// represents (there will be no mangled name).
- ///
- /// @return
- /// The language for the mangled/demangled name, eLanguageTypeUnknown
- /// if there is no mangled or demangled counterpart.
- //----------------------------------------------------------------------
- lldb::LanguageType
- GuessLanguage () const;
+ enum NamePreference {
+ ePreferMangled,
+ ePreferDemangled,
+ ePreferDemangledWithoutArguments
+ };
+
+ enum ManglingScheme {
+ eManglingSchemeNone = 0,
+ eManglingSchemeMSVC,
+ eManglingSchemeItanium
+ };
+
+ //----------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Initialize with both mangled and demangled names empty.
+ //----------------------------------------------------------------------
+ Mangled();
+
+ //----------------------------------------------------------------------
+ /// Construct with name.
+ ///
+ /// Constructor with an optional string and a boolean indicating if it is
+ /// the mangled version.
+ ///
+ /// @param[in] name
+ /// The already const name to copy into this object.
+ ///
+ /// @param[in] is_mangled
+ /// If \b true then \a name is a mangled name, if \b false then
+ /// \a name is demangled.
+ //----------------------------------------------------------------------
+ explicit Mangled(const ConstString &name, bool is_mangled);
+
+ //----------------------------------------------------------------------
+ /// Construct with name.
+ ///
+ /// Constructor with an optional string and auto-detect if \a name is
+ /// mangled or not.
+ ///
+ /// @param[in] name
+ /// The already const name to copy into this object.
+ //----------------------------------------------------------------------
+ explicit Mangled(const ConstString &name);
+
+ //----------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// Releases its ref counts on the mangled and demangled strings that
+ /// live in the global string pool.
+ //----------------------------------------------------------------------
+ ~Mangled();
+
+ //----------------------------------------------------------------------
+ /// Convert to pointer operator.
+ ///
+ /// This allows code to check a Mangled object to see if it contains
+ /// a valid mangled name using code such as:
+ ///
+ /// @code
+ /// Mangled mangled(...);
+ /// if (mangled)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// A pointer to this object if either the mangled or unmangled
+ /// name is set, NULL otherwise.
+ //----------------------------------------------------------------------
+ operator void *() const;
+
+ //----------------------------------------------------------------------
+ /// Logical NOT operator.
+ ///
+ /// This allows code to check a Mangled object to see if it contains
+ /// an empty mangled name using code such as:
+ ///
+ /// @code
+ /// Mangled mangled(...);
+ /// if (!mangled)
+ /// { ...
+ /// @endcode
+ ///
+ /// @return
+ /// Returns \b true if the object has an empty mangled and
+ /// unmangled name, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool operator!() const;
+
+ //----------------------------------------------------------------------
+ /// Clear the mangled and demangled values.
+ //----------------------------------------------------------------------
+ void Clear();
+
+ //----------------------------------------------------------------------
+ /// Compare the mangled string values
+ ///
+ /// Compares the Mangled::GetName() string in \a lhs and \a rhs.
+ ///
+ /// @param[in] lhs
+ /// A const reference to the Left Hand Side object to compare.
+ ///
+ /// @param[in] rhs
+ /// A const reference to the Right Hand Side object to compare.
+ ///
+ /// @return
+ /// @li -1 if \a lhs is less than \a rhs
+ /// @li 0 if \a lhs is equal to \a rhs
+ /// @li 1 if \a lhs is greater than \a rhs
+ //----------------------------------------------------------------------
+ static int Compare(const Mangled &lhs, const Mangled &rhs);
+
+ //----------------------------------------------------------------------
+ /// Dump a description of this object to a Stream \a s.
+ ///
+ /// Dump a Mangled object to stream \a s. We don't force our
+ /// demangled name to be computed currently (we don't use the accessor).
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //----------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ //----------------------------------------------------------------------
+ /// Dump a debug description of this object to a Stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //----------------------------------------------------------------------
+ void DumpDebug(Stream *s) const;
+
+ //----------------------------------------------------------------------
+ /// Demangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the demangled name string object.
+ //----------------------------------------------------------------------
+ const ConstString &GetDemangledName(lldb::LanguageType language) const;
+
+ //----------------------------------------------------------------------
+ /// Display demangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the display demangled name string object.
+ //----------------------------------------------------------------------
+ ConstString GetDisplayDemangledName(lldb::LanguageType language) const;
+
+ void SetDemangledName(const ConstString &name) { m_demangled = name; }
+
+ void SetMangledName(const ConstString &name) { m_mangled = name; }
+
+ //----------------------------------------------------------------------
+ /// Mangled name get accessor.
+ ///
+ /// @return
+ /// A reference to the mangled name string object.
+ //----------------------------------------------------------------------
+ ConstString &GetMangledName() { return m_mangled; }
+
+ //----------------------------------------------------------------------
+ /// Mangled name get accessor.
+ ///
+ /// @return
+ /// A const reference to the mangled name string object.
+ //----------------------------------------------------------------------
+ const ConstString &GetMangledName() const { return m_mangled; }
+
+ //----------------------------------------------------------------------
+ /// Best name get accessor.
+ ///
+ /// @param[in] preference
+ /// Which name would you prefer to get?
+ ///
+ /// @return
+ /// A const reference to the preferred name string object if this
+ /// object has a valid name of that kind, else a const reference to the
+ /// other name is returned.
+ //----------------------------------------------------------------------
+ ConstString GetName(lldb::LanguageType language,
+ NamePreference preference = ePreferDemangled) const;
+
+ //----------------------------------------------------------------------
+ /// Check if "name" matches either the mangled or demangled name.
+ ///
+ /// @param[in] name
+ /// A name to match against both strings.
+ ///
+ /// @return
+ /// \b True if \a name matches either name, \b false otherwise.
+ //----------------------------------------------------------------------
+ bool NameMatches(const ConstString &name, lldb::LanguageType language) const {
+ if (m_mangled == name)
+ return true;
+ return GetDemangledName(language) == name;
+ }
+
+ bool NameMatches(const RegularExpression ®ex,
+ lldb::LanguageType language) const;
+
+ //----------------------------------------------------------------------
+ /// Get the memory cost of this object.
+ ///
+ /// Return the size in bytes that this object takes in memory. This
+ /// returns the size in bytes of this object, not any shared string
+ /// values it may refer to.
+ ///
+ /// @return
+ /// The number of bytes that this object occupies in memory.
+ ///
+ /// @see ConstString::StaticMemorySize ()
+ //----------------------------------------------------------------------
+ size_t MemorySize() const;
+
+ //----------------------------------------------------------------------
+ /// Set the string value in this object.
+ ///
+ /// If \a is_mangled is \b true, then the mangled named is set to \a
+ /// name, else the demangled name is set to \a name.
+ ///
+ /// @param[in] name
+ /// The already const version of the name for this object.
+ ///
+ /// @param[in] is_mangled
+ /// If \b true then \a name is a mangled name, if \b false then
+ /// \a name is demangled.
+ //----------------------------------------------------------------------
+ void SetValue(const ConstString &name, bool is_mangled);
+
+ //----------------------------------------------------------------------
+ /// Set the string value in this object.
+ ///
+ /// This version auto detects if the string is mangled by inspecting the
+ /// string value and looking for common mangling prefixes.
+ ///
+ /// @param[in] name
+ /// The already const version of the name for this object.
+ //----------------------------------------------------------------------
+ void SetValue(const ConstString &name);
+
+ //----------------------------------------------------------------------
+ /// Try to guess the language from the mangling.
+ ///
+ /// For a mangled name to have a language it must have both a mangled
+ /// and a demangled name and it can be guessed from the mangling what
+ /// the language is. Note: this will return C++ for any language that
+ /// uses Itanium ABI mangling.
+ ///
+ /// Standard C function names will return eLanguageTypeUnknown because
+ /// they aren't mangled and it isn't clear what language the name
+ /// represents (there will be no mangled name).
+ ///
+ /// @return
+ /// The language for the mangled/demangled name, eLanguageTypeUnknown
+ /// if there is no mangled or demangled counterpart.
+ //----------------------------------------------------------------------
+ lldb::LanguageType GuessLanguage() const;
private:
- //----------------------------------------------------------------------
- /// Mangled member variables.
- //----------------------------------------------------------------------
- ConstString m_mangled; ///< The mangled version of the name
- mutable ConstString m_demangled; ///< Mutable so we can get it on demand with a const version of this object
+ //----------------------------------------------------------------------
+ /// Mangled member variables.
+ //----------------------------------------------------------------------
+ ConstString m_mangled; ///< The mangled version of the name
+ mutable ConstString m_demangled; ///< Mutable so we can get it on demand with
+ ///a const version of this object
};
-
-Stream& operator << (Stream& s, const Mangled& obj);
+Stream &operator<<(Stream &s, const Mangled &obj);
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_Mangled_h_
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Mangled_h_
More information about the lldb-commits
mailing list