Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

How to trigger a breakpoint when a particular variable goes negative?

Anthony_Richards
新分销商 I
1,240 次查看

Is there a way to get the debugger to do this? How?

0 项奖励
6 回复数
LRaim
新分销商 I
1,240 次查看

Insert a break point where the variable is used. Then by right-clicking on the red-ball you can select  insert condition and type e.g. XYZ .LT. 0.0

0 项奖励
Steven_L_Intel1
1,240 次查看

You can also set a data breakpoint that will check the variable anywhere it is changed in a routine, but I like Luigi's suggestion better.

0 项奖励
FortranFan
名誉分销商 III
1,240 次查看

See this other thread for some added discussion on breakpoints:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/508526

 

0 项奖励
Anthony_Richards
新分销商 I
1,240 次查看

The variable is defined in multiple places in the subprogram, so I want to cover all those places at the same time without having to insert code everywhere.

So, Steve, how is that done?

0 项奖励
mecej4
名誉分销商 III
1,240 次查看

There is hardware support (using the debug registers of the CPU) for watching the contents of four addresses and trapping accesses to those addresses. Watching all variables in the program without localization to a specific line of code (and, even worse, watching arbitrary expressions) would be prohibitively expensive -- after every CPU/FPU instruction, the specified expression would have to be evaluated.

If you want to enable  a program-wide watch on an expression, assign a variable to the expression at the beginning of a block of code that you suspect to contain a bug, be sure to update the new variable whenever any of the variables in the expression changes. You have only four arrows (DR0 to DR3) in your quiver to slay the beast.

0 项奖励
Steven_L_Intel1
1,240 次查看

I wish I could tell you how to do this, but the VS debugger has broken data breakpoints for Fortran and I am not sure how to work around it. I need to ask our debugger developers if they know how to resolve it.

0 项奖励
回复