mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
gdb: update Type.fields doc based on actual GDB behavior
I noticed two errors in the Type.fields documentation: 1. It is possible to call `fields` on an array type, in which case it returns one field representing the array's range. It is not mentioned. 2. When calling `fields` on a type that doesn't have fields (by nature, like an int), GDB raises a TypeError. It does not return an empty sequence, as currently documented. Fix these, and change the text into a bullet list. I find it easier to read than one big paragraph. The first issue is already tested in gdb.python/py-type.exp, but the second one doesn't seem tested. Add a test in gdb.python/py-type.exp for it. gdb/doc/ChangeLog: * python.texi (Types In Python): Re-organize Type.fields doc. Mention handling of array types. Correct doc for when calling the method on another type. gdb/testsuite/ChangeLog: * gdb.python/py-type.exp (test_fields): Test calling fields on an int type. Change-Id: I11c688177504cb070b81a4446ac91dec50b56a22
This commit is contained in:
@@ -1163,12 +1163,32 @@ there is no associated objfile.
|
||||
The following methods are provided:
|
||||
|
||||
@defun Type.fields ()
|
||||
For structure and union types, this method returns the fields. Range
|
||||
types have two fields, the minimum and maximum values. Enum types
|
||||
have one field per enum constant. Function and method types have one
|
||||
field per parameter. The base types of C@t{++} classes are also
|
||||
represented as fields. If the type has no fields, or does not fit
|
||||
into one of these categories, an empty sequence will be returned.
|
||||
|
||||
Return the fields of this type. The behavior depends on the type code:
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
For structure and union types, this method returns the fields.
|
||||
|
||||
@item
|
||||
Range types have two fields, the minimum and maximum values.
|
||||
|
||||
@item
|
||||
Enum types have one field per enum constant.
|
||||
|
||||
@item
|
||||
Function and method types have one field per parameter. The base types of
|
||||
C@t{++} classes are also represented as fields.
|
||||
|
||||
@item
|
||||
Array types have one field representing the array's range.
|
||||
|
||||
@item
|
||||
If the type does not fit into one of these categories, a @code{TypeError}
|
||||
is raised.
|
||||
|
||||
@end itemize
|
||||
|
||||
Each field is a @code{gdb.Field} object, with some pre-defined attributes:
|
||||
@table @code
|
||||
|
||||
Reference in New Issue
Block a user