From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21037 invoked by alias); 11 Nov 2009 22:49:41 -0000 Received: (qmail 21024 invoked by uid 22791); 11 Nov 2009 22:49:40 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,KAM_STOCKGEN,SPF_HELO_PASS,SPF_PASS 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; Wed, 11 Nov 2009 22:49:18 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nABMnH6G007721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Nov 2009 17:49:17 -0500 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nABMnEhs018284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 Nov 2009 17:49:16 -0500 Message-ID: <4AFB3F69.9070107@redhat.com> Date: Wed, 11 Nov 2009 22:49:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [RFA] Typedef support for linespecs Content-Type: multipart/mixed; boundary="------------040406060201050105060902" 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: 2009-11/txt/msg00265.txt.bz2 This is a multi-part message in MIME format. --------------040406060201050105060902 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1030 Hi, CVS HEAD currently fails if a user does something like: class foo { public: void a_function (void) { } }; typedef MyFoo foo; MyFoo instance; (gdb) list MyFoo::a_function This happens because when we lookup "MyFoo", lookup_prefix_sym will only search STRUCT_DOMAIN, and it won't find "MyFoo", since typedefs live in VAR_DOMAIN. The attached patch attempts to address this issue by searching VAR_DOMAIN if the search through STRUCT_DOMAIN fails. [In case I am not always explicit: This patch introduces no regressions or failures/errors of any kind with the test suite on x86 linux.] Comments/Questions/Concerns? Keith ChangeLog 2009-11-11 Keith Seitz * linespec.c (lookup_prefix_sym): Lookup the symbol in both STRUCT_DOMAIN and VAR_DOMAIN. testsuite/ChangeLog 2009-11-11 Keith Seitz * gdb.cp/classes.cc (ByAnyOtherName): Add typedef and use it instead of "Foo". * gdb.cp/classes.exp (do_tests): Add a test to access a method through a typedef'd class name. --------------040406060201050105060902 Content-Type: text/plain; name="linespec-typedef.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="linespec-typedef.patch" Content-length: 2689 Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.92 diff -u -p -r1.92 linespec.c --- linespec.c 19 Oct 2009 09:51:41 -0000 1.92 +++ linespec.c 11 Nov 2009 22:37:47 -0000 @@ -1428,6 +1428,7 @@ lookup_prefix_sym (char **argptr, char * { char *p1; char *copy; + struct symbol *sym; /* Extract the class name. */ p1 = p; @@ -1446,7 +1447,26 @@ lookup_prefix_sym (char **argptr, char * /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA", argptr->"inA::fun" */ - return lookup_symbol (copy, 0, STRUCT_DOMAIN, 0); + sym = lookup_symbol (copy, 0, STRUCT_DOMAIN, 0); + if (sym == NULL) + { + /* Typedefs are in VAR_DOMAIN so the above symbol lookup will + fail when the user attempts to lookup a method of a class + via a typedef'd name (NOT via the class's name, which is already + handled in symbol_matches_domain). So try the lookup again + using VAR_DOMAIN (where typedefs live) and double-check that we + found a struct/class type. */ + struct symbol *s = lookup_symbol (copy, 0, VAR_DOMAIN, 0); + if (s != NULL) + { + struct type *t = SYMBOL_TYPE (s); + CHECK_TYPEDEF (t); + if (TYPE_CODE (t) == TYPE_CODE_STRUCT) + return s; + } + } + + return sym; } /* This finds the method COPY in the class whose type is T and whose Index: testsuite/gdb.cp/classes.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.cc,v retrieving revision 1.7 diff -u -p -r1.7 classes.cc --- testsuite/gdb.cp/classes.cc 21 Sep 2009 19:23:22 -0000 1.7 +++ testsuite/gdb.cp/classes.cc 11 Nov 2009 22:37:48 -0000 @@ -417,6 +417,8 @@ class Foo int times (int y); }; +typedef Foo ByAnyOtherName; + class Bar : public Base1, public Foo { public: int z; @@ -431,7 +433,7 @@ int Foo::st = 100; Foo::operator int() { return x; } -Foo foo(10, 11); +ByAnyOtherName foo(10, 11); Bar bar(20, 21, 22); class ClassWithEnum { Index: testsuite/gdb.cp/classes.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.exp,v retrieving revision 1.22 diff -u -p -r1.22 classes.exp --- testsuite/gdb.cp/classes.exp 21 Sep 2009 19:23:22 -0000 1.22 +++ testsuite/gdb.cp/classes.exp 11 Nov 2009 22:37:48 -0000 @@ -636,6 +636,8 @@ proc do_tests {} { gdb_test "print base1::Base1" "<.*Base1.*>" "print ctor of typedef class" gdb_test "print base1::~Base1" "<.*~Base1(\\(\\))?>" \ "print dtor of typedef class" + + gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*" } do_tests --------------040406060201050105060902--