Hi,? I have a Fortran 77 subroutine (dll). On windows XP, how ?would I 'debug it(Fortran) within R' using gdb? This is how I made it. ---------------------- R CMD SHLIB main.f gfortran -m32 ? ? -O3 ?-mtune=core2 -c main.f -o main.o gcc -m32 -shared -s -static-libgcc -o main.dll tmp.def main.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -lgfortran -LF:/ProgramFiles/R/R-3.1.1/bin/i386 -lR Here is the contents of the file ?main.f ----------------------------------------- ? ? ? SUBROUTINE NGCD(NA, NB, NGCDO)? ? ? ? ? IA = NA ? ? ? ? IB = NB ? ? 1 ? IF (IB.NE.0) THEN ? ? ? ? ? ITEMP = IA ? ? ? ? ? IA = IB ? ? ? ? ? IB = MOD(ITEMP, IB) ? ? ? ? ? GOTO 1 ? ? ? ? END IF ? ? ? ? NGCDO = IA ? ? ? ? ? RETURN ? ? ? END Thank you, Andre Mikulec Andre_Mikulec at Hotmail.com
Debug an R windows (Fortran) DLL within R with gdb?
2 messages · Andre Mikulec, Duncan Murdoch
On 15/09/2014, 5:25 PM, Andre Mikulec wrote:
Hi,
I have a Fortran 77 subroutine (dll).
On windows XP, how would I 'debug it(Fortran) within R' using gdb?
This is how I made it.
----------------------
R CMD SHLIB main.f
gfortran -m32 -O3 -mtune=core2 -c main.f -o main.o
gcc -m32 -shared -s -static-libgcc -o main.dll tmp.def main.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -lgfortran -LF:/ProgramFiles/R/R-3.1.1/bin/i386 -lR
Here is the contents of the file main.f
-----------------------------------------
SUBROUTINE NGCD(NA, NB, NGCDO)
IA = NA
IB = NB
1 IF (IB.NE.0) THEN
ITEMP = IA
IA = IB
IB = MOD(ITEMP, IB)
GOTO 1
END IF
NGCDO = IA
RETURN
END
I don't think you put in any compile options to include symbolic information. You need to do that. I think the option you want is -gdwarf-2, but I rarely use Fortran, and never use SHLIB, so I could be wrong. I'll assume you can figure out how to do that. Run R under gdb using gdb Rgui Load your DLL. Break to gdb using the menu entry "Misc | Break to debugger". Set a breakpoint, e.g. b main.f:3 to set it on line 3. Then use c to let R continue, and make a call to your code. Then the usual gdb commands will work after it breaks. Duncan Murdoch