Don't use gdb_py_long_from_longest
authorTom Tromey <tromey@adacore.com>
Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)
Change the Python layer to avoid gdb_py_long_from_longest, and remove
the defines.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python-internal.h (gdb_py_long_from_longest): Remove
defines.
* python/py-value.c (valpy_long): Use gdb_py_object_from_longest.
* python/py-type.c (convert_field, typy_get_sizeof): Use
gdb_py_object_from_longest.
* python/py-record-btrace.c (btpy_list_index): Use
gdb_py_object_from_longest.

gdb/ChangeLog
gdb/python/py-record-btrace.c
gdb/python/py-type.c
gdb/python/py-value.c
gdb/python/python-internal.h

index 8a7ad2abe75fa80779d2153681b63b31a7ae837a..6df6633b00ab0d6a3f171d965e2648f9be69a47b 100644 (file)
@@ -1,3 +1,13 @@
+2020-09-15  Tom Tromey  <tromey@adacore.com>
+
+       * python/python-internal.h (gdb_py_long_from_longest): Remove
+       defines.
+       * python/py-value.c (valpy_long): Use gdb_py_object_from_longest.
+       * python/py-type.c (convert_field, typy_get_sizeof): Use
+       gdb_py_object_from_longest.
+       * python/py-record-btrace.c (btpy_list_index): Use
+       gdb_py_object_from_longest.
+
 2020-09-15  Tom Tromey  <tromey@adacore.com>
 
        * python/python-internal.h (PyInt_FromSsize_t): Remove define.
index 08613a856d07ac8a123aa9824cfbdccd1a7e7c8e..84a3d9eae73caf2ecb40318619283ba289526f94 100644 (file)
@@ -556,7 +556,7 @@ btpy_list_index (PyObject *self, PyObject *value)
   if (index < 0)
     return PyErr_Format (PyExc_ValueError, _("Not in list."));
 
-  return gdb_py_long_from_longest (index);
+  return gdb_py_object_from_longest (index).release ();
 }
 
 /* Implementation of BtraceList.count (self, value) -> int.  */
index 2e175b641d85528de6587255753e514cf6f3b811..229fde37efec9ccd547bf4e7a3e9accab71c0b52 100644 (file)
@@ -183,8 +183,7 @@ convert_field (struct type *type, int field)
 
       if (type->code () == TYPE_CODE_ENUM)
        {
-         arg.reset (gdb_py_long_from_longest (TYPE_FIELD_ENUMVAL (type,
-                                                                  field)));
+         arg = gdb_py_object_from_longest (TYPE_FIELD_ENUMVAL (type, field));
          attrstring = "enumval";
        }
       else
@@ -192,8 +191,7 @@ convert_field (struct type *type, int field)
          if (TYPE_FIELD_LOC_KIND (type, field) == FIELD_LOC_KIND_DWARF_BLOCK)
            arg = gdbpy_ref<>::new_reference (Py_None);
          else
-           arg.reset (gdb_py_long_from_longest (TYPE_FIELD_BITPOS (type,
-                                                                   field)));
+           arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field));
          attrstring = "bitpos";
        }
 
@@ -725,7 +723,7 @@ typy_get_sizeof (PyObject *self, void *closure)
 
   if (size_varies)
     Py_RETURN_NONE;
-  return gdb_py_long_from_longest (TYPE_LENGTH (type));
+  return gdb_py_object_from_longest (TYPE_LENGTH (type)).release ();
 }
 
 /* Return the alignment of the type represented by SELF, in bytes.  */
index 2d9e77aef2bbc100f717020ab4ae2d5a86826ab2..504a9de9cee363264285e46a0eff0392a5a21b48 100644 (file)
@@ -1733,7 +1733,7 @@ valpy_long (PyObject *self)
   if (type->is_unsigned ())
     return gdb_py_long_from_ulongest (l);
   else
-    return gdb_py_long_from_longest (l);
+    return gdb_py_object_from_longest (l).release ();
 }
 
 /* Implements conversion to float.  */
index e406f37533ec34c72f0e8415d01ae7028b12e7be..b93c78fd6e1d52f14f0ba85d9b5765e3e9d2fb62 100644 (file)
 #define GDB_PY_LLU_ARG "K"
 typedef PY_LONG_LONG gdb_py_longest;
 typedef unsigned PY_LONG_LONG gdb_py_ulongest;
-#define gdb_py_long_from_longest PyLong_FromLongLong
 #define gdb_py_long_from_ulongest PyLong_FromUnsignedLongLong
 #define gdb_py_long_as_ulongest PyLong_AsUnsignedLongLong
 
@@ -136,7 +135,6 @@ typedef unsigned PY_LONG_LONG gdb_py_ulongest;
 #define GDB_PY_LLU_ARG "K"
 typedef long gdb_py_longest;
 typedef unsigned long gdb_py_ulongest;
-#define gdb_py_long_from_longest PyLong_FromLong
 #define gdb_py_long_from_ulongest PyLong_FromUnsignedLong
 #define gdb_py_long_as_ulongest PyLong_AsUnsignedLong