Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: gdb-patches@sourceware.org, eliz@gnu.org
Subject: [PATCH, doc RFA] Fix lazy string type docs
Date: Thu, 03 Nov 2016 17:46:00 -0000	[thread overview]
Message-ID: <94eb2c1121f421b06405406923b6@google.com> (raw)

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  <dje@google.com>

	* 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"
  }



             reply	other threads:[~2016-11-03 17:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03 17:46 Doug Evans [this message]
2016-11-03 18:21 ` Eli Zaretskii
2016-11-03 18:36   ` Doug Evans
     [not found]   ` <CADPb22QnnuHuG+sC=rg5HUJP2L_m1P_J7TTFLv0H-KDd6tON=A@mail.gmail.com>
2016-11-03 19:07     ` Eli Zaretskii
2016-11-03 23:55       ` Doug Evans
2016-11-04  7:31         ` Eli Zaretskii
2016-11-03 19:04 ` Doug Evans
2016-11-03 21:20   ` André Pönitz
2016-11-04  0:01   ` Doug Evans
2016-11-04 17:53     ` Doug Evans
2016-11-04 19:20       ` Phil Muldoon
2016-11-04 19:29         ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94eb2c1121f421b06405406923b6@google.com \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox