aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-29 21:09:02 -0600
committerTom Tromey <tom@tromey.com>2018-04-30 11:33:12 -0600
commit7c66fffc1f3dae0b921ae3cf8139824804cf0705 (patch)
treeb29ace0914f695020f83d745b35062f8e3971f1a /gdb
parentbbfa6f00867946985b954bbec233c0f25f14ac5c (diff)
downloadgdb-7c66fffc1f3dae0b921ae3cf8139824804cf0705.zip
gdb-7c66fffc1f3dae0b921ae3cf8139824804cf0705.tar.gz
gdb-7c66fffc1f3dae0b921ae3cf8139824804cf0705.tar.bz2
Change Python code to use new_reference
This changes a few spots in the Python code to use new_reference rather than the manual incref+constructor that was previously being done. ChangeLog 2018-04-30 Tom Tromey <tom@tromey.com> * varobj.c (varobj_set_visualizer): Use new_reference. * python/python.c (gdbpy_decode_line): Use new_reference. * python/py-cmd.c (cmdpy_function, cmdpy_completer_helper): Use new_reference.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/python/py-cmd.c7
-rw-r--r--gdb/python/python.c10
-rw-r--r--gdb/varobj.c5
4 files changed, 14 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dbac3e8..58640da 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2018-04-30 Tom Tromey <tom@tromey.com>
+ * varobj.c (varobj_set_visualizer): Use new_reference.
+ * python/python.c (gdbpy_decode_line): Use new_reference.
+ * python/py-cmd.c (cmdpy_function, cmdpy_completer_helper): Use
+ new_reference.
+
+2018-04-30 Tom Tromey <tom@tromey.com>
+
* varobj.c (install_new_value): Use new_reference.
* value.h (value_incref): Return void. Swap intro comment with
value_decref.
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index bff445f..27c4689 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -138,8 +138,8 @@ cmdpy_function (struct cmd_list_element *command,
error (_("Could not convert arguments to Python string."));
}
- gdbpy_ref<> ttyobj (from_tty ? Py_True : Py_False);
- Py_INCREF (ttyobj.get ());
+ gdbpy_ref<> ttyobj
+ = gdbpy_ref<>::new_reference (from_tty ? Py_True : Py_False);
gdbpy_ref<> result (PyObject_CallMethodObjArgs ((PyObject *) obj, invoke_cst,
argobj.get (), ttyobj.get (),
NULL));
@@ -246,8 +246,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
if (word == NULL)
{
/* "brkchars" phase. */
- wordobj.reset (Py_None);
- Py_INCREF (Py_None);
+ wordobj = gdbpy_ref<>::new_reference (Py_None);
}
else
{
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 9eae8a1..0dd7d6a 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -876,10 +876,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
}
}
else
- {
- result.reset (Py_None);
- Py_INCREF (Py_None);
- }
+ result = gdbpy_ref<>::new_reference (Py_None);
gdbpy_ref<> return_result (PyTuple_New (2));
if (return_result == NULL)
@@ -892,10 +889,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
return NULL;
}
else
- {
- unparsed.reset (Py_None);
- Py_INCREF (Py_None);
- }
+ unparsed = gdbpy_ref<>::new_reference (Py_None);
PyTuple_SetItem (return_result.get (), 0, unparsed.release ());
PyTuple_SetItem (return_result.get (), 1, result.release ());
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 4656bfa..a0df485 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1455,9 +1455,8 @@ varobj_set_visualizer (struct varobj *var, const char *visualizer)
gdbpy_enter_varobj enter_py (var);
mainmod = PyImport_AddModule ("__main__");
- gdbpy_ref<> globals (PyModule_GetDict (mainmod));
- Py_INCREF (globals.get ());
-
+ gdbpy_ref<> globals
+ = gdbpy_ref<>::new_reference (PyModule_GetDict (mainmod));
gdbpy_ref<> constructor (PyRun_String (visualizer, Py_eval_input,
globals.get (), globals.get ()));