What is the difference between Call Stack and Stack Trace?

爱⌒轻易说出口 提交于 2019-12-20 16:48:00

问题


What is the difference between the terms "Call Stack" and "Stack Trace" ?


回答1:


A call stack is typically "the current stack of operations" - i.e. while it's running.

A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.

In other words, while you're debugging you will look at the current call stack - but when you look at logs, you'll get a stack trace. At least, that's my interpretation of the terms :)




回答2:


Call stack is a data structure storing information about active subroutines in a running program. Stack trace is a representation of the call stack.




回答3:


I think Wikipedia does a fairly good job at distinguishing between them:

a call stack is a stack data structure that stores information about the active subroutines of a computer program

A stack trace is a report of the active stack frames at a certain point in time during the execution of a program.

In other words, the call stack is the actual data structure in memory, while the stack trace is a snapshot of said data structure.



来源:https://stackoverflow.com/questions/7482591/what-is-the-difference-between-call-stack-and-stack-trace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!