From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3161 invoked by alias); 3 May 2011 18:59:08 -0000 Received: (qmail 3142 invoked by uid 22791); 3 May 2011 18:59:07 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate4.uk.ibm.com (HELO mtagate4.uk.ibm.com) (194.196.100.164) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 May 2011 18:58:53 +0000 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p43Iwppq022418 for ; Tue, 3 May 2011 18:58:51 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p43J01jF1990730 for ; Tue, 3 May 2011 20:00:01 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p43Iwpvl006247 for ; Tue, 3 May 2011 12:58:51 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p43IwneJ006235 for ; Tue, 3 May 2011 12:58:50 -0600 Message-Id: <201105031858.p43IwneJ006235@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 03 May 2011 20:58:49 +0200 Subject: Is physname mangled or not? (PR c++/8216) To: gdb-patches@sourceware.org Date: Tue, 03 May 2011 18:59:00 -0000 From: "Ulrich Weigand" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00075.txt.bz2 Hello, PR c++/8216 says: When doing ptype on a templated class, GDB will print out constructors as having a return type of void instead of as having no return type at all. Code in c-typename.c:c_type_print_base does this in an attempt to determine whether a method is a constructor: char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); char *name = type_name_no_tag (type); int is_constructor = name && strcmp (method_name, name) == 0; for (j = 0; j < len2; j++) { char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); int is_full_physname_constructor = is_constructor_name (physname) || is_destructor_name (physname) || method_name[0] == '~'; [...] else if (!is_constructor /* Constructors don't have declared types. */ && !is_full_physname_constructor /* " " */ && !is_type_conversion_operator (type, i, j)) So basically this says: a method is a constructor if either: - the method name equals the type name, or - the C++ ABI routine says the physname is a constructor and, a method is a destructor if either: - the method name starts with a ~, or - the C++ ABI routine says the physname is a destructor I'm not quite sure why we need those duplicate checks, but in any case for the constructor they both fail: - For template classes, the method name of a constructor does *not* contain the template instance type list, while the type name does, and thus the strcmp fails - The is_constructor_name C++ ABI callback actually fails *always*. This is because it works only if it gets a *mangled* name as input, but TYPE_FN_FIELD_PHYSNAME returns a demangled name (at least with dwarf2read.c) ... (For destructors, this problem doesn't apply since the ~ test catches just about everything. I'm just wondering why we still try to do the is_destructor_name (physname) check as well ...) This latter seems to have been due to a deliberate change of physname: dwarf2read now always sets this to a demangled name, while e.g. stabsread sets it to a mangled name. So I guess my question is, how is this supposed to work? Should is_constructor_name accept demangled names? Should there be some generic routine that instead tests a demangled name for whether it is a constructor (or destructor)? Any suggestions to fix this would be appreciated ... Thanks, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com