+2018-09-23 Tom Tromey <tom@tromey.com>
+
+ PR python/18170:
+ * python/py-value.c (valpy_int): Allow conversion from pointer
+ type.
+
2018-09-23 Tom Tromey <tom@tromey.com>
PR python/20126:
value = value_cast (type, value);
}
- if (!is_integral_type (type))
+ if (!is_integral_type (type)
+ && TYPE_CODE (type) != TYPE_CODE_PTR)
error (_("Cannot convert value to int."));
l = value_as_long (value);
+2018-09-23 Tom Tromey <tom@tromey.com>
+
+ PR python/18170:
+ * gdb.python/py-value.exp (test_value_numeric_ops): Add tests to
+ convert pointers to int and long.
+
2018-09-23 Tom Tromey <tom@tromey.com>
PR python/20126:
gdb_test "print (void *) 5" ".*" ""
gdb_test_no_output "python b = gdb.history (0)" ""
+ gdb_test "python print(int(b))" "5" "convert pointer to int"
+ if {!$gdb_py_is_py3k} {
+ gdb_test "python print(long(b))" "5" "convert pointer to long"
+ }
+
gdb_test "python print ('result = ' + str(a+5))" " = 0x7( <.*>)?" "add pointer value with python integer"
gdb_test "python print ('result = ' + str(b-2))" " = 0x3( <.*>)?" "subtract python integer from pointer value"
gdb_test "python print ('result = ' + str(b-a))" " = 3" "subtract two pointer values"
"result = r" "use value as string index"
gdb_test "python print ('result = ' + str((1,2,3)\[gdb.Value(0)\]))" \
"result = 1" "use value as tuple index"
- gdb_test "python print ('result = ' + str(\[1,2,3\]\[gdb.Value(0)\]))" \
- "result = 1" "use value as array index"
+ if {!$gdb_py_is_py3k} {
+ gdb_test "python print ('result = ' + str(\[1,2,3\]\[gdb.Value(0)\]))" \
+ "result = 1" "use value as array index"
+ }
gdb_test "python print('%x' % int(gdb.parse_and_eval('-1ull')))" \
"f+" "int conversion respect type sign"