Reputation: 4419
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()
:
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?
Upvotes: 1
Views: 54
Reputation: 52739
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.
Upvotes: 2