From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21785 invoked by alias); 15 Nov 2005 10:15:37 -0000 Received: (qmail 21757 invoked by uid 22791); 15 Nov 2005 10:15:32 -0000 Received: from server7.nfra.nl (HELO server7.nfra.nl) (192.87.1.57) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 15 Nov 2005 10:15:32 +0000 Received: from jop31.nfra.nl [10.87.10.31] by server7.nfra.nl; Tue, 15 Nov 2005 11:15:21 +0100 Received: from jop31.nfra.nl (localhost [127.0.0.1]) by jop31.nfra.nl (8.13.1/8.12.7/SuSE Linux 0.6) with ESMTP id jAFAFKHZ032229 for ; Tue, 15 Nov 2005 11:15:20 +0100 Received: (from kettenis@localhost) by jop31.nfra.nl (8.13.1/8.13.1/Submit) id jAFAFKXw032226; Tue, 15 Nov 2005 11:15:20 +0100 Date: Tue, 15 Nov 2005 10:15:00 -0000 Message-Id: <200511151015.jAFAFKXw032226@jop31.nfra.nl> From: Mark Kettenis To: gdb@sourceware.org Subject: C++ related core dump Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00292.txt.bz2 I'm debugging some evil C++ code at work, and gdb keeps dumping core on me: (gdb) ptype antennac type = class ROScalarColumn : public virtual ROTableColumn { protected: Bool *canAccessColumn_p; Bool *reaskAccessColumn_p; public: ROScalarColumn(); ROScalarColumn(Table const&, String const&); ROScalarColumn(ROTableColumn const&); ROScalarColumn(ROScalarColumn const&); virtual ~ROScalarColumn(); virtual class ROTableColumn * clone() const; void reference(ROScalarColumn const&); void attach(Table const&, String const&); void get(unsigned int, int&) const; Int operator()(unsigned int) const; void getColumn(Vector&, bool) const; Vector getColumn() const; void getColumnRange(ArraySlicer const&, Vector&, bool) const; Vector getColumnRange(ArraySlicer const&) const; void getColumnCells(RefRows const&, Vector&, bool) const; Vector getColumnCells(RefRows const&) const; private: ROScalarColumn & operator=(ROScalarColumn const&); void reference(ROTableColumn const&); void checkDataType() const; } (gdb) p antennac(0) Segmentation fault (core dumped) This is with gcc 3.2 on sparc-sun-solaris2.7, which still uses stabs debugging info. I tracked it down to some code in valops.c:find_overload_match(), where SYMBOL_CPLUS_DEMANGLED_NAME is returning a null pointer which we pass to cp_func_name() and that function can't deal with that. As a stopgap, I applied the attached patch, and now I get: (gdb) p antennac(0) Invalid data type for function to be called. which isn't quite what I want, but at least keeps my gdb alive. What I really want of course is for the above to invoke antennac.operator()(0). Is that supposed to work at all? I know stabs support for C++ has issues, but reading the code I don't see how this would work for DWARF2 either. Regardless of properly invoking operator(), we should do something about this crash. Can we do something better than the attached patch? Mark Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.161 diff -u -p -r1.161 valops.c --- valops.c 27 May 2005 04:39:32 -0000 1.161 +++ valops.c 15 Nov 2005 09:52:56 -0000 @@ -1847,7 +1847,8 @@ find_overload_match (struct type **arg_t else { const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym); - func_name = cp_func_name (qualified_name); + if (qualified_name) + func_name = cp_func_name (qualified_name); /* If the name is NULL this must be a C-style function. Just return the same symbol. */