xcode 什么是 Swift 的异常堆栈中的 Dead & Exploded?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30764669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's Dead & Exploded in Swift's exception stack?
提问by DenverCoder9
In the exception stack for runtime crashes, Swift often says arguments are Dead or Exploded. What does it mean, and does it matter for debugging purposes?
在运行时崩溃的异常堆栈中,Swift 经常说参数是 Dead 或 Exploded。它是什么意思,对于调试目的是否重要?
For example:
例如:
-> 0x100209cf0 <function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()+44>: brk #0x1
Thanks.
谢谢。
回答by CodaFi
What does it mean?
这是什么意思?
The Swift compiler marks function arguments for a number of reasons, mostly related to internal optimizations. For your question, we'll focus on the mangler, as that's what's contributing to your pretty stack trace, and the Node Printer. As of the time of this post, the function specialization mangler has 6 marks it can apply to an argument:
Swift 编译器出于多种原因标记函数参数,主要与内部优化有关。对于您的问题,我们将重点关注 mangler,因为这有助于您获得漂亮的堆栈跟踪和节点打印机。截至本文发布时,函数专业化管理器有 6 个标记可应用于参数:
Dead
The argument is unused in the function body and can be removed in a dead argument elimination pass.
Closure
The argument is a closure and may require further mangling/demangling.
Constant
The argument is a constant.
Owned to Guaranteed
A caller-owned argument transfers ownership to the callee. The argument thus has a strong reference associated with it [the caller] and is guaranteed to live through the call, so the compiler allows the caller to elide the transfer and instead aggregate retains itself.
SROA
A Scalar Replacement of Aggregatespass should optimize this argument.
In Out To Value
The parameter was marked inout but the callee doesn't actually mutate it.
死的
该参数在函数体中未使用,可以在死参数消除过程中删除。
关闭
论点是一个闭包,可能需要进一步的修改/拆解。
持续的
参数是一个常数。
归保证人所有
调用者拥有的参数将所有权转移给被调用者。因此,该参数有一个与之关联的强引用 [调用者],并保证在调用过程中一直存在,因此编译器允许调用者省略传输,而是聚合保留自身。
SROA
A Scalar Replacement of Aggregatespass 应该优化这个参数。
内在价值
参数被标记为 inout 但被调用者实际上并没有改变它。
The AST Node Printer adds one more mark
AST 节点打印机又增加了一个标记
Exploded
The value comes with an explosion schema that has been realized when the call was made.
爆炸
该值带有在进行调用时已实现的爆炸模式。
For all intents and purposes we only care about Dead
, Owned to Guaranteed
, and Exploded
.
对于所有意图和目的,我们只关心Dead
,Owned to Guaranteed
和Exploded
。
The only one that may still seem mystifying is Exploded
. An Explosionis an optimization construct the Swift compiler uses to determine a strategy to unpack values from small structs and enums into registers. Thus, when the Node Printer says a value is Exploded
, what it means it has already unpacked the value into registers before the call.
唯一可能看起来仍然令人费解的是Exploded
。的爆炸是一个优化构建体夫特编译器使用,以确定从小型结构和枚举到寄存器的策略来解压值。因此,当节点打印机说一个值是 时Exploded
,这意味着它已经在调用之前将该值解包到寄存器中。
does it matter for debugging purposes?
这对调试目的重要吗?
Nope.
不。
回答by Race B
Dead usually means that the value is no longer in memory
死通常意味着该值不再在内存中
Not sure how this is going to help you unless you are really going to dive into Assembly debugging.
不确定这将如何帮助您,除非您真的要深入到程序集调试中。
You might want to check out some online resources, i.e., how to use the debugger in Xcode to troubleshoot issues with your code.
您可能想查看一些在线资源,即如何使用 Xcode 中的调试器来解决您的代码问题。
回答by jbcd13
Based on what I was able to find on Apple's developer library, I believe that when Swift says the argument is exploded, it has been expanded to show the bug until it shows all layers and parts of the argument. Swift does this to make it easier to find bugs that are nested between layers of an argument. I am not sure what dead means. This may be completely off base, but I figure that since you haven't gotten an answer in 6 days, I might as well try and clarify you're problem.
根据我在 Apple 的开发人员库中找到的内容,我相信当 Swift 说参数爆炸时,它已被扩展以显示错误,直到它显示参数的所有层和部分。Swift 这样做是为了更容易地找到嵌套在参数层之间的错误。我不确定死是什么意思。这可能完全偏离基础,但我认为由于您在 6 天内没有得到答案,我不妨尝试澄清您的问题。