Fix int() builtin with range type gdb.Value objects.
Consider the following variable: type Small is range -128 .. 127; SR : Small := 48; Trying to get its value as an integer within Python code yields: (gdb) python sr = gdb.parse_and_eval('sr') (gdb) python print int(sr) Traceback (most recent call last): File "<string>", line 1, in <module> gdb.error: Cannot convert value to int. Error while executing Python code. This is happening because our variable is a range type, and py-value's is_intlike does not handle TYPE_CODE_RANGE. This patch fixes this. gdb/ChangeLog: * python/py-value.c (is_intlike): Add TYPE_CODE_RANGE handling. gdb/testsuite/ChangeLog: * gdb.ada/py_range: New testcase.
This commit is contained in:
parent
4a0a886ab6
commit
df7752b044
7 changed files with 126 additions and 0 deletions
|
@ -1137,6 +1137,7 @@ is_intlike (struct type *type, int ptr_ok)
|
|||
|| TYPE_CODE (type) == TYPE_CODE_ENUM
|
||||
|| TYPE_CODE (type) == TYPE_CODE_BOOL
|
||||
|| TYPE_CODE (type) == TYPE_CODE_CHAR
|
||||
|| TYPE_CODE (type) == TYPE_CODE_RANGE
|
||||
|| (ptr_ok && TYPE_CODE (type) == TYPE_CODE_PTR));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue