forked from Imagelibrary/binutils-gdb
Add new Python APIs to support DAP value display
gdb's language code may know how to display values specially. For example, the Rust code understands that &str is a string-like type, or Ada knows how to handle unconstrained arrays. This knowledge is exposed via val-print, and via varobj -- but currently not via DAP. This patch adds some support code to let DAP also handle these cases, though in a somewhat more generic way. Type.is_array_like and Value.to_array are added to make Python aware of the cases where gdb knows that a structure type is really "array-like". Type.is_string_like is added to make Python aware of cases where gdb's language code knows that a type is string-like. Unlike Value.string, these cases are handled by the type's language, rather than the current language. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
This commit is contained in:
@@ -1206,6 +1206,13 @@ print frame-arguments scalars} (@pxref{Print Settings}).
|
||||
@end table
|
||||
@end defun
|
||||
|
||||
@defun Value.to_array ()
|
||||
If this value is array-like (@pxref{Type.is_array_like}), then this
|
||||
method converts it to an array, which is returned. If this value is
|
||||
already an array, it is simply returned. Otherwise, an exception is
|
||||
throw.
|
||||
@end defun
|
||||
|
||||
@defun Value.string (@r{[}encoding@r{[}, errors@r{[}, length@r{]]]})
|
||||
If this @code{gdb.Value} represents a string, then this method
|
||||
converts the contents to a Python string. Otherwise, this method will
|
||||
@@ -1392,6 +1399,23 @@ which @code{Type.is_scalar} is @code{False}), will raise a
|
||||
@code{ValueError}.
|
||||
@end defvar
|
||||
|
||||
@defvar Type.is_array_like
|
||||
@anchor{Type.is_array_like}
|
||||
A boolean indicating whether this type is array-like.
|
||||
|
||||
Some languages have array-like objects that are represented internally
|
||||
as structures. For example, this is true for a Rust slice type, or
|
||||
for an Ada unconstrained array. @value{GDBN} may know about these
|
||||
types. This determination is done based on the language from which
|
||||
the type originated.
|
||||
@end defvar
|
||||
|
||||
@defvar Type.is_string_like
|
||||
A boolean indicating whether this type is string-like. Like
|
||||
@code{Type.is_array_like}, this is determined based on the originating
|
||||
language of the type.
|
||||
@end defvar
|
||||
|
||||
The following methods are provided:
|
||||
|
||||
@defun Type.fields ()
|
||||
|
||||
Reference in New Issue
Block a user