From fb6a3ed3936ceb4a40d9a3b8ee53ebc561e50431 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 28 Feb 2011 19:38:34 +0000 Subject: * python/python.c (gdbpy_value_cst): New global. (_initialize_python): Initialize it. * python/python-internal.h (gdbpy_value_cst): Declare. * python/py-value.c (convert_value_from_python): Use gdbpy_value_cst. --- gdb/ChangeLog | 8 ++++++++ gdb/python/py-value.c | 3 +-- gdb/python/python-internal.h | 1 + gdb/python/python.c | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 172625b..c0938a4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2011-02-28 Tom Tromey + + * python/python.c (gdbpy_value_cst): New global. + (_initialize_python): Initialize it. + * python/python-internal.h (gdbpy_value_cst): Declare. + * python/py-value.c (convert_value_from_python): Use + gdbpy_value_cst. + 2011-02-28 Michael Snyder * python/py-cmd.c (cmdpy_init): Fix memory leak. diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 0eda620..515eaec 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1162,9 +1162,8 @@ convert_value_from_python (PyObject *obj) else if (gdbpy_is_lazy_string (obj)) { PyObject *result; - PyObject *function = PyString_FromString ("value"); - result = PyObject_CallMethodObjArgs (obj, function, NULL); + result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst, NULL); value = value_copy (((value_object *) result)->value); } else diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 49b6acf..d3cb788 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -271,6 +271,7 @@ extern PyObject *gdbpy_children_cst; extern PyObject *gdbpy_to_string_cst; extern PyObject *gdbpy_display_hint_cst; extern PyObject *gdbpy_enabled_cst; +extern PyObject *gdbpy_value_cst; /* Exception types. */ extern PyObject *gdbpy_gdb_error; diff --git a/gdb/python/python.c b/gdb/python/python.c index 2977a56..3b10d8c 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -62,6 +62,7 @@ PyObject *gdbpy_children_cst; PyObject *gdbpy_display_hint_cst; PyObject *gdbpy_doc_cst; PyObject *gdbpy_enabled_cst; +PyObject *gdbpy_value_cst; /* The GdbError exception. */ PyObject *gdbpy_gdberror_exc; @@ -1015,6 +1016,7 @@ Enables or disables printing of Python stack traces."), gdbpy_display_hint_cst = PyString_FromString ("display_hint"); gdbpy_doc_cst = PyString_FromString ("__doc__"); gdbpy_enabled_cst = PyString_FromString ("enabled"); + gdbpy_value_cst = PyString_FromString ("value"); /* Release the GIL while gdb runs. */ PyThreadState_Swap (NULL); -- cgit v1.1