Fix int() builtin with range type gdb.Value objects.
authorJoel Brobecker <brobecker@adacore.com>
Mon, 18 Nov 2013 08:05:02 +0000 (12:05 +0400)
committerJoel Brobecker <brobecker@adacore.com>
Tue, 19 Nov 2013 02:44:40 +0000 (06:44 +0400)
commitdf7752b044d8ed316827f3887e5afe675d3d243a
tree7729c4c5ddcf59172029109661d74a48274df87d
parent4a0a886ab6202ef83d74063aa9fe3467f815dd4e
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.
gdb/ChangeLog
gdb/python/py-value.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/py_range.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/py_range/foo.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/py_range/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/py_range/pck.ads [new file with mode: 0644]