User forums > Help
Debugging fortran
JoachimB:
For some obscured reason, I'm working on a project where I'm trying to get an old fortran program to come to live again. Now I'm using codeblocks and the GCC (G77). The program actually runs and I can debug it in codeblocks. There is one problem though; The debugger (gdb) knows where in the code in it is and breakpoints works. It also knows the path to the source file but, -and here it comes, the IDE does not point out which line it is on. (Actually, I'm using the IDE to set the breakpoint so that direction is working)
My output looks like below;
Selecting target: Debug
Compiling: done
Adding source dir: C:\Projects\Tiny\fello\
Adding source dir: C:\Projects\Tiny\fello\
Adding file: bin\Debug\fello.exe
Starting debugger: done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 5.2.1
At C:/Projects/Tiny/fello/tiny.f:4 :lol:
The small program I used here looks like this
PROGRAM TINY
CHARACTER ODOR*2
WRITE(UNIT=*,FMT=*)'Hello world'
WRITE(UNIT=*,FMT=*)'Hello hello' :P
READ (UNIT=*,FMT=995) ODOR
WRITE(UNIT=*,FMT=*)'Good bye'
995 FORMAT(A2)
END
The compiler output looks like
-------------- Build: Debug in fello ---------------
mingw32-g++.exe -Wall -g -I- -I. -IC:\MingW\include -c tiny.f -o obj\Debug\tiny.o
mingw32-g++.exe -LC:\MinGW\lib -o bin\Debug\fello.exe obj\Debug\tiny.o ..\..\..\SW_Dev\f2c\libf2c\Libf2c.a
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings
The source file is in the same directory as the cbp file and it is a straight wizard generated console application where I only have added the libf2, removed the main.cpp file and finally added the tiny.f file which is recognized as an other file by the Ide. I have manually marked the tiny.f for compiling and linking.
-Any suggestions on how to get the IDE to point out where the program stopped due to the breakpoint? If someone points me in the right direction I might be able to find a solution in the code (Probably I'm saying to much now)
Joachim
Impressive piece of work, Code::Blocks!
mandrav:
You should enable the debugger's debug log (in debugger options) and paste its output here.
MortenMacFly:
Hmmm... It works for me (see the screenshot).
I wonder why you compile your program with G++ instead of G77... Did you find:
http://wiki.codeblocks.org/index.php?title=Installing_Fortran_Compiler
With regards, Morten.
[attachment deleted by admin]
JoachimB:
I did set "Display debugger´s log and got;
-------------------------------------------
Command-line: c:\dev-cpp\bin\gdb.exe -nx -fullname -args bin/Debug/fello.exe
Working dir : C:\Projects\Tiny\fello\
> set prompt (gdb)
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) (gdb)
> set confirm off
(gdb)
> set width 0
(gdb)
> set height 0
(gdb)
> set breakpoint pending on
No symbol "breakpoint" in current context.
(gdb)
> set print asm-demangle on
(gdb)
> set new-console on
(gdb)
> set disassembly-flavor intel
(gdb)
> directory C:/Projects/Tiny/fello/
(gdb)
> delete breakpoints
(gdb)
> break tiny.f:4
Breakpoint 1 at 0x40131b: file tiny.f, line 4.
(gdb)
> run
Breakpoint 1, MAIN__ () at tiny.f:4
C:/Projects/Tiny/fello/tiny.f:4:84:beg:0x40131b
Current language: auto; currently fortran
(gdb)
--------------------------------------------
and
-----------------------------------------------------------------------------
[21:35:58.919]: Initialize EditColorSet .....
[21:35:58.939]: Loading lexer_angelscript.xml
[21:35:59.009]: Loading lexer_batch.xml
[21:35:59.029]: Loading lexer_cg.xml
[21:35:59.560]: Loading lexer_cpp.xml
[21:35:59.630]: Loading lexer_css.xml
[21:35:59.720]: Loading lexer_d.xml
[21:35:59.830]: Loading lexer_diff.xml
[21:35:59.860]: Loading lexer_f77.xml
[21:35:59.910]: Loading lexer_glsl.xml
[21:36:00.060]: Loading lexer_gm.xml
[21:36:00.090]: Loading lexer_hitasm.xml
[21:36:00.131]: Loading lexer_lua.xml
[21:36:00.161]: Loading lexer_masm.xml
[21:36:00.441]: Loading lexer_matlab.xml
[21:36:01.963]: Loading lexer_nsis.xml
[21:36:02.464]: Loading lexer_OgreCompositor.xml
[21:36:02.494]: Loading lexer_OgreMaterial.xml
[21:36:02.514]: Loading lexer_prg.xml
[21:36:02.604]: Loading lexer_python.xml
[21:36:02.995]: Loading lexer_rc.xml
[21:36:03.045]: Loading lexer_xml.xml
[21:36:03.095]: Initialize EditColorSet: done.
[21:36:03.465]: Loading toolbar...
[21:36:03.746]: AStylePlugin: loaded
[21:36:03.786]: Autosave: loaded
[21:36:04.126]: CBProfiler: loaded
[21:36:04.687]: ClassWizard: loaded
[21:36:04.777]: Concurrent threads for pool set to 1
[21:36:04.927]: CodeCompletion: loaded
[21:36:05.088]: CodeStatistics: loaded
[21:36:05.568]: Added compiler "GNU GCC Compiler"
[21:36:05.568]: Added compiler "Microsoft Visual C++ Toolkit 2003"
[21:36:05.568]: Added compiler "Borland C++ Compiler 5.5"
[21:36:05.568]: Added compiler "Digital Mars Compiler"
[21:36:05.568]: Added compiler "OpenWatcom (W32) Compiler"
[21:36:05.568]: Added compiler "Intel C/C++ Compiler"
[21:36:05.568]: Added compiler "SDCC Compiler"
[21:36:05.568]: Added compiler "GNU GDC Compiler"
[21:36:05.568]: Added compiler "Digital Mars D Compiler"
[21:36:05.568]: Added compiler "GNU ARM GCC Compiler"
[21:36:05.578]: Added compiler "f2c"
[21:36:05.578]: Compiler: loaded
[21:36:05.598]: copystrings: loaded
[21:36:06.279]: Debugger: loaded
[21:36:06.700]: FilesExtensionHandler: loaded
[21:36:07.191]: DevPakUpdater: loaded
[21:36:07.211]: DragScroll: loaded
[21:36:07.321]: Source Exporter: loaded
[21:36:07.481]: HelpPlugin: loaded
[21:36:07.671]: cbKeyBinder: loaded
[21:36:08.152]: PluginWizard: loaded
[21:36:08.212]: Wizard: loaded
[21:36:08.693]: ToDoList: loaded
[21:36:08.763]: wxSmith: loaded
[21:36:08.763]: wxSmithMime: loaded
[21:36:08.833]: wxSmithWizard: loaded
[21:36:08.853]: WindowsXPLookNFeel: loaded
[21:36:08.863]: Source code formatter (AStyle) plugin loaded
[21:36:09.654]: Autosave plugin loaded
[21:36:09.654]: Code profiler plugin loaded
[21:36:09.654]: Class wizard plugin loaded
[21:36:11.046]: Code completion plugin loaded
[21:36:11.046]: Code Statistics plugin loaded
[21:36:11.287]: Compiler plugin loaded
[21:36:11.287]: Copy Strings to clipboard plugin loaded
[21:36:11.777]: Debugger plugin loaded
[21:36:11.777]: Files extension handler plugin loaded
[21:36:11.787]: Dev-C++ DevPak updater/installer plugin loaded
[21:36:11.787]: DragScroll plugin loaded
[21:36:11.787]: Source Exporter plugin loaded
[21:36:11.787]: Help plugin plugin loaded
[21:36:11.787]: Keyboard shortcuts plugin loaded
[21:36:11.787]: Plugin wizard plugin loaded
[21:36:12.348]: Project wizard added for 'Console application wizard'
[21:36:12.348]: Generic wizard plugin loaded
[21:36:12.769]: Project wizard added for 'Irrlicht project wizard'
[21:36:12.939]: Project wizard added for 'Ogre project wizard'
[21:36:13.049]: Project wizard added for 'wxWidgets application wizard'
[21:36:13.169]: Project wizard added for 'D application wizard'
[21:36:13.179]: To-Do List plugin loaded
[21:36:14.571]: wxSmith plugin loaded
[21:36:14.571]: wxSmith - MIME plugin plugin loaded
[21:36:14.571]: wxSmith - Project Wizard plugin plugin loaded
[21:36:14.571]: Windows XP Look'n'Feel plugin loaded
[21:36:14.942]: Initializing plugins...
[21:36:14.972]: Running startup script
[21:37:13.266]: Loading project file...
[21:37:13.296]: Parsing project file...
[21:37:13.296]: Loading target Debug
[21:37:13.296]: Loading target Release
[21:37:13.296]: Loading project files...
[21:37:13.296]: 2 files loaded
[21:37:13.296]: Done loading project in 30ms
[21:37:13.296]: Project's base path: C:\Projects\Tiny\fello\
[21:37:13.306]: Project's common toplevel path: C:\Projects\Tiny\fello\
[21:37:13.326]: project data set for C:\Projects\Tiny\fello\tiny.f
[21:37:13.326]: Top Editor: C:\Projects\Tiny\fello\tiny.f
[21:37:13.336]: Add project fello in parsing queue
[21:37:40.976]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:37:40.976]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:37:40.976]: Scanned 0 files for #includes, cache used 1, cache updated 0
[21:37:40.976]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:37:40.976]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:37:40.986]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:37:40.986]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:29.798]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:29.808]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:29.808]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:29.808]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:32.532]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:32.532]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:32.542]: Scanned 0 files for #includes, cache used 0, cache updated 0
[21:40:32.542]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 1, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:10:22.837]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:11.187]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:11.197]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:11.197]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:11.208]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.136]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.457]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.457]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.457]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:24.457]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 1, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:16:31.146]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 1, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
[22:18:21.495]: Scanned 0 files for #includes, cache used 0, cache updated 0
-----------------------------------------------------------------------------
I also right now tried using the g77 compiler according to the advice in the other reply. (Thanks) It did not help though. Still the same. Missing that little arrow
MortenMacFly:
mandrav: I think he is right. Why it works for me is because I'm usually mixing Fortran and C/C++ programs together using the G2C library. Thus the source is converted into C and than translated. So debugging works for me on a "C" level. If I compile a "pure" (native) Fortran application is doesn't work for me, too... I never tried that before... :oops:
With regards, Morten.
Edit: I guess the important part of JoachimB's output is:
--- Code: ---> break tiny.f:4
Breakpoint 1 at 0x40131b: file tiny.f, line 4.
(gdb)
> run
Breakpoint 1, MAIN__ () at tiny.f:4
C:/Projects/Tiny/fello/tiny.f:4:84:beg:0x40131b
Current language: auto; currently fortran
(gdb)
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version