java IntelliJ 调试器卡住了
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37863400/
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
IntelliJ debugger gets stuck
提问by Luca Mozzo
I'm debugging a normal Java application, no GUI, just a lot of computations and ~5 calls in the stack for the main thread when the problem occurs. Basically it keeps saying "Collecting data" in the local variable watch.
我正在调试一个普通的 Java 应用程序,没有 GUI,只有在出现问题时在主线程的堆栈中进行大量计算和 ~5 次调用。基本上它在局部变量手表中一直说“收集数据”。
So instead of going step-by-step I've tried to add a breakpoint immediately after an press "Resume". Now it says "Waiting until last debugger command completes".
因此,我没有一步一步地尝试在按下“恢复”后立即添加断点。现在它说“等待最后一个调试器命令完成”。
Have anyone had this problem before? Is changing the debugger the only way to figure this out?
以前有人遇到过这个问题吗?改变调试器是解决这个问题的唯一方法吗?
回答by CharlieB
On IntelliJ (2017.1.4 Community Edition), the following fixed the problem for me:
在 IntelliJ(2017.1.4 社区版)上,以下解决了我的问题:
- File->Settings
- Type in "toString"
- Navigate to Build, Execution, Deployment->Debugger->Data views->Java
- Find the "Enable 'toString()' object view:" checkbox
- Uncheckthe box
- 文件->设置
- 输入“toString”
- 导航到构建、执行、部署->调试器->数据视图->Java
- 找到“启用‘toString()’对象视图:”复选框
- 取消选中该框
Re-run the debugger.
重新运行调试器。
回答by ayluo
The following fixed it for me on IntelliJ 2018.2.4:
以下在 IntelliJ 2018.2.4 上为我修复了它:
- Right click breakpoint
- Toggle the setting to suspend "Thread" instead of "All"
- 右键断点
- 切换设置以挂起“线程”而不是“全部”
This won't be helpful if you actually need to suspend all the threads for debugging, but it got rid of the "Collecting data..." and "Waiting until last debugger command completes" messages for me. The setting also persists for subsequent breakpoints, so you only need to change it once.
如果您确实需要挂起所有线程进行调试,这将无济于事,但它为我摆脱了“正在收集数据...”和“等待最后一个调试器命令完成”消息。该设置对于后续断点也保持不变,因此您只需更改一次。
回答by James Lent
I just ran into what looks like the same issue. In my case it was a class (KafkaStream) in the breakpoint stack trace with a "bad" toString
method. The toString
method blocks and therefore hangs the debugger. I tested the toString
method in the main line code and it hung the main thread (i.e. this is not a debugger specific issue).
我刚刚遇到了同样的问题。在我的情况下,它是断点堆栈跟踪中的一个类(KafkaStream),带有“坏”toString
方法。该toString
方法会阻塞并因此挂起调试器。我toString
在主行代码中测试了该方法,它挂起了主线程(即这不是调试器特定的问题)。
Here is the stack trace for my thread that hit the breakpoint (on a line that was just trying to test a boolean attribute of my class):
这是我的线程遇到断点的堆栈跟踪(在试图测试我的类的布尔属性的行上):
Intellij provides a way to work around for my issue. It allows you to override how the debugger renders the class:
Intellij 提供了一种解决我的问题的方法。它允许您覆盖调试器呈现类的方式:
If your issue comes back I suggest taking a thread dump (inside or outside of the IDE) and see what your thread is doing.
如果您的问题再次出现,我建议进行线程转储(IDE 内部或外部)并查看您的线程在做什么。
回答by Michael Scott
The fix that worked for me was to remove method breakpoints. That made it superfast.
对我有用的修复方法是删除方法断点。这使它变得超快。
回答by Sravan Reddy
In most cases, it would be because of the watches that you add while debugging. Clear the watch statements that would result in recursive execution of same statements as in the code. Always keep the watches clean before debugging.
在大多数情况下,这是因为您在调试时添加了手表。清除会导致递归执行与代码中相同的语句的 watch 语句。调试前始终保持手表清洁。