From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4108 invoked by alias); 24 Jun 2013 19:11:33 -0000 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 Received: (qmail 4095 invoked by uid 89); 24 Jun 2013 19:11:33 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS,TW_XS autolearn=ham version=3.3.1 Received: from mail-ye0-f202.google.com (HELO mail-ye0-f202.google.com) (209.85.213.202) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 24 Jun 2013 19:11:31 +0000 Received: by mail-ye0-f202.google.com with SMTP id r11so72307yen.1 for ; Mon, 24 Jun 2013 12:11:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type :x-gm-message-state; bh=dztIyk/16l55KmuGJ6qmCYVDZvwmth9wKkoarXLdIN8=; b=Sq/TeV61QXALMxxbgP05T9uLBg4m9Y/UymxuDDInnCwEBC8FT5NVQVWSvt6bL5ObSY G5+II8QyUNRsf7Vy5DrZKjktceYQnYzCT7Vc29eoCBnWDwCzhcIjZQdtJjQYper1cb3M OvaH1+YEmRhDvy5N2SAoWwx2oqMTrdcR7bFcaFgU4VS8GDw7OvzpKL1b3+q5kKL6+riE hr2nqurXnS+r9oTz9dhcBUjEXUdvSL9tclXReyEX2nPv+QogIVWgITpqUg6YpoloTpXu DxB9VlLe7TUoEart6fXoJdyFSiHrTKnjGWiO6Wma9LNbA97hqjvZcOojrYejJ3q3miRf tj1A== X-Received: by 10.236.174.202 with SMTP id x50mr13871539yhl.20.1372101089769; Mon, 24 Jun 2013 12:11:29 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id t25si9685421yhg.6.2013.06.24.12.11.29 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2013 12:11:29 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 3B6BE5A41D4; Mon, 24 Jun 2013 12:11:29 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org, brobecker@adacore.com Subject: [RFA] Apply fix to 15519 to 7.6 branch Date: Mon, 24 Jun 2013 19:16:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQmdADrE3jtTdf4fucckzP4RqaPHAVjpIIIu/2InXsieRuuNMHBx/cecxcaON4kkJ08RzSzYow6TmXB1ooD7c3Zdj8S7c5Icyx1Zl6SMQ6Yq0AHYlUOklbv1CdzdBn6z54c9sV1Ugob6jMxy3aoAbS9tMBjmn9aSxkV/3lB9i9bObrSaVm9itgN+l1AB91foZCX+8+vCEEqyBRSCMZUBri05pNklzw== X-SW-Source: 2013-06/txt/msg00672.txt.bz2 Hi. I'd like to apply this to the 7.6 branch. Regression tested on amd64-linux, with/without Fission. Ok to check in? 2013-06-06 Doug Evans * gdb.cp/derivation.exp: Make tests have unique names. 2013-06-05 Doug Evans Keith Seitz PR 15519 * cp-namespace.c (find_symbol_in_baseclass): Call cp_lookup_symbol_in_namespace instead of cp_lookup_symbol_namespace. Check result of call to lookup_symbol_static. Call lookup_static_symbol_aux unconditionally. Call check_typedef on base types before accessing them. (cp_lookup_nested_symbol): Fix comment. testsuite/ * gdb.cp/derivation2.cc: New file. * gdb.cp/derivation.cc (main): Call foo2. * gdb.cp/derivation.exp: Add tests for typedefs in another file, and when there's an active block. Index: cp-namespace.c =================================================================== RCS file: /cvs/src/src/gdb/cp-namespace.c,v retrieving revision 1.65.2.1 diff -u -p -r1.65.2.1 cp-namespace.c --- cp-namespace.c 18 Mar 2013 09:20:02 -0000 1.65.2.1 +++ cp-namespace.c 24 Jun 2013 19:06:00 -0000 @@ -717,36 +717,40 @@ find_symbol_in_baseclass (struct type *p for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i) { size_t len; + struct type *base_type = TYPE_BASECLASS (parent_type, i); const char *base_name = TYPE_BASECLASS_NAME (parent_type, i); if (base_name == NULL) continue; /* Search this particular base class. */ - sym = cp_lookup_symbol_namespace (base_name, name, block, VAR_DOMAIN); + sym = cp_lookup_symbol_in_namespace (base_name, name, block, + VAR_DOMAIN, 0); if (sym != NULL) break; + /* Now search all static file-level symbols. We have to do this for + things like typedefs in the class. First search in this symtab, + what we want is possibly there. */ len = strlen (base_name) + 2 + strlen (name) + 1; concatenated_name = xrealloc (concatenated_name, len); xsnprintf (concatenated_name, len, "%s::%s", base_name, name); sym = lookup_symbol_static (concatenated_name, block, VAR_DOMAIN); + if (sym != NULL) + break; - /* If there is currently no BLOCK, e.g., the inferior hasn't yet - been started, then try searching all STATIC_BLOCK symbols in - all objfiles. */ - if (block == NULL) - { - sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); - if (sym != NULL) - break; - } + /* Nope. We now have to search all static blocks in all objfiles, + even if block != NULL, because there's no guarantees as to which + symtab the symbol we want is in. */ + sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); + if (sym != NULL) + break; /* If this class has base classes, search them next. */ - if (TYPE_N_BASECLASSES (TYPE_BASECLASS (parent_type, i)) > 0) + CHECK_TYPEDEF (base_type); + if (TYPE_N_BASECLASSES (base_type) > 0) { - sym = find_symbol_in_baseclass (TYPE_BASECLASS (parent_type, i), - name, block); + sym = find_symbol_in_baseclass (base_type, name, block); if (sym != NULL) break; } @@ -794,8 +798,8 @@ cp_lookup_nested_symbol (struct type *pa if (sym != NULL) return sym; - /* Now search all static file-level symbols. Not strictly - correct, but more useful than an error. We do not try to + /* Now search all static file-level symbols. We have to do this + for things like typedefs in the class. We do not try to guess any imported namespace as even the fully specified namespace search is already not C++ compliant and more assumptions could make it too magic. */ Index: testsuite/gdb.cp/derivation.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/derivation.cc,v retrieving revision 1.5 diff -u -p -r1.5 derivation.cc --- testsuite/gdb.cp/derivation.cc 1 Jan 2013 06:33:27 -0000 1.5 +++ testsuite/gdb.cp/derivation.cc 24 Jun 2013 19:06:01 -0000 @@ -16,6 +16,8 @@ along with this program. If not, see . */ +extern void foo2 (); /* from derivation2.cc */ + namespace N { typedef double value_type; struct Base { typedef int value_type; }; @@ -306,9 +308,7 @@ int main(void) N::Derived::value_type d = 1; N::value_type n = 3.0; dobj.doit (); + foo2 (); return 0; } - - - Index: testsuite/gdb.cp/derivation.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/derivation.exp,v retrieving revision 1.24 diff -u -p -r1.24 derivation.exp --- testsuite/gdb.cp/derivation.exp 1 Jan 2013 06:33:27 -0000 1.24 +++ testsuite/gdb.cp/derivation.exp 24 Jun 2013 19:06:01 -0000 @@ -32,22 +32,25 @@ if { [skip_cplus_tests] } { continue } load_lib "cp-support.exp" -standard_testfile .cc +standard_testfile derivation.cc derivation2.cc -if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { +if {[prepare_for_testing $testfile.exp $testfile \ + [list $srcfile $srcfile2] {debug c++}]} { return -1 } # Check inheritance of typedefs. -foreach klass {"A" "D" "E" "F"} { - gdb_test "ptype ${klass}::value_type" "type = int" - gdb_test "whatis ${klass}::value_type" "type = int" - gdb_test "p (${klass}::value_type) 0" " = 0" -} -foreach klass {"Z" "ZZ"} { - gdb_test "ptype ${klass}::value_type" "type = float" - gdb_test "whatis ${klass}::value_type" "type = float" - gdb_test "p (${klass}::value_type) 0" " = 0" +with_test_prefix "before run" { + foreach klass {"A" "D" "E" "F" "A2" "D2"} { + gdb_test "ptype ${klass}::value_type" "type = int" + gdb_test "whatis ${klass}::value_type" "type = int" + gdb_test "p (${klass}::value_type) 0" " = 0" + } + foreach klass {"Z" "ZZ"} { + gdb_test "ptype ${klass}::value_type" "type = float" + gdb_test "whatis ${klass}::value_type" "type = float" + gdb_test "p (${klass}::value_type) 0" " = 0" + } } # Set it up at a breakpoint so we can play with the variable values. @@ -57,6 +60,15 @@ if ![runto 'marker1'] then { continue } +# Check inheritance of typedefs again, but this time with an active block. +with_test_prefix "at marker1" { + foreach klass {"A" "D" "A2" "D2"} { + gdb_test "ptype ${klass}::value_type" "type = int" + gdb_test "whatis ${klass}::value_type" "type = int" + gdb_test "p (${klass}::value_type) 0" " = 0" + } +} + gdb_test "up" ".*main.*" "up from marker1" # Print class types and values. Index: testsuite/gdb.cp/derivation2.cc =================================================================== RCS file: testsuite/gdb.cp/derivation2.cc diff -N testsuite/gdb.cp/derivation2.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/derivation2.cc 24 Jun 2013 19:06:01 -0000 @@ -0,0 +1,49 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 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 . + */ + +/* A copy of some classes in derivation.cc so that we can test symbol lookup + in other CUs. */ + +class A2 { +public: + typedef int value_type; + value_type a; + + A2() + { + a=1; + } +}; + +class D2 : public A2 { +public: + value_type d; + + D2() + { + d=7; + } +}; + +void +foo2 () +{ + D2 d2_instance; + d2_instance.a = 42; + d2_instance.d = 43; +}