<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/tools/debugserver/source/MacOSX/MachException.cpp, branch main</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>[debugserver] Remove PThreadMutex (NFC) (#137555)</title>
<updated>2025-04-28T18:28:45+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-04-28T18:28:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9d77a3fa1a4a68a533090266662863d32e9d5717'/>
<id>9d77a3fa1a4a68a533090266662863d32e9d5717</id>
<content type='text'>
Now that all uses of PThreadMutex have been migrated to their C++
equivalent, this PR removes PThreadMutex itself.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that all uses of PThreadMutex have been migrated to their C++
equivalent, this PR removes PThreadMutex itself.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][debugserver][MacOSX] Work around sanitizer misaligned address errors when reading exception data (#132193)</title>
<updated>2025-03-21T11:21:29+00:00</updated>
<author>
<name>Michael Buch</name>
<email>michaelbuch12@gmail.com</email>
</author>
<published>2025-03-21T11:21:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=52de49e4b9cd69957b7dc50a5fed061ecd0b0d77'/>
<id>52de49e4b9cd69957b7dc50a5fed061ecd0b0d77</id>
<content type='text'>
We've been dealing with UBSAN issues around this code for some time now
(see `9c36859b33b386fbfa9599646de1e2ae01158180` and
`1a2122e9e9d1d495fdf337a4a9445b61ca56df6f`). On recent macOS versions, a
UBSAN-enabled debugserver will crash when performing a `memcpy` of the
input `mach_exception_data_t`. The pointer to the beginning of the
exception data may not be aligned on a doubleword boundary, leading to
UBSAN failures such as:
```
$ ./bin/debugserver 0.0.0.0:5555 /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/build-sanitized-release/tools/lldb/test/Shell/Recognizer/Output/verbose_trap.test.tmp.out
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12: runtime error: store to misaligned address 0x00016ddfa634 for type 'mach_exception_data_type_t *' (aka 'long long *'), which requires 8 byte alignment
0x00016ddfa634: note: pointer points here
  02 00 00 00 03 00 01 00  00 00 00 00 11 00 00 00  00 00 00 00 00 00 00 00  08 00 00 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12
```

Work around these failures by pretending the input data is a `char*`
buffer.

Drive-by changes:
* I factored out some duplicated code into a static
`AppendExceptionData` and made the types consistent

---------

Co-authored-by: Jonas Devlieghere &lt;jonas@devlieghere.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We've been dealing with UBSAN issues around this code for some time now
(see `9c36859b33b386fbfa9599646de1e2ae01158180` and
`1a2122e9e9d1d495fdf337a4a9445b61ca56df6f`). On recent macOS versions, a
UBSAN-enabled debugserver will crash when performing a `memcpy` of the
input `mach_exception_data_t`. The pointer to the beginning of the
exception data may not be aligned on a doubleword boundary, leading to
UBSAN failures such as:
```
$ ./bin/debugserver 0.0.0.0:5555 /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/build-sanitized-release/tools/lldb/test/Shell/Recognizer/Output/verbose_trap.test.tmp.out
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12: runtime error: store to misaligned address 0x00016ddfa634 for type 'mach_exception_data_type_t *' (aka 'long long *'), which requires 8 byte alignment
0x00016ddfa634: note: pointer points here
  02 00 00 00 03 00 01 00  00 00 00 00 11 00 00 00  00 00 00 00 00 00 00 00  08 00 00 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12
```

Work around these failures by pretending the input data is a `char*`
buffer.

Drive-by changes:
* I factored out some duplicated code into a static
`AppendExceptionData` and made the types consistent

---------

Co-authored-by: Jonas Devlieghere &lt;jonas@devlieghere.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Add clarifying parenthesis around non-trivial conditions in ternary expressions. (#90391)</title>
<updated>2024-05-04T17:38:45+00:00</updated>
<author>
<name>luolent</name>
<email>56246516+luolent@users.noreply.github.com</email>
</author>
<published>2024-05-04T17:38:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a98a6e95be1be9a5c28da15b4d19a6f39872461d'/>
<id>a98a6e95be1be9a5c28da15b4d19a6f39872461d</id>
<content type='text'>
Fixes [#85868](https://github.com/llvm/llvm-project/issues/85868)

Parenthesis are added as requested on ternary operators with non trivial conditions.

I used this [precedence table](https://en.cppreference.com/w/cpp/language/operator_precedence) for reference, to make sure we get the expected behavior on each change.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes [#85868](https://github.com/llvm/llvm-project/issues/85868)

Parenthesis are added as requested on ternary operators with non trivial conditions.

I used this [precedence table](https://en.cppreference.com/w/cpp/language/operator_precedence) for reference, to make sure we get the expected behavior on each change.</pre>
</div>
</content>
</entry>
<entry>
<title>Align mach exception data before accessing it</title>
<updated>2023-08-18T22:34:13+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jason@molenda.com</email>
</author>
<published>2023-08-18T22:34:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1a2122e9e9d1d495fdf337a4a9445b61ca56df6f'/>
<id>1a2122e9e9d1d495fdf337a4a9445b61ca56df6f</id>
<content type='text'>
The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.

Differential Revision: https://reviews.llvm.org/D158312
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.

Differential Revision: https://reviews.llvm.org/D158312
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Align mach exception data before accessing it"</title>
<updated>2023-08-18T22:33:32+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jason@molenda.com</email>
</author>
<published>2023-08-18T22:33:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ef70f5c6bbdadcaaeed6f028ed8eee8112b6543a'/>
<id>ef70f5c6bbdadcaaeed6f028ed8eee8112b6543a</id>
<content type='text'>
This reverts commit b10c2f846d936a98eecfcef1a90a754522282285.

Need to add the phabracator line to the message.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit b10c2f846d936a98eecfcef1a90a754522282285.

Need to add the phabracator line to the message.
</pre>
</div>
</content>
</entry>
<entry>
<title>Align mach exception data before accessing it</title>
<updated>2023-08-18T22:32:03+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jason@molenda.com</email>
</author>
<published>2023-08-18T22:30:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b10c2f846d936a98eecfcef1a90a754522282285'/>
<id>b10c2f846d936a98eecfcef1a90a754522282285</id>
<content type='text'>
The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.
</pre>
</div>
</content>
</entry>
<entry>
<title>AArch64 debugserver parse ESR register for watchpoints</title>
<updated>2023-04-13T01:36:17+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jason@molenda.com</email>
</author>
<published>2023-04-13T01:31:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e76cfaca70be0b45e62149e52f68d8352fa8ea2f'/>
<id>e76cfaca70be0b45e62149e52f68d8352fa8ea2f</id>
<content type='text'>
Have debugserver parse the watchpoint flags out of the exception
syndrome register when we get a watchpoint mach exception.  Relay
those fields up to lldb in the stop reply packet, if the watchpoint
number was reported by the hardware, use the address from that as
the watchpoint address.

Change how watchpoints are reported to lldb from using the mach
exception data, to using the `reason:watchpoint` and `description:asciihex`
method that lldb-server uses, which can relay the actual trap address
as well as the address of a watched memory region responsible for
the trap, so lldb can step past it.

Have debugserver look for the nearest watchpoint that it has set
when it gets a watchpoint trap, so accesses that are reported as
starting before the watched region are associated with the correct
watchpoint to lldb.  Add a test case for this specific issue.

Differential Revision: https://reviews.llvm.org/D147820
rdar://83996471
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Have debugserver parse the watchpoint flags out of the exception
syndrome register when we get a watchpoint mach exception.  Relay
those fields up to lldb in the stop reply packet, if the watchpoint
number was reported by the hardware, use the address from that as
the watchpoint address.

Change how watchpoints are reported to lldb from using the mach
exception data, to using the `reason:watchpoint` and `description:asciihex`
method that lldb-server uses, which can relay the actual trap address
as well as the address of a watched memory region responsible for
the trap, so lldb can step past it.

Have debugserver look for the nearest watchpoint that it has set
when it gets a watchpoint trap, so accesses that are reported as
starting before the watched region are associated with the correct
watchpoint to lldb.  Add a test case for this specific issue.

Differential Revision: https://reviews.llvm.org/D147820
rdar://83996471
</pre>
</div>
</content>
</entry>
<entry>
<title>Add a darwin platform setting to specify which exceptions debugserver</title>
<updated>2022-05-18T17:16:11+00:00</updated>
<author>
<name>Jim Ingham</name>
<email>jingham@apple.com</email>
</author>
<published>2022-05-11T22:10:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bff4673b41781ec5bff6b96b52cf321d2271726c'/>
<id>bff4673b41781ec5bff6b96b52cf321d2271726c</id>
<content type='text'>
should not receive as exceptions (some will get converted to BSD
signals instead).  This is really the only stable way to ensure that
a Mach exception gets converted to it's equivalent BSD signal.  For
programs that rely on BSD signal handlers, this has to happen or you
can't even get the program to invoke the signal handler when under
the debugger.

This builds on a previous solution to this problem which required you
start debugserver with the -U flag.  This was not very discoverable
and required lldb be the one to launch debugserver, which is not always
the case.

Differential Revision: https://reviews.llvm.org/D125434
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
should not receive as exceptions (some will get converted to BSD
signals instead).  This is really the only stable way to ensure that
a Mach exception gets converted to it's equivalent BSD signal.  For
programs that rely on BSD signal handlers, this has to happen or you
can't even get the program to invoke the signal handler when under
the debugger.

This builds on a previous solution to this problem which required you
start debugserver with the -U flag.  This was not very discoverable
and required lldb be the one to launch debugserver, which is not always
the case.

Differential Revision: https://reviews.llvm.org/D125434
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFC] Use C++ versions of the deprecated C standard library headers</title>
<updated>2021-05-26T10:46:12+00:00</updated>
<author>
<name>Raphael Isemann</name>
<email>teemperor@gmail.com</email>
</author>
<published>2021-05-26T10:19:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=76e47d4887f456878c0e2f20ebfae36267006cd7'/>
<id>76e47d4887f456878c0e2f20ebfae36267006cd7</id>
<content type='text'>
The C headers are deprecated so as requested in D102845, this is replacing them
all with their (not deprecated) C++ equivalent.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D103084
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The C headers are deprecated so as requested in D102845, this is replacing them
all with their (not deprecated) C++ equivalent.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D103084
</pre>
</div>
</content>
</entry>
<entry>
<title>Upstream a few small Apple changes to debugserver - arm64_32, Catalyst</title>
<updated>2019-08-07T02:06:06+00:00</updated>
<author>
<name>Jason Molenda</name>
<email>jmolenda@apple.com</email>
</author>
<published>2019-08-07T02:06:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6cebeafac31ceb500494bb301e365363c3d5992a'/>
<id>6cebeafac31ceb500494bb301e365363c3d5992a</id>
<content type='text'>
Adrian's changes to support Catalyst processes and my
changes to support debugserver running on an arm64_32
device (Apple Watch Series 4, which uses an IPL32 model
on arm64 cpus).

llvm-svn: 368118
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Adrian's changes to support Catalyst processes and my
changes to support debugserver running on an arm64_32
device (Apple Watch Series 4, which uses an IPL32 model
on arm64 cpus).

llvm-svn: 368118
</pre>
</div>
</content>
</entry>
</feed>
