Skip to content

Commit 30cb7a2

Browse files
authored
Merge pull request #59349 from mikeash/concurrency-tracing-log-categories
[Concurrency] Set final subsystem/categories for concurrency tracing.
2 parents a00c0b4 + 72499c5 commit 30cb7a2

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

stdlib/public/Concurrency/TracingSignpost.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@
1919
#include "TracingSignpost.h"
2020
#include <stdio.h>
2121

22-
// Temporary until we work out what categories we should really use.
23-
#ifndef OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING
24-
#define OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING "DynamicStackTracing"
25-
#endif
26-
27-
#define SWIFT_LOG_CONCURRENCY_ACTOR_SUBSYSTEM "com.apple.swift.actor"
28-
#define SWIFT_LOG_CONCURRENCY_TASK_SUBSYSTEM "com.apple.swift.task"
29-
#define SWIFT_LOG_ACTOR_CATEGORY OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING
30-
#define SWIFT_LOG_TASK_CATEGORY OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING
22+
#define SWIFT_LOG_CONCURRENCY_SUBSYSTEM "com.apple.swift.concurrency"
23+
#define SWIFT_LOG_ACTOR_CATEGORY "Actor"
24+
#define SWIFT_LOG_TASK_CATEGORY "Task"
3125

3226
namespace swift {
3327
namespace concurrency {
@@ -38,9 +32,9 @@ os_log_t TaskLog;
3832
swift::once_t LogsToken;
3933

4034
void setupLogs(void *unused) {
41-
ActorLog = os_log_create(SWIFT_LOG_CONCURRENCY_ACTOR_SUBSYSTEM,
35+
ActorLog = os_log_create(SWIFT_LOG_CONCURRENCY_SUBSYSTEM,
4236
SWIFT_LOG_ACTOR_CATEGORY);
43-
TaskLog = os_log_create(SWIFT_LOG_CONCURRENCY_TASK_SUBSYSTEM,
37+
TaskLog = os_log_create(SWIFT_LOG_CONCURRENCY_SUBSYSTEM,
4438
SWIFT_LOG_TASK_CATEGORY);
4539
}
4640

unittests/runtime/Actor.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static SWIFT_CC(swift)
9999
void destroyTestActor(SWIFT_CONTEXT HeapObject *_object) {
100100
delete static_cast<TestActor*>(_object);
101101
}
102-
static const FullMetadata<ClassMetadata> TestActorMetadata = {
102+
static FullMetadata<ClassMetadata> TestActorMetadata = {
103103
{ { &destroyTestActor }, { &VALUE_WITNESS_SYM(Bo) } },
104104
{ { nullptr }, ClassFlags::UsesSwiftRefcounting, 0, 0, 0, 0, 0, 0 }
105105
};
@@ -108,6 +108,15 @@ TestActor::TestActor() : DefaultActor(&TestActorMetadata) {
108108
}
109109

110110
static TestActor *createActor() {
111+
static ClassDescriptor *descriptor;
112+
if (!descriptor) {
113+
// Install a fake descriptor pointer into the actor metadata so that
114+
// swift_getTypeName will tolerate it. Otherwise we crash when trying to
115+
// signpost actor creation.
116+
descriptor =
117+
reinterpret_cast<ClassDescriptor *>(calloc(sizeof(*descriptor), 1));
118+
TestActorMetadata.setDescription(descriptor);
119+
}
111120
return new TestActor();
112121
}
113122

0 commit comments

Comments
 (0)