From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13279 invoked by alias); 7 Sep 2012 10:36:36 -0000 Received: (qmail 13139 invoked by uid 22791); 7 Sep 2012 10:36:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Fri, 07 Sep 2012 10:36:23 +0000 Received: (qmail invoked by alias); 07 Sep 2012 10:36:21 -0000 Received: from HSI-KBW-078-042-238-225.hsi3.kabel-badenwuerttemberg.de (EHLO [192.168.2.2]) [78.42.238.225] by mail.gmx.net (mp027) with SMTP; 07 Sep 2012 12:36:21 +0200 Message-ID: <5049CE37.4020005@gmx.de> Date: Fri, 07 Sep 2012 10:36:00 -0000 From: Johannes Bauer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.8.1.23) Gecko/20091110 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: gdb@sourceware.org Subject: Building gdb frontend Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00008.txt.bz2 Hi list, I'm having a strange issue with gdb. Currently I'm building a frontend for gdb to augment its features easily. It uses Python and forks a gdb subprocess that it communicates over stdin/stdout. This all works nice and well, but sometimes it locks up. The frontend always waits to see a terminated line and then the prompt "(gdb) ". So for example, if I send "p" without arguments, usually the response will be (calling read with a 1024 bytes buffer): b'The history is empty.' b'\n' b'(gdb) ' At which I know gdb is ready to receive another command. However, sometimes the order of these messages is messed up and reception happens like this: b'The history is empty.' b'(gdb) ' b'\n' So that my frontend waits for the prompt (because it sees "The history is empty.(gdb) " as one line). When I change the reading buffer to minimum size 1, the results become even more unpredictable: b'(' b'The history is empty.\n' b'g' b'd' b'b' b')' b' ' i.e. "(The history is empty.\n" and "gdb) ", which also leads to a lockup. There seems to be some kind of concurrency/buffering issue here. Is there a way to solve this? Is there a preferred way to talk to gdb in a "machine-readable" friendly way so I know exactly when gdb is ready to receive commands again? Best regards, Johannes