From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18853 invoked by alias); 22 Jun 2010 15:43:47 -0000 Received: (qmail 18834 invoked by uid 22791); 22 Jun 2010 15:43:46 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 15:43:39 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5MFhWnX003767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Jun 2010 11:43:32 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5MFhN7r024262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Jun 2010 11:43:29 -0400 Message-ID: <4C20DA1A.10301@redhat.com> Date: Tue, 22 Jun 2010 15:43:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Lightning/1.0b2pre Thunderbird/3.0.4 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Pedro Alves Subject: Re: [RFA] c++/11734 References: <4C20103B.1080906@redhat.com> <201006221045.23196.pedro@codesourcery.com> In-Reply-To: <201006221045.23196.pedro@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070604060901000409060206" X-IsSubscribed: yes 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: 2010-06/txt/msg00482.txt.bz2 This is a multi-part message in MIME format. --------------070604060901000409060206 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 561 On 06/22/2010 02:45 AM, Pedro Alves wrote: > It looks like `name' is invariant in > this loop, so you could for example, move the `new' declaration > out of the loop, initialized as NULL, and allocate it only once > on first need. I completely missed that. [Forest/trees kind of thing, I guess.] I noticed that I also missed adding this logic to the linear search case. I've attached a revised patch which addresses this missed bit and moves the alloca out of the loop. Good catch! Keith PS. In case it isn't well-known: regression-free on x86_64 linux. --------------070604060901000409060206 Content-Type: text/plain; name="pr11734-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr11734-2.patch" Content-length: 11880 Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.103 diff -u -p -r1.103 linespec.c --- linespec.c 14 May 2010 23:41:04 -0000 1.103 +++ linespec.c 22 Jun 2010 15:39:18 -0000 @@ -1217,6 +1217,19 @@ decode_compound (char **argptr, int funf struct type *t; char *saved_java_argptr = NULL; + /* Strip single quotes from SAVED_ARG. This interferes with this function + which might, e.g., later call strcmp_iw with SYMBOL_LINKAGE_NAME + (which never contains quotes). */ + if (*saved_arg == '\'') + { + char *close = strrchr (saved_arg, '\''); + if (close) + { + ++saved_arg; + *close = '\0'; + } + } + /* First check for "global" namespace specification, of the form "::foo". If found, skip over the colons and jump to normal symbol processing. I.e. the whole line specification starts with Index: psymtab.c =================================================================== RCS file: /cvs/src/src/gdb/psymtab.c,v retrieving revision 1.4 diff -u -p -r1.4 psymtab.c --- psymtab.c 16 May 2010 01:27:02 -0000 1.4 +++ psymtab.c 22 Jun 2010 15:39:20 -0000 @@ -432,6 +432,7 @@ lookup_partial_symbol (struct partial_sy struct partial_symbol **top, **real_top, **bottom, **center; int length = (global ? pst->n_global_syms : pst->n_static_syms); int do_linear_search = 1; + char *simple_name = NULL, *paren; if (length == 0) { @@ -441,6 +442,14 @@ lookup_partial_symbol (struct partial_sy pst->objfile->global_psymbols.list + pst->globals_offset : pst->objfile->static_psymbols.list + pst->statics_offset); + paren = strchr (name, '('); + if (paren) + { + simple_name = alloca (strlen (name)); + memcpy (simple_name, name, paren - name); + simple_name[name - paren] = '\0'; + } + if (global) /* This means we can use a binary search. */ { do_linear_search = 0; @@ -476,12 +485,32 @@ lookup_partial_symbol (struct partial_sy if (!(top == bottom)) internal_error (__FILE__, __LINE__, _("failed internal consistency check")); - while (top <= real_top - && SYMBOL_MATCHES_SEARCH_NAME (*top, name)) + while (top <= real_top) { - if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), - SYMBOL_DOMAIN (*top), domain)) - return (*top); + if (SYMBOL_MATCHES_SEARCH_NAME (*top, name)) + { + if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), + SYMBOL_DOMAIN (*top), domain)) + return (*top); + } + else + { + if (simple_name) + { + /* NAME has overload information. Partial symbols, however, + do not. This is a case of mistaken identity. + + Although hacky, this is fixed by expanding this psymtab, + which will allow any subsequent symtab search to succeed. + + For more details/test case, please refer to c++/11734. */ + + if (SYMBOL_MATCHES_SEARCH_NAME (*top, simple_name)) + PSYMTAB_TO_SYMTAB (pst); + } + else + break; + } top++; } } @@ -497,6 +526,11 @@ lookup_partial_symbol (struct partial_sy SYMBOL_DOMAIN (*psym), domain) && SYMBOL_MATCHES_SEARCH_NAME (*psym, name)) return (*psym); + else if (simple_name && SYMBOL_MATCHES_SEARCH_NAME (*psym, simple_name)) + { + PSYMTAB_TO_SYMTAB (pst); + break; + } } } Index: testsuite/gdb.cp/pr11734-1.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-1.cc diff -N testsuite/gdb.cp/pr11734-1.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-1.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +int +main () +{ + pr11734 *p = new pr11734; + p->foo (); + return 0; +} + Index: testsuite/gdb.cp/pr11734-2.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-2.cc diff -N testsuite/gdb.cp/pr11734-2.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-2.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo(void) +{ +} + Index: testsuite/gdb.cp/pr11734-3.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-3.cc diff -N testsuite/gdb.cp/pr11734-3.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-3.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo (int a) +{ +} + Index: testsuite/gdb.cp/pr11734-4.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-4.cc diff -N testsuite/gdb.cp/pr11734-4.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-4.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo (char *a) +{ +} + Index: testsuite/gdb.cp/pr11734.exp =================================================================== RCS file: testsuite/gdb.cp/pr11734.exp diff -N testsuite/gdb.cp/pr11734.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734.exp 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,67 @@ +# Copyright 2010 Free Software Foundation, Inc. +# +# Contributed by Red Hat, originally written by Keith Seitz. +# +# 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 3 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, see . + +# This file is part of the gdb testsuite. + +if { [skip_cplus_tests] } { continue } + +set testfile "pr11734" +set class $testfile +set binfile [file join $objdir $subdir $testfile] + +set srcfiles {} +for {set i 1} {$i < 5} {incr i} { + lappend srcfiles [file join $srcdir $subdir $testfile-$i.cc] +} +if {[gdb_compile $srcfiles $binfile executable {debug c++}] != "" } { + untested pr11734.exp + return -1 +} + +if {[get_compiler_info $binfile "c++"]} { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $binfile + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# An array holding the overload types for the method pr11734::foo. The +# first element is the overloaded method parameter. The second element +# is the expected source file number, e.g. "pr11734-?.cc". +array set tests { + "char*" 4 + "int" 3 + "" 2 +} + +# Test each overload instance twice: once quoted, once unquoted +foreach ovld [array names tests] { + set method "${class}::foo\($ovld\)" + set result "Breakpoint (\[0-9\]).*file .*/$class-$tests($ovld).*" + gdb_test "break $method" $result + gdb_test "break '$method'" $result +} + +gdb_exit +return 0 Index: testsuite/gdb.cp/pr11734.h =================================================================== RCS file: testsuite/gdb.cp/pr11734.h diff -N testsuite/gdb.cp/pr11734.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734.h 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +class pr11734 +{ + public: + void foo (); + void foo (int); + void foo (char *); +}; + --------------070604060901000409060206--