当托管代码中发生异常时,该异常的堆栈跟踪可以帮助您了解发生异常的原因。但是,在 iOS 上的某些情况下,如下所述,托管堆栈跟踪可能不会按预期显示。堆栈跟踪也会根据 Xcode 构建配置而有所不同。
对 iOS 使用调试版本配置时,IL2CPP 应报告可靠的托管堆栈跟踪,并在调用堆栈中包含每个托管方法。该堆栈跟踪不包含原始 C# 源代码中的行号。
使用发布版本配置时,IL2CPP 可能会生成缺少一个或多个托管方法的调用堆栈。这是因为 C++ 编译器已经内联了缺少的方法。方法内联通常对运行时的性能有好处,但可能会使调用堆栈更难理解。IL2CPP 始终在调用堆栈上提供至少一个托管方法。此方法便是发生异常的方法。调用堆栈上还包括其他未内联的方法。
如果可在本地重现异常,请使用 Xcode 确定已进行内联的方法。使用发布配置在 Xcode 中运行应用程序,并设置一个异常断点。Xcode 中的本机调用堆栈视图应该会显示实际存在的方法以及已进行内联的方法。
在调试或发布配置中,IL2CPP 调用堆栈不包含源代码行号信息。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.