From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64596 invoked by alias); 3 Nov 2016 19:04:31 -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 64582 invoked by uid 89); 3 Nov 2016 19:04:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=otoh, OTOH X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Nov 2016 19:04:29 +0000 Received: by mail-wm0-f48.google.com with SMTP id a197so6408290wmd.0 for ; Thu, 03 Nov 2016 12:04:28 -0700 (PDT) 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:from:date :message-id:subject:to; bh=jkvCQDoE3WSEWzJ0ZjA6aP2/QkRj6MsOifGxvKW3QcU=; b=L0GW6acx2VAKlzDZuW1eB5SicW1CAH5/jSmclzrirJUnqQdWJKG1Gi6mPutAA8xqF4 UHTDlFzbRiNA7FS8V+jG6dfGCCIyKg69gwxdNUO6mubDH5vG4B73e0hFS6P+f2NEQWa1 vyYSgDDXlh0ARBNYDzKve1LrFYgP/KviJuDDLw/ol6pr2v7/JIKKYjaOHEKc27rRCQDK NlGbEm61n4a9l1InR1TiNenQwsxqfQxTvRCJn9l0gj9j7XlfD9EyEy4gM8lYqPMurqHr xdP/WvIcKRZjiJu8mcJlasAceR5KGEvgU1qSLq6l6wv7mJxvISAn18xTliV9U0RL0tLL t6SQ== X-Gm-Message-State: ABUngvf85B/rz9HZ3vB8U/SdDrjasKxVh5IBSSw77WG4p9GKY84Lkj9+45ha1zRl21kId4D+5Suhv39A+uevUNme X-Received: by 10.28.157.200 with SMTP id g191mr3402594wme.33.1478199867115; Thu, 03 Nov 2016 12:04:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.152.70 with HTTP; Thu, 3 Nov 2016 12:03:46 -0700 (PDT) In-Reply-To: <94eb2c1121f421b06405406923b6@google.com> References: <94eb2c1121f421b06405406923b6@google.com> From: Doug Evans Date: Thu, 03 Nov 2016 19:04:00 -0000 Message-ID: Subject: Re: [PATCH, doc RFA] Fix lazy string type docs To: gdb-patches , Eli Zaretskii , Phil Muldoon Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00070.txt.bz2 On Thu, Nov 3, 2016 at 10:46 AM, Doug Evans wrote: > Hi. > > I was trying to understand a problem I was having with python lazy strings. > It turns out the docs are wrong, and the "type" attribute of a lazy > string is the character type, not a pointer to the character's type. ... Unless the thing we're making a lazy string out of is an array instead of a pointer. const char* foo = "Dave"; const char bar[] = "No, man, I'm Dave."; (gdb) py print gdb.parse_and_eval("foo").lazy_string().type const char (gdb) py print gdb.parse_and_eval("bar").lazy_string().type const char [19] I don't have a strong opinion on what the correct answer is, but there is certainly a bug here. Phil, do you remember why this code exists in valpy_lazy_string(): if (TYPE_CODE (value_type (value)) == TYPE_CODE_PTR) value = value_ind (value); [lazy string support went in in commit be759fcf] I kinda like the type of the lazy string version of a char array still being a char array. OTOH, when I look at the definition of a lazy string, recording the character type makes more sense (to me anyway: e.g., length would be redundant for the case where type is a char array) typedef struct { PyObject_HEAD /* Holds the address of the lazy string. */ CORE_ADDR address; /* Holds the encoding that will be applied to the string when the string is printed by GDB. If the encoding is set to None then GDB will select the most appropriate encoding when the sting is printed. */ char *encoding; /* Holds the length of the string in characters. If the length is -1, then the string will be fetched and encoded up to the first null of appropriate width. */ long length; /* This attribute holds the type that is represented by the lazy string's type. */ struct type *type; } lazy_string_object; To fix this bug we're going to have to break one or the other, or add a knob (bleah) to control the old, broken, behaviour. Or mark the "type" LazyString attribute as broken/deprecated and provide a new attribute with correct behaviour. Opinions?