public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Johannes Bauer <dfnsonfsduifb@gmx.de>
To: gdb@sourceware.org
Subject: Building gdb frontend
Date: Fri, 07 Sep 2012 10:36:00 -0000	[thread overview]
Message-ID: <5049CE37.4020005@gmx.de> (raw)

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

             reply	other threads:[~2012-09-07 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 10:36 Johannes Bauer [this message]
2012-09-07 10:46 ` Pedro Alves
2012-09-07 11:05   ` Johannes Bauer
2012-09-07 16:42 ` Andrew Burgess

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=5049CE37.4020005@gmx.de \
    --to=dfnsonfsduifb@gmx.de \
    --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).