Firebug控制台堆栈跟踪

时间:2012-07-07 11:29:25

标签: javascript firefox firebug

如何使用Firebug的错误控制台获取堆栈跟踪?

我尝试过以下测试:

<!DOCTYPE html>
<html>
<head>

<script type = "text/javascript">

function f3() { console.trace(); }

function f2() { f3(); }

function f1() { f2(); }

</script>
</head>
<body onLoad = "f1()">
</body>
</html>

这个测试只需要调用3个不同的函数,创建一个3级深度的堆栈。第三个函数只打印出一个堆栈跟踪。但是,Firebug控制台没有显示任何内容:

[07:26:47.955] GET http://mydomain.com/test.html [HTTP/1.0 200 OK 23ms]

我还需要做些什么来让堆栈跟踪工作吗?

1 个答案:

答案 0 :(得分:1)

有趣的事实:当我运行你的代码时,我在safari中得到以下堆栈跟踪:

enter image description here

但是当我运行这个

<!DOCTYPE html>
<html>
<head>
<body>
  <script type = "text/javascript">
    function f3() { console.trace(); }
    function f2() { f3(); }
    function f1() { f2(); }
    f1();
  </script>
</body>
</html>

堆栈跟踪如下所示:

enter image description here

这可能是一些奇怪的优化?