From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 71B143858D39 for ; Tue, 2 Nov 2021 16:40:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 71B143858D39 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhwpz-0003A2-Q3 for gdb@sourceware.org; Tue, 02 Nov 2021 12:40:39 -0400 Received: from ip5f5a8d68.dynamic.kabel-deutschland.de ([95.90.141.104]:51289 helo=[192.168.111.41]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhwpz-0000Ol-Fx for gdb@sourceware.org; Tue, 02 Nov 2021 12:40:39 -0400 From: Simon Sobisch To: gdb@sourceware.org Subject: How to create new mi commands via python / get current interpreter in python Message-ID: Date: Tue, 2 Nov 2021 17:40:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2021 16:40:41 -0000 It is possible to send `interpreter-exec mi "command"` from a python extension, but how can we check the _current_ interpreter a python create gdb command was executed in? The reason: depending on the interpreter the return value should be different interpreter-exec console "break" --> returns user output (which may be parsed) vs. interpreter-exec mi "-break-insert" --> returns interpreter output intended to be parsed Additional to this question: is there an option to create new MI commands from python (instead of "console commands"), or python helper functions which provide better ways to return mi-messages than plain "print" with self-formatting? Thanks for any insights, Simon