From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2663 invoked by alias); 15 May 2012 06:44:37 -0000 Received: (qmail 2654 invoked by uid 22791); 15 May 2012 06:44:35 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pz0-f41.google.com (HELO mail-pz0-f41.google.com) (209.85.210.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 May 2012 06:44:22 +0000 Received: by dakp5 with SMTP id p5so7525650dak.0 for ; Mon, 14 May 2012 23:44:22 -0700 (PDT) Received: by 10.68.192.39 with SMTP id hd7mr2417272pbc.49.1337064261941; Mon, 14 May 2012 23:44:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.249.129 with HTTP; Mon, 14 May 2012 23:44:01 -0700 (PDT) In-Reply-To: <4FB1F5B5.6090701@noobody.org> References: <4FB1F5B5.6090701@noobody.org> From: Eran Ifrah Date: Tue, 15 May 2012 06:44:00 -0000 Message-ID: Subject: Re: [mingw gdb/mi] Separating debuggee output from MI To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-05/txt/msg00063.txt.bz2 Hi, I also faced this problem while ago when implementing it, what did the trick for me was to execute 'set new-console on' after starting gdb but before executing the target so the sequence should be something like this: >gdb >set new-console on >.. other initialization commands ... >run By running this command, gdb will create a new console for the debugee outp= ut. i.e. all the redirected IO that you capture in your frontend will always be gdb's output. Note: this command does not work under Linux / Mac. To achieve this on *NIX, you need to pass --tty=3D/dev/pts/XX to gdb for achieving the same effect. Also, here is a complete reference for codelite's GDB MI implementation: http://codelite.svn.sourceforge.net/viewvc/codelite/trunk/Debugger/debugger= gdb.cpp?revision=3D5439&view=3Dmarkup Look at around line 1025 in function : DoInitializeGdb() HTH On Tue, May 15, 2012 at 9:20 AM, Noobody wrote: > I'm currently writing a gdb frontend using the GDB/MI interface, but I ha= ve > been experiencing difficulties with differentiating between output by the > debuggee and output from gdb itself. > > The documentation mentions target-stream-output, which is prefixed with "= @", > but it seems it is not actually being used. Instead, target output appears > interleaved with gdb output. > > This can cause various problems, so I would like to be able to safely > separate > target output/input from gdb output/input. Searching for a bit revealed t= hat > this is quite a common problem when writing gdb frontends on windows due = to > various limitations of the OS, but I was unable to find a good solution. > > I implemented a workaround to this which seems to work, however I am not > quite > sure whether it is safe to use. > > What I'm doing right now is start the debuggee process in suspended mode > from > the frontend (with CreateProcess and CREATE_SUSPENDED flag), create the g= db > process separately, attach it to the suspended process and then resume it > with ResumeThread (assuming a single-threaded program). > > Something like this: > > /* Start debug process */ > CreateProcess(...) > > /* Start gdb */ > =A0gdb.exe -i mi >>> -target-attach pid > << *stopped >>> -exec-continue > << *running,thread-id=3D"all" > > /* Resume suspended process */ > ResumeThread(...) > > This seems to work, as I now have the debuggee input/output and the gdb > input/output in separate pipes. However, I have not had the chance to test > this > any further, so I'm wondering - could this setup could cause any problems? > Especially the fact that I'm doing -exec-continue on a suspended process > seems > like asking for trouble. > > Thanks! > Benedikt Bitterli --=20 Eran Ifrah Author of the cross platform, open source C++ IDE: http://www.codelite.org YTubePlayer http://www.ytubeplayer.com