[英]how can i debug the opening of my application from a file on OSX?
I linked my application to a file extension, so when i double click those files it opens my application.我将我的应用程序链接到文件扩展名,因此当我双击这些文件时,它会打开我的应用程序。 However i experience crash when doing so, and i am looking for a way to breakpoint that and see what's going wrong.
但是,这样做时我会遇到崩溃,我正在寻找一种方法来断点并查看发生了什么问题。 I'm using Xcode, it's an OSX app.
我正在使用 Xcode,它是一个 OSX 应用程序。
Any idea?任何的想法?
lldb doesn't have a "launch with open AppleEvent" feature, so you can't do this directly. lldb 没有“使用开放 AppleEvent 启动”功能,因此您不能直接执行此操作。
But you can use lldb's "attach wait" feature to catch the app early in startup.但是您可以使用 lldb 的“附加等待”功能在启动初期捕获应用程序。 You can do this in Xcode by turning on "Wait for the executable to be launched" in the Info tab of the Run scheme of your App target.
您可以通过在应用程序目标的运行方案的信息选项卡中打开“等待可执行文件启动”在 Xcode 中执行此操作。 Then click the Run button, and go to Finder to launch your app by double-clicking on one of its files.
然后单击“运行”按钮,并转到 Finder 以通过双击其文件之一来启动您的应用程序。
If your system is not heavily loaded, lldb will generally stop the app pretty early in its startup, usually before it gets to handling the open event.如果您的系统负载不重,lldb 通常会在应用程序启动的早期停止,通常是在它开始处理 open 事件之前。 Xcode will auto-continue the app, so it should just proceed right to the crash.
Xcode 将自动继续应用程序,因此它应该直接进行到崩溃。
If for some reason lldb doesn't attach early enough, edit the main function of your application, and at the very top put in:如果由于某种原因 lldb 没有足够早地附加,请编辑应用程序的主要功能,并在最顶部输入:
int go_on = 0;
while(!go_on) {
sleep(1);
}
That way your app will stall in launching before it handles the open event, giving lldb time to attach.这样你的应用程序将在它处理 open 事件之前停止启动,给 lldb 时间来附加。 Once it has attached, Pause the app in the debugger, select the thread and frame containing this main function, go to the lldb Console and do:
附加后,在调试器中暂停应用程序,选择包含此主要功能的线程和框架,转到 lldb 控制台并执行以下操作:
(lldb) expr go_on = 1
and then continue.然后继续。 Now your app should finish starting up, handle the open event and crash into the debugger.
现在您的应用程序应该完成启动,处理打开事件并崩溃到调试器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.