From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23281 invoked by alias); 30 Jul 2003 01:07:17 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 23274 invoked from network); 30 Jul 2003 01:07:17 -0000 Received: from unknown (HELO mail-out1.apple.com) (17.254.0.52) by sources.redhat.com with SMTP; 30 Jul 2003 01:07:17 -0000 Received: from mailgate2.apple.com (A17-129-100-225.apple.com [17.129.100.225]) by mail-out1.apple.com (8.12.9/8.12.9) with ESMTP id h6U173iB017443 for ; Tue, 29 Jul 2003 18:07:03 -0700 (PDT) Received: from scv2.apple.com (scv2.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Tue, 29 Jul 2003 18:07:16 -0700 Received: from apple.com (keatge.apple.com [17.201.20.159]) by scv2.apple.com (8.12.9/8.12.9) with ESMTP id h6U17BQZ028078; Tue, 29 Jul 2003 18:07:11 -0700 (PDT) Date: Wed, 30 Jul 2003 01:07:00 -0000 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: multipart/mixed; boundary=Apple-Mail-2--384343024 Subject: Fwd: Two possible function stabs patches From: Geoffrey Keating To: Michael Elizabeth Chastain , gcc-patches@gcc.gnu.org, gdb@sources.redhat.com, Daniel Jacobowitz Message-Id: <288F3C82-C22A-11D7-B17B-0030657EA24A@apple.com> X-SW-Source: 2003-07/txt/msg00333.txt.bz2 --Apple-Mail-2--384343024 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 858 Oops! Forgot to attach the actual patches. Fixed below. OK, so I have not one, but two patches! The first one is less interesting. It uses the language's name for the function, unless it's a C++ function, in which case it uses the (mangled) assembler name. It'll give a stab like .stabs "__ZN3bar3fooEv:F(0,1)",36,0,2,__ZN3bar3fooEv or .stabs "foo:F(0,1)",36,0,2,foo.11 The second one uses the 'printable name' for the function. That is, for C it's just the name, and for C++ it's the demangled version of its name. I am not at all sure it'll work, because it gives stabs like: .stabs "int bar::foo():F(0,1)",36,0,2,__ZN3bar3fooEv which I suspect can't be parsed. Could someone help me test these? It needs a machine that can use stabs and on which the GDB testsuite doesn't give too many false positives. --Apple-Mail-2--384343024 Content-Disposition: attachment; filename=gcc-funstab-mangled.patch Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="gcc-funstab-mangled.patch" Content-length: 2149 Index: dbxout.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v retrieving revision 1.156 diff -u -p -u -p -r1.156 dbxout.c --- dbxout.c 19 Jul 2003 14:47:02 -0000 1.156 +++ dbxout.c 30 Jul 2003 00:53:32 -0000 @@ -2184,27 +2184,36 @@ dbxout_symbol (tree decl, int local ATTR || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) break; FORCE_TEXT; + + { + const char *gdb_name; - fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP, - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), - TREE_PUBLIC (decl) ? 'F' : 'f'); - result = 1; + /* GDB knows how to demangle C++ mangled names, so treat those + as the "real" name of the function. Otherwise the "real" name + is the name that the language has for the function. */ + gdb_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + if (gdb_name[0] != '_' || gdb_name[1] != 'Z') + gdb_name = IDENTIFIER_POINTER (DECL_NAME (decl)); - current_sym_code = N_FUN; - current_sym_addr = XEXP (DECL_RTL (decl), 0); - - if (TREE_TYPE (type)) - dbxout_type (TREE_TYPE (type), 0); - else - dbxout_type (void_type_node, 0); - - /* For a nested function, when that function is compiled, - mention the containing function name - as well as (since dbx wants it) our own assembler-name. */ - if (context != 0) - fprintf (asmfile, ",%s,%s", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), - IDENTIFIER_POINTER (DECL_NAME (context))); + fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP, gdb_name, + TREE_PUBLIC (decl) ? 'F' : 'f'); + result = 1; + + current_sym_code = N_FUN; + current_sym_addr = XEXP (DECL_RTL (decl), 0); + + if (TREE_TYPE (type)) + dbxout_type (TREE_TYPE (type), 0); + else + dbxout_type (void_type_node, 0); + + /* For a nested function, when that function is compiled, + mention the containing function name + as well as (since dbx wants it) our own name. */ + if (context != 0) + fprintf (asmfile, ",%s,%s", gdb_name, + IDENTIFIER_POINTER (DECL_NAME (context))); + } dbxout_finish_symbol (decl); break; --Apple-Mail-2--384343024 Content-Disposition: attachment; filename=gcc-funstab-printable.patch Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="gcc-funstab-printable.patch" Content-length: 1923 Index: dbxout.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v retrieving revision 1.156 diff -u -p -u -p -r1.156 dbxout.c --- dbxout.c 19 Jul 2003 14:47:02 -0000 1.156 +++ dbxout.c 30 Jul 2003 00:58:19 -0000 @@ -2184,27 +2184,32 @@ dbxout_symbol (tree decl, int local ATTR || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) break; FORCE_TEXT; + + { + const char *gdb_name; - fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP, - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), - TREE_PUBLIC (decl) ? 'F' : 'f'); - result = 1; + /* Use the demangled version of the name. */ + gdb_name = lang_hooks.decl_printable_name (decl, 2); - current_sym_code = N_FUN; - current_sym_addr = XEXP (DECL_RTL (decl), 0); - - if (TREE_TYPE (type)) - dbxout_type (TREE_TYPE (type), 0); - else - dbxout_type (void_type_node, 0); - - /* For a nested function, when that function is compiled, - mention the containing function name - as well as (since dbx wants it) our own assembler-name. */ - if (context != 0) - fprintf (asmfile, ",%s,%s", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), - IDENTIFIER_POINTER (DECL_NAME (context))); + fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP, gdb_name, + TREE_PUBLIC (decl) ? 'F' : 'f'); + result = 1; + + current_sym_code = N_FUN; + current_sym_addr = XEXP (DECL_RTL (decl), 0); + + if (TREE_TYPE (type)) + dbxout_type (TREE_TYPE (type), 0); + else + dbxout_type (void_type_node, 0); + + /* For a nested function, when that function is compiled, + mention the containing function name + as well as (since dbx wants it) our own name. */ + if (context != 0) + fprintf (asmfile, ",%s,%s", IDENTIFIER_POINTER (DECL_NAME (decl)), + IDENTIFIER_POINTER (DECL_NAME (context))); + } dbxout_finish_symbol (decl); break; --Apple-Mail-2--384343024 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 40 -- Geoff Keating --Apple-Mail-2--384343024--