Eclipse Breakpoint System.out [英] Eclipse Breakpoint System.out

查看:78
本文介绍了Eclipse Breakpoint System.out的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想观察运行情况时,通常在Java应用程序中设置一个断点。

typically I set a breakpoint in my Java application when I want to observe the run.

但是有时候我只是想知道是否调用了一个方法。因此,断点无济于事,我插入了 systrace语句
System.out.println( method signature);

However sometimes I just want to know if a method is called or not. Therefore a breakpoint does not help me, and I insert a "systrace" statement System.out.println("method signature");

如果可以设置断点并在达到断点时仅打印出systrace消息并继续运行,我认为这将是一个不错的功能。

I thought it would be a nice feature If I could set a breakpoint and when the breakpoint is reached to just print out the systrace message and continue the run.

您知道这是否可行吗?

推荐答案

您必须使用一个条件断点以下条件:

You have to make it a conditional breakpoint with a following condition:

System.out.printf(Thread.currentThread().getStackTrace()[1].getMethodName() + "\n") == null

在我的Eclipse中可以正常工作。我正在使用printf使打印代码评估为布尔值。不确定是否有办法自动将此代码插入断点。

Works fine in my Eclipse. I'm using printf to make printing code evaluate to boolean. Not sure if there's a way to automate inserting this code into a breakpoint.

这篇关于Eclipse Breakpoint System.out的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆