<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/source/Breakpoint/Watchpoint.cpp, branch users/dlav-sc/lldb_refactor_stopinfo</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][NFC] Refactor StopInfoWatchpoint::PerformAction</title>
<updated>2025-10-16T04:37:35+00:00</updated>
<author>
<name>Daniil Avdeev</name>
<email>daniil.avdeev@syntacore.com</email>
</author>
<published>2025-02-10T03:16:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b35eaf0aa8aa9b4de19ca88b101ba950e0b91b0e'/>
<id>b35eaf0aa8aa9b4de19ca88b101ba950e0b91b0e</id>
<content type='text'>
Refactor watchpoint logic 2/2

This patch refactors the StopInfoWatchpoint::PerformAction function. It
leverages the ShouldReport method introduced in the previous patch to
significantly simplify the PerformAction logic.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Refactor watchpoint logic 2/2

This patch refactors the StopInfoWatchpoint::PerformAction function. It
leverages the ShouldReport method introduced in the previous patch to
significantly simplify the PerformAction logic.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFC] Refactor Watchpoint class</title>
<updated>2025-10-16T04:33:34+00:00</updated>
<author>
<name>Daniil Avdeev</name>
<email>daniil.avdeev@syntacore.com</email>
</author>
<published>2025-02-10T03:16:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c191fd18dee872b1c56dc5c75336fa6a9acfb691'/>
<id>c191fd18dee872b1c56dc5c75336fa6a9acfb691</id>
<content type='text'>
Refactor watchpoint logic 1/2

This patch refactors the Watchpoint class to prepare for future code
improvements. The core changes include:

* Adding check logic to the stoppoint side
This patch adds a ShouldReport method to the Watchpoint class. This
method implements the logic from PerformAction for determining whether
a watchpoint hit should be reported. While the original logic in
StopInfoWatchpoint remains unchanged for now, ShouldReport allows to
simplify PerformAction and reduce coupling between the classes in the
subsequent patch.

* Preparing to eliminate redundant calculations
Currently, WatchedValueReportable and CaptureWatchedValue contain
duplicated code for calculating the watched value. Since PerformAction
calls these methods sequentially, the value is computed twice.
Consolidation of logic in ShouldReport provides the ability to remove
the code duplication and redundant calculations in the next patch.

Note that this patch doesn't use new functions yet. This is just a
preparatory step that facilitates the subsequent refactoring of
PerformAction logic.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Refactor watchpoint logic 1/2

This patch refactors the Watchpoint class to prepare for future code
improvements. The core changes include:

* Adding check logic to the stoppoint side
This patch adds a ShouldReport method to the Watchpoint class. This
method implements the logic from PerformAction for determining whether
a watchpoint hit should be reported. While the original logic in
StopInfoWatchpoint remains unchanged for now, ShouldReport allows to
simplify PerformAction and reduce coupling between the classes in the
subsequent patch.

* Preparing to eliminate redundant calculations
Currently, WatchedValueReportable and CaptureWatchedValue contain
duplicated code for calculating the watched value. Since PerformAction
calls these methods sequentially, the value is computed twice.
Consolidation of logic in ShouldReport provides the ability to remove
the code duplication and redundant calculations in the next patch.

Note that this patch doesn't use new functions yet. This is just a
preparatory step that facilitates the subsequent refactoring of
PerformAction logic.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Fix else-after-return in Breakpoint (NFC)</title>
<updated>2025-07-02T19:07:20+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-07-02T17:37:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ab0fa6c5dc725ef6f839ac8cea9b3a41aa3a5b75'/>
<id>ab0fa6c5dc725ef6f839ac8cea9b3a41aa3a5b75</id>
<content type='text'>
The LLVM Coding Standards [1] discourages the use of 'else' or 'else if'
after something that interrupts control flow. Bulk fix all instances as
I'm working on this part of LLDB.

[1] https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The LLVM Coding Standards [1] discourages the use of 'else' or 'else if'
after something that interrupts control flow. Bulk fix all instances as
I'm working on this part of LLDB.

[1] https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Move ValueObject into its own library (NFC) (#113393)</title>
<updated>2024-10-25T03:20:48+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2024-10-25T03:20:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b852fb1ec5fa15f0b913cc4988cbd09239b19904'/>
<id>b852fb1ec5fa15f0b913cc4988cbd09239b19904</id>
<content type='text'>
ValueObject is part of lldbCore for historical reasons, but conceptually
it deserves to be its own library. This does introduce a (link-time) circular
dependency between lldbCore and lldbValueObject, which is unfortunate
but probably unavoidable because so many things in LLDB rely on
ValueObject. We already have cycles and these libraries are never built
as dylibs so while this doesn't improve the situation, it also doesn't
make things worse.

The header includes were updated with the following command:

```
find . -type f -exec sed -i.bak "s%include \"lldb/Core/ValueObject%include \"lldb/ValueObject/ValueObject%" '{}' \;
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ValueObject is part of lldbCore for historical reasons, but conceptually
it deserves to be its own library. This does introduce a (link-time) circular
dependency between lldbCore and lldbValueObject, which is unfortunate
but probably unavoidable because so many things in LLDB rely on
ValueObject. We already have cycles and these libraries are never built
as dylibs so while this doesn't improve the situation, it also doesn't
make things worse.

The header includes were updated with the following command:

```
find . -type f -exec sed -i.bak "s%include \"lldb/Core/ValueObject%include \"lldb/ValueObject/ValueObject%" '{}' \;
```</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[lldb] unique_ptr-ify some GetUserExpression APIs. (#106034)"</title>
<updated>2024-08-28T05:49:40+00:00</updated>
<author>
<name>Lang Hames</name>
<email>lhames@gmail.com</email>
</author>
<published>2024-08-28T05:49:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e6cbea11578f197589801297d22b9b3bc4f1bd10'/>
<id>e6cbea11578f197589801297d22b9b3bc4f1bd10</id>
<content type='text'>
This reverts commit 3c5ab5a75a9c8fb87dcb13cdf4207aa975fd6972 while I investigate
bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/163/builds/4286).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 3c5ab5a75a9c8fb87dcb13cdf4207aa975fd6972 while I investigate
bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/163/builds/4286).
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] unique_ptr-ify some GetUserExpression APIs. (#106034)</title>
<updated>2024-08-28T05:36:57+00:00</updated>
<author>
<name>Lang Hames</name>
<email>lhames@gmail.com</email>
</author>
<published>2024-08-28T05:36:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3c5ab5a75a9c8fb87dcb13cdf4207aa975fd6972'/>
<id>3c5ab5a75a9c8fb87dcb13cdf4207aa975fd6972</id>
<content type='text'>
These methods already returned a uniquely owned object, this just makes
them self-documenting.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These methods already returned a uniquely owned object, this just makes
them self-documenting.</pre>
</div>
</content>
</entry>
<entry>
<title>Convert ValueObject::Dump() to return llvm::Error() (NFCish)</title>
<updated>2024-06-20T17:32:06+00:00</updated>
<author>
<name>Adrian Prantl</name>
<email>aprantl@apple.com</email>
</author>
<published>2024-06-17T21:29:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d1bc75c0bce141b94f9afadfde4e784760735ec0'/>
<id>d1bc75c0bce141b94f9afadfde4e784760735ec0</id>
<content type='text'>
This change by itself has no measurable effect on the LLDB
testsuite. I'm making it in preparation for threading through more
errors in the Swift language plugin.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change by itself has no measurable effect on the LLDB
testsuite. I'm making it in preparation for threading through more
errors in the Swift language plugin.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add a new SBExpressionOptions::SetLanguage() API (NFCI) (#89981)</title>
<updated>2024-04-29T20:26:24+00:00</updated>
<author>
<name>Adrian Prantl</name>
<email>aprantl@apple.com</email>
</author>
<published>2024-04-29T20:26:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=975eca0e6a3459e59e96b0df33ea0cfbd157c597'/>
<id>975eca0e6a3459e59e96b0df33ea0cfbd157c597</id>
<content type='text'>
that separates out language and version. To avoid reinventing the wheel
and introducing subtle incompatibilities, this API uses the table of
languages and versiond defined by the upcoming DWARF 6 standard
(https://dwarfstd.org/languages-v6.html). While the DWARF 6 spec is not
finialized, the list of languages is broadly considered stable.

The primary motivation for this is to allow the Swift language plugin to
switch between language dialects between, e.g., Swift 5.9 and 6.0 with
out introducing a ton of new language codes. On the main branch this
change is considered NFC.

Depends on https://github.com/llvm/llvm-project/pull/89980</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
that separates out language and version. To avoid reinventing the wheel
and introducing subtle incompatibilities, this API uses the table of
languages and versiond defined by the upcoming DWARF 6 standard
(https://dwarfstd.org/languages-v6.html). While the DWARF 6 spec is not
finialized, the list of languages is broadly considered stable.

The primary motivation for this is to allow the Swift language plugin to
switch between language dialects between, e.g., Swift 5.9 and 6.0 with
out introducing a ton of new language codes. On the main branch this
change is considered NFC.

Depends on https://github.com/llvm/llvm-project/pull/89980</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Add support for large watchpoints in lldb (#79962)</title>
<updated>2024-02-01T05:03:38+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jason@molenda.com</email>
</author>
<published>2024-02-01T05:01:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=147d7a64f8493e78669581097a3ff06c985aa3a1'/>
<id>147d7a64f8493e78669581097a3ff06c985aa3a1</id>
<content type='text'>
This patch is the next piece of work in my Large Watchpoint proposal,
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116

This patch breaks a user's watchpoint into one or more
WatchpointResources which reflect what the hardware registers can cover.
This means we can watch objects larger than 8 bytes, and we can watched
unaligned address ranges. On a typical 64-bit target with 4 watchpoint
registers you can watch 32 bytes of memory if the start address is
doubleword aligned.

Additionally, if the remote stub implements AArch64 MASK style
watchpoints (e.g. debugserver on Darwin), we can watch any power-of-2
size region of memory up to 2GB, aligned to that same size.

I updated the Watchpoint constructor and CommandObjectWatchpoint to
create a CompilerType of Array&lt;UInt8&gt; when the size of the watched
region is greater than pointer-size and we don't have a variable type to
use. For pointer-size and smaller, we can display the watched granule as
an integer value; for larger-than-pointer-size we will display as an
array of bytes.

I have `watchpoint list` now print the WatchpointResources used to
implement the watchpoint.

I added a WatchpointAlgorithm class which has a top-level static method
that takes an enum flag mask WatchpointHardwareFeature and a user
address and size, and returns a vector of WatchpointResources covering
the request. It does not take into account the number of watchpoint
registers the target has, or the number still available for use. Right
now there is only one algorithm, which monitors power-of-2 regions of
memory. For up to pointer-size, this is what Intel hardware supports.
AArch64 Byte Address Select watchpoints can watch any number of
contiguous bytes in a pointer-size memory granule, that is not currently
supported so if you ask to watch bytes 3-5, the algorithm will watch the
entire doubleword (8 bytes). The newly default "modify" style means we
will silently ignore modifications to bytes outside the watched range.

I've temporarily skipped TestLargeWatchpoint.py for all targets. It was
only run on Darwin when using the in-tree debugserver, which was a proxy
for "debugserver supports MASK watchpoints". I'll be adding the
aforementioned feature flag from the stub and enabling full mask
watchpoints when a debugserver with that feature is enabled, and
re-enable this test.

I added a new TestUnalignedLargeWatchpoint.py which only has one test
but it's a great one, watching a 22-byte range that is unaligned and
requires four 8-byte watchpoints to cover.

I also added a unit test, WatchpointAlgorithmsTests, which has a number
of simple tests against WatchpointAlgorithms::PowerOf2Watchpoints. I
think there's interesting possible different approaches to how we cover
these; I note in the unit test that a user requesting a watch on address
0x12e0 of 120 bytes will be covered by two watchpoints today, a
128-bytes at 0x1280 and at 0x1300. But it could be done with a 16-byte
watchpoint at 0x12e0 and a 128-byte at 0x1300, which would have fewer
false positives/private stops. As we try refining this one, it's helpful
to have a collection of tests to make sure things don't regress.

I tested this on arm64 macOS, (genuine) x86_64 macOS, and AArch64
Ubuntu. I have not modifed the Windows process plugins yet, I might try
that as a standalone patch, I'd be making the change blind, but the
necessary changes (see ProcessGDBRemote::EnableWatchpoint) are pretty
small so it might be obvious enough that I can change it and see what
the Windows CI thinks.

There isn't yet a packet (or a qSupported feature query) for the gdb
remote serial protocol stub to communicate its watchpoint capabilities
to lldb. I'll be doing that in a patch right after this is landed,
having debugserver advertise its capability of AArch64 MASK watchpoints,
and have ProcessGDBRemote add eWatchpointHardwareArmMASK to
WatchpointAlgorithms so we can watch larger than 32-byte requests on
Darwin.

I haven't yet tackled WatchpointResource *sharing* by multiple
Watchpoints. This is all part of the goal, especially when we may be
watching a larger memory range than the user requested, if they then add
another watchpoint next to their first request, it may be covered by the
same WatchpointResource (hardware watchpoint register). Also one "read"
watchpoint and one "write" watchpoint on the same memory granule need to
be handled, making the WatchpointResource cover all requests.

As WatchpointResources aren't shared among multiple Watchpoints yet,
there's no handling of running the conditions/commands/etc on multiple
Watchpoints when their shared WatchpointResource is hit. The goal beyond
"large watchpoint" is to unify (much more) the Watchpoint and Breakpoint
behavior and commands. I have a feeling I may be slowly chipping away at
this for a while.

Re-landing this patch after fixing two undefined behaviors in
WatchpointAlgorithms found by UBSan and by failures on different
CI bots.

rdar://108234227
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch is the next piece of work in my Large Watchpoint proposal,
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116

This patch breaks a user's watchpoint into one or more
WatchpointResources which reflect what the hardware registers can cover.
This means we can watch objects larger than 8 bytes, and we can watched
unaligned address ranges. On a typical 64-bit target with 4 watchpoint
registers you can watch 32 bytes of memory if the start address is
doubleword aligned.

Additionally, if the remote stub implements AArch64 MASK style
watchpoints (e.g. debugserver on Darwin), we can watch any power-of-2
size region of memory up to 2GB, aligned to that same size.

I updated the Watchpoint constructor and CommandObjectWatchpoint to
create a CompilerType of Array&lt;UInt8&gt; when the size of the watched
region is greater than pointer-size and we don't have a variable type to
use. For pointer-size and smaller, we can display the watched granule as
an integer value; for larger-than-pointer-size we will display as an
array of bytes.

I have `watchpoint list` now print the WatchpointResources used to
implement the watchpoint.

I added a WatchpointAlgorithm class which has a top-level static method
that takes an enum flag mask WatchpointHardwareFeature and a user
address and size, and returns a vector of WatchpointResources covering
the request. It does not take into account the number of watchpoint
registers the target has, or the number still available for use. Right
now there is only one algorithm, which monitors power-of-2 regions of
memory. For up to pointer-size, this is what Intel hardware supports.
AArch64 Byte Address Select watchpoints can watch any number of
contiguous bytes in a pointer-size memory granule, that is not currently
supported so if you ask to watch bytes 3-5, the algorithm will watch the
entire doubleword (8 bytes). The newly default "modify" style means we
will silently ignore modifications to bytes outside the watched range.

I've temporarily skipped TestLargeWatchpoint.py for all targets. It was
only run on Darwin when using the in-tree debugserver, which was a proxy
for "debugserver supports MASK watchpoints". I'll be adding the
aforementioned feature flag from the stub and enabling full mask
watchpoints when a debugserver with that feature is enabled, and
re-enable this test.

I added a new TestUnalignedLargeWatchpoint.py which only has one test
but it's a great one, watching a 22-byte range that is unaligned and
requires four 8-byte watchpoints to cover.

I also added a unit test, WatchpointAlgorithmsTests, which has a number
of simple tests against WatchpointAlgorithms::PowerOf2Watchpoints. I
think there's interesting possible different approaches to how we cover
these; I note in the unit test that a user requesting a watch on address
0x12e0 of 120 bytes will be covered by two watchpoints today, a
128-bytes at 0x1280 and at 0x1300. But it could be done with a 16-byte
watchpoint at 0x12e0 and a 128-byte at 0x1300, which would have fewer
false positives/private stops. As we try refining this one, it's helpful
to have a collection of tests to make sure things don't regress.

I tested this on arm64 macOS, (genuine) x86_64 macOS, and AArch64
Ubuntu. I have not modifed the Windows process plugins yet, I might try
that as a standalone patch, I'd be making the change blind, but the
necessary changes (see ProcessGDBRemote::EnableWatchpoint) are pretty
small so it might be obvious enough that I can change it and see what
the Windows CI thinks.

There isn't yet a packet (or a qSupported feature query) for the gdb
remote serial protocol stub to communicate its watchpoint capabilities
to lldb. I'll be doing that in a patch right after this is landed,
having debugserver advertise its capability of AArch64 MASK watchpoints,
and have ProcessGDBRemote add eWatchpointHardwareArmMASK to
WatchpointAlgorithms so we can watch larger than 32-byte requests on
Darwin.

I haven't yet tackled WatchpointResource *sharing* by multiple
Watchpoints. This is all part of the goal, especially when we may be
watching a larger memory range than the user requested, if they then add
another watchpoint next to their first request, it may be covered by the
same WatchpointResource (hardware watchpoint register). Also one "read"
watchpoint and one "write" watchpoint on the same memory granule need to
be handled, making the WatchpointResource cover all requests.

As WatchpointResources aren't shared among multiple Watchpoints yet,
there's no handling of running the conditions/commands/etc on multiple
Watchpoints when their shared WatchpointResource is hit. The goal beyond
"large watchpoint" is to unify (much more) the Watchpoint and Breakpoint
behavior and commands. I have a feeling I may be slowly chipping away at
this for a while.

Re-landing this patch after fixing two undefined behaviors in
WatchpointAlgorithms found by UBSan and by failures on different
CI bots.

rdar://108234227
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFCI] Remove m_being_created from Breakpoint classes (#79716)</title>
<updated>2024-01-31T22:44:52+00:00</updated>
<author>
<name>Alex Langford</name>
<email>alangford@apple.com</email>
</author>
<published>2024-01-31T22:44:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=db68e9229b54f1d72c0a4445682718d75e532b5d'/>
<id>db68e9229b54f1d72c0a4445682718d75e532b5d</id>
<content type='text'>
The purpose of m_being_created in these classes was to prevent
broadcasting an event related to these Breakpoints during the creation
of the breakpoint (i.e. in the constructor). In Breakpoint and
Watchpoint, m_being_created had no effect. That is to say, removing it
does not change behavior.
However, BreakpointLocation does still use m_being_created. In the
constructor, SetThreadID is called which does broadcast an event only if
`m_being_created` is false. Instead of having this logic be roundabout,
the constructor instead calls `SetThreadIDInternal`, which actually
changes the thread ID. `SetThreadID` also will call
`SetThreadIDInternal` in addition to broadcasting a changed event.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The purpose of m_being_created in these classes was to prevent
broadcasting an event related to these Breakpoints during the creation
of the breakpoint (i.e. in the constructor). In Breakpoint and
Watchpoint, m_being_created had no effect. That is to say, removing it
does not change behavior.
However, BreakpointLocation does still use m_being_created. In the
constructor, SetThreadID is called which does broadcast an event only if
`m_being_created` is false. Instead of having this logic be roundabout,
the constructor instead calls `SetThreadIDInternal`, which actually
changes the thread ID. `SetThreadID` also will call
`SetThreadIDInternal` in addition to broadcasting a changed event.</pre>
</div>
</content>
</entry>
</feed>
