From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98666 invoked by alias); 18 Apr 2019 17:08:00 -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 98647 invoked by uid 89); 18 Apr 2019 17:08:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=inspiration X-HELO: mail-wm1-f47.google.com Received: from mail-wm1-f47.google.com (HELO mail-wm1-f47.google.com) (209.85.128.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Apr 2019 17:07:58 +0000 Received: by mail-wm1-f47.google.com with SMTP id r186so7361562wmf.1 for ; Thu, 18 Apr 2019 10:07:58 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id a13sm3654041wrn.63.2019.04.18.10.07.55 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 10:07:55 -0700 (PDT) Subject: Re: [PATCHv2 4/5] gdb: Introduce new language field la_is_string_type_p To: Andrew Burgess , gdb-patches@sourceware.org References: From: Pedro Alves Message-ID: <7134c1a3-8cd3-bcb2-c1b3-444f1c879049@redhat.com> Date: Thu, 18 Apr 2019 17:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-04/txt/msg00350.txt.bz2 On 4/17/19 12:06 AM, Andrew Burgess wrote: > This commit is preparation work for the next commit, and by itself > makes no user visible change to GDB. I've split this work into a > separate commit in order to make code review easier. > > This commit adds a new field 'la_is_string_type_p' to the language > struct, this predicate will return true if a type is a string type for > the given language. > > Some languages already have a "is this a string" predicate that I was > able to reuse, while for other languages I've had to add a new > predicate. In this case I took inspiration from the value printing > code for that language - what different conditions would result in > printing something as a string. > > A default "is this a string" method has also been added that looks for > TYPE_CODE_STRING, this is the fallback I've used for a couple of > languages. > > In this commit I add the new field and initialise it for each > language, however at this stage the new field is never used. > Thanks. This nicely addresses one of my previous review comments. I can't speak to whether the implementation for the different languages are correct. E.g., I'm curious from where you extracted the M2 and the Rust bits. Didn't seem like it was a refactoring job? Formatting comments below. > +/* Return true if TYPE is a string. */ > +static bool Empty line after comment. > +static bool > +m2_is_string_type_p (struct type *type) > +{ > + type = check_typedef (type); > + if (TYPE_CODE (type) == TYPE_CODE_ARRAY > + && TYPE_LENGTH (type) > 0 > + && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) > + { > + struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); > + > + if (TYPE_LENGTH (elttype) == 1 && && goes on the next line. > + (TYPE_CODE (elttype) == TYPE_CODE_INT > + || TYPE_CODE (elttype) == TYPE_CODE_CHAR)) > + return true; > + } > + > + return false; > +} > + Thanks, Pedro Alves