Unable to profile simple C++ program in Instruments: "failed to execute loader thread"

I made a new command-line tool C++ project in Xcode, with the following main.cpp:

#include <iostream>

int main() {
  std::cout << "Hello, World!\n";
}

When I try to profile it in Instruments with any template, I get the following error before my program even starts:

Failed to execute loader thread for /Applications/Xcode.app/Contents/SharedFrameworks/DVTInstrumentsFoundation.framework/Resources/liboainject.dylib in target; target process <pid> likely exited

I get the same error when I try running Instruments with xctrace.

How do I get Instruments to properly load my programs?

Setup:

  • Xcode version: 13.4.1 (13F100)
  • Hardware: 2020 M1 MacBook Air

Accepted Reply

Turns out you can have a program that's too fast for Instruments, so I needed to add some extra artificial time before small programs like this would launch in the profiler.

Replies

Turns out you can have a program that's too fast for Instruments, so I needed to add some extra artificial time before small programs like this would launch in the profiler.