public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Eran Ifrah <eran.ifrah@gmail.com>
To: gdb@sourceware.org
Subject: Re: [mingw gdb/mi] Separating debuggee output from MI
Date: Tue, 15 May 2012 06:44:00 -0000	[thread overview]
Message-ID: <CAAvfv_Bv2_dUNF8d4iOE-0J3K0O5vZw6y3dBp=QpehOn-9Q=Dg@mail.gmail.com> (raw)
In-Reply-To: <4FB1F5B5.6090701@noobody.org>

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 <executable>
>set new-console on
>.. other initialization commands ...
>run <args>


By running this command, gdb will create a new console for the debugee output.
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=/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/debuggergdb.cpp?revision=5439&view=markup

Look at around line 1025 in function : DoInitializeGdb()


HTH

On Tue, May 15, 2012 at 9:20 AM, Noobody <mail@noobody.org> wrote:
> I'm currently writing a gdb frontend using the GDB/MI interface, but I have
> 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 that
> 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 gdb
> 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 */
>  gdb.exe -i mi
>>> -target-attach pid
> << *stopped
>>> -exec-continue
> << *running,thread-id="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



-- 
Eran Ifrah
Author of the cross platform, open source C++ IDE: http://www.codelite.org
YTubePlayer http://www.ytubeplayer.com

  reply	other threads:[~2012-05-15  6:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15  6:20 Noobody
2012-05-15  6:44 ` Eran Ifrah [this message]
2012-05-15  7:24   ` asmwarrior
     [not found] ` <CAAvfv_ABV8dvu56EZ=4c_2R7SzzEXnE6buPddE9u3V-NhgGz9w@mail.gmail.com>
2012-05-15 12:13   ` Noobody
2012-05-17 14:42     ` Marc Khouzam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAvfv_Bv2_dUNF8d4iOE-0J3K0O5vZw6y3dBp=QpehOn-9Q=Dg@mail.gmail.com' \
    --to=eran.ifrah@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).