This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Building gdb frontend


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]