From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17019 invoked by alias); 10 Mar 2004 10:57:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16966 invoked from network); 10 Mar 2004 10:57:19 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 10 Mar 2004 10:57:19 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i2AAvI07013242 for ; Wed, 10 Mar 2004 05:57:18 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i2AAvHM29785 for ; Wed, 10 Mar 2004 05:57:18 -0500 Received: from cygbert.vinschen.de (vpn50-12.rdu.redhat.com [172.16.50.12]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i2AAvGR03580 for ; Wed, 10 Mar 2004 02:57:16 -0800 Received: by cygbert.vinschen.de (Postfix, from userid 500) id CBBB5580E2; Wed, 10 Mar 2004 11:57:09 +0100 (CET) Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] minsyms.c: Fix switching to GNU v3 ABI Message-ID: <20040310105709.GJ25204@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-RedHat-Spam-Score: -4.9 X-SW-Source: 2004-03/txt/msg00227.txt.bz2 Hi, I was debugging a situation, in which an C++ object file has been build using v3 ABI, but GDB did not recognize it and was assuming v2 ABI. The target system is sh-elf, the compiler gcc 3.4. What I found is this: - The C++ ABI is set to v2 by default (gnu-v2-abi.c, _initialize_gnu_v2_abi). - While reading symbols from the object file, at one point elf_symfile_read() (elfread.c) is called. - elf_symfile_read() calls elf_symtab_read() which calls record_minimal_symbol() which calls prim_record_minimal_symbol_and_info(). - In prim_record_minimal_symbol_and_info(), the symbol language is set to language_auto unconditionally. - After returning from elf_symtab_read(), install_minimal_symbols() is called. At the end of install_minimal_symbols() a loop over all msymbols tries to figure out if v3 ABI is used. This is done by requesting the demangeled name calling SYMBOL_DEMANGLED_NAME. The problem is that SYMBOL_LANGUAGE is still set to language_auto and the demangled name hasn't been generated at this point. symbol_demangled_name() only returns the demangled name if the language is set to a specific mangeling language and only if the demangeled name has already been created. This isn't the case at this point. Ergo, the v3 ABI isn't recognized and GDB wrongly assumes v2 ABI. What's especially weird is the comment above install_minimal_symbols(). It implies that the function will try to demangle all symbols to set the language correctly, but the function is not doing that. It would only recognize symbols which has already been demangeled but that just don't happen. I not sure if the below solution is entirely correct, but it solves the problem in my case. The solution is the create the demangled name in the aforementioned loop in install_minimal_symbols(). This change drops the FAIL count in the gdb.cp testsuite part from 54 to 6! Corinna * minsyms.c (install_minimal_symbols): Create demangled names for all msymbol entries. Index: minsyms.c =================================================================== RCS file: /cvs/src/src/gdb/minsyms.c,v retrieving revision 1.41 diff -u -p -r1.41 minsyms.c --- minsyms.c 9 Feb 2004 19:13:46 -0000 1.41 +++ minsyms.c 10 Mar 2004 10:55:25 -0000 @@ -924,6 +924,8 @@ install_minimal_symbols (struct objfile mixing ABIs then the user will need to "set cp-abi" manually. */ const char *name = SYMBOL_LINKAGE_NAME (&objfile->msymbols[i]); + SYMBOL_SET_NAMES (&objfile->msymbols[i], name, strlen (name), + objfile); if (name[0] == '_' && name[1] == 'Z' && SYMBOL_DEMANGLED_NAME (&objfile->msymbols[i]) != NULL) { -- Corinna Vinschen Cygwin Developer Red Hat, Inc. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17019 invoked by alias); 10 Mar 2004 10:57:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16966 invoked from network); 10 Mar 2004 10:57:19 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 10 Mar 2004 10:57:19 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i2AAvI07013242 for ; Wed, 10 Mar 2004 05:57:18 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i2AAvHM29785 for ; Wed, 10 Mar 2004 05:57:18 -0500 Received: from cygbert.vinschen.de (vpn50-12.rdu.redhat.com [172.16.50.12]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i2AAvGR03580 for ; Wed, 10 Mar 2004 02:57:16 -0800 Received: by cygbert.vinschen.de (Postfix, from userid 500) id CBBB5580E2; Wed, 10 Mar 2004 11:57:09 +0100 (CET) Date: Wed, 10 Mar 2004 10:57:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] minsyms.c: Fix switching to GNU v3 ABI Message-ID: <20040310105709.GJ25204@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-RedHat-Spam-Score: -4.9 X-SW-Source: 2004-03.o/txt/msg00227.txt Message-ID: <20040310105700.ZJ-n-dMYLaVTLOzvUHtgpK07BF6SdSJCjhPnRPDIeA0@z> Hi, I was debugging a situation, in which an C++ object file has been build using v3 ABI, but GDB did not recognize it and was assuming v2 ABI. The target system is sh-elf, the compiler gcc 3.4. What I found is this: - The C++ ABI is set to v2 by default (gnu-v2-abi.c, _initialize_gnu_v2_abi). - While reading symbols from the object file, at one point elf_symfile_read() (elfread.c) is called. - elf_symfile_read() calls elf_symtab_read() which calls record_minimal_symbol() which calls prim_record_minimal_symbol_and_info(). - In prim_record_minimal_symbol_and_info(), the symbol language is set to language_auto unconditionally. - After returning from elf_symtab_read(), install_minimal_symbols() is called. At the end of install_minimal_symbols() a loop over all msymbols tries to figure out if v3 ABI is used. This is done by requesting the demangeled name calling SYMBOL_DEMANGLED_NAME. The problem is that SYMBOL_LANGUAGE is still set to language_auto and the demangled name hasn't been generated at this point. symbol_demangled_name() only returns the demangled name if the language is set to a specific mangeling language and only if the demangeled name has already been created. This isn't the case at this point. Ergo, the v3 ABI isn't recognized and GDB wrongly assumes v2 ABI. What's especially weird is the comment above install_minimal_symbols(). It implies that the function will try to demangle all symbols to set the language correctly, but the function is not doing that. It would only recognize symbols which has already been demangeled but that just don't happen. I not sure if the below solution is entirely correct, but it solves the problem in my case. The solution is the create the demangled name in the aforementioned loop in install_minimal_symbols(). This change drops the FAIL count in the gdb.cp testsuite part from 54 to 6! Corinna * minsyms.c (install_minimal_symbols): Create demangled names for all msymbol entries. Index: minsyms.c =================================================================== RCS file: /cvs/src/src/gdb/minsyms.c,v retrieving revision 1.41 diff -u -p -r1.41 minsyms.c --- minsyms.c 9 Feb 2004 19:13:46 -0000 1.41 +++ minsyms.c 10 Mar 2004 10:55:25 -0000 @@ -924,6 +924,8 @@ install_minimal_symbols (struct objfile mixing ABIs then the user will need to "set cp-abi" manually. */ const char *name = SYMBOL_LINKAGE_NAME (&objfile->msymbols[i]); + SYMBOL_SET_NAMES (&objfile->msymbols[i], name, strlen (name), + objfile); if (name[0] == '_' && name[1] == 'Z' && SYMBOL_DEMANGLED_NAME (&objfile->msymbols[i]) != NULL) { -- Corinna Vinschen Cygwin Developer Red Hat, Inc.