Results 1 to 8 of 8

Thread: gfortran and gdb problem

  1. #1

    gfortran and gdb problem

    Hi all,
    I have a problem in using GDB on code generated by gfortran under Ubuntu Gutsy.
    I compile a simple "hello world" program with -g and then run gdb on the resulting executable.
    Now, if, in the gdb prompt I type "l" I get the correct listing for the program code:

    Code:
    1       program hello
    2
    3               write(*,*) 'hello world'
    4       end program
    At this point, this is what happens:

    Code:
    (gdb) break main
    Breakpoint 1 at 0x804869e
    (gdb) r
    Starting program: /home/abuttari/Numerical/Junk/a.out 
    
    Breakpoint 1, 0x0804869e in main ()
    (gdb) n
    Single stepping until exit from function main, 
    which has no line number information.
     hello world
    0xb7d06050 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
    The same procedure on an executable generated by gcc from C code works perfect.
    I have this same problem on another system running ubuntu gusty. I tried gfortran-4.1 and 4.2, I also recompiled GDB 6.7 myself (gutsy has 6.6).

    Has anybody here had the same problem? and maybe also knows how to solve it?
    If not I'm prepared to submit a bug in launchpad.

    Thanks

    alfredo
    -----------------------------------------
    Alfredo Buttari, PhD
    CNRS-IRIT
    http://buttari.perso.enseeiht.fr

  2. #2
    Join Date
    Oct 2004
    Location
    Florida
    Beans
    206
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: gfortran and gdb problem

    I just tested this on my laptop running Gutsy.

    Could not reproduce the error. Are you running on x86_64 or x86?

    Output as follows:

    program
    Code:
            program hello
            
                write(*,*) 'hello world'
            end program
    console output
    Code:
    zbrown[~]$ gfortran -g test.f
    zbrown[~]$ gdb a.out 
    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 "i486-linux-gnu"...
    Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
    (gdb) r
    Starting program: /home/zbrown/a.out 
     hello world
    
    Program exited normally.
    (gdb)
    Hope that helps
    Student / Developer | Registered Linux User: 356244 | Registered FSF Member: 5697
    Website: http://zacbrown.org | Advogato me!
    "My cat" is not a float. Every string should learn to swim.

  3. #3

    Re: gfortran and gdb problem

    Quote Originally Posted by rufius View Post
    I just tested this on my laptop running Gutsy.

    Could not reproduce the error. Are you running on x86_64 or x86?

    Output as follows:

    program
    Code:
            program hello
            
                write(*,*) 'hello world'
            end program
    console output
    Code:
    zbrown[~]$ gfortran -g test.f
    zbrown[~]$ gdb a.out 
    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 "i486-linux-gnu"...
    Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
    (gdb) r
    Starting program: /home/zbrown/a.out 
     hello world
    
    Program exited normally.
    (gdb)
    Hope that helps
    Rufius,
    thanks for the quick reply. I am running on x86. However what you did is not the same sequence of steps I did. Try set a breakpoint in main, then run, and then next please. Here it is the sequence of gdb commands
    Code:
    (gdb) break main
    (gdb) r
    (gdb) n
    What you did (i.e., simply running) works fine for me as well.
    Thanks for the help

    PS
    if you are running on x86 you can maybe send me you executable...

    alfredo
    -----------------------------------------
    Alfredo Buttari, PhD
    CNRS-IRIT
    http://buttari.perso.enseeiht.fr

  4. #4
    Join Date
    Oct 2004
    Location
    Florida
    Beans
    206
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: gfortran and gdb problem

    Hmmm it appears that is a bug. Though I'm not sure if its Ubuntu specific or gfortran's issue. You might check around gfortran's and gdb's bug trackers for things like that.

    Interesting. My mistake
    Student / Developer | Registered Linux User: 356244 | Registered FSF Member: 5697
    Website: http://zacbrown.org | Advogato me!
    "My cat" is not a float. Every string should learn to swim.

  5. #5

    Re: gfortran and gdb problem

    Quote Originally Posted by rufius View Post
    Hmmm it appears that is a bug. Though I'm not sure if its Ubuntu specific or gfortran's issue. You might check around gfortran's and gdb's bug trackers for things like that.

    Interesting. My mistake
    Rufius,
    I found the same thing on many other systems (including fedora and debian with many combinations of gfortran and gdb versions).
    if the breakpoint is set like this

    Code:
    (gdb) break hello.f90:2
    then everything works.
    Thanks

    Alfredo
    -----------------------------------------
    Alfredo Buttari, PhD
    CNRS-IRIT
    http://buttari.perso.enseeiht.fr

  6. #6
    Join Date
    Oct 2004
    Location
    Florida
    Beans
    206
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: gfortran and gdb problem

    Actually that makes sense... seeing as there was never a declaration of anything named "main" in those fortran programs unlike the C programs.

    Its not a bug, its a mistake on yours & my part.

    That makes more sense .
    Student / Developer | Registered Linux User: 356244 | Registered FSF Member: 5697
    Website: http://zacbrown.org | Advogato me!
    "My cat" is not a float. Every string should learn to swim.

  7. #7
    Join Date
    Mar 2007
    Beans
    19

    compiling gfortran

    Fortran Program

    hello_world.f

    program hello_world
    write(*,*) 'Hello World!'
    end program

    Terminal command:

    gfortran hello_world.f

    gfortran hello_world.f -o hello_world_out.txt

    The output file doesnt show the any readable text.

    Need suggestions.

  8. #8
    Join Date
    Mar 2007
    Beans
    19

    Re: gfortran and gdb problem

    Problem Solved

    gfortran hello_world.f -o hello
    ./hello

    Cool!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •