public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Building gdb frontend
@ 2012-09-07 10:36 Johannes Bauer
  2012-09-07 10:46 ` Pedro Alves
  2012-09-07 16:42 ` Andrew Burgess
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Bauer @ 2012-09-07 10:36 UTC (permalink / raw)
  To: gdb

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-07 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-07 10:36 Building gdb frontend Johannes Bauer
2012-09-07 10:46 ` Pedro Alves
2012-09-07 11:05   ` Johannes Bauer
2012-09-07 16:42 ` Andrew Burgess

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).