mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-24 02:37:23 +08:00
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:
@ -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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user