Commit Graph

9 Commits

Author SHA1 Message Date
Alejandro Alonso
382510fa50 Rename Reflection library to RemoteInspection (#62846) 2023-01-06 13:21:32 -05:00
Alastair Houghton
efe599754c [Tools] Fix swift-reflection-fuzzer.
A couple of things that swift-reflection-fuzzer uses have been updated
without updating swift-reflection-fuzzer, the upshot being that it now
won't build (which also blocks use of swift-demangle-fuzzer).

rdar://94143566
2022-05-31 12:28:42 +01:00
Alastair Houghton
28c0d9d989 [SR-14813] Reformat code slightly.
Used git-clang-format to fix up the changed code.
2021-06-23 12:57:20 +01:00
Alastair Houghton
501f30d302 [SR-14813] Tidy up the DLQ_GetPtrAuthMask case.
We should be using C++ casts here.
2021-06-23 12:54:23 +01:00
Alastair Houghton
b7db1600aa [SR-14813] Use the C++ standard library includes.
Replace use of stdio.h, stddef.h and stdint.h with the C++ versions of
those headers.
2021-06-23 12:53:26 +01:00
Alastair Houghton
a6ec498099 [SR-14813] [Fuzzers] Fix the mangler and reflection fuzzer build.
The mangler fuzzer and reflection fuzzer build was broken, both by a problem in
the CMake scripts and also because of changes that have happened in other parts
of the code.
2021-06-22 11:56:53 +01:00
Mishal Shah
6336b14db4 [Apple Silicon] [In-process memory reader] Adjust low-bits computation for arm64 macOS 2020-07-02 18:32:23 -07:00
tbkka
0d361bd3ea Teach RemoteMirror how to project enum values (#30161)
Teach RemoteMirror how to project enum values

This adds two new functions to the SwiftRemoteMirror
facility that support inspecting enum values.

Currently, these support non-payload enums and
single-payload enums, including nested enums and
payloads with struct, tuple, and reference payloads.
In particular, it handles nested `Optional` types.

TODO: Multi-payload enums use different strategies for
encoding the cases that aren't yet supported by this
code.

Note: This relies on information from dataLayoutQuery
to correctly decode invalid pointer values that are used
to encode enums.  Existing clients will need to augment
their DLQ functions before using these new APIs.

Resolves rdar://59961527

```
/// Projects the value of an enum.
///
/// Takes the address and typeref for an enum and determines the
/// index of the currently-selected case within the enum.
///
/// Returns true iff the enum case could be successfully determined.
/// In particular, note that this code may fail for valid in-memory data
/// if the compiler is using a strategy we do not yet understand.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
                                      swift_addr_t EnumAddress,
                                      swift_typeref_t EnumTypeRef,
                                      uint64_t *CaseIndex);

/// Finds information about a particular enum case.
///
/// Given an enum typeref and index of a case, returns:
/// * Typeref of the associated payload or zero if there is no payload
/// * Name of the case if known.
///
/// The Name points to a freshly-allocated C string on the heap.  You
/// are responsible for freeing the string (via `free()`) when you are finished.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
                                        swift_typeref_t EnumTypeRef,
                                        unsigned CaseIndex,
                                        char **CaseName,
                                        swift_typeref_t *PayloadTypeRef);
```


Co-authored-by: Mike Ash <mikeash@apple.com>
2020-03-06 13:17:40 -08:00
Davide Italiano
3a17628611 [Reflection] Add an utility to stress test the metadata reader.
lldb now uses this quite extensively so we want to make sure
we don't crash on invalid.

<rdar://problem/49043621>
2019-03-21 10:34:33 -07:00