From df7752b044d8ed316827f3887e5afe675d3d243a Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 18 Nov 2013 12:05:02 +0400 Subject: 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 "", line 1, in 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. --- gdb/python/py-value.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gdb/python/py-value.c') diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 07feaf8..451bfaf 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -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)); } -- cgit v1.1