From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9033 invoked by alias); 25 Sep 2007 17:34:29 -0000 Received: (qmail 9023 invoked by uid 22791); 25 Sep 2007 17:34:27 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Sep 2007 17:34:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8B7B12AB0F7; Tue, 25 Sep 2007 13:34:21 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 9FJ7uPFd2QML; Tue, 25 Sep 2007 13:34:21 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3163F2AB0EE; Tue, 25 Sep 2007 13:34:21 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id EEC08E7B58; Tue, 25 Sep 2007 10:34:18 -0700 (PDT) Date: Wed, 26 Sep 2007 06:29:00 -0000 From: Joel Brobecker To: Carlos Eduardo Seo Cc: gdb@sourceware.org Subject: Re: Problems while debugging fortran Message-ID: <20070925173418.GA23641@adacore.com> References: <46EB035B.4090802@linux.vnet.ibm.com> <20070920173246.GJ16400@adacore.com> <46F2CE45.5020308@linux.vnet.ibm.com> <20070920204622.GB4368@adacore.com> <46F5D13D.2070303@linux.vnet.ibm.com> <20070923025033.GA20073@adacore.com> <46F81E0C.7030709@linux.vnet.ibm.com> <20070924234910.GB8601@adacore.com> <46F9439A.3010806@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46F9439A.3010806@linux.vnet.ibm.com> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00211.txt.bz2 > 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