如何在Linux中的JAVA程序中设置显示堆栈跟踪的所有错误细节?

huangapple go评论69阅读模式
英文:

How to set show all the error details of stack trace in JAVA program in Linux?

问题

In ubuntu 20.04,我运行一个名为 batfish-tiramisu 的Java程序,但遇到了问题。错误日志如下所示:

问题: arcRAG actions=[ACCEPTED]
org.batfish.common.BatfishException: 未能回答问题
   at org.batfish.main.Batfish.answer(Batfish.java:635)
   at org.batfish.main.Batfish.run(Batfish.java:3042)
   at org.batfish.main.Driver.lambda$runBatfish$3(Driver.java:580)
   at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
   at org.batfish.mulgraph.Rag.taint_propagate(Rag.java:191)
   at org.batfish.mulgraph.Rag.taint(Rag.java:187)
   at org.batfish.mulgraph.buildRag.run(buildRag.java:124)
   at org.batfish.mulgraph.buildTpg.buildGraph(buildTpg.java:123)
   at org.batfish.mulgraph.buildTpg.run(buildTpg.java:144)
   at org.batfish.symbolic.smt.PropertyChecker.checkRAG(PropertyChecker.java:962)
   at org.batfish.main.Batfish.arcRAG(Batfish.java:3681)
   at org.batfish.question.GraphRAGQuestionPlugin$GraphRAGAnswerer.answer(GraphRAGQuestionPlugin.java:33)
   at org.batfish.main.Batfish.answer(Batfish.java:632)
   ... 3 more

总结: 0 (非断言) 结果;

在其中写有 “3 more”,如何让它显示所有的函数堆栈?任何帮助将不胜感激。

英文:

In ubuntu 20.04, I run a java program named batfish-tiramisu but fell into problem. The error log is shown as below:

Question: arcRAG actions=[ACCEPTED]
org.batfish.common.BatfishException: Failed to answer question
   at org.batfish.main.Batfish.answer(Batfish.java:635)
   at org.batfish.main.Batfish.run(Batfish.java:3042)
   at org.batfish.main.Driver.lambda$runBatfish$3(Driver.java:580)
   at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
   at org.batfish.mulgraph.Rag.taint_propagate(Rag.java:191)
   at org.batfish.mulgraph.Rag.taint(Rag.java:187)
   at org.batfish.mulgraph.buildRag.run(buildRag.java:124)
   at org.batfish.mulgraph.buildTpg.buildGraph(buildTpg.java:123)
   at org.batfish.mulgraph.buildTpg.run(buildTpg.java:144)
   at org.batfish.symbolic.smt.PropertyChecker.checkRAG(PropertyChecker.java:962)
   at org.batfish.main.Batfish.arcRAG(Batfish.java:3681)
   at org.batfish.question.GraphRAGQuestionPlugin$GraphRAGAnswerer.answer(GraphRAGQuestionPlugin.java:33)
   at org.batfish.main.Batfish.answer(Batfish.java:632)
   ... 3 more

Summary: 0 (non-assertion) results; 

There wrote "3 more", how can I let it show all the function stack?
Any help would be highly appreciated.

答案1

得分: 1

'3 more' 指的是与上述堆栈相同。换句话说,无论何时在Java堆栈跟踪中看到'... x more',只有在你在'Caused by: ...'跟踪中时才会发生。查看此堆栈跟踪是'caused by'的,然后获取最后的x行。换句话说,缺失的3行是直接在'Caused by'上面的最后3行:

   at org.batfish.main.Batfish.run(Batfish.java:3042)
   at org.batfish.main.Driver.lambda$runBatfish$3(Driver.java:580)
   at java.base/java.lang.Thread.run(Thread.java:829)

没有办法让Java只输出这种混乱的内容,我真的不明白为什么你会希望在解决方案明显是'查找和计数'的情况下这样做。如果你控制源代码,可以在主线程上设置默认的异常处理程序并编写自己的堆栈跟踪打印程序。最多只需要大约半页的代码;查看Throwable的javadoc(特别是getStackTrace())以获取更多信息。

除了控制源代码或类似的巧妙替代方法(编辑类文件、运行代理以原地修改它们等)外,没有办法做到这一点。

英文:

'3 more' refers to the same stack as above. In other words, whenever you see '... x more' in a java stack trace like this, that only ever occurs if you're in a Caused by: ... trace. Look at the stacktrace that this stacktrace is a 'caused by' for, and take the last x lines. In other words, the missing 3 lines are the last 3 lines immediately above Caused by:

   at org.batfish.main.Batfish.run(Batfish.java:3042)
   at org.batfish.main.Driver.lambda$runBatfish$3(Driver.java:580)
   at java.base/java.lang.Thread.run(Thread.java:829)

There is no way to make java just emit this cruft and I don't really understand why you would want it to in light of the solution simply being: 'look up and count'. If you have control over the source code, you could set up a default exception handler on the main thread and write your own stack stace printer. Would be about half a page worth of code at most; check the javadoc of Throwable (particularly, getStackTrace()) for more information.

There is no way to do that without controlling the source code or other similar hacky alternatives (editing the class files, running an agent to modify them in place, etc).

huangapple
  • 本文由 发表于 2023年4月13日 21:37:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76006108.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定