简体   繁体   中英

Strange behavior when debugging Eclipse CDT with Eclipse Debugger

When debugging Eclipse CDT code I witnessed a strange behavior. I try to explain it with screen-shots. I am sure people who don't know CDT can still give me an answer to this question, because I think it's related to (debugging) Java code with Eclipse in general.

The IIndexFile file you see in the highlighted line will have a field with a wrong value and I try to understand where that value comes from.

Before entering getFile() :

getFile()将被调用

Inside getFile() a new PDOMFile is created. The constructor with two parameters is called: 在此处输入图片说明

Shortly before leaving the constructor we can see on the right side that location is null. Not surprising, as it hasn't been set yet. 在此处输入图片说明

The next image shows the first thing that surprises me a bit. When leaving the constructor for PDOMFILE I actually expect the debugger to tell me the return value. Instead it says No explicit return value . Maybe it's because it was a constructor or maybe it's because of the if-statement. 在此处输入图片说明

Now the highlighted line shows that the dubber is back from the call getFile() , but the assignment to file hasn't been done yet. We can see that the location field is still null. 在此处输入图片说明

And this is what I don't understand. Why is location from file set now?

在此处输入图片说明

The debugger calls toString() to obtain the string displayed in the bottom pane of the "Variables" view. PDOMFile.toString() calls getLocation() which sets location on its first call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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