简体   繁体   English

Eclipse调试获得完整堆栈

[英]Eclipse debugging getting full stack

I just have a simple question, consider the following method 我只是有一个简单的问题,请考虑以下方法

public void do_something(long arg){
//some work
}

and in eclipse, I added a break point for the above method and run the program, everything is fine, but I cannot find out the stack of current point?! 在eclipse中,我为上面的方法添加了一个断点并运行程序,一切都很好,但我找不到当前堆栈的堆栈?! for example 例如

call do_something
push id
call previous_method
call xyz
pop z
call useZ
push z

I mean this method is called by 10 different methods and different stack, how would I find out the full stack of the thread(including methods) with eclipse?! 我的意思是这个方法是由10种不同的方法和不同的堆栈调用的,我怎样才能找到eclipse的完整堆栈(包括方法)? should I change some default property or what?! 我应该更改一些默认属性还是什么?!

To put an image, I repeat my comment as an answer. 为了放置图像,我重复我的评论作为答案。

In the Debug View you can find the call stack and in the Variables View you can find the actual parameters and values of the local variables: 在Debug视图中,您可以找到调用堆栈,在Variables View中可以找到局部变量的实际参数和值:

调用Stack for单线程应用程序

To get the actual parameters and values of local variables of an other method in the call stack just click in the Debug View on a method above the current method. 要获取调用堆栈中其他方法的局部变量的实际参数和值,只需在当前方法上方的方法上单击Debug视图。

This isn't working for a multi-threaded application. 这不适用于多线程应用程序。 You can only see the call stack for the current thread where the method is running in it. 您只能看到当前运行该方法的线程的调用堆栈。 Look at: 看着: 调用堆栈用于多线程应用程序

In the method foo a thread is created by creating a timer. 在方法foo通过创建计时器来创建线程。 If the jvm suspend on bar , it only sees the call stack of TimerTask.run -> bar but not main -> foo -> run -> bar . 如果jvm挂起bar ,它只能看到TimerTask.run的调用堆栈 - > bar而不是main - > foo - > run - > bar

What you've described isn't a stack. 你所描述的不是堆栈。

It's a history. 这是一段历史。

Eclipse isn't designed to give you a history. Eclipse不是为了给你一个历史而设计的。 However, there are other tools that can show you the history, such as Chronon. 但是,还有其他工具可以显示历史记录,例如Chronon。 However, that might be too expensive for you! 但是,这对你来说可能太贵了! It also might use too much memory if your application is very complex. 如果您的应用程序非常复杂,它也可能会使用太多内存。

The simplest way to get a history, however, is to put System.out.println("some message") in lots of places. 然而,获取历史记录的最简单方法是将System.out.println("some message")放在很多地方。

It can be inconvenient to use System.out.println everywhere, so a couple of other ideas have been developed to improve on this: 在任何地方使用System.out.println都不方便,因此已经开发了其他一些想法来改进:

  1. Logging frameworks handle common tasks such as printing the time when something happened, rotating big log files etc. 日志框架处理常见任务,例如打印发生事件的时间,旋转大日志文件等。
  2. Aspect-oriented programming allows you to inject logging in lots of places at once. 面向方面的编程允许您一次在许多地方注入日志。

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

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