Commit Graph

17 Commits

Author SHA1 Message Date
Mike Ash
31f68b1687 [RemoteMirror] Add a call for iterating over the allocations belonging to an AsyncTask.
rdar://72907056
2021-02-11 17:14:38 -05:00
3405691582
7687bc13d2 [tools] Fix invocation of execv.
If execv fails, then there is no valid indication of what failed. This
may manifest itself as an unexpected EOF in `collectBytesFromPipe` when
in fact this is a problem with `execv`. Check the return status and be
noisy if the exec fails.

Now, on other platforms, it may not be a runtime error to call
`execv(..., NULL)`, despite the manual pages and standards requesting
that a valid array be passed. Furthermore, other platforms may require
that argv[0] be populated, and with a valid executable name.

Ensuring that these conditions are fulfilled is more correct, and
permits the Reflection validation tests to successfully run and pass on
OpenBSD.
2021-02-07 10:22:59 -05:00
David Zarzycki
f4be48b157 [NFC] arithmetic on a pointer to void is a GNU extension [-Wpointer-arith] 2021-02-01 07:43:07 -05:00
Augusto Noronha
3cb8f9b6fc Add entrypoints to the runtime that exposes metadata necessary for reflection tests on Linux (#32339) 2020-07-24 15:26:15 -07: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
3c8fde7885 Implement MultiPayloadEnum support for projectEnumValue (#30635)
This code rearchitects and simplifies the projectEnumValue support by
introducing a new `TypeInfo` subclass for each kind of enum, including trivial,
no-payload, single-payload, and three different classes for multi-payload enums:

* "UnsupportedEnum" that we don't understand.  This returns "don't know" answers for all requests in cases where the runtime lacks enough information to accurately handle a particular enum.

* MP Enums that only use a separate tag value.  This includes generic enums and other dynamic layouts, as well as enums whose payloads have no spare bits.

* MP Enums that use spare bits, possibly in addition to a separate tag.  This logic can only be used, of course, if we can in fact compute a spare bit mask that agrees with the compiler.

The final challenge is to choose one of the above three handlings for every MPE.  Currently, we do not have an accurate source of information for the spare bit mask, so we never choose the third option above.  We use the second option for dynamic MPE layouts (including generics) and the first for everything else.

TODO: Once we can arrange for the compiler to expose spare bit mask data, we'll be able to use that to drive more MPE cases.
2020-03-31 15:12:44 -07:00
Kuba Mracek
c0ab0c9c0a Fixup swift-reflection-test.c and swift-reflection-dump.cpp 2020-03-07 08:11:52 -08:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08: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
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
David Zarzycki
12ccc5df2c [Testing] Review feedback 2019-08-27 10:56:23 +01:00
David Zarzycki
db0fea4cb4 [Testing] Fix some build warnings 2019-08-26 08:16:06 +01:00
Saleem Abdulrasool
7b1f732b1d swift-reflection-test: silence tautological warning
PE/COFF does not permit weak linking semantics.  This means that the
expression `&symbol == NULL` is tautologically false.  In order to
support this semantic, the symbol needs to be dynamically looked up at
runtime.  Since the ObjC runtime is not in use on Windows currently,
just ignore this for the time being.  Silences a warning from clang
about the tautological comparison.
2019-06-02 11:36:49 -07:00
Mike Ash
8b0ab1cc49 [RemoteMirror] Mark swift_reflection_classIsSwiftMask as a weak import.
Also have swift-reflection-test check if the symbol exists. This allows swift-reflection-test to work with older Remote Mirror dylibs that don't have it.

rdar://problem/50030805
2019-04-23 11:37:37 -04:00
Mike Ash
fbe990481b [Runtime] Dynamically select the is-Swift bit at runtime on Apple platforms.
Recent Swift uses 2 as the is-Swift bit when running on newer versions, and 1 on older versions. Since it's difficult or impossible to know what we'll be running on at build time, make the selection at runtime.
2019-03-07 10:12:27 -05:00
Mike Ash
dd170399e4 [Reflection] Add some (disabled by default) debug logging in swift-reflection-test.c. 2019-02-27 14:37:33 -05:00
Michael Gottesman
089e3a8ecd [cmake] tools/swift-reflection-test => stdlib/tools/swift-reflection-test.
If one thinks about it, swift's build has two sections: a runtime or target
section (i.e. ./stdlib) and a host section (everything
else). swift-reflection-test is an abberation from that pattern since it is
built for target platforms but is in the section of host tools.

In this commit, I move it into ./stdlib. Beyond being a bitter location
conceptually this will additionally allow me to avoid a dependency cycle in
between the compiler and the stdlib build.

After this, there is only one more target in the compiler code: swift-lang. From
talking with Xi Ge, we can move that into its own separate project as a
package. Once that is done, I will not have any more cycles.
2018-12-09 02:20:33 -08:00