<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/CallStackTree",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit13CallStackTreeV"
  },
  "title" : "CallStackTree"
}
-->

# CallStackTree

A tree structure representing a collection of call stacks captured during a diagnostic event.

```
struct CallStackTree
```

## Discussion

Each diagnostic struct — including [`CrashDiagnostic`](/documentation/MetricKit/CrashDiagnostic), [`HangDiagnostic`](/documentation/MetricKit/HangDiagnostic), [`CPUExceptionDiagnostic`](/documentation/MetricKit/CPUExceptionDiagnostic), [`DiskWriteExceptionDiagnostic`](/documentation/MetricKit/DiskWriteExceptionDiagnostic), [`AppLaunchDiagnostic`](/documentation/MetricKit/AppLaunchDiagnostic), and [`MemoryExceptionDiagnostic`](/documentation/MetricKit/MemoryExceptionDiagnostic) — carries a `callStackTree` property of this type.

The tree is organized into threads via [`callStackThreads`](/documentation/MetricKit/CallStackTree/callStackThreads). Each [`CallStackThread`](/documentation/MetricKit/CallStackThread) contains root [`CallStackFrame`](/documentation/MetricKit/CallStackFrame) values that form a tree of sub-frames. Binary metadata is deduplicated in [`binaryInfo`](/documentation/MetricKit/CallStackTree/binaryInfo-swift.property), keyed by UUID, so frames reference binaries by UUID rather than repeating the name.

Use [`forEachFrame(_:)`](/documentation/MetricKit/CallStackTree/forEachFrame(_:)) for an optimized iterative depth-first traversal of all frames across all threads:

```swift
callStackTree.forEachFrame { frame in
    if let name = frame.binaryName(from: callStackTree) {
        print(name, frame.offsetIntoBinaryTextSegment ?? 0)
    }
}
```

## Topics

### Threads and frames

[`callStackThreads`](/documentation/MetricKit/CallStackTree/callStackThreads)

Array of call stack threads

[`callStackPerThread`](/documentation/MetricKit/CallStackTree/callStackPerThread)

Whether call stacks are organized per-thread

[`forEachFrame(_:)`](/documentation/MetricKit/CallStackTree/forEachFrame(_:))

Iterates all frames efficiently.

### Binary information

[`binaryInfo`](/documentation/MetricKit/CallStackTree/binaryInfo-swift.property)

Deduplicated binary information indexed by UUID

### Related types

[`CallStackThread`](/documentation/MetricKit/CallStackThread)

A single stack thread within a call stack tree.

[`CallStackFrame`](/documentation/MetricKit/CallStackFrame)

A single frame within a call stack thread.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)