Skip to content

Conversation

fortmarek
Copy link
Collaborator

I'm not sure when TaskBacktrace was introduced but it seems to be a new of the section attachment. Example value from after tokenization:

[type: list, count: 2]
[type: classNameRef, className: "IDEFoundation.IDEActivityLogSectionAttachment"]
[type: string, value: "com.apple.dt.ActivityLogSectionAttachment.TaskBacktrace"]
[type: int, value: 1]
[type: int, value: 0]
[type: json, value: [{"description":"'Planning Swift module ConcurrencyExtras (arm64)' had never run","category":{"ruleNeverBuilt":{}},"identifier":{"storage":{"task":{"_0":[0,80,50,58,116,97,114,103,101,116,45,67,111,110,99,117,114,114,101,110,99,121,69,120,116,114,97,115,45,101,102,52,50,51,48,52,53,57,52,98,102,56,53,50,102,52,51,56,101,102,55,99,51,97,49,51,54,98,50,99,57,48,100,102,56,55,49,56,97,102,50,98,57,100,51,97,97,99,48,100,48,100,99,97,50,50,98,52,99,50,57,99,50,45,58,66,101,116,97,32,68,101,98,117,103,58,51,99,57,97,99,57,53,50,98,52,99,56,49,100,57,99,99,49,55,100,49,97,102,52,55,49,97,48,52,53,101,56]}}},"frameKind":{"genericTask":{}}}]]
[type: classNameRef, className: "IDEFoundation.IDEActivityLogSectionAttachment"]
[type: string, value: "com.apple.dt.ActivityLogSectionAttachment.TaskMetrics"]
[type: int, value: 1]
[type: int, value: 0]
[type: json, value: {"utime":15551,"stime":15551,"maxRSS":0,"wcStartTime":771519075106417,"wcDuration":15551}]

The second attachment is the one we currently parse, support for which was introduced in #204.

The first attachment is new – and currently XCLogParser fails when parsing it because it expects all attachments to be a task metric.

This PR adds support for parsing it. The JSON value is quite odd – I decided to parse just the category and description, discarding the identifier and frameKind. If you feel strongly, I can try adding support for those as well, but I'm not sure how they would be useful.

@fortmarek fortmarek requested a review from pepicrft July 3, 2025 18:54
@fortmarek fortmarek force-pushed the fix/backtrace branch 3 times, most recently from 0164ace to 9563934 Compare July 3, 2025 19:08
@fortmarek
Copy link
Collaborator Author

The backtrace logs only appear when the following setting is on: https://github.com/swiftlang/swift-build/blob/ab993847ee362913fe64f5d58a02770999c4d724/SwiftBuild.docc/Development/build-debugging.md?plain=1#L21

I've also realized, now that swift-build is open source, we can better structure the models based on the actual underlying source code: https://github.com/swiftlang/swift-build/blob/ab993847ee362913fe64f5d58a02770999c4d724/Sources/SwiftBuild/SWBBuildOperationBacktraceFrame.swift

We could even consider using those models directly – but the resulting JSON from the SLF tokenization doesn't seem to be the same as the JSON I'd expect those structs to produce based on the auto-synthesized Codable conformation.

@fortmarek fortmarek marked this pull request as ready for review July 4, 2025 08:22
Signed-off-by: fortmarek <marekfort@me.com>
@fortmarek fortmarek merged commit b2d7f2e into master Jul 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants