Document array indexing for Python gdb.Value

Message ID 20230718143935.4002759-1-tromey@adacore.com
State New
Headers
Series Document array indexing for Python gdb.Value |

Commit Message

Tom Tromey July 18, 2023, 2:39 p.m. UTC
  I noticed that the documentation for gdb.Value doesn't mention array
indexing.
---
 gdb/doc/python.texi | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Eli Zaretskii July 18, 2023, 4:26 p.m. UTC | #1
> Cc: Tom Tromey <tromey@adacore.com>
> Date: Tue, 18 Jul 2023 08:39:35 -0600
> From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
> 
> I noticed that the documentation for gdb.Value doesn't mention array
> indexing.
> ---
>  gdb/doc/python.texi | 7 +++++++
>  1 file changed, 7 insertions(+)

Thanks.

> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 9a342f34bf0..aeff483dc0d 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -831,6 +831,13 @@ structure, then @code{bar} can also be accessed as follows:
>  bar = some_val[foo_field]
>  @end smallexample
>  
> +If a @code{gdb.Value} has array or pointer type, an integer can be
> +used to access elements.
> +
> +@smallexample
> +result = some_array[23]
> +@end smallexample
> +

"An integer" or "an index"?

Approved-By: Eli Zaretskii <eliz@gnu.org>
  
Tom Tromey July 21, 2023, 3:47 p.m. UTC | #2
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> +If a @code{gdb.Value} has array or pointer type, an integer can be
>> +used to access elements.
>> +
>> +@smallexample
>> +result = some_array[23]
>> +@end smallexample


Eli> "An integer" or "an index"?

How about "an integer index"?

Tom
  
Eli Zaretskii July 21, 2023, 3:53 p.m. UTC | #3
> From: Tom Tromey <tromey@adacore.com>
> Cc: Tom Tromey <tromey@adacore.com>,  gdb-patches@sourceware.org
> Date: Fri, 21 Jul 2023 09:47:05 -0600
> 
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> +If a @code{gdb.Value} has array or pointer type, an integer can be
> >> +used to access elements.
> >> +
> >> +@smallexample
> >> +result = some_array[23]
> >> +@end smallexample
> 
> 
> Eli> "An integer" or "an index"?
> 
> How about "an integer index"?

Perfect, thanks.
  

Patch

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 9a342f34bf0..aeff483dc0d 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -831,6 +831,13 @@  structure, then @code{bar} can also be accessed as follows:
 bar = some_val[foo_field]
 @end smallexample
 
+If a @code{gdb.Value} has array or pointer type, an integer can be
+used to access elements.
+
+@smallexample
+result = some_array[23]
+@end smallexample
+
 A @code{gdb.Value} that represents a function can be executed via
 inferior function call.  Any arguments provided to the call must match
 the function's prototype, and must be provided in the order specified