Topic: 当跟踪进系统函数后,如何Inspect局部变量值

  Print this page

1.当跟踪进系统函数后,如何Inspect局部变量值 Copy to clipboard
Posted by: widewindow
Posted on: 2008-08-05 17:52

在安装了JDK及其源代码后,我发现可以在eclipse中可以跟踪进入系统函数,比如DrawImage,但进入后只能查看(Inspect)类的成员变量的值,对于函数的局部变量,如果去查看,eclipse会说变量名"unsolved",请问有办法解决这个问题吗?谢谢。

2.Re:当跟踪进系统函数后,如何Inspect局部变量值 [Re: widewindow] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-08-15 00:59

I don't know how to reproduce your scenario, can you provide me more details?

e.g. 在eclipse中可以跟踪进入系统函数,比如DrawImage
Where is "DrawImage"?? How to enter 系统函数????

3.Re:当跟踪进系统函数后,如何Inspect局部变量值 [Re: HenryShanley] Copy to clipboard
Posted by: widewindow
Posted on: 2008-08-15 10:33

函数如下:
  public void draw(Graphics2D graphics2d, BufferedImage img) {
    graphics2d.drawImage(img, 0, 0, ((java.awt.image.ImageObserver) (null)));
  }
如果在graphics2d.drawImage()处跟进的话,将进入SunGraphics2D.drawImage(),之后,还可以一直进入到很深的Java库函数中。注意,必须用JDK7才有所有源代码。在这些函数中可以查看类的成员变量,但不能查看函数的局部变量。

4.Re:当跟踪进系统函数后,如何Inspect局部变量值 [Re: widewindow] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-08-15 22:51

I don't have JDK7 at the moment. But I have already known that JDK7 did have improved the API a lot. I will go and find out some outstanding new features of JDK7 before I will ever think about using it.

But I still don't understand your questions... (correct me if I am wrong)

"如果在graphics2d.drawImage()处跟进的话,将进 SunGraphics2D.drawImage(),之后"

Are you talking about browsing the source code using Eclipse?
- if yes, then I don't see why you cannot view the local variables. Because they are just ASCII source code.

Or are you talking about debugging the JDK code?
- if yes, then some of the JDK code are not compiled using the debug flag, it is one of the biggest issue since the first version of JDK. I see that lots of the developers requested SUN to compile the source code using debug-able flag, but so far SUN microsystems seems ignoring this common request so far. (I understand one of the big disadvantage of compiling the code using debug flag will result a bigger JRE classes in space). However I am still looking forward for this happening in JDK7. If what you mentioned is true, then I am a little bit disappointed.

If none of the above is true, then you'd better give me a pistol and let me kill myself.. Smile

Thanks,
Jiafan

5.Re:当跟踪进系统函数后,如何Inspect局部变量值 [Re: HenryShanley] Copy to clipboard
Posted by: widewindow
Posted on: 2008-08-16 10:03

Thank you for your reply! Surely I meant debugging. The JDK7 is compilable if we follow the guide inside the package, but this may require some efforts. Thank you!

6.Re:当跟踪进系统函数后,如何Inspect局部变量值 [Re: widewindow] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-08-16 15:58

widewindow wrote:
Thank you for your reply! Surely I meant debugging. The JDK7 is compilable if we follow the guide inside the package, but this may require some efforts. Thank you!

Yes, there are already some debates on the Internet on whether we should compile the JDK source code by developers or not.

My personal opinion is that we should not compile the source code by ourselves. It is preferred not to mess the JDK code like that only for the debugging purpose.

Another reason not to compile JDK is because Sun microsystems have done a lot of effort to improve the usability of JDK as well as reducing bugs. They don't want/and should not let developers to debug the source code. (You can image that a JRE contains debugging information could be much bigger than one does not contain so)

If you only want to learn the JDK code, you'd better read the Javadoc instead of debugging code yourself. Because it does not contain debug-able flag, of course Eclipse cannot recognise those "local variables" or others when performing debugging. If you really want to compile the JDK yourself, (I haven't done it myself, but I will give you my knowledge if some problems encountered when you proceed)

On the other side, I do understand lots of developers want to have the flag set in the JRE so that we can debug them, well..... (maybe Sun have done some shiXX jobs that do not want others to find them) in that case, I suggest you send an email to Sun microsystems like others to request for that feature in the next release of JDK.

One thing may be obvious but noteworthy is that this is not only for JDK7 that cannot be debug-able. It is a disadvantage for the other previous versions of JDK.

by the by, I suggest you to use some common terms when describing a particular computer technology, in order to avoid some misunderstanding like here.
e.g.
I misunderstood you here when you mention about "debugging".

Thanks,
Jiafan


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923