Return gdbpy_ref from gdb_py_object_from_*longest
This changes gdb_py_object_from_longest and gdb_py_object_from_ulongest to return a gdbpy_ref rather than a PyObject*. gdb/ChangeLog 2018-11-04 Tom Tromey <tom@tromey.com> * python/python-internal.h (gdb_py_object_from_longest) (gdb_py_object_from_ulongest): Return gdbpy_ref. * python/py-value.c (valpy_int): Update. * python/py-utils.c (gdb_py_object_from_longest): Return gdbpy_ref. (gdb_py_object_from_ulongest): Likewise. * python/py-type.c (typy_get_alignof): Update. * python/py-linetable.c (ltpy_get_all_source_lines) (ltpy_entry_get_line, ltpy_entry_get_pc): Update. * python/py-block.c (blpy_get_start, blpy_get_end): Update.
This commit is contained in:
parent
9446bd8ad6
commit
12dfa12a3c
7 changed files with 34 additions and 21 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2018-11-04 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/python-internal.h (gdb_py_object_from_longest)
|
||||||
|
(gdb_py_object_from_ulongest): Return gdbpy_ref.
|
||||||
|
* python/py-value.c (valpy_int): Update.
|
||||||
|
* python/py-utils.c (gdb_py_object_from_longest): Return
|
||||||
|
gdbpy_ref.
|
||||||
|
(gdb_py_object_from_ulongest): Likewise.
|
||||||
|
* python/py-type.c (typy_get_alignof): Update.
|
||||||
|
* python/py-linetable.c (ltpy_get_all_source_lines)
|
||||||
|
(ltpy_entry_get_line, ltpy_entry_get_pc): Update.
|
||||||
|
* python/py-block.c (blpy_get_start, blpy_get_end): Update.
|
||||||
|
|
||||||
2018-11-03 Philippe Waroquiers <philippe.waroquiers@skynet.be>
|
2018-11-03 Philippe Waroquiers <philippe.waroquiers@skynet.be>
|
||||||
|
|
||||||
* ada-lang.c (_initialize_ada_language): Fix typo.
|
* ada-lang.c (_initialize_ada_language): Fix typo.
|
||||||
|
|
|
@ -110,7 +110,7 @@ blpy_get_start (PyObject *self, void *closure)
|
||||||
|
|
||||||
BLPY_REQUIRE_VALID (self, block);
|
BLPY_REQUIRE_VALID (self, block);
|
||||||
|
|
||||||
return gdb_py_object_from_ulongest (BLOCK_START (block));
|
return gdb_py_object_from_ulongest (BLOCK_START (block)).release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -120,7 +120,7 @@ blpy_get_end (PyObject *self, void *closure)
|
||||||
|
|
||||||
BLPY_REQUIRE_VALID (self, block);
|
BLPY_REQUIRE_VALID (self, block);
|
||||||
|
|
||||||
return gdb_py_object_from_ulongest (BLOCK_END (block));
|
return gdb_py_object_from_ulongest (BLOCK_END (block)).release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -244,7 +244,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
|
||||||
include in the source set. */
|
include in the source set. */
|
||||||
if (item->line > 0)
|
if (item->line > 0)
|
||||||
{
|
{
|
||||||
gdbpy_ref<> line (gdb_py_object_from_longest (item->line));
|
gdbpy_ref<> line = gdb_py_object_from_longest (item->line);
|
||||||
|
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -327,7 +327,7 @@ ltpy_entry_get_line (PyObject *self, void *closure)
|
||||||
{
|
{
|
||||||
linetable_entry_object *obj = (linetable_entry_object *) self;
|
linetable_entry_object *obj = (linetable_entry_object *) self;
|
||||||
|
|
||||||
return gdb_py_object_from_longest (obj->line);
|
return gdb_py_object_from_longest (obj->line).release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of gdb.LineTableEntry.pc (self) -> Long. Returns a
|
/* Implementation of gdb.LineTableEntry.pc (self) -> Long. Returns a
|
||||||
|
@ -338,7 +338,7 @@ ltpy_entry_get_pc (PyObject *self, void *closure)
|
||||||
{
|
{
|
||||||
linetable_entry_object *obj = (linetable_entry_object *) self;
|
linetable_entry_object *obj = (linetable_entry_object *) self;
|
||||||
|
|
||||||
return gdb_py_object_from_longest (obj->pc);
|
return gdb_py_object_from_longest (obj->pc).release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LineTable iterator functions. */
|
/* LineTable iterator functions. */
|
||||||
|
|
|
@ -755,7 +755,7 @@ typy_get_alignof (PyObject *self, void *closure)
|
||||||
|
|
||||||
/* Ignore exceptions. */
|
/* Ignore exceptions. */
|
||||||
|
|
||||||
return gdb_py_object_from_ulongest (align);
|
return gdb_py_object_from_ulongest (align).release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct type *
|
static struct type *
|
||||||
|
|
|
@ -295,47 +295,47 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
|
||||||
/* Convert a LONGEST to the appropriate Python object -- either an
|
/* Convert a LONGEST to the appropriate Python object -- either an
|
||||||
integer object or a long object, depending on its value. */
|
integer object or a long object, depending on its value. */
|
||||||
|
|
||||||
PyObject *
|
gdbpy_ref<>
|
||||||
gdb_py_object_from_longest (LONGEST l)
|
gdb_py_object_from_longest (LONGEST l)
|
||||||
{
|
{
|
||||||
#ifdef IS_PY3K
|
#ifdef IS_PY3K
|
||||||
if (sizeof (l) > sizeof (long))
|
if (sizeof (l) > sizeof (long))
|
||||||
return PyLong_FromLongLong (l);
|
return gdbpy_ref<> (PyLong_FromLongLong (l));
|
||||||
return PyLong_FromLong (l);
|
return gdbpy_ref<> (PyLong_FromLong (l));
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_LONG_LONG /* Defined by Python. */
|
#ifdef HAVE_LONG_LONG /* Defined by Python. */
|
||||||
/* If we have 'long long', and the value overflows a 'long', use a
|
/* If we have 'long long', and the value overflows a 'long', use a
|
||||||
Python Long; otherwise use a Python Int. */
|
Python Long; otherwise use a Python Int. */
|
||||||
if (sizeof (l) > sizeof (long)
|
if (sizeof (l) > sizeof (long)
|
||||||
&& (l > PyInt_GetMax () || l < (- (LONGEST) PyInt_GetMax ()) - 1))
|
&& (l > PyInt_GetMax () || l < (- (LONGEST) PyInt_GetMax ()) - 1))
|
||||||
return PyLong_FromLongLong (l);
|
return gdbpy_ref<> (PyLong_FromLongLong (l));
|
||||||
#endif
|
#endif
|
||||||
return PyInt_FromLong (l);
|
return gdbpy_ref<> (PyInt_FromLong (l));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert a ULONGEST to the appropriate Python object -- either an
|
/* Convert a ULONGEST to the appropriate Python object -- either an
|
||||||
integer object or a long object, depending on its value. */
|
integer object or a long object, depending on its value. */
|
||||||
|
|
||||||
PyObject *
|
gdbpy_ref<>
|
||||||
gdb_py_object_from_ulongest (ULONGEST l)
|
gdb_py_object_from_ulongest (ULONGEST l)
|
||||||
{
|
{
|
||||||
#ifdef IS_PY3K
|
#ifdef IS_PY3K
|
||||||
if (sizeof (l) > sizeof (unsigned long))
|
if (sizeof (l) > sizeof (unsigned long))
|
||||||
return PyLong_FromUnsignedLongLong (l);
|
return gdbpy_ref<> (PyLong_FromUnsignedLongLong (l));
|
||||||
return PyLong_FromUnsignedLong (l);
|
return gdbpy_ref<> (PyLong_FromUnsignedLong (l));
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_LONG_LONG /* Defined by Python. */
|
#ifdef HAVE_LONG_LONG /* Defined by Python. */
|
||||||
/* If we have 'long long', and the value overflows a 'long', use a
|
/* If we have 'long long', and the value overflows a 'long', use a
|
||||||
Python Long; otherwise use a Python Int. */
|
Python Long; otherwise use a Python Int. */
|
||||||
if (sizeof (l) > sizeof (unsigned long) && l > PyInt_GetMax ())
|
if (sizeof (l) > sizeof (unsigned long) && l > PyInt_GetMax ())
|
||||||
return PyLong_FromUnsignedLongLong (l);
|
return gdbpy_ref<> (PyLong_FromUnsignedLongLong (l));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (l > PyInt_GetMax ())
|
if (l > PyInt_GetMax ())
|
||||||
return PyLong_FromUnsignedLong (l);
|
return gdbpy_ref<> (PyLong_FromUnsignedLong (l));
|
||||||
|
|
||||||
return PyInt_FromLong (l);
|
return gdbpy_ref<> (PyInt_FromLong (l));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1516,9 +1516,9 @@ valpy_int (PyObject *self)
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
if (TYPE_UNSIGNED (type))
|
if (TYPE_UNSIGNED (type))
|
||||||
return gdb_py_object_from_ulongest (l);
|
return gdb_py_object_from_ulongest (l).release ();
|
||||||
else
|
else
|
||||||
return gdb_py_object_from_longest (l);
|
return gdb_py_object_from_longest (l).release ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -705,8 +705,8 @@ extern void gdbpy_convert_exception (struct gdb_exception)
|
||||||
int get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
|
int get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
|
||||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||||
|
|
||||||
PyObject *gdb_py_object_from_longest (LONGEST l);
|
gdbpy_ref<> gdb_py_object_from_longest (LONGEST l);
|
||||||
PyObject *gdb_py_object_from_ulongest (ULONGEST l);
|
gdbpy_ref<> gdb_py_object_from_ulongest (ULONGEST l);
|
||||||
int gdb_py_int_as_long (PyObject *, long *);
|
int gdb_py_int_as_long (PyObject *, long *);
|
||||||
|
|
||||||
PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
|
PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue