From: Eli Zaretskii <eliz@gnu.org>
To: Vladimir Prus <ghost@cs.msu.su>
Cc: gdb@sources.redhat.com
Subject: Re: printfs output in wrong order in MI
Date: Thu, 13 Apr 2006 08:10:00 -0000 [thread overview]
Message-ID: <u1ww152q0.fsf@gnu.org> (raw)
In-Reply-To: <e1kt1v$ssc$1@sea.gmane.org> (message from Vladimir Prus on Thu, 13 Apr 2006 11:02:23 +0400)
> From: Vladimir Prus <ghost@cs.msu.su>
> Date: Thu, 13 Apr 2006 11:02:23 +0400
>
> Vladimir Prus wrote:
>
> >
> > Hi,
> > I'm seing strange behaviour of the "printf" command if used in MI:
> >
> > (gdb)
> > print &i
> > &"print &i\n"
> > ~"$1 = (int *) 0xbfc5f484\n"
> > ^done
> > (gdb)
> > printf "%x", &i
> > &"printf \"%x\", &i\n"
> > ^done
> > (gdb)
> > ~"bfc5f484"
> > -interpreter-exec console "printf \"%x\", &i"
> > ^done
> > (gdb)
> > ~"bfc5f484"
> >
> > The output of 'print' appears before "^done", but the output of "printf"
> > appears *after* both "^done", and the prompt, which makes it impossible to
> > reliably catch the output.
> ....
> > Any ideas why "printf" is so special?
>
> I turns out that using
>
> printf "%x\n", &i
>
> (that is, adding "\n"), fixes the problem. Still looks like a bug to me,
> though.
I think it's expected behavior: printf uses buffered output, so if you
don't finish the line with a newline, the buffer is not flushed.
Similar ``bugs'' can be seen in any C program that displays characters
via printf without \n or fflush.
next prev parent reply other threads:[~2006-04-13 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-12 16:54 Vladimir Prus
2006-04-13 8:02 ` Vladimir Prus
2006-04-13 8:10 ` Eli Zaretskii [this message]
2006-04-13 8:20 ` Vladimir Prus
2006-04-13 16:04 ` Eli Zaretskii
2006-04-14 13:38 ` Daniel Jacobowitz
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=u1ww152q0.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb@sources.redhat.com \
--cc=ghost@cs.msu.su \
/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