<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/source/Utility/Broadcaster.cpp, branch users/nico/python-2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[lldb] Make Broadcaster mutexes non-recursive (#97400)</title>
<updated>2024-07-03T08:29:17+00:00</updated>
<author>
<name>Pavel Labath</name>
<email>pavel@labath.sk</email>
</author>
<published>2024-07-03T08:29:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2a14c0643597c5932af85f22172c99800f9b4a6c'/>
<id>2a14c0643597c5932af85f22172c99800f9b4a6c</id>
<content type='text'>
Non-recursive mutexes encourage better locking discipline and avoid bugs
like #96750, where one can unexpectedly re-enter the critical section on
the same thread, and interrupt a presumed-indivisible operation.

In this case, the only needed fix was to remove locking from some
BroadcastManager functions, which were only called from the Listener
class (and the listener already locked those mutexes to preserve lock
ordering).

While doing that, I noticed we don't have unit tests for these
functions, so I added one.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Non-recursive mutexes encourage better locking discipline and avoid bugs
like #96750, where one can unexpectedly re-enter the critical section on
the same thread, and interrupt a presumed-indivisible operation.

In this case, the only needed fix was to remove locking from some
BroadcastManager functions, which were only called from the Listener
class (and the listener already locked those mutexes to preserve lock
ordering).

While doing that, I noticed we don't have unit tests for these
functions, so I added one.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Use SmallVector::erase correctly</title>
<updated>2024-06-28T08:40:13+00:00</updated>
<author>
<name>Pavel Labath</name>
<email>pavel@labath.sk</email>
</author>
<published>2024-06-28T08:18:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b22ea2dc1e065f14a88df44e22a62427965a9b05'/>
<id>b22ea2dc1e065f14a88df44e22a62427965a9b05</id>
<content type='text'>
erase() invalidates the iterator, we must use the returned iterator to
continue iterating.

This does not actually make a difference with the current implementation
of SmallVector (erase will effectively return the same pointer), but it
avoids future confusion.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
erase() invalidates the iterator, we must use the returned iterator to
continue iterating.

This does not actually make a difference with the current implementation
of SmallVector (erase will effectively return the same pointer), but it
avoids future confusion.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][nfc] Move broadcaster class strings away from ConstString (#89690)</title>
<updated>2024-04-24T19:13:18+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2024-04-24T19:13:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=57794835279669358ff2828d659eb7133fc0e4bf'/>
<id>57794835279669358ff2828d659eb7133fc0e4bf</id>
<content type='text'>
These are hardcoded strings that are already present in the data section
of the binary, no need to immediately place them in the ConstString
StringPools. Lots of code still calls `GetBroadcasterClass` and places
the return value into a ConstString. Changing that would be a good
follow-up.

Additionally, calls to these functions are still wrapped in ConstStrings
at the SBAPI layer. This is because we must guarantee the lifetime of
all strings handed out publicly.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are hardcoded strings that are already present in the data section
of the binary, no need to immediately place them in the ConstString
StringPools. Lots of code still calls `GetBroadcasterClass` and places
the return value into a ConstString. Changing that would be a good
follow-up.

Additionally, calls to these functions are still wrapped in ConstStrings
at the SBAPI layer. This is because we must guarantee the lifetime of
all strings handed out publicly.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique (#79045)</title>
<updated>2024-01-26T18:40:33+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2024-01-26T18:40:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=02d3a799e7eb2997950d6a288a08a5e51ff0ff59'/>
<id>02d3a799e7eb2997950d6a288a08a5e51ff0ff59</id>
<content type='text'>
Instead of passing the data to BroadcastEventIfUnique to create an Event
object on the behalf of the caller, the caller can create the Event
up-front.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of passing the data to BroadcastEventIfUnique to create an Event
object on the behalf of the caller, the caller can create the Event
up-front.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFCI] Remove EventData* param from BroadcastEvent (#78773)</title>
<updated>2024-01-22T18:46:20+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2024-01-22T18:46:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8'/>
<id>0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8</id>
<content type='text'>
BroadcastEvent currently takes its EventData* param and shoves it into
an Event object, which takes ownership of the pointer and places it into
a shared_ptr to manage the lifetime.

Instead of relying on `new` and passing raw pointers around, I think it
would make more sense to create the shared_ptr up front.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
BroadcastEvent currently takes its EventData* param and shoves it into
an Event object, which takes ownership of the pointer and places it into
a shared_ptr to manage the lifetime.

Instead of relying on `new` and passing raw pointers around, I think it
would make more sense to create the shared_ptr up front.</pre>
</div>
</content>
</entry>
<entry>
<title>Fix a little thinko in sending events to secondary listeners. (#71997)</title>
<updated>2023-11-11T00:12:51+00:00</updated>
<author>
<name>jimingham</name>
<email>jingham@apple.com</email>
</author>
<published>2023-11-11T00:12:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0f8d3e62d3fe3db905ac94e5d11fee87553c7794'/>
<id>0f8d3e62d3fe3db905ac94e5d11fee87553c7794</id>
<content type='text'>
If `unique` is true, I was redoing the uniqueness check for the
secondary listeners, which is racy since a "duplicate" event could come
in between deciding to send the event to the main listener and checking
for the shadow listener, and then the two streams would get out of sync.

There's not a good way to write a direct test for this, but the
test_shadow_listeners test has been flakey and this is the only racy
part of that system I can find. So the test would be that that
test_shadow_listeners becomes not flakey.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If `unique` is true, I was redoing the uniqueness check for the
secondary listeners, which is racy since a "duplicate" event could come
in between deciding to send the event to the main listener and checking
for the shadow listener, and then the two streams would get out of sync.

There's not a good way to write a direct test for this, but the
test_shadow_listeners test has been flakey and this is the only racy
part of that system I can find. So the test would be that that
test_shadow_listeners becomes not flakey.</pre>
</div>
</content>
</entry>
<entry>
<title>Replace the singleton "ShadowListener" with a primary and N secondary Listeners</title>
<updated>2023-08-16T17:35:32+00:00</updated>
<author>
<name>Jim Ingham</name>
<email>jingham@apple.com</email>
</author>
<published>2023-08-15T18:32:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2e7aa2ee34eb53347396731dc8a3b2dbc6a3df45'/>
<id>2e7aa2ee34eb53347396731dc8a3b2dbc6a3df45</id>
<content type='text'>
Before the addition of the process "Shadow Listener" you could only have one
Listener observing the Process Broadcaster.  That was necessary because fetching the
Process event is what switches the public process state, and for the execution
control logic to be manageable you needed to keep other listeners from causing
this to happen before the main process control engine was ready.

Ismail added the notion of a "ShadowListener" - which allowed you ONE
extra process listener.  This patch inverts that setup by designating the
first listener as primary - and giving it priority in fetching events.

Differential Revision: https://reviews.llvm.org/D157556
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before the addition of the process "Shadow Listener" you could only have one
Listener observing the Process Broadcaster.  That was necessary because fetching the
Process event is what switches the public process state, and for the execution
control logic to be manageable you needed to keep other listeners from causing
this to happen before the main process control engine was ready.

Ismail added the notion of a "ShadowListener" - which allowed you ONE
extra process listener.  This patch inverts that setup by designating the
first listener as primary - and giving it priority in fetching events.

Differential Revision: https://reviews.llvm.org/D157556
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFCI] Change type of Broadcaster's name</title>
<updated>2023-06-07T17:14:53+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2023-06-06T01:05:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=867ee3b8a76a78e02c56e78382e31bfd76fa468b'/>
<id>867ee3b8a76a78e02c56e78382e31bfd76fa468b</id>
<content type='text'>
Broadcasters don't need their names in the StringPool. It doesn't
benefit from fast comparisons and doesn't benefit from uniqueness.

Differential Revision: https://reviews.llvm.org/D152220
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Broadcasters don't need their names in the StringPool. It doesn't
benefit from fast comparisons and doesn't benefit from uniqueness.

Differential Revision: https://reviews.llvm.org/D152220
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFCI] Remove n^2 loops and simplify iterator usage</title>
<updated>2023-05-10T10:18:27+00:00</updated>
<author>
<name>Felipe de Azevedo Piovezan</name>
<email>fpiovezan@apple.com</email>
</author>
<published>2023-05-09T18:58:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c'/>
<id>25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c</id>
<content type='text'>
The code inside Broadcaster makes usage of iterators using olden C++ coding
style. Hidden in this old style is a couple of N^2 loops: we iterate over a map
(sequentially), removing the first element that matches some predicate. The
search is _always_ done from the start of the map, which implies that, if the
map has N elements and if all matches happen on the second half of the map, then
we visit the first N/2 elements exactly N/2 * N/2 times.

Ideally some of the code here would benefit from `std::map`s own "erase_if", but
this is only available with C++20:
https://en.cppreference.com/w/cpp/container/map/erase_if

We spent quite some time trying to make these loops more elegant, but it is
surprisingly tricky to do so.

Differential Revision: https://reviews.llvm.org/D150219
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The code inside Broadcaster makes usage of iterators using olden C++ coding
style. Hidden in this old style is a couple of N^2 loops: we iterate over a map
(sequentially), removing the first element that matches some predicate. The
search is _always_ done from the start of the map, which implies that, if the
map has N elements and if all matches happen on the second half of the map, then
we visit the first N/2 elements exactly N/2 * N/2 times.

Ideally some of the code here would benefit from `std::map`s own "erase_if", but
this is only available with C++20:
https://en.cppreference.com/w/cpp/container/map/erase_if

We spent quite some time trying to make these loops more elegant, but it is
surprisingly tricky to do so.

Differential Revision: https://reviews.llvm.org/D150219
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Simplify predicates of find_if in BroadcastManager</title>
<updated>2023-05-09T17:00:02+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2023-05-09T01:29:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ec77d1f3d9fcf7105b6bda25fb4d0e5ed5afd0c5'/>
<id>ec77d1f3d9fcf7105b6bda25fb4d0e5ed5afd0c5</id>
<content type='text'>
We had some custom classes that were used as the predicate for
`std::find_if`. It would be a lot simpler if we used lambdas instead.

Differential Revision: https://reviews.llvm.org/D150168
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We had some custom classes that were used as the predicate for
`std::find_if`. It would be a lot simpler if we used lambdas instead.

Differential Revision: https://reviews.llvm.org/D150168
</pre>
</div>
</content>
</entry>
</feed>
