This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Improve error message when trying to debug a non-debuggable process
ClosedPublic

Authored by JDevlieghere on Aug 10 2023, 11:24 AM.

Details

Summary

On the Swift forums [1][2], people are disabling SIP in order to debug process that are missing the get-task-allow entitlement. Improve the error to give developers a hint at the potential issues.

[1] https://forums.swift.org/t/yo-apple-xcode-debugging-swift-is-still-horribly-broken/62702/26
[2] https://forums.swift.org/t/finding-cycles-with-the-memory-graph-debugger-with-swift-pm-projects/62769/7

rdar://113704200

Diff Detail

Event Timeline

JDevlieghere created this revision.Aug 10 2023, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 11:24 AM
JDevlieghere requested review of this revision.Aug 10 2023, 11:24 AM

I'm fine with this but on macOS I believe it's com.apple.security.get-task-allow v. "Entitlements on macOS"
https://developer.apple.com/documentation/technotes/tn3125-inside-code-signing-provisioning-profiles

Maybe get-task-allow is allowed (lol) on macOS too.

jasonmolenda accepted this revision.Aug 10 2023, 12:51 PM
This revision is now accepted and ready to land.Aug 10 2023, 12:51 PM

Maybe

const char *ent_name = 
#if TARGET_OS_OSX
"com.apple.security.get-task-allow";
#else
"get-task-allow";
#endif

debugserver is running on the target device so compile time checks are fine.

In this function we have the path to the binary. We could spawn codesign -d -entitlements - and then we would know whether it had that entitlement.

Maybe that's more work than you wanted to do here, however.

Not sure if codesign exists on iOS devices, but at least we could do this on macOS.

I thought we'd be able to tell from the Team Identifier whether it was a platform binary, but for /bin/ls & Co I get "not set" for the Team Identifier.

In this function we have the path to the binary. We could spawn codesign -d -entitlements - and then we would know whether it had that entitlement.

Maybe that's more work than you wanted to do here, however.

Yeah I'm not sure that being able to be more precise is a huge improvement over the current error message. If we still see a lot of people struggling with this we can easily reconsider.

Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 10:47 AM