简体   繁体   English

是否有用于Java的任何功能级别的调试/记录工具?

[英]Are there any function level debugging/logging tools for Java?

I'm sorry if the title is confusing but I couldn't think of anything similar to call it. 很抱歉,标题令人困惑,但我想不出任何类似的名称。 What I'm looking for is if there is any sort of tool (or eclipse plugin, etc) that will log all the translated lines from a program. 我正在寻找的是是否有某种工具(或eclipse插件等)将记录程序中所有已翻译的行。 For example: 例如:

int b = 20;
for (int x = 0; x < z; x++)
b = b + 5;

Would get translated into 将被翻译成

b = 20
for (int x = 0; 0 < 50; 0++)
b = 20 + 5;

I ask because it seems it wouldn't be too difficult to implement relatively, since we can debug one line at a time and I think it would save an enormous amount of time. 我问,因为相对而言,实现起来似乎并不难,因为我们可以一次调试一行,而且我认为这样可以节省大量时间。 If you could just go through a log file and look for your error and check out exactly what line the problem occurred on and the context that caused it then debugging would be a lot easier. 如果您可以浏览日志文件并查找错误,然后准确地检查出问题所在的行以及引起该错误的上下文,那么调试会容易得多。 XDebug for PHP has function level traces so you can see the value of the variables passed in your program, and have that dumped to a log. XDebug for PHP具有函数级别的跟踪,因此您可以查看程序中传递的变量的值,并将其转储到日志中。 I found that it saved me a large amount of debugging time. 我发现它为我节省了大量调试时间。 The problems were usually obvious and easy to fix then. 问题通常很明显,然后很容易解决。

It would sure beat adding logging statements. 它肯定会胜过添加日志记录语句。

EDIT: I want to clarify that I am not looking for a traditional debugger ala Eclipse style. 编辑:我想澄清一下,我不是在寻找传统的调试器ala Eclipse样式。 I'm simply looking for a overall logging of the variables and states. 我只是在寻找变量和状态的整体记录。

Eclipse and any IDE worth its salt comes with a debugger that can do this and much more. Eclipse和任何物有所值的IDE都带有调试器,它可以做到这一点以及更多。 Rather than print out traces, you can have the program halt at any specific line of code (whenever it is reached, or only when specific conditions are met) and inspect the state of variables at that point, as well as modify variables and execute arbitrary statements to see their return value. 您可以使程序在任何特定的代码行暂停(无论何时到达,或仅在满足特定条件的情况下),而不是打印跟踪,并在该点检查变量的状态,以及修改变量并执行任意操作语句以查看其返回值。

For web applications where the code is running on a server, you can even connect the debugger via the network to a remote JVM. 对于其中代码在服务器上运行的Web应用程序,您甚至可以通过网络将调试器连接到远程JVM。

Here's a tutorial on how to use the eclipse debugger. 这是有关如何使用Eclipse调试器的教程 There's even a plugin that allows you to use it for PHP code. 甚至还有一个插件,允许您将其用于PHP代码。

I think Trace may be what you want, although in practice, I would expect a good debugger with expression evaluation and conditional breakpoints might solve your overall problem more quickly. 我认为Trace可能是您想要的,尽管在实践中,我希望具有表达式评估和条件断点的良好调试器可以更快地解决您的总体问题。 Note that Trace is written to the JPDA and its code is available. 请注意,Trace已写入JPDA,并且其代码可用。

I don't understand how such a tool would work. 我不知道这样的工具将如何工作。 What would it do for conditionals? 有条件的话会做什么? For user input? 供用户输入?

int x=getUserInput();
print(x);  // What would your translator show for this line?

Also, it sounds a bit like any such tool could be used to solve the Halting Problem ...just look at the last line. 而且,听起来有点像可以使用任何此类工具来解决“ 暂停问题” ...只看最后一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM