]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix break on Python 2
authorTim Wiederhake <tim.wiederhake@intel.com>
Tue, 21 Mar 2017 07:19:59 +0000 (08:19 +0100)
committerTim Wiederhake <tim.wiederhake@intel.com>
Tue, 21 Mar 2017 07:19:59 +0000 (08:19 +0100)
This changes the return type of "gdb.BtraceInstruction.data ()" from
"memoryview" to "buffer" on Python 2.7 and below, similar to what
"gdb.Inferior.read_memory ()" does.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/py-record-btrace.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-record-btrace.exp

index 02ab32c697f9c170def9f7ae0876f00605e4f465..95c847bc79a51d5220c16aff0dea2b7f3251e100 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-21  Tim Wiederhake  <tim.wiederhake@intel.com>
+
+       * python/py-record-btrace.c (btpy_insn_data): Change return type
+       for Python 2.
+
 2017-03-20  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * spu-linux-nat.c (spu_fetch_inferior_registers,
index 1657ab83d31188f5df9899451a87dc81f5dedeb5..8253cbeac8f2c01db4efb96d8feca0c7878405b1 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-21  Tim Wiederhake  <tim.wiederhake@intel.com>
+
+       * python.texi (Recordings In Python): Document return type of
+       gdb.BtraceInstruction.data.
+
 2017-03-20  Marc-Andre Laperle  <marc-andre.laperle@ericsson.com>
 
        * gdb.texinfo (gdb/mi Symbol Query Commands): Document new MI
index f6ec08c7aa2b53bbb523db209135583b55d05009..1fb8b2599112a5123914ea648f51fad1601a4cd7 100644 (file)
@@ -3185,7 +3185,8 @@ if the instruction is a gap or the debug symbols could not be read.
 
 @defvar BtraceInstruction.data
 A buffer with the raw instruction data.  May be @code{None} if the
-instruction is a gap.
+instruction is a gap.  In Python 3, the return value is a @code{memoryview}
+object.
 @end defvar
 
 @defvar BtraceInstruction.decoded
index 6158f31fe9a1324d904a98ac3d479610c8263a23..c8163326d01cfec37cc834377a3b6b7b3f3f6695 100644 (file)
@@ -330,7 +330,12 @@ btpy_insn_data (PyObject *self, void *closure)
   if (object == NULL)
     return NULL;
 
+#ifdef IS_PY3K
   return PyMemoryView_FromObject (object);
+#else
+  return PyBuffer_FromObject (object, 0, Py_END_OF_BUFFER);
+#endif
+
 }
 
 /* Implementation of BtraceInstruction.decode [str].  Returns
index 2853d8a3b869f587dcd1354a51e2ba98c1fda47f..7937ee8f62fe2bd6b7c7663d75a4f87ca25d2afb 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-21  Tim Wiederhake  <tim.wiederhake@intel.com>
+
+       * gdb.python/py-record-btrace.exp: Check for buffer on Python 2
+       and memory view on Python 3.
+
 2017-03-20  Artemiy Volkov  <artemiyv@acm.org>
            Keith Seitz  <keiths@redhat.com>
 
index 65a3e7d041395c7be6667e7741672b1e6d08ead7..7752cac5b796aa8af818ccc7957e3846ba1d4d5c 100644 (file)
@@ -85,7 +85,11 @@ with_test_prefix "instruction " {
     gdb_test "python print(i.error)" "None"
     gdb_test "python print(i.sal)" "symbol and line for .*"
     gdb_test "python print(i.pc)" "$decimal"
-    gdb_test "python print(i.data)" "<memory at $hex>"
+    if { $gdb_py_is_py3k == 0 } {
+       gdb_test "python print(repr(i.data))" "<read-only buffer for $hex,.*>"
+    } else {
+       gdb_test "python print(repr(i.data))" "<memory at $hex>"
+    }
     gdb_test "python print(i.decoded)" ".*"
     gdb_test "python print(i.size)" "$decimal"
     gdb_test "python print(i.is_speculative)" "False"