Author Topic: Using code::blocks debbug tools with Fortran  (Read 12451 times)

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Using code::blocks debbug tools with Fortran
« on: July 25, 2007, 12:14:08 pm »
Hi all,
first thank you very much for the great program!

I use Intel Fortran Compiler (under GNU/Linux) with an home-made lexer in order to use Fortran95 code; at the present I use a custom makefile (and this maybe my problem); I know that the Fortran language is "unsupported" by Code::Blocks and I have already read all the documentations about Fortran/Code::Blocks both in the wiki and in the forum.   
I use Code::Blocks  with very very satisfaction but the debugger doesn't work. I have tried both Intel debugger and GDB selecting them in the compiler option, but they don't work.
I think that the problem is my ignorance of Code::Blocks; my procedure is as follow: I compile my code with my custom makefile (with debugging options activated); in the source code I put some breakpoint; finally I run the code in debugging mode (button Debbug/ Continue); the only output that I get is:

Code: [Select]
Building to ensure sources are up-to-date
Build succeeded
Selecting target: link
Adding source dir: /home/szaghi/Desktop/EoS-v-1.3-OP/
Adding source dir: /home/szaghi/Desktop/EoS-v-1.3-OP/
Adding file: EoS
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 6.6-debian
No symbol table is loaded.  Use the "file" command.

It seems that there are no debugging symbols. Can anyone help me?
Thank you very much.
Stefano

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Using code::blocks debbug tools with Fortran
« Reply #1 on: July 25, 2007, 01:01:15 pm »
Go to debugger settings and enable the "Debugger's debug log". This will open up a new message tab that will contain the entire (raw) conversation with gdb. If you can't see what's wrong, paste that log's contents here.
Be patient!
This bug will be fixed soon...

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #2 on: July 25, 2007, 01:17:30 pm »
Go to debugger settings and enable the "Debugger's debug log". This will open up a new message tab that will contain the entire (raw) conversation with gdb. If you can't see what's wrong, paste that log's contents here.

Hi mandraw thank's for you quick replay!
This is message:

Code: [Select]
LD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args EoS
Working dir : /home/szaghi/Desktop/EoS-v-1.3-OP/
> set prompt >>>>>>cb_gdb:
EoS: No such file or directory.
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.6-debian
Copyright (C) 2006 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 "x86_64-linux-gnu".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> directory /home/szaghi/Desktop/EoS-v-1.3-OP/
>>>>>>cb_gdb:
> break "/home/szaghi/Desktop/EoS-v-1.3-OP/Sorgenti/01-Main.f90:129"
No symbol table is loaded.  Use the "file" command.
>>>>>>cb_gdb:
> start
No symbol table loaded.  Use the "file" command.
>>>>>>cb_gdb:

What do you think about it?

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #3 on: July 25, 2007, 01:24:24 pm »
I find one problem (only the first I think....): the name of the executable is different from the name of project...
Stefano

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Using code::blocks debbug tools with Fortran
« Reply #4 on: July 25, 2007, 01:49:09 pm »
It can't find your executable.
Be patient!
This bug will be fixed soon...

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #5 on: July 25, 2007, 02:12:15 pm »
Yes!!!!!!
Now, changing the name, it seems to work... I have just experimented a Code::Blocks crash, but it is great that debbuger  is working!
Thank you very much!

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Using code::blocks debbug tools with Fortran
« Reply #6 on: July 25, 2007, 03:29:58 pm »
if you use modules, you might find watching module variables a little bit tricky as gfortran (don't know about the others) uses name mangling that is at this point not understood in the debugger plugin.

For example, to watch variable bar in module foo, you have to watch something like foo_MP_bar. If bar is an array, things get even uglier: each array variable has members base and offset that point to the array data and I'm not sure you can see them correctly in codeblocks, but in gdb itself you can issue the command: x /10fg foo_MP_bar.base (assumes bar is type real)

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #7 on: July 25, 2007, 04:17:48 pm »
if you use modules, you might find watching module variables a little bit tricky as gfortran (don't know about the others) uses name mangling that is at this point not understood in the debugger plugin.

For example, to watch variable bar in module foo, you have to watch something like foo_MP_bar. If bar is an array, things get even uglier: each array variable has members base and offset that point to the array data and I'm not sure you can see them correctly in codeblocks, but in gdb itself you can issue the command: x /10fg foo_MP_bar.base (assumes bar is type real)
Ok, this was my next question, you are a seer! thank you for your triks!
Stefano

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #8 on: July 26, 2007, 09:18:43 am »
Hi all,
I have news for the debugger plug-in and Intel Fortran Compiler; as dmoore said fortran compilers rename the variables placed into a module in a strange way and so it is not obvious to watch them. I find that intel fortran compiler rename those variables in this way:

ModuleName_mp_VariableName_

this renaming is like the gfortran renaming but it adds an underscore at the end. To find how a compiler rename those variables just open a compiled .o (object compiled and not linked) with a text editor like vi.

Stefano   

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Using code::blocks debbug tools with Fortran
« Reply #9 on: July 26, 2007, 01:08:28 pm »
thanks for the info. before it gets lost, it needs to go on the wiki.

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #10 on: July 26, 2007, 01:44:27 pm »
thanks for the info. before it gets lost, it needs to go on the wiki.

Hi dmoore, you are welcome.

I understand that you have already used code::blocks to program in fortran90/95; in such a case can you send me your lexer file? I have made one but I have problems with "interface blocks" folding (code::blocks recognizes the "interface blocks" but it interprets in a wrong way the key words "module procedure"); I don't know if the problem is due to "scintilla", but I think that my lexer is very bad...
Stefano

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Using code::blocks debbug tools with Fortran
« Reply #11 on: July 26, 2007, 03:07:07 pm »
if you are using a reasonably recent nightly build (last month maybe -- I can't remember when I submitted the patch), you should already have mine. the lexer spec for fortran90 and above is in share\CodeBlocks\lexers\lexer_fortran.xml and not to be confused with lexer_f77.xml, which is the lexer for fortran77. By default it handles extensions .f90, .f95 and .f2k. You can add more extensions by editing the lexer file directly or changing the settings in editor settings->syntax highlighting (just check that your extensions don't overlap with those in lexer_f77.xml, because the lexer used will then depend on the order those files are loaded). if the highlighting is still strange, you can maybe play around with the keyword groups and see if that helps. Patches are welcome here (especially if you do a good job on colors/styles - i spent about 3 nano seconds thinking about them :) )
« Last Edit: July 26, 2007, 03:09:36 pm by dmoore »

Offline Il Nero

  • Single posting newcomer
  • *
  • Posts: 8
Re: Using code::blocks debbug tools with Fortran
« Reply #12 on: July 27, 2007, 09:40:09 am »
Hi dmoore, thanks for your help!
I find two problems in the folding of this kind blocks:

1)
interface Name_Interface
  module procedure Name_Procedure_1, &
                                Name_Procedure_2, &
                                Name_Procedure_3, &
                                Name_Procedure_4
endinterface

Code::Blocks interprets the the endinterface keyword as the end of the module (procedure) keyword and not as the end of the interface keyword. I think that this is due to the module  keyword that appears after the interface keyword without the endmodule keyword. This is problem is due to scintilla or Code::Blocks?

2)
Code:.Blocks doesn't recognize a do cycle with a label, like the following:

Name_Cycle do i=1,100
enddo Name_Cycle

Anyone knows the solutions of these problems?
Stefano
« Last Edit: July 27, 2007, 11:59:40 am by Il Nero »