From patchwork Thu Nov 3 17:46:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 17166 Received: (qmail 91800 invoked by alias); 3 Nov 2016 17:46:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91787 invoked by uid 89); 3 Nov 2016 17:46:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:sk:94eb2c1, H*MI:sk:94eb2c1, 3336, 48838 X-HELO: mail-pa0-f74.google.com Received: from mail-pa0-f74.google.com (HELO mail-pa0-f74.google.com) (209.85.220.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Nov 2016 17:46:30 +0000 Received: by mail-pa0-f74.google.com with SMTP id fi11so163253pac.2 for ; Thu, 03 Nov 2016 10:46:30 -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:message-id:date:subject:from:to; bh=AU9xlNOdqkkXc3kD5TkPL85Cu7lNwBMNcO8eF7jr4qk=; b=Cd/+26HO/fu0JXVRvTqgryEmB/fQOR4hZzoLw72DwVZR01tefh6ekDCsg2CEpizS6V 39Wc0wps0hn08BOdK6nJyqNl1KEbJSE2gEKXMLIrv3mucflz1oAgTdDeRxI92Cc++Eva ai46KoQ0eLGPdtKihrzWsH5XzwiQyvb3jmwDlAx7a/GW2iN5s/VPjLvbwdFHbmVyp6ZW Qenad/K36qVIiqTuODyF5BypH7ifURkgdTJ0ZpcAweDkXDwVQ8lsqU81KE0UxdFadDtN RqLg18kfpOLrfSSOeUFFh7MLNihKwJU9FOb2+wWODJbMUUCc0Dvn00OsApmees37m3aM R5NA== X-Gm-Message-State: ABUngvdwKv4HrZkLM02ryKkXwpbm3wJrJAqDkKGBhLl4VFmf7vaehi0sMnuCExA9fBJ3PPfmeWa0JVj422y9CooBTmv4bYBBcc5MOZi0tXoOKFObnnIAThKmUoNShPVxZUi3LvcKQfKiRpkcxqJFHMo8UeTQ1x6B4b+Kl5LF+2VBSU//53Pn3Q== MIME-Version: 1.0 X-Received: by 10.98.22.196 with SMTP id 187mr2857723pfw.41.1478195188682; Thu, 03 Nov 2016 10:46:28 -0700 (PDT) Message-ID: <94eb2c1121f421b06405406923b6@google.com> Date: Thu, 03 Nov 2016 17:46:28 +0000 Subject: [PATCH, doc RFA] Fix lazy string type docs From: Doug Evans To: gdb-patches@sourceware.org, eliz@gnu.org X-IsSubscribed: yes 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. Tested on amd64-linux. 2016-11-03 Doug Evans * python/py-lazy-string.c (lazy_string_object): Add comment. doc/ * guile.texi (Lazy Strings In Guile): Fix docs for lazy-string-type. * python.texi (Lazy Strings In Python): Fix docs for LazyString.type. testsuite/ * gdb.guile/scm-value.exp (test_lazy_strings): Add test for lazy-string-type. * gdb.python/py-value.exp (test_lazy_strings): Add test for LazyString.type. diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index d4b40df..49b3744 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -40,8 +40,7 @@ typedef struct { the first null of appropriate width. */ long length; - /* This attribute holds the type that is represented by the lazy - string's type. */ + /* This attribute holds the type of a character in the string. */ struct type *type; } lazy_string_object; diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi index 0030f3f..a413802 100644 --- a/gdb/doc/guile.texi +++ b/gdb/doc/guile.texi @@ -3247,9 +3247,7 @@ most appropriate encoding when the string is printed. @end deffn @deffn {Scheme Procedure} lazy-string-type lazy-string -Return the type that is represented by @var{lazy-string}'s type. -For a lazy string this will always be a pointer type. To -resolve this to the lazy string's character type, use @code{type-target-type}. +Return the type of a character in @var{lazy-string}. @xref{Types In Guile}. @end deffn diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index d6507e5..63fca68 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -4883,11 +4883,8 @@ is not writable. @end defvar @defvar LazyString.type -This attribute holds the type that is represented by the lazy string's -type. For a lazy string this will always be a pointer type. To -resolve this to the lazy string's character type, use the type's -@code{target} method. @xref{Types In Python}. This attribute is not -writable. +This attribute holds the type of a character in the string. +@xref{Types In Python}. This attribute is not writable. @end defvar @node Architectures In Python diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index 1d07c9f..02730ae 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -241,6 +241,8 @@ proc test_lazy_strings {} { "= 0" "Test lazy string length" gdb_test "gu (print (lazy-string-address snstr))" \ "= 0" "Test lazy string address" + gdb_test "gu (print (lazy-string-type snstr))" \ + "= const char" "Test lazy string type" } proc test_inferior_function_call {} { diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 89be659..3ed1801 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -333,6 +333,7 @@ proc test_lazy_strings {} { gdb_py_test_silent_cmd "python snstr = snptr.lazy_string(length=0)" "Succesfully create a lazy string" 1 gdb_test "python print (snstr.length)" "0" "Test lazy string length" gdb_test "python print (snstr.address)" "0" "Test lazy string address" + gdb_test "python print (snstr.type)" "const char" "Test lazy string type" }