Slowness when attaching to LLDB

Since updating to Big Sur, there has been a very annoying lag using CLion and command-line lldb when debugging JUCE projects, even the simplest ones like a Hello World console app.

Whenever the debugger is attached, there’s about 5-7 second delay until the program runs. Without the debugger it runs instantly. It also works perfectly using Xcode, or when debugging non-JUCE projects, or on the same computers running Parallels/Boot Camp.

The issue only happens on Intel Macs (I’ve tried 3) and only when running Big Sur. It’s fine on Catalina and M1 macs, and seems to happen with both LLDB version 10 and 11.

To test, clone the following demo project:

Either debug the console app using CLion, or generate a a project and attach lldb by typing:

lldb /PathToCode/JUCECmakeRepoPrototype/cmake-build-debug/Apps/ConsoleAppTemplate/ConsoleAppTemplate_artefacts/Debug/ConsoleAppTemplate

And then run

2 Likes

I realize this somewhat of an obscure bug, but it probably affects pretty much everyone debugging JUCE projects on Intel Mac/CLion with Big Sur.

I’ve been reporting it to CLion (and recently to LLDB), but this seems to be related to something specific JUCE is doing, probably some static lib loading?

Update, I managed to isolate the issue to be related to the three apple frameworks that JUCE is bringing, as basically an empty CMake file with an empty main() function and the following line:

target_link_libraries(TestMacDebug PRIVATE
        "-framework Cocoa"
        "-framework Foundation"
        "-framework IOKit")

causes the same debug hang.

I’m wondering, is there any other way to link with those libraries so the debugger will have an easier time?

1 Like

Not directly related but seems like some people got similar regression since Big Sur 11.3?
https://developer.apple.com/forums/thread/679098

I’ve had that bug since earlier versions of Big Sur actually.

Also, I learned that this bug is totally solved in the Xcode-provided version of LLDB:

/Applications/Xcode.app/Contents/Developer/usr/bin/lldb

That custom version of LLDB and Xcode itself debugs instantly.

For some reason, I still haven’t figured out how to point CLion to that version instead. I even tried patching the installed package with no luck yet…