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 2E66C3858024 for ; Sun, 18 Oct 2020 14:08:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2E66C3858024 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43872) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kU9Mj-0008SQ-GQ; Sun, 18 Oct 2020 10:08:53 -0400 Received: from pool-96-233-64-159.bstnma.fios.verizon.net ([96.233.64.159]:45704 helo=pdslaptop.home) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kU9Mj-0000cx-74; Sun, 18 Oct 2020 10:08:53 -0400 Message-ID: Subject: Re: GDB: Setting the prompt from python From: Paul Smith Reply-To: psmith@gnu.org To: Matt Rice Cc: GDB Date: Sun, 18 Oct 2020 10:08:52 -0400 In-Reply-To: References: <46a8f2123a154c4b86b8f38fff332f059b72fc77.camel@gnu.org> Organization: GNU's Not UNIX! Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Sun, 18 Oct 2020 14:08:55 -0000 On Sun, 2020-10-18 at 09:24 +0000, Matt Rice wrote: > > It seems that no matter what I do, the trailing space is stripped > > off. Is there some other way to set the prompt from Python? > > Weird, using the python prompt hook does work. > > (gdb) python > > gdb.prompt_hook = lambda old_prompt: "XXX " > > end > XXX quit Aha! Thanks. Well, it kind of makes sense to me but is unfortunate. The problem is probably that GDB is stripping the command that is passed to it via gdb.execute() before running it so the whitespace goes away before GDB tries to run the command. In the prompt_hook version the static string containing the space is returned and so is preserved.