This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 156253 - Conditional breakpoints not working
Summary: Conditional breakpoints not working
Status: CLOSED WONTFIX
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@debugger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-04 06:34 UTC by _ wadechandler
Modified: 2010-04-29 09:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ wadechandler 2009-01-04 06:34:30 UTC
I have conditional break points set trying to track down issue 153877. I am trying to set breakpoints to see the call
stack which is saving the file projectuiapi.properties. I have a conditional breakpoint set in the JDK sources in
java.io.File using String.endsWith. Specifically one example is pathName.endsWith("projectuiapi.properties"). According
to the documentation this should work. I do not have a breakpoint hit count set. The problem is that the breakpoint is
stopped on at every single call instead of only when the condition is true. The documentation from the IDE states:
"The condition may include anything that can be on the right side of the equal sign (=). The condition may also include
variables and methods that are within the current context."

but, unless I'm missing something this is not working at all.
Comment 1 _ wadechandler 2009-01-04 07:02:14 UTC
That pathName should be pathname, but it doesn't work, that is just a typo. child.endsWith("projectuiapi.properties")
doesn't work either. I have conditional breakpoints in all possible paths with different variables. My watches work
fine, but the conditional breakpoints do not.
Comment 2 _ wadechandler 2009-01-04 07:17:01 UTC
OK. So, if I use variables which are directly on the breakpoint line then it works, but for instance in the code:
    public File(File parent, String child) {
	if (child == null) {
	    throw new NullPointerException();
	}
	if (parent != null) {
	    if (parent.path.equals("")) {
		this.path = fs.resolve(fs.getDefaultParent(),
				       fs.normalize(child));
	    } else {
		this.path = fs.resolve(parent.path,
				       fs.normalize(child));
	    }
	} else {
	    this.path = fs.normalize(child);
	}
	this.prefixLength = fs.prefixLength(this.path);//breakpoint here
    }

Where I have set the breakpoint where I added a comment. The conditional breakpoint can not reference child and work
correctly. I have to use this.path instead. For some reason too watches are not working on the context relative
information either. The watches were what actually alerted me to get around the issue. The debug information must be
available in the JDK as I am seeing the line numbers and all in the call stack in the debugger window, but still the
debugger thinks these variables are not in the context for some reason. This in the case where child is obviously set as
it has a value which is put into this.path which I am able to see.
Comment 3 Filip Zamboj 2009-01-05 16:26:15 UTC
Hi Wade.

I have tried to reproduce this issue but didn't succeed. However, correct me if I am mistaken and i didn't understand or
notice something you wrote in your posts. I put breakpoint on the same line in the code you mentioned and add an
conditional breakpoint to stop if child.endsWith("txt"), child should be child.txt in my example and it works very well. 

Do you experience this troubles in other cases or it's just in this particular case? If yes, post some "step-by-step
manual" how to reproduce, please. 

Regards, 
Filip 
Comment 4 _ wadechandler 2009-01-05 17:27:57 UTC
Similar to you I used that exact type logic except mine ended in the final file name. I experienced the same problem in
all of the java.io.File constructors. If I set a conditional breakpoint on a specific line then the other context
related variables did not work correctly in the condition. Too, watches didn't work for other things in the context.
This is on Windows XP with JDK 1.5_16 (using that to develop NB sources). The only things I could successfully access
were on the exact line where the breakpoint was set. Step by step for me:

1) Make sure you are on Windows XP using the same JDK ( 1.5_16 ). May be related to different OS?
2) Use the navigate action to go to type java.io.File
3) In the constructors create conditional breakpoints near the end where all things should be realized and set etc.
4) In those break points try to use the parameters of the method call, and make sure you are using endsWith and the
value projectuiapi.properties for the condition.
5) Open up the NB sources project projectuiapi.
6) Right click on the projectuiapi project and choose debug.
7) When the debugger starts make sure the JDK sources are checked in the sources window.
8) Create a new Java SE project in the NB instance you are debugging.
9) When the project is created, right click on it, and choose properties. (break points may have been hit before this if
they are not working correctly or once on startup if the persistence is accessed...can't remember on the persistence and
startup bit...of course if the path doesn't end in projectuiapi.properties then the breakpoint should not stop if it is
working correctly)

That is really all I did. When that didn't work correctly I changed to use only the variables being accessed on the
exact same line where the breakpoint was set, and that worked. I did that trying to get it to work so I could use it and
of course to find out what the issue was.
Comment 5 Martin Entlicher 2009-01-06 22:16:18 UTC
Do NetBeans in which you debug, run on JDK 1.5 also?

It works for me fine as well in NetBeans dev #081210 when running on JDK 6.
On JDK 5, Debugger Console says:
Breakpoint hit at line 290 in class java.io.File by thread main.
***
"child" is not a known variable in the current context.
***

This is expected, since JDK classes are *NOT* compiled with variable debug information. Therefore "child" variable
really can not be found.

On JDK 6 we use http://java.sun.com/javase/6/docs/jdk/api/jpda/jdi/com/sun/jdi/StackFrame.html#getArgumentValues() and
bind the argument names to the correct values. Therefore it works on JDK 6.

Run NetBeans on JDK 6 as a workaround. It can NOT be fixed on JDK 5.
Comment 6 _ wadechandler 2009-01-06 23:29:28 UTC
Ah, that would do it then. OK.
Comment 7 Quality Engineering 2010-04-29 09:46:17 UTC
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.