This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems while debugging fortran


> If I change the name of my Fortran program to "main", I can set a
> breakpoint by line number inside it. So it seems that GDB is only
> looking for "main". This is fine for C, [...]

Exactly.

> [..] but it won't work for Fortran IMHO, not even using that patch
> Daniel posted. So, I believe we should address this issue in
> symtab.c:find_main_name. I can start looking into it.

That's what I was trying to say.

To give you a bit more context, let me give you a few more datapoints.
This is as much as I will be able to help you, because I do not know
Fortran at all.

First of all, I think the term "main" is a bit overloaded in our discussion.
There is what we usually call the "main program", which is the routine
that gets called to start our program. And then there is the function
whose name is "main". In languages such as C, the "main program" will
always be called "main". But on the other hand, in Ada, the main program
can be called anything.

Let's develop a bit more the Ada case. Consider the following simplistic
program that does pretty much nothing:

        procedure Foo is
        begin
           null;
        end Foo;

We can make this procedure our "main program". To do that, we build
the program using the following command:

        % gnatmake -g foo

(gnatmake is the equivalent of "make" except that it computes the
dependencies automatically)

Now, how does the debugger find out that, in this case, the main
routine name is procedure "Foo"? It knows that the Ada compiler
in GCC generates a symbol whose name is well known, that points
to a string containing the full name of our main routine. Check
out ada-lang.c:ada_main_name(). So if we find our symbol, then
we know the main procedure is in Ada, and what its name is.

I am hoping that the Fortran compiler does something similar,
that it leaves a mark of some kind that will allow you to determine
what the main routine name is.

> In the scenario above, a breakpoint by line number inside a function
> will fail. I think this may has to do with the compiler generating two
> DWARF compilation units (one for "main" and other for the function)
> and GDB is not reading the one related to the function. What are your
> thoughts about this?

I'm hoping that the description above makes it clearer for you what
needs to be done. I am a bit lost in your particular example, simply
because I don't know what the Fortran compiler actually does...

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]