Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Features**

- Updated libswift demangle to v6.1.0. ([#913](https://github.com/getsentry/symbolic/pull/913))

## 12.15.3

**Features**
Expand Down
3 changes: 3 additions & 0 deletions symbolic-demangle/tests/test_swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,8 @@ fn test_demangle_swift_no_args() {
// Swift 6.0.3
"$ss27withTaskCancellationHandler9operation8onCancel9isolationxxyYaKXE_yyYbXEScA_pSgYitYaKlFTwb" => "withTaskCancellationHandler<A>",
"$s11Supercharge2AXO7ElementPAAE8elements33_35EDDAA799FBB5B74D2F426690B0D99DLL3for2asSayqd__GSo28NSAccessibilityAttributeNamea_qd__mtSo7AXErrorVYKAcDRd__lFAC3AppC_AC6WindowCTgm5" => "specialized AX.Element.elements<A>",

// Swift 6.1.0
"$sTB" => "$sTB",
});
}
14 changes: 7 additions & 7 deletions symbolic-demangle/vendor/swift/1-arguments.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
commit 80e772078494a73f2fbb5e385de2092e6057d913
Author: David Herberth <[email protected]>
Date: Thu Jan 9 10:54:28 2025 +0100
commit 688c78af45dc197ce0ef8a0ea520d77592905394
Author: Sebastian Zivota <[email protected]>
Date: Wed Apr 16 18:43:43 2025 +0200

apply patch
Apply patch

diff --git a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h
index f66dd7fd..940c3652 100644
index 3e029a9b..da18a09a 100644
--- a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h
+++ b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h
@@ -58,6 +58,7 @@ struct DemangleOptions {
Expand All @@ -25,10 +25,10 @@ index f66dd7fd..940c3652 100644
return Opt;
};
diff --git a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp
index 6c309bbf..5b251e8d 100644
index d9098192..5e8ae258 100644
--- a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp
+++ b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp
@@ -955,10 +955,11 @@ private:
@@ -966,10 +966,11 @@ private:
if (isSendable)
Printer << "@Sendable ";

Expand Down
10 changes: 6 additions & 4 deletions symbolic-demangle/vendor/swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This folder contains a vendored subset of the [Swift Programming Language]. The Swift library is
reduced to the demangler only to reduce the size of this package.

The current version is **Swift 5.5.1**.
The current version is **Swift 6.1.0**.

## Sentry Modifications

Expand All @@ -28,7 +28,7 @@ patch is maintained in `1-arguments.patch`.
4. Check out the release branch of the latest release:
```
$ cd swift
$ git checkout swift-5.5.1-RELEASE
$ git checkout swift-x.x.x-RELEASE
```
5. Build the complete swift project (be very patient, this may take long):
```
Expand All @@ -40,14 +40,16 @@ patch is maintained in `1-arguments.patch`.
$ ./update.py swift-source
```
2. Check for modifications.
3. Commit _"feat(demangle): Import libswift demangle x.x.x"_ before proceeding.
3. **BUG**: If the file `./include/swift/ABI/InvertibleProtocols.def` is not automatically
copied, copy it manually from `swift-source/swift/include/swift/ABI/InvertibleProtocols.def`.
4. Commit _"feat(demangle): Import libswift demangle x.x.x"_ before proceeding.
3. **Apply the patch:**
1. Apply `1-arguments.patch`.
2. Build the Rust library and ensure tests work.
3. Commit the changes.
4. **Add tests for new mangling schemes:**
1. Identify new mangling schemes. Skip if there are no known changes.
2. Add test cases to `tests/swift.rs`
2. Add test cases to `tests/test_swift.rs`
5. **Update Repository metadata**:
1. Bump the Swift version number in this README.
2. Check for changes in the license and update the files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ enum class MangledDifferentiabilityKind : char {
Linear = 'l',
};

enum class MangledLifetimeDependenceKind : char { Inherit = 'i', Scope = 's' };
enum class MangledSILThunkKind : char {
Invalid = 0,
Identity = 'I',
HopToMainActorIfNeeded = 'H',
};

/// The pass that caused the specialization to occur. We use this to make sure
/// that two passes that generate similar changes do not yield the same
Expand Down Expand Up @@ -247,6 +251,25 @@ class Node {
}
}

static bool deepEquals(const Node *lhs, const Node *rhs) {
if (lhs == rhs)
return true;
if ((!lhs && rhs) || (lhs && !rhs))
return false;
if (!lhs->isSimilarTo(rhs))
return false;
for (auto li = lhs->begin(), ri = rhs->begin(), le = lhs->end(); li != le;
++li, ++ri) {
if (!deepEquals(*li, *ri))
return false;
}
return true;
}

bool isDeepEqualTo(const Node *other) const {
return deepEquals(this, other);
}

bool hasText() const { return NodePayloadKind == PayloadKind::Text; }
llvm::StringRef getText() const {
assert(hasText());
Expand Down Expand Up @@ -601,6 +624,7 @@ struct [[nodiscard]] ManglingError {
UnknownEncoding,
InvalidImplCalleeConvention,
InvalidImplDifferentiability,
InvalidImplCoroutineKind,
InvalidImplFunctionAttribute,
InvalidImplParameterConvention,
InvalidImplParameterSending,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NODE(BoundGenericTypeAlias)
NODE(BoundGenericFunction)
NODE(BuiltinTypeName)
NODE(BuiltinTupleType)
NODE(BuiltinFixedArray)
NODE(CFunctionPointer)
NODE(ClangType)
CONTEXT_NODE(Class)
Expand Down Expand Up @@ -140,6 +141,7 @@ NODE(ImplFunctionAttribute)
NODE(ImplFunctionConvention)
NODE(ImplFunctionConventionName)
NODE(ImplFunctionType)
NODE(ImplCoroutineKind)
NODE(ImplInvocationSubstitutions)
CONTEXT_NODE(ImplicitClosure)
NODE(ImplParameter)
Expand All @@ -152,6 +154,7 @@ NODE(InfixOperator)
CONTEXT_NODE(Initializer)
CONTEXT_NODE(InitAccessor)
NODE(Isolated)
CONTEXT_NODE(IsolatedDeallocator)
NODE(Sending)
NODE(IsolatedAnyFunctionType)
NODE(SendingResultFunctionType)
Expand All @@ -177,6 +180,7 @@ NODE(ObjCMetadataUpdateFunction)
NODE(ObjCResilientClassStub)
NODE(FullObjCResilientClassStub)
CONTEXT_NODE(ModifyAccessor)
CONTEXT_NODE(Modify2Accessor)
CONTEXT_NODE(Module)
CONTEXT_NODE(NativeOwningAddressor)
CONTEXT_NODE(NativeOwningMutableAddressor)
Expand Down Expand Up @@ -229,6 +233,7 @@ NODE(ReabstractionThunkHelper)
NODE(ReabstractionThunkHelperWithSelf)
NODE(ReabstractionThunkHelperWithGlobalActor)
CONTEXT_NODE(ReadAccessor)
CONTEXT_NODE(Read2Accessor)
NODE(RelatedEntityDeclName)
NODE(RetroactiveConformance)
NODE(ReturnType)
Expand Down Expand Up @@ -287,6 +292,8 @@ NODE(ReflectionMetadataAssocTypeDescriptor)
NODE(ReflectionMetadataSuperclassDescriptor)
NODE(GenericTypeParamDecl)
NODE(CurryThunk)
NODE(SILThunkIdentity)
NODE(SILThunkHopToMainActorIfNeeded)
NODE(DispatchThunk)
NODE(MethodDescriptor)
NODE(ProtocolRequirementsBaseDescriptor)
Expand Down Expand Up @@ -321,7 +328,7 @@ NODE(AssociatedTypeGenericParamRef)
NODE(SugaredOptional)
NODE(SugaredArray)
NODE(SugaredDictionary)
NODE(SugaredParen)
NODE(SugaredParen) // Removed in Swift 6.TBD

// Added in Swift 5.1
NODE(AccessorFunctionReference)
Expand Down Expand Up @@ -374,7 +381,7 @@ NODE(NonUniqueExtendedExistentialTypeShapeSymbolicReference)
NODE(SymbolicExtendedExistentialType)

// Added in Swift 5.8
NODE(MetatypeParamsRemoved)
NODE(DroppedArgument)
NODE(HasSymbolQuery)
NODE(OpaqueReturnTypeIndex)
NODE(OpaqueReturnTypeParent)
Expand All @@ -388,8 +395,6 @@ NODE(AsyncRemoved)

// Added in Swift 5.TBD
NODE(ObjectiveCProtocolSymbolicReference)
NODE(ParamLifetimeDependence)
NODE(SelfLifetimeDependence)

NODE(OutlinedInitializeWithCopyNoValueWitness)
NODE(OutlinedAssignWithTakeNoValueWitness)
Expand All @@ -398,5 +403,10 @@ NODE(OutlinedDestroyNoValueWitness)

NODE(DependentGenericInverseConformanceRequirement)

// Added in Swift 6.TBD
NODE(Integer)
NODE(NegativeInteger)
NODE(DependentGenericParamValueMarker)

#undef CONTEXT_NODE
#undef NODE
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class NodeFactory {
/// The end of the current slab.
char *End = nullptr;

struct Slab {
struct AllocatedSlab {
// The previously allocated slab.
Slab *Previous;
AllocatedSlab *Previous;
// Tail allocated memory starts here.
};

/// The head of the single-linked slab list.
Slab *CurrentSlab = nullptr;
AllocatedSlab *CurrentSlab = nullptr;

/// The size of the previously allocated slab. This may NOT be the size of
/// CurrentSlab, in the case where a checkpoint has been popped.
Expand All @@ -66,7 +66,7 @@ class NodeFactory {
& ~((uintptr_t)Alignment - 1));
}

static void freeSlabs(Slab *slab);
static void freeSlabs(AllocatedSlab *slab);

/// If not null, the NodeFactory from which this factory borrowed free memory.
NodeFactory *BorrowedFrom = nullptr;
Expand Down Expand Up @@ -149,8 +149,8 @@ class NodeFactory {
// No. We have to malloc a new slab.
// We double the slab size for each allocated slab.
SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T));
size_t AllocSize = sizeof(Slab) + SlabSize;
Slab *newSlab = (Slab *)malloc(AllocSize);
size_t AllocSize = sizeof(AllocatedSlab) + SlabSize;
AllocatedSlab *newSlab = (AllocatedSlab *)malloc(AllocSize);

// Insert the new slab in the single-linked list of slabs.
newSlab->Previous = CurrentSlab;
Expand Down Expand Up @@ -225,7 +225,7 @@ class NodeFactory {
/// A checkpoint which captures the allocator's state at any given time. A
/// checkpoint can be popped to free all allocations made since it was made.
struct Checkpoint {
Slab *Slab;
AllocatedSlab *Slab;
char *CurPtr;
char *End;
};
Expand Down Expand Up @@ -594,7 +594,9 @@ class Demangler : public NodeFactory {
NodePointer popDependentAssociatedConformance();
NodePointer demangleDependentProtocolConformanceAssociated();
NodePointer demangleThunkOrSpecialization();
NodePointer demangleGenericSpecialization(Node::Kind SpecKind);
NodePointer demangleGenericSpecialization(Node::Kind SpecKind,
NodePointer droppedArguments);
NodePointer demangleGenericSpecializationWithDroppedArguments();
NodePointer demangleFunctionSpecialization();
NodePointer demangleFuncSpecParam(Node::Kind Kind);
NodePointer addFuncSpecParamNumber(NodePointer Param,
Expand Down Expand Up @@ -635,7 +637,7 @@ class Demangler : public NodeFactory {
bool demangleBoundGenerics(Vector<NodePointer> &TypeListList,
NodePointer &RetroactiveConformances);

NodePointer demangleLifetimeDependenceKind(bool isSelfDependence);
NodePointer demangleIntegerType();

void dump();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#define MANGLE_AS_STRING(M) STRINGIFY_MANGLING(M)

/// The mangling prefix for the new mangling.
#if !defined(_MSC_VER) || _MSC_VER-0 >= 1926
#if defined(__clang__)
_Pragma("clang diagnostic push")
_Pragma("clang diagnostic ignored \"-Wdollar-in-identifier-extension\"")
#endif
#define MANGLING_PREFIX $s
#if !defined(_MSC_VER) || _MSC_VER-0 >= 1926
#if defined(__clang__)
_Pragma("clang diagnostic pop")
#endif

Expand Down
6 changes: 6 additions & 0 deletions symbolic-demangle/vendor/swift/include/swift/Strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ constexpr static const StringLiteral CLANG_MODULE_DEFAULT_SPI_GROUP_NAME =
constexpr static const StringLiteral SPI_AVAILABLE_ATTRNAME =
"_spi_available";

/// The attribute name for @_unavailableInEmbedded
constexpr static const StringLiteral UNAVAILABLE_IN_EMBEDDED_ATTRNAME =
"_unavailableInEmbedded";

/// A composition class containing a StringLiteral for the names of
/// Swift builtins. The reason we use this is to ensure that we when
/// necessary slice off the "Builtin." prefix from these names in a
Expand Down Expand Up @@ -172,6 +176,8 @@ constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_UNKNOWNOBJECT = {
/// The name of the Builtin type for Vector
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_VEC = {
"Builtin.Vec"};
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_FIXEDARRAY = {
"Builtin.FixedArray"};
/// The name of the Builtin type for SILToken
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_SILTOKEN = {
"Builtin.SILToken"};
Expand Down
2 changes: 1 addition & 1 deletion symbolic-demangle/vendor/swift/lib/Demangling/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::string Context::demangleTypeAsString(llvm::StringRef MangledName,
const DemangleOptions &Options) {
NodePointer root = demangleTypeAsNode(MangledName);
if (!root) return MangledName.str();

std::string demangling = nodeToString(root, Options);
if (demangling.empty())
return MangledName.str();
Expand Down
Loading
Loading