 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Wed May 27, 2015 8:54 am Post subject: Debugging: Can't step into function |
|
|
Whilst trying to debug someone else's code I found that I am not able to step into an external function that has been provided with an explicit interface using a module.
The following code illustrates this. When you run using the debugger you are not able to step into the adder function (the line: adder = a + b). You are not able to "Getto cursor" to this location either.
It works if the interface is copied into main directly (copy/paste and remove the module), but not with it in the module.
Any thoughts? The stack trace shows a call to the interface, which isn't right.
Code: |
module interfaces
interface
function adder(a, b)
real, intent(in) :: a, b
real :: adder
end function adder
end interface
end module interfaces
function adder(a, b)
real, intent(in) :: a, b
real :: adder
adder = a + b
end function adder
program main
use interfaces, only: adder
real :: a, b, y
a = 1.0
b = 2.0
y = adder(a, b)
print *, y
end program main
|
_________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
Robert

Joined: 29 Nov 2006 Posts: 457 Location: Manchester
|
Posted: Wed May 27, 2015 9:16 am Post subject: |
|
|
What do you mean by 'external function'? Presumably the code is question is compiled with a debug option? |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Wed May 27, 2015 1:17 pm Post subject: Re: |
|
|
Robert wrote: | What do you mean by 'external function'? | That is the term used to make it clear that the code for the body of the function in question is not CONTAINed in a module.
I can reproduce the bug with FTN95 7.10 and 7.20. For every compilation mentioned here, I used the /DEBUG option. Here are a couple of related findings.
1. If the module with just the interface in it is moved to a separate file, source debugging capability is restored. DavidB, please try this strategy with your larger program and advise us as to whether it worked.
2. If just the function code is moved to a separate file, leaving the module with the interface in place, source level debugging capability is lost completely. When SDBG is launched with this modification to the source code, we see the disassembly immediately.
Last edited by mecej4 on Mon Jun 15, 2015 11:08 pm; edited 1 time in total |
|
Back to top |
|
 |
Robert

Joined: 29 Nov 2006 Posts: 457 Location: Manchester
|
Posted: Wed May 27, 2015 3:26 pm Post subject: |
|
|
Could you send us your simple example so we can look at it? |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Wed May 27, 2015 3:52 pm Post subject: |
|
|
DavidB already posted his simple example code, where you can do symbolic debugging in the main program but not in the function. Here is the code to reproduce case 2 in my post above, where there is complete failure of source debugging.
File adder.f90:
Code: | module interfaces
interface
function adder(a, b)
real, intent(in) :: a, b
real :: adder
end function adder
end interface
end module interfaces
program main
use interfaces, only: adder
real :: a, b, y
a = 1.0
b = 2.0
y = adder(a, b)
print *, y
end program main |
File func.f90:
Code: | function adder(a, b)
real, intent(in) :: a, b
real :: adder
adder = a + b
end function adder |
Building and debugging:
Code: | ftn95 adder.f90 /debug
ftn95 func.f90 /debug
slink adder.obj func.obj /debug
sdbg adder.exe |
|
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Wed May 27, 2015 5:34 pm Post subject: Re: |
|
|
Robert wrote: | What do you mean by 'external function'? |
As mecej4 says, it just means a function that is not inside a module. Sorry, I was using External in the sense of its definition in the Fortran standard.
I am compiling with debugging enabled (actually I am using /CHECK but that doesn't matter).
The "complete" example is given at the top of this post.
mecej4 wrote: |
1. If the module with just the interface in it is moved to a separate file, source debugging capability is restored. DavidB, please try this strategy with your larger program and advise us as to whether it worked. |
Yes this does work.
mecej4 wrote: |
2. If just the function code is moved to a separate file, leaving the module with the interface in place, source level debugging capability is lost completely. When SDBG is launched with this modification to the source code, we see the disassembly immediately. |
Another manifestation of the same bug.
I generally don't use external functions so have only just found this with other peoples' code. Unfortunately they want the functions to be exportable in a DLL so I can't just move the function bodies into the modules. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|