简体   繁体   English

如何从 OSX 上的文件调试我的应用程序的打开?

[英]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.

相关问题 如何将CEF3嵌入到我的OSX应用程序中? - How can I embed CEF3 into my OSX application? 如何在OSX应用程序中运行嵌入式二进制文件? - How can I run an embedded binary in my OSX application? 如何调试iOS应用程序中的迦太基(自有)依赖项? - How can I debug carthage (owned) dependencies in my iOS application? 如何在我的swift应用程序中调试/测试URL打开 - How do I debug/test URL opening in my swift app 如何从冷启动中调试打开通用链接? - How can you debug opening universal links from a cold start? 如何在OSX Swift应用程序中要求管理员登录? - How can I ask for an Administrator Login in an OSX Swift Application? 如何检测OSX上正在运行的应用程序 - How can I detect what application is running on OSX OSX菜单栏应用程序在归档和导出时无法启动,如何调试? - OSX menu bar application not launching when archived and exported, how to debug? 尝试在我的iPhone上运行我的应用程序进行调试时,我在XCode中收到“无法安装应用程序”错误 - I get “Can't install application” error in XCode when trying to run my application on my iPhone for debug 我想将pch文件添加到osx应用程序项目中,但是在构建设置中没有前缀标头字段 - I want to add pch file to my osx application project but thers is no prefix header field in build settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM