Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29435 Discussions

How to set conditional breakpoints on variable value?

WSinc
Nouveau contributeur I
1 619 Visites
I thought there was a way to halt execution when a variable is equal to a certain value,
or within a certain range. Yet I can't find any writeupw on how to do this. And playing around with
the debugger doesn't reveal anything.

I know about "watch windows," but unfortunately, it might take many thousands of passes thru a certain part of the code before this condition is met.

The way I do it now is insert something in the code, like

if (N.eq.1003)then
continue ! breakpoint here
endif


or like this:

if(n.le.2433 .and. N.gt. 1742)then
continue
endif


and put a breakpoint on the continue statment.
as effective as this is, it requires me to recompile the code there,
and restart execution.

I thought there was a way to avoid having to recompile anything, but
maybe I'm mistaken?

A data breakpoint won't do the job unless it can also watch for a condition like I
mentioned above. The variable changes value many thousands of times before it
gets within the range of interest, so that's an agonizing process.....

I could not set a condition. It keeps telling me it does not recognize the symbol,
or can't parse the condition. Does one use Fortran syntax, like .ge. .ne. .gt., or does one use
< > = >= etc? I wish there was a writeup somewhere.

I guess one could put something permanently in the code, and change the upper and lower limits at run time.
i.e:

if(N.ge.N1 .and N.le.N2)then
continue ! breakpoint here
print *,"read in new N1,N2:"
read *,N1,N2
endif


Then take it out later when you have some confidence about the program.
BTW, How do we put a data beakpoint on an integer(8) value?
VS 2008 only allows 4 bytes max at a time. I thought it was integrated with Fortran.
If it knows the variable type, shouldn't it know how many bytes anyway?
Actually if you want to monitior more than one adjacent element, the upper limit
could be a lot higher than 4, right?
0 Compliments
5 Réponses
IanH
Contributeur émérite III
1 619 Visites
Conditional breakpoints certainly work for me, using either fortran or C syntax, noting that "=" in your list is assignment in both languages. Use == or .EQ. in the expression if you want "equals to" comparison. More specific detail may help diagnose the problem.
0 Compliments
Jugoslav_Dujic
Précieux contributeur II
1 619 Visites
Bill, to set up a conditional breakpoint, create an ordinary breakpoint first (F9), right click on its "red ball" symbol and select "Condition...". The debugger recognizes Fortran syntax here (e.g. "N.ge.N1 .and. N.le.N2"). Be aware that it slows down execution, especially with complex expressions and numerous conditional breakpoints, so use sparingly.
0 Compliments
WSinc
Nouveau contributeur I
1 619 Visites
I tried that, but I could not get it to work. The problem may be that it doesn't like integer(8) variables.

Most of the variables in my project are 8 byte integers, which C++ kinda hiccups and dies upon.

That is, unless C++ has been upgraded to work with those recently. I tried both the fortran and C++ syntax, but still get that "cannot parse" or "do not recognize synbol" message.

In order to monitor integer(8) variables, wouldn't it have to look at all 8 bytes?
The upper limit is four, according to what it tells me. One workaround would be
to use two hex addresses of 4 bytes, but that's really clumsy.

(Actually, I get the same message with 4 byte variables too.)

It would be nice to be able to monitor a higher number, so one could monitor more than
one element in an array, for example.
0 Compliments
Jugoslav_Dujic
Précieux contributeur II
1 619 Visites
Hm, Bill, are we talking about the same dialog? "Data breakpoint"/="Conditional breakpoint". The former breaks anywhere when the variable changes, and is limited to 4 bytes indeed (and tends to be quirky). The latter breaks on given fixed line, but only when the condition is met, and has no variable limitations that I know.

You seem to be talking about the former, but I'm talking about the later.



0 Compliments
IanH
Contributeur émérite III
1 619 Visites
What exactly is the condition that you are using? INTEGER(8) variables seem to work in conditional breakpoint expressions (VS2005, IVF 11.1.060):

Conditional breakpoint screen shot
0 Compliments
Répondre