From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10956 invoked by alias); 5 Mar 2004 17:33:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10929 invoked from network); 5 Mar 2004 17:33:56 -0000 Received: from unknown (HELO coconut.kealia.com) (209.3.10.89) by sources.redhat.com with SMTP; 5 Mar 2004 17:33:56 -0000 Received: from coconut.kealia.com (localhost.localdomain [127.0.0.1]) by coconut.kealia.com (8.12.8/8.12.8) with ESMTP id i25HXiSH011156; Fri, 5 Mar 2004 09:33:44 -0800 Received: (from carlton@localhost) by coconut.kealia.com (8.12.8/8.12.8/Submit) id i25HXhEg011154; Fri, 5 Mar 2004 09:33:43 -0800 X-Authentication-Warning: coconut.kealia.com: carlton set sender to carlton@kealia.com using -f To: gdb-patches@sources.redhat.com Cc: Daniel Jacobowitz Subject: [commit] fix recursion bug in cp_lookup_transparent_type_loop From: David Carlton Date: Fri, 05 Mar 2004 17:33:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-03.o/txt/msg00108.txt There was a silly bug in cp_lookup_transparent_type_loop that could lead to infinite recursion if you had types in nested namespaces. I've committed the attached patch as obvious to mainline (tested with GCC 3.2, 3.4); I'll commit it to the branch after running it through the testsuite there. David Carlton carlton@kealia.com 2004-03-05 David Carlton * cp-namespace.c (cp_lookup_transparent_type_loop): Fix recursion bug. 2004-03-05 David Carlton * gdb.cp/rtti.exp: Add 'print *obj3' test. * gdb.cp/rtti.h: Update copyright. (namespace n2::n3): New. * gdb.cp/rtti1.cc: (refer_to (n2::n3::C3 *)): New. (n2::n3::func3): New. (main): Call n2::n3::func3. * gdb.cp/rtti2.cc: Update copyright. (n2::create3): New. Index: cp-namespace.c =================================================================== RCS file: /cvs/src/src/gdb/cp-namespace.c,v retrieving revision 1.12 diff -u -p -r1.12 cp-namespace.c --- cp-namespace.c 9 Feb 2004 22:19:26 -0000 1.12 +++ cp-namespace.c 5 Mar 2004 17:24:17 -0000 @@ -603,7 +603,7 @@ static struct type * cp_lookup_transparent_type_loop (const char *name, const char *scope, int length) { - int scope_length = cp_find_first_component (scope + length); + int scope_length = length + cp_find_first_component (scope + length); char *full_name; /* If the current scope is followed by "::", look in the next Index: testsuite/gdb.cp/rtti.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.exp,v retrieving revision 1.4 diff -u -p -r1.4 rtti.exp --- testsuite/gdb.cp/rtti.exp 23 Jan 2004 23:03:31 -0000 1.4 +++ testsuite/gdb.cp/rtti.exp 5 Mar 2004 17:24:18 -0000 @@ -140,5 +140,10 @@ gdb_continue_to_breakpoint "end of const gdb_test "print *obj" "\\$\[0-9\]* = { = .*}" +gdb_breakpoint [gdb_get_line_number "func3-constructs-done"] +gdb_continue_to_breakpoint "end of constructors in func3" + +gdb_test "print *obj3" "\\$\[0-9\]* = { = .*}" + gdb_exit return 0 Index: testsuite/gdb.cp/rtti.h =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.h,v retrieving revision 1.1 diff -u -p -r1.1 rtti.h --- testsuite/gdb.cp/rtti.h 23 Aug 2003 03:55:59 -0000 1.1 +++ testsuite/gdb.cp/rtti.h 5 Mar 2004 17:24:18 -0000 @@ -1,6 +1,6 @@ /* Code to go along with tests in rtti.exp. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -45,4 +45,12 @@ namespace n2 { }; extern C2 *create2(); + + namespace n3 { + class C3 : public C2 { + public: + }; + } + + extern n3::C3 *create3(); } Index: testsuite/gdb.cp/rtti1.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti1.cc,v retrieving revision 1.2 diff -u -p -r1.2 rtti1.cc --- testsuite/gdb.cp/rtti1.cc 23 Jan 2004 23:03:31 -0000 1.2 +++ testsuite/gdb.cp/rtti1.cc 5 Mar 2004 17:24:18 -0000 @@ -63,16 +63,33 @@ void refer_to (n2::C2 *obj) // Do nothing. } +void refer_to (n2::n3::C3 *obj) +{ + // Do nothing. +} + namespace n2 { void func () { C2 *obj = create2 (); - refer_to (obj); // func-constructs-done + refer_to (obj); // func-constructs-done return; } + + namespace n3 + { + void func3 () + { + C3 *obj3 = create3 (); + + refer_to (obj3); // func3-constructs-done + + return; + } + } } int main() @@ -84,6 +101,7 @@ int main() C2 *e2 = create2(); n2::func(); // main-constructs-done + n2::n3::func3(); return 0; } Index: testsuite/gdb.cp/rtti2.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti2.cc,v retrieving revision 1.1 diff -u -p -r1.1 rtti2.cc --- testsuite/gdb.cp/rtti2.cc 23 Aug 2003 03:55:59 -0000 1.1 +++ testsuite/gdb.cp/rtti2.cc 5 Mar 2004 17:24:18 -0000 @@ -1,6 +1,6 @@ /* Code to go along with tests in rtti.exp. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -31,6 +31,10 @@ namespace n2 { C2 *create2() { return new D2(0, 0); + } + + n3::C3 *create3() { + return new n3::C3(); } } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10956 invoked by alias); 5 Mar 2004 17:33:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10929 invoked from network); 5 Mar 2004 17:33:56 -0000 Received: from unknown (HELO coconut.kealia.com) (209.3.10.89) by sources.redhat.com with SMTP; 5 Mar 2004 17:33:56 -0000 Received: from coconut.kealia.com (localhost.localdomain [127.0.0.1]) by coconut.kealia.com (8.12.8/8.12.8) with ESMTP id i25HXiSH011156; Fri, 5 Mar 2004 09:33:44 -0800 Received: (from carlton@localhost) by coconut.kealia.com (8.12.8/8.12.8/Submit) id i25HXhEg011154; Fri, 5 Mar 2004 09:33:43 -0800 X-Authentication-Warning: coconut.kealia.com: carlton set sender to carlton@kealia.com using -f To: gdb-patches@sources.redhat.com Cc: Daniel Jacobowitz Subject: [commit] fix recursion bug in cp_lookup_transparent_type_loop From: David Carlton Date: Fri, 19 Mar 2004 00:09:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-03/txt/msg00108.txt.bz2 Message-ID: <20040319000900.8BMVcfsLxaJxxs_nbjXc0I5PZpIHPm56TDtI-kp1-mo@z> There was a silly bug in cp_lookup_transparent_type_loop that could lead to infinite recursion if you had types in nested namespaces. I've committed the attached patch as obvious to mainline (tested with GCC 3.2, 3.4); I'll commit it to the branch after running it through the testsuite there. David Carlton carlton@kealia.com 2004-03-05 David Carlton * cp-namespace.c (cp_lookup_transparent_type_loop): Fix recursion bug. 2004-03-05 David Carlton * gdb.cp/rtti.exp: Add 'print *obj3' test. * gdb.cp/rtti.h: Update copyright. (namespace n2::n3): New. * gdb.cp/rtti1.cc: (refer_to (n2::n3::C3 *)): New. (n2::n3::func3): New. (main): Call n2::n3::func3. * gdb.cp/rtti2.cc: Update copyright. (n2::create3): New. Index: cp-namespace.c =================================================================== RCS file: /cvs/src/src/gdb/cp-namespace.c,v retrieving revision 1.12 diff -u -p -r1.12 cp-namespace.c --- cp-namespace.c 9 Feb 2004 22:19:26 -0000 1.12 +++ cp-namespace.c 5 Mar 2004 17:24:17 -0000 @@ -603,7 +603,7 @@ static struct type * cp_lookup_transparent_type_loop (const char *name, const char *scope, int length) { - int scope_length = cp_find_first_component (scope + length); + int scope_length = length + cp_find_first_component (scope + length); char *full_name; /* If the current scope is followed by "::", look in the next Index: testsuite/gdb.cp/rtti.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.exp,v retrieving revision 1.4 diff -u -p -r1.4 rtti.exp --- testsuite/gdb.cp/rtti.exp 23 Jan 2004 23:03:31 -0000 1.4 +++ testsuite/gdb.cp/rtti.exp 5 Mar 2004 17:24:18 -0000 @@ -140,5 +140,10 @@ gdb_continue_to_breakpoint "end of const gdb_test "print *obj" "\\$\[0-9\]* = { = .*}" +gdb_breakpoint [gdb_get_line_number "func3-constructs-done"] +gdb_continue_to_breakpoint "end of constructors in func3" + +gdb_test "print *obj3" "\\$\[0-9\]* = { = .*}" + gdb_exit return 0 Index: testsuite/gdb.cp/rtti.h =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.h,v retrieving revision 1.1 diff -u -p -r1.1 rtti.h --- testsuite/gdb.cp/rtti.h 23 Aug 2003 03:55:59 -0000 1.1 +++ testsuite/gdb.cp/rtti.h 5 Mar 2004 17:24:18 -0000 @@ -1,6 +1,6 @@ /* Code to go along with tests in rtti.exp. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -45,4 +45,12 @@ namespace n2 { }; extern C2 *create2(); + + namespace n3 { + class C3 : public C2 { + public: + }; + } + + extern n3::C3 *create3(); } Index: testsuite/gdb.cp/rtti1.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti1.cc,v retrieving revision 1.2 diff -u -p -r1.2 rtti1.cc --- testsuite/gdb.cp/rtti1.cc 23 Jan 2004 23:03:31 -0000 1.2 +++ testsuite/gdb.cp/rtti1.cc 5 Mar 2004 17:24:18 -0000 @@ -63,16 +63,33 @@ void refer_to (n2::C2 *obj) // Do nothing. } +void refer_to (n2::n3::C3 *obj) +{ + // Do nothing. +} + namespace n2 { void func () { C2 *obj = create2 (); - refer_to (obj); // func-constructs-done + refer_to (obj); // func-constructs-done return; } + + namespace n3 + { + void func3 () + { + C3 *obj3 = create3 (); + + refer_to (obj3); // func3-constructs-done + + return; + } + } } int main() @@ -84,6 +101,7 @@ int main() C2 *e2 = create2(); n2::func(); // main-constructs-done + n2::n3::func3(); return 0; } Index: testsuite/gdb.cp/rtti2.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti2.cc,v retrieving revision 1.1 diff -u -p -r1.1 rtti2.cc --- testsuite/gdb.cp/rtti2.cc 23 Aug 2003 03:55:59 -0000 1.1 +++ testsuite/gdb.cp/rtti2.cc 5 Mar 2004 17:24:18 -0000 @@ -1,6 +1,6 @@ /* Code to go along with tests in rtti.exp. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -31,6 +31,10 @@ namespace n2 { C2 *create2() { return new D2(0, 0); + } + + n3::C3 *create3() { + return new n3::C3(); } }