From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Wu1wGuH8/2GWDgAAWB0awg (envelope-from ) for ; Sun, 06 Feb 2022 11:52:49 -0500 Received: by simark.ca (Postfix, from userid 112) id 59B511F3C6; Sun, 6 Feb 2022 11:52:49 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DCDAA1ECEB for ; Sun, 6 Feb 2022 11:52:48 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D19B3858422 for ; Sun, 6 Feb 2022 16:52:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D19B3858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1644166368; bh=gs5GWRayTEY1W8AvTAfMQiMcmedLczdu8Cz3XE6Twk4=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=vHbUyYEyd3dzUUvuDs2WEOjDNN/XPMxl83KEdRT/0XPZFjWeRty9XgXvdVgRIaOiO mFTrcELuCmLYVnWaw7nBJQ9DV3KYuwxQ3ejznhvZorMjWQeebA8SxTo5gF54QKmQHp wWzdOa+4270WeK6UzDZGVSJPWc2WJT5ECD+//Nn8= 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 To: Jan Vrany 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-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: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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.