From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.133.114]) by sourceware.org (Postfix) with ESMTPS id E5EAA3875DCE for ; Tue, 10 Oct 2023 10:28:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5EAA3875DCE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-JqMw-8EIOYqn29k5WHKbYA-1; Tue, 10 Oct 2023 06:28:16 -0400 X-MC-Unique: JqMw-8EIOYqn29k5WHKbYA-1 Received: from SA0PR17MB4314.namprd17.prod.outlook.com (2603:10b6:806:e7::16) by DS0PR17MB7063.namprd17.prod.outlook.com (2603:10b6:8:ff::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 10:28:14 +0000 Received: from SA0PR17MB4314.namprd17.prod.outlook.com ([fe80::30eb:4c4a:cb5a:dd91]) by SA0PR17MB4314.namprd17.prod.outlook.com ([fe80::30eb:4c4a:cb5a:dd91%4]) with mapi id 15.20.6863.032; Tue, 10 Oct 2023 10:28:14 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany , Andrew Burgess Subject: [pushed] gdb/python: generalize serialize_mi_result() Date: Tue, 10 Oct 2023 11:27:56 +0100 Message-ID: <20231010102757.115874-1-jan.vrany@labware.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: LO4P265CA0250.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::12) To SA0PR17MB4314.namprd17.prod.outlook.com (2603:10b6:806:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR17MB4314:EE_|DS0PR17MB7063:EE_ X-MS-Office365-Filtering-Correlation-Id: 534f4e27-0d6f-4ec0-2129-08dbc97b9c1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: cL4P0uJTTEfXoHQF36/tLmA7myPABQlTlbQ87TbJTVzvSpSS/Pk3pU7fnaJSL1pJEofXkYeLSj4/eyatB3CzH0wYRieeCgZwR++PAG3XUWiRlBbj+QMqa7xkvYTE5c7gKrHy+Aa57iKgfptzu6T8OU9IAypCZ38WpPlq0dWrfCRK5y08XT1YQzF0oqhe8UHoF1Prjyc+sxaCWA/5pqNWdPqF95Epd0XhIcF9a8uBfWXJMiY1x7wNI7FDlvfHfZM/j+YUJkNO8aIrh9Iu1SVtYfz4BKsLLL7cpXCMhYxNUQspCsXgUfppnmvYZ1yHJpiI9M0WcIeuyzstHEyj8wH2rmfvZEoo8t2WGsWiutm4npNzrN2kxh/yYomEmIw6vfzOhMcNk4X0OqMWJpUlZlhwufmiQ4vB5OFC0nktWXWFd+4Vm7pTAWHw/h7iaYLbXfa5LIgpGO4v9Oj4me2JHu2GsxkFJbiihi7jh3YYTSS3PpgiGOX25Zv4CF1juEJ5+hYAvgoZzzUrCI0RtJZazBuKZNOWlZm+6viiDUweWidz1pQFwmXfFvle/bCwZ8GYcH22 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR17MB4314.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39850400004)(376002)(396003)(136003)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(6506007)(41300700001)(26005)(8936002)(83380400001)(8676002)(38100700002)(4326008)(66556008)(66946007)(66476007)(6512007)(6916009)(5660300002)(6486002)(1076003)(54906003)(2616005)(478600001)(2906002)(44832011)(316002)(6666004)(30864003)(36756003)(86362001);DIR:OUT;SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Fl918QI7wX6HR/PeUlcj9vdQLTHp1XfLyoCzaq1AvoWIr9kq4qazBAqv6QpI?= =?us-ascii?Q?lSetdupEojBpjY7OHDbdMtg+JGkwfw0GM8skQ2WMNwwmf1tUSmGTswbLxkO1?= =?us-ascii?Q?EB9/CLXd53BaOZ4pPdr1rt8yjDiEUc6qa++Wcwad79rllXHoZIsKtWDm49LJ?= =?us-ascii?Q?56/IpFtrFxsJuyy5dczT7MwF1+uaZvDpEofTO7JyA7ZeAnZ2+deL409U8Bil?= =?us-ascii?Q?nnKGb3dfyKCurPXgw1qgmr+tZo38Pq6TzDSHIEd4/JzwZH9bEVh0TD655+Yr?= =?us-ascii?Q?idXsQc8C8JuJn6jW0hWuNdsM78RvBfg4635qk/wTVfdThDuLNuLtm2cnJjjH?= =?us-ascii?Q?DSB9FJINzMqCoePrQbPTf0vq1dJkZGEOprVNYYvfVMooSp1Xr163gMgKfsNd?= =?us-ascii?Q?jHnQ3CtLpxZ1r2Gp3cgY2cNmnmPcyNzq7ZKM4GLNEpJny6RBl2fTkqY14jc/?= =?us-ascii?Q?oZilcIqzg+O/UUp+beCh07GB0dajOCWdGvbAmbzIMI3kO1/qbEWHqSdpyhWJ?= =?us-ascii?Q?SpaKFFXrjqw2OhnUWJC3KD80Eahfj1xc6E95De0fDBmRSaDzBbLhiuXqXzSl?= =?us-ascii?Q?TU6Nu4pI2UPYByYsSm8leylYrVl18PP3TZ5BZ1Aw0q/zEWi7ATZ0sIMJDxQt?= =?us-ascii?Q?K0i/aJ1zGlXUG7Sh8ahNHP67xd3bSY9Znyv2atPmUR8kPGzZXqPSv59TVs6W?= =?us-ascii?Q?qbVulDvuj/lOE753vDpSxDqPzYpfQ58y0IYQnXHil8QdWto4GojEyANYUgNX?= =?us-ascii?Q?KIIzRihcorW+BBPb9H1PMMeh1uENFEXk9BbeQcZ/Y43wdcuE73MbdqveZWOw?= =?us-ascii?Q?GoB3xbPSOWuhsyXC3iV+SyrLP8BaCRdrFQ294Gjm8/6CWqXLt5jT86CEmzQE?= =?us-ascii?Q?bJroCHeAs4wQw1MqF5nIlqGNWqBQ9qB5qIguEarDs19M/bBioKPKB6wr4trp?= =?us-ascii?Q?ndKu02QAFdurSsIZeDzyZDy63vDjcqS9ecFd+vTK2YlLR0rsAsJbLIO/RK5M?= =?us-ascii?Q?yoBLSt2YJTkiwAojhA32lOD24N+kSq4cmfbUcXAHJGE0wILtwJgaT8VUVPVJ?= =?us-ascii?Q?BW0n0wwUc5KzhjmC4CQKBoJu08J8UJG244X9ys2QKxBNHrjLDUEndYXN/AvJ?= =?us-ascii?Q?ImUTILC0cAFbjnnWeEV8bRz4vyfkXXHn0NQPK7n73fhvrg/2WiUgytAgJH6h?= =?us-ascii?Q?ktaRiXlJuLuSGzuUlpBDcYfpWecUQ1Iy+EFvh9DROBLyNREh1wikbdXh8f0N?= =?us-ascii?Q?0gj1IflWHQlz4yVEQqwFWjhbO0hKC3qgvh33dPVrWh6qZToD/PFMSyR9w+Gp?= =?us-ascii?Q?8wElYeMFCtMNRut1S1/lCE9Rac+W2eb8Zu025vOQLqyfZXxma/1AV5/pGbob?= =?us-ascii?Q?Qm6YUZAuxY+Z6Qk/zZiHmgssd4EWLHJdlXlLjiTB5mKmnPAfBpa1Sgt4fV6a?= =?us-ascii?Q?8CHRhfErZXRE7TmGmO1XpmIBJXk+YhcOT6nbWYwDIx6+Xuct5NfphqXhpw65?= =?us-ascii?Q?iVogYnVIyoXYAMp+RJd1rEt3w7y6jRoHjVPAF79pJ5FduyIStVVnO6K2syB5?= =?us-ascii?Q?FrHUs4Zu67HXrYvMy86rnW8+J+s2Rz3ZHkChm1gs?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 534f4e27-0d6f-4ec0-2129-08dbc97b9c1d X-MS-Exchange-CrossTenant-AuthSource: SA0PR17MB4314.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 10:28:14.3144 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rtXhhwsRq2S2Qboq6YIof5E+iL75Cpn8dq35QCIcWW4KSCDm5ieHPp6PBf+/u0NQTm8kUGeQWhpEREneE5/t0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR17MB7063 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This commit generalizes serialize_mi_result() to make usable in different contexts than printing result of custom MI command. To do so, the check whether passed Python object is a dictionary has been moved to the caller - at the very least, different uses require different error messages. Also it has been renamed to serialize_mi_results() to bett= er match GDB/MI output syntax (see corresponding section in documentation, in particular rules 'result-record' and 'async-output'. Since it is now more generic function, it has been moved to py-mi.c. This is a preparation for implementing Python support for sending custom MI async events. Approved-By: Andrew Burgess --- gdb/python/py-mi.c | 159 ++++++++++++++++++++++++++++++ gdb/python/py-micmd.c | 185 ++--------------------------------- gdb/python/python-internal.h | 13 +++ 3 files changed, 181 insertions(+), 176 deletions(-) diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index 66dc6fb8a32..36bcb6ceece 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -296,3 +296,162 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *a= rgs, PyObject *kw) =20 return uiout.result (); } + +/* Convert KEY_OBJ into a string that can be used as a field name in MI + output. KEY_OBJ must be a Python string object, and must only contain + characters suitable for use as an MI field name. + + If KEY_OBJ is not a string, or if KEY_OBJ contains invalid characters, + then an error is thrown. Otherwise, KEY_OBJ is converted to a string + and returned. */ + +static gdb::unique_xmalloc_ptr +py_object_to_mi_key (PyObject *key_obj) +{ + /* The key must be a string. */ + if (!PyUnicode_Check (key_obj)) + { + gdbpy_ref<> key_repr (PyObject_Repr (key_obj)); + gdb::unique_xmalloc_ptr key_repr_string; + if (key_repr !=3D nullptr) +=09key_repr_string =3D python_string_to_target_string (key_repr.get ()); + if (key_repr_string =3D=3D nullptr) +=09gdbpy_handle_exception (); + + gdbpy_error (_("non-string object used as key: %s"), +=09=09 key_repr_string.get ()); + } + + gdb::unique_xmalloc_ptr key_string + =3D python_string_to_target_string (key_obj); + if (key_string =3D=3D nullptr) + gdbpy_handle_exception (); + + /* Predicate function, returns true if NAME is a valid field name for us= e + in MI result output, otherwise, returns false. */ + auto is_valid_key_name =3D [] (const char *name) -> bool + { + gdb_assert (name !=3D nullptr); + + if (*name =3D=3D '\0' || !isalpha (*name)) + return false; + + for (; *name !=3D '\0'; ++name) + if (!isalnum (*name) && *name !=3D '_' && *name !=3D '-') +=09return false; + + return true; + }; + + if (!is_valid_key_name (key_string.get ())) + { + if (*key_string.get () =3D=3D '\0') +=09gdbpy_error (_("Invalid empty key in MI result")); + else +=09gdbpy_error (_("Invalid key in MI result: %s"), key_string.get ()); + } + + return key_string; +} + +/* Serialize RESULT and print it in MI format to the current_uiout. + FIELD_NAME is used as the name of this result field. + + RESULT can be a dictionary, a sequence, an iterator, or an object that + can be converted to a string, these are converted to the matching MI + output format (dictionaries as tuples, sequences and iterators as lists= , + and strings as named fields). + + If anything goes wrong while formatting the output then an error is + thrown. + + This function is the recursive inner core of serialize_mi_result, and + should only be called from that function. */ + +static void +serialize_mi_result_1 (PyObject *result, const char *field_name) +{ + struct ui_out *uiout =3D current_uiout; + + if (PyDict_Check (result)) + { + PyObject *key, *value; + Py_ssize_t pos =3D 0; + ui_out_emit_tuple tuple_emitter (uiout, field_name); + while (PyDict_Next (result, &pos, &key, &value)) +=09{ +=09 gdb::unique_xmalloc_ptr key_string +=09 (py_object_to_mi_key (key)); +=09 serialize_mi_result_1 (value, key_string.get ()); +=09} + } + else if (PySequence_Check (result) && !PyUnicode_Check (result)) + { + ui_out_emit_list list_emitter (uiout, field_name); + Py_ssize_t len =3D PySequence_Size (result); + if (len =3D=3D -1) +=09gdbpy_handle_exception (); + for (Py_ssize_t i =3D 0; i < len; ++i) +=09{ +=09 gdbpy_ref<> item (PySequence_ITEM (result, i)); +=09 if (item =3D=3D nullptr) +=09 gdbpy_handle_exception (); +=09 serialize_mi_result_1 (item.get (), nullptr); +=09} + } + else if (PyIter_Check (result)) + { + gdbpy_ref<> item; + ui_out_emit_list list_emitter (uiout, field_name); + while (true) +=09{ +=09 item.reset (PyIter_Next (result)); +=09 if (item =3D=3D nullptr) +=09 { +=09 if (PyErr_Occurred () !=3D nullptr) +=09=09gdbpy_handle_exception (); +=09 break; +=09 } +=09 serialize_mi_result_1 (item.get (), nullptr); +=09} + } + else + { + if (PyLong_Check (result)) +=09{ +=09 int overflow =3D 0; +=09 gdb_py_longest val =3D gdb_py_long_as_long_and_overflow (result, +=09=09=09=09=09=09=09=09 &overflow); +=09 if (PyErr_Occurred () !=3D nullptr) +=09 gdbpy_handle_exception (); +=09 if (overflow =3D=3D 0) +=09 { +=09 uiout->field_signed (field_name, val); +=09 return; +=09 } +=09 /* Fall through to the string case on overflow. */ +=09} + + gdb::unique_xmalloc_ptr string (gdbpy_obj_to_string (result)); + if (string =3D=3D nullptr) +=09gdbpy_handle_exception (); + uiout->field_string (field_name, string.get ()); + } +} + +/* See python-internal.h. */ + +void +serialize_mi_results (PyObject *results) +{ + gdb_assert (PyDict_Check (results)); + + PyObject *key, *value; + Py_ssize_t pos =3D 0; + while (PyDict_Next (results, &pos, &key, &value)) + { + gdb::unique_xmalloc_ptr key_string +=09(py_object_to_mi_key (key)); + serialize_mi_result_1 (value, key_string.get ()); + } +} diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c index 01fc6060ece..0153f84e7a0 100644 --- a/gdb/python/py-micmd.c +++ b/gdb/python/py-micmd.c @@ -173,178 +173,6 @@ extern PyTypeObject micmdpy_object_type =20 static PyObject *invoke_cst; =20 -/* Convert KEY_OBJ into a string that can be used as a field name in MI - output. KEY_OBJ must be a Python string object, and must only contain - characters suitable for use as an MI field name. - - If KEY_OBJ is not a string, or if KEY_OBJ contains invalid characters, - then an error is thrown. Otherwise, KEY_OBJ is converted to a string - and returned. */ - -static gdb::unique_xmalloc_ptr -py_object_to_mi_key (PyObject *key_obj) -{ - /* The key must be a string. */ - if (!PyUnicode_Check (key_obj)) - { - gdbpy_ref<> key_repr (PyObject_Repr (key_obj)); - gdb::unique_xmalloc_ptr key_repr_string; - if (key_repr !=3D nullptr) -=09key_repr_string =3D python_string_to_target_string (key_repr.get ()); - if (key_repr_string =3D=3D nullptr) -=09gdbpy_handle_exception (); - - gdbpy_error (_("non-string object used as key: %s"), -=09=09 key_repr_string.get ()); - } - - gdb::unique_xmalloc_ptr key_string - =3D python_string_to_target_string (key_obj); - if (key_string =3D=3D nullptr) - gdbpy_handle_exception (); - - /* Predicate function, returns true if NAME is a valid field name for us= e - in MI result output, otherwise, returns false. */ - auto is_valid_key_name =3D [] (const char *name) -> bool - { - gdb_assert (name !=3D nullptr); - - if (*name =3D=3D '\0' || !isalpha (*name)) - return false; - - for (; *name !=3D '\0'; ++name) - if (!isalnum (*name) && *name !=3D '_' && *name !=3D '-') -=09return false; - - return true; - }; - - if (!is_valid_key_name (key_string.get ())) - { - if (*key_string.get () =3D=3D '\0') -=09gdbpy_error (_("Invalid empty key in MI result")); - else -=09gdbpy_error (_("Invalid key in MI result: %s"), key_string.get ()); - } - - return key_string; -} - -/* Serialize RESULT and print it in MI format to the current_uiout. - FIELD_NAME is used as the name of this result field. - - RESULT can be a dictionary, a sequence, an iterator, or an object that - can be converted to a string, these are converted to the matching MI - output format (dictionaries as tuples, sequences and iterators as lists= , - and strings as named fields). - - If anything goes wrong while formatting the output then an error is - thrown. - - This function is the recursive inner core of serialize_mi_result, and - should only be called from that function. */ - -static void -serialize_mi_result_1 (PyObject *result, const char *field_name) -{ - struct ui_out *uiout =3D current_uiout; - - if (PyDict_Check (result)) - { - PyObject *key, *value; - Py_ssize_t pos =3D 0; - ui_out_emit_tuple tuple_emitter (uiout, field_name); - while (PyDict_Next (result, &pos, &key, &value)) -=09{ -=09 gdb::unique_xmalloc_ptr key_string -=09 (py_object_to_mi_key (key)); -=09 serialize_mi_result_1 (value, key_string.get ()); -=09} - } - else if (PySequence_Check (result) && !PyUnicode_Check (result)) - { - ui_out_emit_list list_emitter (uiout, field_name); - Py_ssize_t len =3D PySequence_Size (result); - if (len =3D=3D -1) -=09gdbpy_handle_exception (); - for (Py_ssize_t i =3D 0; i < len; ++i) -=09{ -=09 gdbpy_ref<> item (PySequence_ITEM (result, i)); -=09 if (item =3D=3D nullptr) -=09 gdbpy_handle_exception (); -=09 serialize_mi_result_1 (item.get (), nullptr); -=09} - } - else if (PyIter_Check (result)) - { - gdbpy_ref<> item; - ui_out_emit_list list_emitter (uiout, field_name); - while (true) -=09{ -=09 item.reset (PyIter_Next (result)); -=09 if (item =3D=3D nullptr) -=09 { -=09 if (PyErr_Occurred () !=3D nullptr) -=09=09gdbpy_handle_exception (); -=09 break; -=09 } -=09 serialize_mi_result_1 (item.get (), nullptr); -=09} - } - else - { - if (PyLong_Check (result)) -=09{ -=09 int overflow =3D 0; -=09 gdb_py_longest val =3D gdb_py_long_as_long_and_overflow (result, -=09=09=09=09=09=09=09=09 &overflow); -=09 if (PyErr_Occurred () !=3D nullptr) -=09 gdbpy_handle_exception (); -=09 if (overflow =3D=3D 0) -=09 { -=09 uiout->field_signed (field_name, val); -=09 return; -=09 } -=09 /* Fall through to the string case on overflow. */ -=09} - - gdb::unique_xmalloc_ptr string (gdbpy_obj_to_string (result)); - if (string =3D=3D nullptr) -=09gdbpy_handle_exception (); - uiout->field_string (field_name, string.get ()); - } -} - -/* Serialize RESULT and print it in MI format to the current_uiout. - - This function handles the top-level result initially returned from the - invoke method of the Python command implementation. At the top-level - the result must be a dictionary. The values within this dictionary can - be a wider range of types. Handling the values of the top-level - dictionary is done by serialize_mi_result_1, see that function for more - details. - - If anything goes wrong while parsing and printing the MI output then an - error is thrown. */ - -static void -serialize_mi_result (PyObject *result) -{ - /* At the top-level, the result must be a dictionary. */ - - if (!PyDict_Check (result)) - gdbpy_error (_("Result from invoke must be a dictionary")); - - PyObject *key, *value; - Py_ssize_t pos =3D 0; - while (PyDict_Next (result, &pos, &key, &value)) - { - gdb::unique_xmalloc_ptr key_string -=09(py_object_to_mi_key (key)); - serialize_mi_result_1 (value, key_string.get ()); - } -} - /* Called when the MI command is invoked. PARSE contains the parsed command line arguments from the user. */ =20 @@ -381,14 +209,19 @@ mi_command_py::invoke (struct mi_parse *parse) const =20 gdb_assert (this->m_pyobj !=3D nullptr); gdb_assert (PyErr_Occurred () =3D=3D nullptr); - gdbpy_ref<> result + gdbpy_ref<> results (PyObject_CallMethodObjArgs ((PyObject *) this->m_pyobj.get (), invoke= _cst, =09=09=09=09 argobj.get (), nullptr)); - if (result =3D=3D nullptr) + if (results =3D=3D nullptr) gdbpy_handle_exception (); =20 - if (result !=3D Py_None) - serialize_mi_result (result.get ()); + if (results !=3D Py_None) + { + /* At the top-level, the results must be a dictionary. */ + if (!PyDict_Check (results.get ())) +=09gdbpy_error (_("Result from invoke must be a dictionary")); + serialize_mi_results (results.get ()); + } } =20 /* See declaration above. */ diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 93217375cc5..60b795ff98c 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -486,6 +486,19 @@ struct gdbarch *arch_object_to_gdbarch (PyObject *obj)= ; extern PyObject *gdbpy_execute_mi_command (PyObject *self, PyObject *args, =09=09=09=09=09 PyObject *kw); =20 +/* Serialize RESULTS and print it in MI format to the current_uiout. + + This function handles the top-level results passed as a dictionary. + The caller is responsible for ensuring that. The values within this + dictionary can be a wider range of types. Handling the values of the t= op-level + dictionary is done by serialize_mi_result_1, see that function for more + details. + + If anything goes wrong while parsing and printing the MI output then an + error is thrown. */ + +extern void serialize_mi_results (PyObject *results); + /* Convert Python object OBJ to a program_space pointer. OBJ must be a gdb.Progspace reference. Return nullptr if the gdb.Progspace is not valid (see gdb.Progspace.is_valid), otherwise return the program_space --=20 2.42.0