From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 04F703858D3C for ; Sun, 6 Feb 2022 16:52:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 04F703858D3C Received: from Plymouth (unknown [IPv6:2a02:390:9086:0:7df6:51f9:bb25:44c1]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 1DD2B80D5D; Sun, 6 Feb 2022 16:52:29 +0000 (UTC) Date: Sun, 6 Feb 2022 16:52:24 +0000 From: Lancelot SIX To: Jan Vrany Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/5] gdb/python: create GDB/MI commands using python. Message-ID: <20220206165224.qan7fagj756av3y5@Plymouth> References: <20220117124425.2658516-1-jan.vrany@labware.com> <20220117124425.2658516-3-jan.vrany@labware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220117124425.2658516-3-jan.vrany@labware.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Sun, 06 Feb 2022 16:52:29 +0000 (UTC) X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2022 16:52:31 -0000 Hi, I just have minor comments. See below. > +#include "defs.h" > +#include "python-internal.h" > +#include "python/py-micmd.h" > +#include "arch-utils.h" > +#include "charset.h" > +#include "language.h" > + > +#include > + > +static PyObject *invoke_cst; > + > +extern PyTypeObject > + micmdpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("micmdpy_object"); > + > +/* If the command invoked returns a list, this function parses it and create an ^ creates ? > + appropriate MI out output. > + > + The returned values must be Python string, and can be contained within Python > + lists and dictionaries. It is possible to have a multiple levels of lists > + and/or dictionaries. */ > + > +static void > +parse_mi_result (PyObject *result, const char *field_name) > +{ > + struct ui_out *uiout = current_uiout; > + > + if (PyDict_Check (result)) > + { > + PyObject *key, *value; > + Py_ssize_t pos = 0; > + ui_out_emit_tuple tuple_emitter (uiout, field_name); > + while (PyDict_Next (result, &pos, &key, &value)) > + { > + if (!PyString_Check (key)) > + { > + gdbpy_ref<> key_repr (PyObject_Repr (key)); > + if (PyErr_Occurred () != NULL) Ideally, s/NULL/nullptr/ on the patch. You use nullptr in few places already. > + try > + { > + mi_command_up micommand = mi_command_up(new mi_command_py (name + 1, self_ref)); > + > + bool result = insert_mi_cmd_entry (std::move (micommand)); > + > + if (!result) > + { > + error (_("Unable to insert command." > + "The name might already be in use.")); The two strings will be concatenated. You might want to ensure a space is added between the "." and "The" here. For the rest, I am not very familiar with the python bindings, so I mainly skimmed through the patch. Best, Lancelot.