From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26304 invoked by alias); 18 Nov 2014 23:59:45 -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 26293 invoked by uid 89); 18 Nov 2014 23:59:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-oi0-f48.google.com Received: from mail-oi0-f48.google.com (HELO mail-oi0-f48.google.com) (209.85.218.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 18 Nov 2014 23:59:43 +0000 Received: by mail-oi0-f48.google.com with SMTP id u20so3390142oif.35 for ; Tue, 18 Nov 2014 15:59:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=i5TqxZSXo89m/25gGEKNbLrAebjQPOBQvFWAF8nrP5Q=; b=GoIedhK0ERDG6BbCW9NkcZHU2NIH1IDM4+e86Z39voXS+q9DFZKzzkIqYWaPlNQdVG Vh6H435YMmSXIoeuqod7JYHR3m+zAg/bC8xkALK6djq/9D8b+CLr3C3ht+OeVxvJWFD3 HIJa8HTOnxeSCULoC2BSKbgVsE/KhLVyqZcuQKKyl2l2N40vsZi9rYJdpd+lI+72QG57 lfYk3gJNsUyydZeO3IRHc5XYTkTf4Uw8Sj9LCIfJBlBtNIow7bf994fbk3KyLdjIoO5O h3nDV7B+u0uJjB0ZfPi78g2XYQ+XF+qDoQCVWPal1MhB7QmFcoRFDmeji9z5yKxRppLC wXpg== X-Gm-Message-State: ALoCoQmKr2zsIieskir9tiGJlNUdcpd6JTEaRSNvS0tcZyTaTFtnBwpDEoeRUk2qLiQwBF/rUd8k MIME-Version: 1.0 X-Received: by 10.60.50.97 with SMTP id b1mr32714272oeo.1.1416355181652; Tue, 18 Nov 2014 15:59:41 -0800 (PST) Received: by 10.202.137.1 with HTTP; Tue, 18 Nov 2014 15:59:41 -0800 (PST) In-Reply-To: References: Date: Tue, 18 Nov 2014 23:59:00 -0000 Message-ID: Subject: Re: [PATCH] Remove unwanted spaces when looking up builtin types From: Siva Chandra To: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00428.txt.bz2 On Fri, Nov 7, 2014 at 5:49 AM, Siva Chandra wrote: > On Wed, Oct 29, 2014 at 11:50 AM, Siva Chandra wrote: >> Currently, if we do something like gdb.lookup_type(" unsigned long "), >> GDB errors out because of the leading and trailing spaces. The >> attached patch fixes this problem. >> >> A practical situation where this problem is hit is when invoking >> template methods. Its not uncommon to do things like this: >> >> (gdb) p foo.bar< unsigned long >() >> >> If "bar" happens to be an xmethod, then its implementation will >> typically need to parse the name of the method ("bar< unsigned long >" >> in the above example) to get the template argument and lookup the >> type. GDB currently fails for such cases. One could of course >> sanitize/fix such inputs in Python before calling lookup_type, but I >> think it is better done on the GDB side as having white spaces is >> valid syntax. >> >> For non-builtin types, lookup_type goes through the symbol lookup >> path. AFAIU, that path already ignores whitespaces. > Ping. This is not super critical, but I see that an xmethod test fails after I have upgraded to gcc-4.8.2 from gcc-4.6. The essential difference I have found is that looking up a symbol for " unsigned int " works when the test is compiled with gcc-4.6 and it does not when compiled with 4.8.2. And, when it does not, the type is looked up via "language_lookup_primitive_type_by_name" which errors out as it does an exact string match. [I have not yet looked into why there is a difference between gcc-4.6 and gcc-4.8.2 as I think that the proposed fix is not inappropriate and does fix the problem.] > > gdb/ChangeLog: > > 2014-11-07 Siva Chandra Reddy > > * language.c (language_lookup_primitive_type_by_name): Remove > unwanted space in the type name before looking it up. > (whitespace_p): New function. > > gdb/testsuite/ChangeLog: > > 2014-11-07 Siva Chandra Reddy > > * gdb.python/py-type.exp: Add new tests.