From: Tom Tromey Date: Mon, 17 Aug 2020 14:50:35 +0000 (-0600) Subject: Convert CORE_ADDR to Python using gdb_py_object_from_ulongest X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b017825fabd0ff6f6ff2a8526d50d0b7218606d0;p=binutils-gdb.git Convert CORE_ADDR to Python using gdb_py_object_from_ulongest An internal test failed on a riscv64-elf cross build because Inferior.search_memory returned a negative value. I tracked this down to to use of PyLong_FromLong in infpy_search_memory. Then, I looked at other conversions of CORE_ADDR to Python and fixed these as well. I don't think there is a good way to write a test for this. gdb/ChangeLog 2020-08-17 Tom Tromey * python/py-inferior.c (infpy_search_memory): Use gdb_py_object_from_ulongest. * python/py-infevents.c (create_inferior_call_event_object) (create_memory_changed_event_object): Use gdb_py_object_from_ulongest. * python/py-linetable.c (ltpy_entry_get_pc): Use gdb_py_object_from_ulongest. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d7e56069041..e15dd15f7be 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2020-08-17 Tom Tromey + + * python/py-inferior.c (infpy_search_memory): Use + gdb_py_object_from_ulongest. + * python/py-infevents.c (create_inferior_call_event_object) + (create_memory_changed_event_object): Use + gdb_py_object_from_ulongest. + * python/py-linetable.c (ltpy_entry_get_pc): Use + gdb_py_object_from_ulongest. + 2020-08-17 Simon Marchi * loc.c (class symbol_needs_eval_context): Fix indentation. diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index b9268c11d43..a7699510db7 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -736,7 +736,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) GDB_PY_HANDLE_EXCEPTION (except); if (found) - return PyLong_FromLong (found_addr); + return gdb_py_object_from_ulongest (found_addr).release (); else Py_RETURN_NONE; } diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c index 291cb274424..3cf746103c7 100644 --- a/gdb/python/py-infevents.c +++ b/gdb/python/py-infevents.c @@ -48,7 +48,7 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid, if (evpy_add_attribute (event.get (), "ptid", ptid_obj.get ()) < 0) return NULL; - gdbpy_ref<> addr_obj (PyLong_FromLongLong (addr)); + gdbpy_ref<> addr_obj = gdb_py_object_from_ulongest (addr); if (addr_obj == NULL) return NULL; @@ -97,7 +97,7 @@ create_memory_changed_event_object (CORE_ADDR addr, ssize_t len) if (event == NULL) return NULL; - gdbpy_ref<> addr_obj (PyLong_FromLongLong (addr)); + gdbpy_ref<> addr_obj = gdb_py_object_from_ulongest (addr); if (addr_obj == NULL) return NULL; diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index 858313bb22d..49e98c0d898 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -336,7 +336,7 @@ ltpy_entry_get_pc (PyObject *self, void *closure) { linetable_entry_object *obj = (linetable_entry_object *) self; - return gdb_py_object_from_longest (obj->pc).release (); + return gdb_py_object_from_ulongest (obj->pc).release (); } /* LineTable iterator functions. */