Convert CORE_ADDR to Python using gdb_py_object_from_ulongest
authorTom Tromey <tromey@adacore.com>
Mon, 17 Aug 2020 14:50:35 +0000 (08:50 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 17 Aug 2020 14:50:35 +0000 (08:50 -0600)
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  <tromey@adacore.com>

* 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.

gdb/ChangeLog
gdb/python/py-inferior.c
gdb/python/py-infevents.c
gdb/python/py-linetable.c

index d7e560690416b45c70be983e5f5226f36429aa0c..e15dd15f7be4ee326afd584f740de4ae57edb196 100644 (file)
@@ -1,3 +1,13 @@
+2020-08-17  Tom Tromey  <tromey@adacore.com>
+
+       * 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  <simon.marchi@polymtl.ca>
 
        * loc.c (class symbol_needs_eval_context): Fix indentation.
index b9268c11d4385b6eeef25aa0e92222c796ed30eb..a7699510db717fb45fd85624ce590f541c9b8ba8 100644 (file)
@@ -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;
 }
index 291cb274424180bcd9fb804dd8b55fb69d71052c..3cf746103c7fb1816a25bd7380719f260eff7a19 100644 (file)
@@ -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;
 
index 858313bb22d033238c0a9862ac34edf50ab084c4..49e98c0d8988493616721994bb9a12c1a35b1ca8 100644 (file)
@@ -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.  */