This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix bug with command `printf "%s\n", $_as_string($pc)`


On 2017-02-19 12:32, Matthew Malcomson wrote:
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index eb3d307b19..c786f68865 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1615,7 +1615,7 @@ convert_value_from_python (PyObject *obj)
       gdb::unique_xmalloc_ptr<char> s
         = python_string_to_target_string (obj);
       if (s != NULL)
-        value = value_cstring (s.get (), strlen (s.get ()),
+        value = value_cstring (s.get (), strlen (s.get ()) + 1,
                    builtin_type_pychar);
     }
       else if (PyObject_TypeCheck (obj, &value_object_type))

This fix looks good to me.

One test (py-mi.exp) needs to be updated though. You can run all the Python-related tests using:

  $ make check TESTS="gdb.python/*.exp"

Normally, the Python tests all pass reliably, unlike some other parts of the testsuite.

It might also be good to improve gdb.python/py-as-string.exp to include a test for this bug.

Thanks,

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]