aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2013-11-18 12:05:02 +0400
committerJoel Brobecker <brobecker@adacore.com>2013-11-19 06:44:40 +0400
commitdf7752b044d8ed316827f3887e5afe675d3d243a (patch)
tree7729c4c5ddcf59172029109661d74a48274df87d /gdb/python
parent4a0a886ab6202ef83d74063aa9fe3467f815dd4e (diff)
downloadgdb-df7752b044d8ed316827f3887e5afe675d3d243a.zip
gdb-df7752b044d8ed316827f3887e5afe675d3d243a.tar.gz
gdb-df7752b044d8ed316827f3887e5afe675d3d243a.tar.bz2
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.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-value.c1
1 files changed, 1 insertions, 0 deletions
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));
}