Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29286 Discussions

Conditional breakpoints when debugging

sabur
Beginner
2,128 Views

I am using IVF 9.1 and of course Visual Studio. I have a nested loop and I would like to break when the counter for the inside loop is a certain value and also when the counter for the outside loop is a certain value. I.e. break when two conditions are true at the same time.

I can do it for one condition; just set, say, "j=134" in that little condition box and it works fine. J is the outside loop counter. I is the inside one. I would like to break when, say "j=134" AND also when "i=40". How do I do this?

I've tried things like "j=134 and i=40", "j=134 .and. i=40", "j=134, j=40" and many others. I've tried Visual Studio help and I've googled but I can't find the exact syntax anywhere and am getting tired of throwing darts.

I just discovered recently that I'm actually using the Visual Studio debugger. Perhaps this is the wrong forum/company but I always thought debugging aFORTRAN program was aFORTRAN thing. This Visual Studio environment thing is very confusing.

Thanks

Mike

0 Kudos
12 Replies
Steven_L_Intel1
Employee
2,128 Views
You're in the right place. You may be using the Visual Studio debugger but you're using the Intel Fortran enhancement to it so that it understands Fortran.

I have not yet tried this, but it should accept normal Fortran expression syntax. For example:

(j == 134) .and. (i == 40)

Note the dots as used in Fortran logical operators and the double-equal (could also use .eq.)

There has been some flakiness reported with data breakpoints, so I can't promise this will work.
0 Kudos
sabur
Beginner
2,128 Views

Cool. That worked.

I am familiar with the "dotted" Fortran logical operators and had tried using ".and." in some fashion. I also discovered the double equal sign when googling a while back when I was using CVF. That enabled me to do simple conditional breaking back then and I believe it was, you guessed it, a post I found googling by someone named Steve Lyons or Liens or maybe Lional; something like that. I also tried the double equal sign but I didn't use them and ".and."together in the wayjust described

Just out of idol curiosity, is this ..uh, documented anywhere?

Howthe bleep do you find the time to respond to as many of these questions as you do and keep up with all this stuff?

Mike

0 Kudos
Steven_L_Intel1
Employee
2,128 Views
Sabur:
I found googling by someone named Steve Lyons or Liens or maybe Lional; something like that.


Something like that... :-)

Just out of idol curiosity, is this ..uh, documented anywhere?

Um, yeah. The syntax is just normal Fortran expression syntax. I'll agree that data watchpoints aren't documented specifically for Fortran. I'll suggest that that can be improved.

Howthe bleep do you find the time to respond to as many of these questions as you do and keep up with all this stuff?

Well, it is part of my job, and I've gotten pretty good at it over the years.

Enjoy.
0 Kudos
martinez_paneda__emi
2,128 Views

Steve Lionel (Intel) wrote:

Just out of idol curiosity, is this ..uh, documented anywhere?

 

 

Um, yeah. The syntax is just normal Fortran expression syntax. I'll agree that data watchpoints aren't documented specifically for Fortran. I'll suggest that that can be improved.

I was struggling with the exactly same issue as sabur until I discovered this comments. Thanks a lot for your help Steve

However, altough I thought I was familiar with Fortran expression syntax, it never ocurred to me that (j == 134) .and. (i == 40) could be a valid expresion for the conditional breakpoint, because (for example) in an IF-THEN-END IF statement the brackets are used only once: ( j == 134 .and. i==40).

Therefore, since this post is quite old, do you know if valid conditional expressions for Fortran debugging with VS are now documented anywhere? I've searched VS2008 documentation throughly and I did not found anything related. 

Thank you

0 Kudos
dboggs
New Contributor I
2,128 Views

(Sorry, I posted the following in the wrong chain. Here it is and sorry about the duplication)

I take this opportunity to ask a related question. I want the program to break whenever a certain variable changes value, say var_1. This is not well described in the documentation. I gather that the feature is called a "data breakpoint." The documentation describes that this is not explicitly supported for Fortran, but the C++ support can be used if the variable is "entered" (where?) in caps, i.e. VAR_1. It goes on for an explicit example in the case of an array variable, where it instructs Debug > New Breakpoint > New Data Breakpoint, then enter the address in loc form, and the byte count (whatever that would be in my case), and finally the language as C++. That choice (nor any choices at all) are not available in my list.

Should I conclude that what I want to do is not supported by the VS Shell?

0 Kudos
mecej4
Honored Contributor III
2,128 Views

DBoggs: I do not have installed on my machines any of the VS shells that come with Intel Fortran, but you may find the following suggestion to work. I have found that if I compile Fortran source with the /Zi option, the resulting EXE can be debugged with, for example, Visual Studio Express 2013 for Windows Desktop. However, lacking Fortran integration, this version of VS has to be used in a C-centric way. With the test program[fortran]      program dbrk
      integer i,j
      do i=1,10
         j=i*i+3
         write(*,*)i,j
      end do
      end[/fortran]

I built the EXE from the command line, started up VS Express, and caused the the program to be entered by pressing F11. I then tested two types of breakpoints:

  • A conditional code breakpoint on Line-5 with the condition J > 50
  • A data breakpoint (which, behind the scenes, exploits the CPU feature of setting data breakpoints on a small number of specified memory addresses) for a change in the local variable J.

I set the data breakpoint by specifying &J as the variable to watch. The uppercase name is needed because that is what Intel Fortran puts out as debug information on IA32; the '&' is needed because VS Express has no Fortran integration. I could have, alternatively, looked up the hex-address of J and entered that address into the data breakpoint specification. This alternative has the drawback that the addresses of variables may change with repeated executions of the program, because of Windows address "randomization", which is implemented in some versions of Windows.

As you may have observed yourself, data breakpoints can be added only after program execution has been started in the debugger. That is probably because local variables are addressed through EBP and addresses of global/common variables are subject to relocation during program start-up.

0 Kudos
dboggs
New Contributor I
2,128 Views

Thanks, I appreciate the response and suggestions. But...

When I attempt to run the program using f11, I get an error message "source code not found" looking for crt0.c. This happens with or without /Zi. I'm out of my league here so don't think I will pursue further. I survived without data breakpoints for years and can probably survive a few more.

btw, is there anyplace I can find a description of the limitations of the VS shell, so I could consider the advantages of upgrading to the full VS? Until now I had supposed that the shell was providing nearly everything I needed. That is until as I recently learned (1) inability to print in color, (2) inability to customize the header on printed output (even if those things require an extension, since the extensions cannot be installed in the shell). Well those are minor, and don't strongly affect my ability to develop Fortran programs, but it seems the limitations keep piling up now.

0 Kudos
andrew_4619
Honored Contributor III
2,128 Views

On of the biggest limitations of VS shell is no resource editor, that is a pain! I am aware that is a Microsoft restriction.

 

0 Kudos
dboggs
New Contributor I
2,128 Views

Yes, I am aware of that one, and agree that it is a big pain. Thanks for mentioning it.

Even worse than the absence of some of these, the Intel documentation on how to use them--meager as it is--seems to always assume that you have the full VS. Using resource files is a good example. You can use 3rd-party editors to create .rc files (I use my old edition of Compaq Visual Fortran, before Microsoft took the editor away) to create them, but when it comes to integrating them with your project--well, let's just say you are on your own, and the Intel documentation can hurt more than it helps.

0 Kudos
andrew_4619
Honored Contributor III
2,128 Views

I also use an older maintained version of VS for resources, I used REsedit for a time but then  I had some features that did not work in Resedit and there isn't any real support for it, it is not a commercial code.

There really should be a supported resource  solution bundled with the product, it is after-all 'Visual Fortran' and resources are a big part of Visual.

0 Kudos
mecej4
Honored Contributor III
2,128 Views

 I get an error message "source code not found" looking for crt0.c
You can either ignore the message or you can set a breakpoint at function _MAIN__ (the Fortran code entry point) and let the program reach that breakpoint before attempting anything else. 

0 Kudos
dboggs
New Contributor I
2,128 Views

mecej4,

Yes, I can do it now. It's too bad this requires such roundabout steps to accomplish. But thanks.

0 Kudos
Reply