Skip to content

Commit b0af8a1

Browse files
committed
Revert "[lldb] [mostly NFC] Large WP foundation: WatchpointResources (#68845)"
...and follow ups. As it has caused test failures on Linux Arm and AArch64: https://lab.llvm.org/buildbot/#/builders/96/builds/49126 https://lab.llvm.org/buildbot/#/builders/17/builds/45824 ``` lldb-shell :: Subprocess/clone-follow-child-wp.test lldb-shell :: Subprocess/fork-follow-child-wp.test lldb-shell :: Subprocess/vfork-follow-child-wp.test ``` This reverts commit a6c62bf, commit a0a1ff3 and commit fc6b725.
1 parent 1459c62 commit b0af8a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+759
-1428
lines changed

lldb/include/lldb/Breakpoint/BreakpointSite.h

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
4545
// display any breakpoint opcodes.
4646
};
4747

48-
typedef lldb::break_id_t SiteID;
49-
typedef lldb::break_id_t ConstituentID;
50-
5148
~BreakpointSite() override;
5249

5350
// This section manages the breakpoint traps
@@ -80,8 +77,8 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
8077
/// Tells whether the current breakpoint site is enabled or not
8178
///
8279
/// This is a low-level enable bit for the breakpoint sites. If a
83-
/// breakpoint site has no enabled constituents, it should just get removed.
84-
/// This enable/disable is for the low-level target code to enable and disable
80+
/// breakpoint site has no enabled owners, it should just get removed. This
81+
/// enable/disable is for the low-level target code to enable and disable
8582
/// breakpoint sites when single stepping, etc.
8683
bool IsEnabled() const;
8784

@@ -104,46 +101,44 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
104101
/// Standard Dump method
105102
void Dump(Stream *s) const override;
106103

107-
/// The "Constituents" are the breakpoint locations that share this breakpoint
108-
/// site. The method adds the \a constituent to this breakpoint site's
109-
/// constituent list.
104+
/// The "Owners" are the breakpoint locations that share this breakpoint
105+
/// site. The method adds the \a owner to this breakpoint site's owner list.
110106
///
111-
/// \param[in] constituent
112-
/// \a constituent is the Breakpoint Location to add.
113-
void AddConstituent(const lldb::BreakpointLocationSP &constituent);
107+
/// \param[in] owner
108+
/// \a owner is the Breakpoint Location to add.
109+
void AddOwner(const lldb::BreakpointLocationSP &owner);
114110

115111
/// This method returns the number of breakpoint locations currently located
116112
/// at this breakpoint site.
117113
///
118114
/// \return
119-
/// The number of constituents.
120-
size_t GetNumberOfConstituents();
115+
/// The number of owners.
116+
size_t GetNumberOfOwners();
121117

122118
/// This method returns the breakpoint location at index \a index located at
123-
/// this breakpoint site. The constituents are listed ordinally from 0 to
124-
/// GetNumberOfConstituents() - 1 so you can use this method to iterate over
125-
/// the constituents
119+
/// this breakpoint site. The owners are listed ordinally from 0 to
120+
/// GetNumberOfOwners() - 1 so you can use this method to iterate over the
121+
/// owners
126122
///
127123
/// \param[in] idx
128-
/// The index in the list of constituents for which you wish the
129-
/// constituent location.
124+
/// The index in the list of owners for which you wish the owner location.
130125
///
131126
/// \return
132127
/// A shared pointer to the breakpoint location at that index.
133-
lldb::BreakpointLocationSP GetConstituentAtIndex(size_t idx);
128+
lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx);
134129

135-
/// This method copies the breakpoint site's constituents into a new
136-
/// collection. It does this while the constituents mutex is locked.
130+
/// This method copies the breakpoint site's owners into a new collection.
131+
/// It does this while the owners mutex is locked.
137132
///
138133
/// \param[out] out_collection
139-
/// The BreakpointLocationCollection into which to put the constituents
134+
/// The BreakpointLocationCollection into which to put the owners
140135
/// of this breakpoint site.
141136
///
142137
/// \return
143138
/// The number of elements copied into out_collection.
144-
size_t CopyConstituentsList(BreakpointLocationCollection &out_collection);
139+
size_t CopyOwnersList(BreakpointLocationCollection &out_collection);
145140

146-
/// Check whether the constituents of this breakpoint site have any thread
141+
/// Check whether the owners of this breakpoint site have any thread
147142
/// specifiers, and if yes, is \a thread contained in any of these
148143
/// specifiers.
149144
///
@@ -156,7 +151,7 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
156151
bool ValidForThisThread(Thread &thread);
157152

158153
/// Print a description of this breakpoint site to the stream \a s.
159-
/// GetDescription tells you about the breakpoint site's constituents. Use
154+
/// GetDescription tells you about the breakpoint site's owners. Use
160155
/// BreakpointSite::Dump(Stream *) to get information about the breakpoint
161156
/// site itself.
162157
///
@@ -208,10 +203,9 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
208203

209204
void BumpHitCounts();
210205

211-
/// The method removes the constituent at \a break_loc_id from this breakpoint
206+
/// The method removes the owner at \a break_loc_id from this breakpoint
212207
/// list.
213-
size_t RemoveConstituent(lldb::break_id_t break_id,
214-
lldb::break_id_t break_loc_id);
208+
size_t RemoveOwner(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
215209

216210
BreakpointSite::Type m_type; ///< The type of this breakpoint site.
217211
uint8_t m_saved_opcode[8]; ///< The saved opcode bytes if this breakpoint site
@@ -221,20 +215,20 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
221215
bool
222216
m_enabled; ///< Boolean indicating if this breakpoint site enabled or not.
223217

224-
// Consider adding an optimization where if there is only one constituent, we
225-
// don't store a list. The usual case will be only one constituent...
226-
BreakpointLocationCollection
227-
m_constituents; ///< This has the BreakpointLocations
228-
/// that share this breakpoint site.
229-
std::recursive_mutex m_constituents_mutex; ///< This mutex protects the
230-
///< constituents collection.
218+
// Consider adding an optimization where if there is only one owner, we don't
219+
// store a list. The usual case will be only one owner...
220+
BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations
221+
///that share this breakpoint site.
222+
std::recursive_mutex
223+
m_owners_mutex; ///< This mutex protects the owners collection.
231224

232225
static lldb::break_id_t GetNextID();
233226

234227
// Only the Process can create breakpoint sites in
235228
// Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool).
236-
BreakpointSite(const lldb::BreakpointLocationSP &constituent,
237-
lldb::addr_t m_addr, bool use_hardware);
229+
BreakpointSite(BreakpointSiteList *list,
230+
const lldb::BreakpointLocationSP &owner, lldb::addr_t m_addr,
231+
bool use_hardware);
238232

239233
BreakpointSite(const BreakpointSite &) = delete;
240234
const BreakpointSite &operator=(const BreakpointSite &) = delete;
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
//===-- BreakpointSiteList.h ------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLDB_BREAKPOINT_BREAKPOINTSITELIST_H
10+
#define LLDB_BREAKPOINT_BREAKPOINTSITELIST_H
11+
12+
#include <functional>
13+
#include <map>
14+
#include <mutex>
15+
16+
#include "lldb/Breakpoint/BreakpointSite.h"
17+
18+
namespace lldb_private {
19+
20+
/// \class BreakpointSiteList BreakpointSiteList.h
21+
/// "lldb/Breakpoint/BreakpointSiteList.h" Class that manages lists of
22+
/// BreakpointSite shared pointers.
23+
class BreakpointSiteList {
24+
// At present Process directly accesses the map of BreakpointSites so it can
25+
// do quick lookups into the map (using GetMap).
26+
// FIXME: Find a better interface for this.
27+
friend class Process;
28+
29+
public:
30+
/// Default constructor makes an empty list.
31+
BreakpointSiteList();
32+
33+
/// Destructor, currently does nothing.
34+
~BreakpointSiteList();
35+
36+
/// Add a BreakpointSite to the list.
37+
///
38+
/// \param[in] bp_site_sp
39+
/// A shared pointer to a breakpoint site being added to the list.
40+
///
41+
/// \return
42+
/// The ID of the BreakpointSite in the list.
43+
lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp);
44+
45+
/// Standard Dump routine, doesn't do anything at present. \param[in] s
46+
/// Stream into which to dump the description.
47+
void Dump(Stream *s) const;
48+
49+
/// Returns a shared pointer to the breakpoint site at address \a addr.
50+
///
51+
/// \param[in] addr
52+
/// The address to look for.
53+
///
54+
/// \result
55+
/// A shared pointer to the breakpoint site. May contain a NULL
56+
/// pointer if no breakpoint site exists with a matching address.
57+
lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr);
58+
59+
/// Returns a shared pointer to the breakpoint site with id \a breakID.
60+
///
61+
/// \param[in] breakID
62+
/// The breakpoint site ID to seek for.
63+
///
64+
/// \result
65+
/// A shared pointer to the breakpoint site. May contain a NULL pointer if
66+
/// the
67+
/// breakpoint doesn't exist.
68+
lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID);
69+
70+
/// Returns a shared pointer to the breakpoint site with id \a breakID -
71+
/// const version.
72+
///
73+
/// \param[in] breakID
74+
/// The breakpoint site ID to seek for.
75+
///
76+
/// \result
77+
/// A shared pointer to the breakpoint site. May contain a NULL pointer if
78+
/// the
79+
/// breakpoint doesn't exist.
80+
const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const;
81+
82+
/// Returns the breakpoint site id to the breakpoint site at address \a
83+
/// addr.
84+
///
85+
/// \param[in] addr
86+
/// The address to match.
87+
///
88+
/// \result
89+
/// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
90+
lldb::break_id_t FindIDByAddress(lldb::addr_t addr);
91+
92+
/// Returns whether the breakpoint site \a bp_site_id has \a bp_id
93+
// as one of its owners.
94+
///
95+
/// \param[in] bp_site_id
96+
/// The breakpoint site id to query.
97+
///
98+
/// \param[in] bp_id
99+
/// The breakpoint id to look for in \a bp_site_id.
100+
///
101+
/// \result
102+
/// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
103+
/// owners of that site.
104+
bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id,
105+
lldb::break_id_t bp_id);
106+
107+
void ForEach(std::function<void(BreakpointSite *)> const &callback);
108+
109+
/// Removes the breakpoint site given by \b breakID from this list.
110+
///
111+
/// \param[in] breakID
112+
/// The breakpoint site index to remove.
113+
///
114+
/// \result
115+
/// \b true if the breakpoint site \a breakID was in the list.
116+
bool Remove(lldb::break_id_t breakID);
117+
118+
/// Removes the breakpoint site at address \a addr from this list.
119+
///
120+
/// \param[in] addr
121+
/// The address from which to remove a breakpoint site.
122+
///
123+
/// \result
124+
/// \b true if \a addr had a breakpoint site to remove from the list.
125+
bool RemoveByAddress(lldb::addr_t addr);
126+
127+
bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound,
128+
BreakpointSiteList &bp_site_list) const;
129+
130+
typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp,
131+
void *baton);
132+
133+
/// Enquires of the breakpoint site on in this list with ID \a breakID
134+
/// whether we should stop for the breakpoint or not.
135+
///
136+
/// \param[in] context
137+
/// This contains the information about this stop.
138+
///
139+
/// \param[in] breakID
140+
/// This break ID that we hit.
141+
///
142+
/// \return
143+
/// \b true if we should stop, \b false otherwise.
144+
bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
145+
146+
/// Returns the number of elements in the list.
147+
///
148+
/// \result
149+
/// The number of elements.
150+
size_t GetSize() const {
151+
std::lock_guard<std::recursive_mutex> guard(m_mutex);
152+
return m_bp_site_list.size();
153+
}
154+
155+
bool IsEmpty() const {
156+
std::lock_guard<std::recursive_mutex> guard(m_mutex);
157+
return m_bp_site_list.empty();
158+
}
159+
160+
protected:
161+
typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
162+
163+
collection::iterator GetIDIterator(lldb::break_id_t breakID);
164+
165+
collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const;
166+
167+
mutable std::recursive_mutex m_mutex;
168+
collection m_bp_site_list; // The breakpoint site list.
169+
};
170+
171+
} // namespace lldb_private
172+
173+
#endif // LLDB_BREAKPOINT_BREAKPOINTSITELIST_H

0 commit comments

Comments
 (0)