From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2146 invoked by alias); 20 Sep 2007 20:56:45 -0000 Received: (qmail 2133 invoked by uid 22791); 20 Sep 2007 20:56:44 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Sep 2007 20:56:32 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id F1ECE982AD; Thu, 20 Sep 2007 20:56:30 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id B6FF998298; Thu, 20 Sep 2007 20:56:30 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1IYT4X-0004dj-Op; Thu, 20 Sep 2007 16:56:29 -0400 Date: Fri, 21 Sep 2007 06:52:00 -0000 From: Daniel Jacobowitz To: Joel Brobecker Cc: Carlos Eduardo Seo , gdb@sourceware.org Subject: Re: Problems while debugging fortran Message-ID: <20070920205629.GA17779@caradoc.them.org> Mail-Followup-To: Joel Brobecker , Carlos Eduardo Seo , gdb@sourceware.org References: <46EB035B.4090802@linux.vnet.ibm.com> <20070920173246.GJ16400@adacore.com> <46F2CE45.5020308@linux.vnet.ibm.com> <20070920204622.GB4368@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070920204622.GB4368@adacore.com> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes 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/msg00165.txt.bz2 On Thu, Sep 20, 2007 at 01:46:22PM -0700, Joel Brobecker wrote: > > No, just "break ". However, I tried your command and it > > worked. Why? Shouldn't the behavior be the same in both cases? > > It should be the same if the "current file" is set to test.f. > It looks like it isn't. For some reason, GDB thinks that the current > file is something else. Again, perhaps a copy of your GDB session > might give a clue. Here's a relevant patch from the Debian packages of GDB. As you can see it comes from a mailing list message - I don't remember exactly who submitted it without looking it up and I don't remember exactly why it was never committed, but it was probably Wu Zhou and it was probably never merged because of the larger issue of symbol case sensitivity. -- Daniel Jacobowitz CodeSourcery Daniel, Although the proper way of adding case insensitivity to symbol lookup is still under discussion, I think it might be desirable to set the main function of Fortran programs to "MAIN__" first. Because it can at least let GDB recognize that the language is Fortran after loading a Fortran executable only. What is your idea on this? Please comments. TIA! Here is the patch to set the main function in Fortran programs to "MAIN__". And followed is a patch to verify this. Tested with g77 and gfortran on x86, and g77 on ppc64. With the first patch, it reported PASS; without, report FAIL. No regression is found in gdb.fortran testcases. P.S: if there is a symbol named "MAIN__" in sources of other languages, it might disturb the debugging. But I am not sure how much it is. --- gdb/symtab.c | 8 +++++-- gdb/testsuite/gdb.fortran/lang.exp | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) Index: gdb/symtab.c =================================================================== --- gdb/symtab.c.orig 2007-01-27 20:35:18.000000000 -0500 +++ gdb/symtab.c 2007-01-27 20:35:34.000000000 -0500 @@ -4189,8 +4189,12 @@ find_main_name (void) } /* The languages above didn't identify the name of the main procedure. - Fallback to "main". */ - set_main_name ("main"); + Fallback to "MAIN__" (g77 and gfortran) if we can find it in the + minimal symtab, to "main" otherwise. */ + if (lookup_minimal_symbol ("MAIN__", NULL, NULL)) + set_main_name ("MAIN__"); + else + set_main_name ("main"); } char * Index: gdb/testsuite/gdb.fortran/lang.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb/testsuite/gdb.fortran/lang.exp 2007-01-27 20:35:34.000000000 -0500 @@ -0,0 +1,40 @@ +# Copyright 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was written by Wu Zhou. (woodzltc@cn.ibm.com) + +# This file is part of the gdb testsuite. It is intended to test that gdb +# could recognize the Fortran language after loading the binary + +if $tracelevel then { + strace $tracelevel +} + +set testfile "array-element" +set srcfile ${srcdir}/${subdir}/${testfile}.f +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcfile}" "${binfile}" executable {debug f77}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "show language" ".*currently fortran.*" "show language(fortran)"