This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, doc RFA] Fix lazy string type docs


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]