This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb/python: Make cmdpy_completer_helper return gdbpy_ref<>
- From: Andrew Burgess <aburgess at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 25 Oct 2018 11:23:54 -0000
- Subject: [binutils-gdb] gdb/python: Make cmdpy_completer_helper return gdbpy_ref<>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=50db9ef4c014d28dd64b2d660b043a40224a1a27
commit 50db9ef4c014d28dd64b2d660b043a40224a1a27
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Mon Sep 10 11:48:28 2018 +0100
gdb/python: Make cmdpy_completer_helper return gdbpy_ref<>
Make cmdpy_completer_helper return a gdbpy_ref<> directly rather than
building a gdbpy_ref<>, releasing it, and then having a new
gdbpy_ref<> created to hold the result.
gdb/ChangeLog:
* python/py-cmd.c (cmdpy_completer_helper): Return gdbpy_ref<>.
(cmdpy_completer_handle_brkchars): Adjust.
(cmdpy_completer): Adjust.
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/python/py-cmd.c | 16 ++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 14de366..6ab2ec8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2018-10-25 Andrew Burgess <andrew.burgess@embecosm.com>
+ * python/py-cmd.c (cmdpy_completer_helper): Return gdbpy_ref<>.
+ (cmdpy_completer_handle_brkchars): Adjust.
+ (cmdpy_completer): Adjust.
+
+2018-10-25 Andrew Burgess <andrew.burgess@embecosm.com>
+
* riscv-linux-nat.c (riscv_linux_nat_target::fetch_registers):
Pass correct regnum to raw_supply_zeroed.
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index e7eb66f..d560b3a 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -174,10 +174,10 @@ cmdpy_function (struct cmd_list_element *command,
and then a "complete"-completion sequentially. Therefore, we just
recalculate everything twice for TAB-completions.
- This function returns the PyObject representing the Python method
- call. */
+ This function returns a reference to the PyObject representing the
+ Python method call. */
-static PyObject *
+static gdbpy_ref<>
cmdpy_completer_helper (struct cmd_list_element *command,
const char *text, const char *word)
{
@@ -220,7 +220,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
PyErr_Clear ();
}
- return resultobj.release ();
+ return resultobj;
}
/* Python function called to determine the break characters of a
@@ -235,9 +235,9 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
{
gdbpy_enter enter_py (get_current_arch (), current_language);
- /* Calling our helper to obtain the PyObject of the Python
+ /* Calling our helper to obtain a reference to the PyObject of the Python
function. */
- gdbpy_ref<> resultobj (cmdpy_completer_helper (command, text, word));
+ gdbpy_ref<> resultobj = cmdpy_completer_helper (command, text, word);
/* Check if there was an error. */
if (resultobj == NULL)
@@ -278,9 +278,9 @@ cmdpy_completer (struct cmd_list_element *command,
{
gdbpy_enter enter_py (get_current_arch (), current_language);
- /* Calling our helper to obtain the PyObject of the Python
+ /* Calling our helper to obtain a reference to the PyObject of the Python
function. */
- gdbpy_ref<> resultobj (cmdpy_completer_helper (command, text, word));
+ gdbpy_ref<> resultobj = cmdpy_completer_helper (command, text, word);
/* If the result object of calling the Python function is NULL, it
means that there was an error. In this case, just give up. */