Commit Graph

17 Commits

Author SHA1 Message Date
Augusto Noronha
58df5534d2 [NFC][RemoteInspection] Add an opaque AddressSpace field to RemoteAddress
Add an extra opaque field to AddressSpace, which can be used by clients
of RemoteInspection to distinguish between different address spaces.

LLDB employs an optimization where it reads memory from files instead of
the running process whenever it can to speed up memory reads (these can
be slow when debugging something over a network). To do this, it needs
to keep track whether an address originated from a process or a file. It
currently distinguishes addresses by setting an unused high bit on the
address, but because of pointer authentication this is not a reliable
solution. In order to keep this optimization working, this patch adds an
extra opaque AddressSpace field to RemoteAddress, which LLDB can use on
its own implementation of MemoryReader to distinguish between addresses.

This patch is NFC for the other RemoteInspection clients, as it adds
extra information to RemoteAddress, which is entirely optional and if
unused should not change the behavior of the library.

Although this patch is quite big the changes are largely mechanical,
replacing threading StoredPointer with RemoteAddress.

rdar://148361743
2025-07-09 14:52:42 -07:00
Mike Ash
ca06ced1d2 [Reflection] Cache the various DataQuery values.
We can end up querying the pointer size and similar things very frequently, which can be slow. These values don't change for any given reader, so call them once and cache the values locally instead.

rdar://150221008
2025-06-30 17:03:28 -04:00
Augusto Noronha
6a6b0ce80b [RemoteMirror] Remove accidental unconditional return 2025-05-08 15:15:43 -07:00
Mike Ash
a3c9ba16d0 [RemoteMirror] Fix generic subclasses of resilient superclasses.
Fix readMetadataBoundsOfSuperclass to recursively apply adjustForSubclass while going through the superclass chain.

Strip indirect descriptor pointers so we can deal with signed pointers here.

Make CMemoryReader assert (in asserts builds) that the addresses being read don't have any signature bits set, which helps track down places where we need to add stripping.

rdar://134448718
2024-08-22 18:12:05 -04:00
Joe Groff
263bbbb839 RemoteMirror: Work around flaw in C interface
The CMemoryReader interface relies on a `GetStringLength` callback, which
returns zero either if the address is invalid or if a valid zero-length
string exists at the given address. We don't want to break ABI with
RemoteMirror, but we can work around this by issuing a one-byte read
at the address and confirming that a null terminator exists there.
2019-10-01 12:36:49 -07:00
Kuba (Brecka) Mracek
84e71b8d7a Change the RemoteMirror API to have extensible data layout callback (#15291)
* Change the RemoteMirror API to have extensible data layout callback

* Use DLQ_Get prefix on DataLayoutQueryType enum values

* Simplify MemoryReaderImpl and synthesize minimalDataLayoutQueryFunction
2018-03-16 14:54:04 -07:00
Mike Ash
553ef86a4b [RemoteMirrors] Change MemoryReader::readBytes to return a unique_ptr instead of a tuple so that the destructor handles freeing the memory. 2018-03-02 12:05:36 -05:00
Mike Ash
d775f72d19 [RemoteMirrors] Support passing NULL for the FreeBytesFunction. 2018-02-27 15:16:15 -05:00
Mike Ash
71f1c391ab [RemoteMirrors] Move FreeBytesFunction from an out-parameter on ReadBytesFunction to a function pointer passed in when creating a reflection context. 2018-02-27 12:51:04 -05:00
Mike Ash
bf58357e54 [Reflection] Change ReadBytesFunction to return a pointer rather than copying data, and adjust its users accordingly.
rdar://problem/37538580
2018-02-21 12:17:28 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
David Farler
210f8dfe63 swift-reflection-test: Target SwiftRemoteMirror C API
This tool should test the usage from SwiftRemoteMirror dylib and
the C API, since that is the public interface from which we're
vending the remote reflection functionality.
2016-04-28 19:38:03 -07:00
David Farler
90f1523c4c Add opaque context pointer to SwiftRemoteMirror C API Reader API
Memory readers on the C-side of the API may actually have an object-
oriented design, so they may want to pass an instance to revive
when callbacks make it to the other side of the API boundary.
2016-04-25 00:00:27 -07:00
practicalswift
39c6b56fd0 [gardening] Fix file header formatting. 2016-04-13 10:07:23 +02:00
Chris Lattner
0f9d2c1d22 add some newlines at the end of files to avoid "dangerous" implementation
defined behavior in C++98.  I thought that C++'11 fixed this though, so it
isn't clear why clang is complaining about it.
2016-04-12 21:07:28 -07:00
John McCall
91f02848df Organize the MemoryReader interface headers to better support
multiple clients.
2016-04-12 16:05:29 -07:00