Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using gdb on windows

0 views
Skip to first unread message

Ron Ford

unread,
May 16, 2008, 12:08:45 AM5/16/08
to
One reason that I keep silverfrost's f95 suite around is that if I can get
a program to compile, I can step through it with a debugger that I invoke
on one of the pull-downs. I'd like to emulate this capability with gcc's
gdb.

I googled for "gfortran debugger" and found a lot of information that was
often more relevant to the linux crowd. I *did* find this from a previous
exchange with FX:

> I read all the time about gfortran and gdb questions that seem to get
> solid answers. I believe they are available for linux.

OK then, a brief summary: gfortran is the GNU Fortran compiler, part of
GCC (the GNU Compiler Collection). GCC happens to be the system compiler
on Linux and most other free software operating systems, which means it's
widely used on these OS. gdb is the GNU debugger, also the default
debugger on Linux and other free software OS.

But that doesn't mean it's restricted to Linux. Both GCC (and gfortran)
and gdb are known to work on (free|net|open)bsd, Solaris, MacOS X,
Windows, AIX, Irix, HP-UX, Tru64 and probably others.

!end excerpt

I can't quite seem to get out of the starting blocks on this one, and it's
becoming more relevant as the programs one wants to step through have more
f03 than ever. I tried "gdb [executable name]" and didn't get a bite on
the command line. Is this perhaps addressed in gfortran.pdf?

Thanks in advance,
--
ron Ford

FX

unread,
May 16, 2008, 7:31:09 AM5/16/08
to

I tried "gdb [executable name]" and didn't get a bite on the command
> line. Is this perhaps addressed in gfortran.pdf?

The documentation for gdb is the gdb doc, but I don't include it in the
Windows distribution of gfortran I build. You can find it online,
however: http://sourceware.org/gdb/documentation/

As for your problem, well, as you don't say what happens, it's hard to
debug. I should work, as far as I can tell (see below for an example
debugging session). If it's the command line you don't know, here's a
short primer to get your started:

b myfile.f90:line -- sets a breakpoint at a given line in myfile.f90
r -- runs the program from the start
c -- continue until the next breakpoint
p myvariable -- display the content of a given variable
n -- advance to next source line in that procedure
s (or "step") -- advance to next statement, possibly entering into
a subroutine or function (while with "n", you'll
never follow a function call)
q -- quit the debugger

There also are programs that provide a visual interface to gdb, but I've
never used them much (apart from DDD, but I don't thing it's easy to
install on Windows).

$ cat a.f90
program abstest
complex c

c = ( 1.7951958020513104220, 2.6457513110645905904 )
write(*,*) abs(c)
end program abstest

$ ./gfortran/bin/gfortran.exe -g a.f90

$ gdb a.exe
GNU gdb 6.6
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 "i686-pc-mingw32"...
(gdb) b a.f90:5
Breakpoint 1 at 0x40136d: file a.f90, line 5.
(gdb) r
Starting program: C:\msys\1.0.10\home\FX\irun/a.exe
Loaded symbols for C:\WINDOWS\system32\ntdll.dll
Loaded symbols for C:\WINDOWS\system32\kernel32.dll
Loaded symbols for C:\WINDOWS\system32\msvcrt.dll

Breakpoint 1, abstest () at a.f90:5
5 write(*,*) abs(c)
Current language: auto; currently fortran
(gdb) p c
$1 = (1.79519582,2.64575124)
(gdb) c
Continuing.
3.1973000

Program exited normally.
(gdb) quit

--
FX

Ron Ford

unread,
May 17, 2008, 3:04:52 AM5/17/08
to

Thanks, FX, that will get me started. In that old thread that I dug up,
there was apparently some talk of whether gdb could access specific values
in an array. I'll see what happens when I step through James' sort_row
program.

I don't have a "problem" other than that I've only used debuggers from
IDE's. Since gdb seems to be joined to the hip with gfortran, it might
merit an addition to gfortran.pdf.
--
Ron Ford

Arjan

unread,
May 17, 2008, 1:50:19 PM5/17/08
to
> I don't have a "problem" other than that I've only used debuggers from
> IDE's. Since gdb seems to be joined to the hip with gfortran, it might
> merit an addition to gfortran.pdf.

Already for some time now I am trying to get a working installation of
Photran and my compiler (I use g95, but that's irrelevant) plus other
utilities (automatic generation of makefiles with sources in order of
dependence). This is an IDE for your fortran-compiler (e.g. gfortran)
together with your debugger (e.g. gdb), with capabilities beyond
belief! Only problem is that it is all a bit complex to install. But
there are many factsheets with info on this, so if you want to give it
a try... And if you succeed, let me know!

Arjan

Ron Ford

unread,
May 18, 2008, 3:21:07 AM5/18/08
to
On Fri, 16 May 2008 11:31:09 +0000 (UTC), FX wrote:


> The documentation for gdb is the gdb doc, but I don't include it in the
> Windows distribution of gfortran I build. You can find it online,
> however: http://sourceware.org/gdb/documentation/

I've been looking through the information at this link today. Is this
possibly true:


12.4.3 Fortran

GDB can be used to debug programs written in Fortran, but it currently
supports only the features of Fortran 77 language.

?
--
ron Ford

Ron Ford

unread,
May 19, 2008, 1:12:09 AM5/19/08
to

I think it's revealing about my character that I just get more excited when
something is described as "probably a fool's errand." :-) What about this
IDE? Can it work with gdb on win32 xp?

I'm not sure what others expect from a debugger. From the tips that
display when I fire up silverforst's sdgb.exe, I see that I only use a
small part of its functionality. For buttons, one displays variables,
three deal with the stack, and two deal with "stepping:" in or over.

What I typically do is step over everything in the road until I see the
value of the variable I'm keyed on. Another thing I do is step through new
progs so as to see how it runs. I can't always *see* what a program does
without ... seeing.
--
Ron Ford
"Moxie, a twelve-pound canine, visited unexpectedly yesterday. Since I was
dog-sitting, I used the time to fix the face of a slat-wooden gate whence
she might elope. I then repaired the jamb with a dutchman."

0 new messages