Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Procedure pointers and debug

Pietro_P_
Beginner
210 Views

Hi,

I have a code making use of a large amount of procedure pointers. I've always wondered if there is a way to know which procedure the procedure pointer is pointing at when debugging. I'm using Intel Version 16.0.0063.2010.

thanks 

PP

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
210 Views

Neither - it's that there doesn't seem to be a way to do this. I tried a few ideas I had, none of them worked out. I think the C debugger can do this - not sure if it's possible for Intel to get the Fortran integration to do so (Microsoft doesn't provide all the hooks to other languages). Submit it as a feature request at the Intel Online Service Center. One might also like to know what variable a data pointer points at. I tried the memory view but that didn't help.

View solution in original post

6 Replies
Pietro_P_
Beginner
210 Views

I guess the question is either too simple or completely non-sense...

Steve_Lionel
Black Belt Retired Employee
211 Views

Neither - it's that there doesn't seem to be a way to do this. I tried a few ideas I had, none of them worked out. I think the C debugger can do this - not sure if it's possible for Intel to get the Fortran integration to do so (Microsoft doesn't provide all the hooks to other languages). Submit it as a feature request at the Intel Online Service Center. One might also like to know what variable a data pointer points at. I tried the memory view but that didn't help.

View solution in original post

Pietro_P_
Beginner
210 Views

Steve Lionel (Ret.) wrote:

Neither - it's that there doesn't seem to be a way to do this. I tried a few ideas I had, none of them worked out. I think the C debugger can do this - not sure if it's possible for Intel to get the Fortran integration to do so (Microsoft doesn't provide all the hooks to other languages). Submit it as a feature request at the Intel Online Service Center. One might also like to know what variable a data pointer points at. I tried the memory view but that didn't help.

thanks Lionel, as usual!

I'm not a "coder" but still i find it hard to believe that noone had this need before...

I'll try with the feature request: is it properly explained as i've put it on my first post?

 

Steve_Lionel
Black Belt Retired Employee
210 Views

I had another thought and found a way to do this, though it requires a bit of effort.

Let's say you have two subroutines, sub1 and sub2 and you want to know which one a procedure pointer is pointing to. First thing to do is to switch the debugger's Locals view to Hexadecimal - right click anywhere in the Locals pane and select "Hexadecimal display".

Now switch to the Watch pane (probably labeled "Watch 1". In the Name field, type "loc(sub1)". In the second row, type "loc(sub2)". Like this:

Screenshot_1.jpg

If you now look at the value of the pointer in Locals you can compare it against the values in the Watch window and see which one it is. (I just realized you don't have to choose hexadecimal - works fine without it - I changed my strategy mid-post!) 

The nice thing about this is that the Watch window will stay around, and even come back if you restart the program. This still isn't an automated method, but it's a lot better than nothing.

If you want to make your feature request, I think your original text is fine.

Pietro_P_
Beginner
210 Views

Steve Lionel (Ret.) wrote:

I had another thought and found a way to do this, though it requires a bit of effort.

Let's say you have two subroutines, sub1 and sub2 and you want to know which one a procedure pointer is pointing to. First thing to do is to switch the debugger's Locals view to Hexadecimal - right click anywhere in the Locals pane and select "Hexadecimal display".

Now switch to the Watch pane (probably labeled "Watch 1". In the Name field, type "loc(sub1)". In the second row, type "loc(sub2)". Like this:

If you now look at the value of the pointer in Locals you can compare it against the values in the Watch window and see which one it is. (I just realized you don't have to choose hexadecimal - works fine without it - I changed my strategy mid-post!) 

The nice thing about this is that the Watch window will stay around, and even come back if you restart the program. This still isn't an automated method, but it's a lot better than nothing.

If you want to make your feature request, I think your original text is fine.

Hi,

it works, but it is more more a method to check whether the pointer is actually pointing at what you think it is, than a method to find out what it is pointing at. It just takes a code with 10 "pointable" procedures to make it a nightmare...

I still think it would require a very little effort for programmers to establish a link between the procedure symbol and the memory address, am I wrong?

Steve_Lionel
Black Belt Retired Employee
210 Views

It may be a lot of effort or not even possible, depending on what APIs Microsoft has for such queries. If there's an API to convert addresses to symbols that is available to non-Microsoft code, it is possible. My recollection is that the hooks in the debugger are rather few in nature.

Reply