Skip to content

How to profile a macOS app #588

@msdrigg

Description

@msdrigg

Hi guys. First of all, this is really good. I stumbled onto this project while trying to write a custom symbolicator for MetricKit CrashDiagnostics, and your samply-symbols crate is best-in-class. Overall, super easy to read, extend, and work with overall.

Ok, now my issue is I am working on an XCode app for macOS. Think standard, UI app with swiftUI and the whole setup. It's very reliant on xcode or at least xcodebuild to build. How can I build this app in a way that samply can profile it. When I perform a standard debug build, and then run samply with samply record path/to/MyApp.app/Contents/MacOS/MyApp, I get this log

> samply record /Applications/Roam.app/Contents/MacOS/Roam
^CUnexpected Shutdown message for root task?
Profiling failed: Could not obtain the root task.

On macOS, samply cannot profile system commands, such as the sleep command or system python. This is because system executables are signed in such a way that they block the DYLD_INSERT_LIBRARIES environment variable, which subverts samply's attempt to siphon out the mach task port of the process.

Suggested remedy: You can profile any binaries that you've compiled yourself, or which are unsigned or locally-signed, such as anything installed by cargo install or by Homebrew.

Now the app runs fine under samply, but it no sampling is shown when I press Ctrl-C and stop samply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions