all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* gdb-mi and debugging interactive programs
@ 2012-08-12 18:12 Eli Zaretskii
  2012-08-13 17:42 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Eli Zaretskii @ 2012-08-12 18:12 UTC (permalink / raw)
  To: emacs-devel, Nick Roberts

Can someone (Nick?) who knows the details of how gdb-mi and GDB set up
the standard handles of both GDB itself and the debuggee please look
at bug #12163?

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12163

(The end of the discussion is in bug 12180, for some reason.)

I only studied this in detail on MS-Windows, and there the situation
looks hopeless (unless one uses "set new-console on" before running
the debuggee) when you try to debug a program that reads stdin and
writes its stdout.  It seems like gdb-mi sends commands to GDB
regardless of whether GDB is ready to receive them.  AFAIK, the only
safe time to send a command to GDB is after we receive the "(gdb) "
prompt.  But gdb-mi does not do that, it generally sends commands like
"-thread-info" whenever it feels like it.  That causes those commands
to be read by the debuggee as input, instead of giving the user chance
to type input.  And if the user eventually succeeds to type input for
the program, gdb-mi wraps it in "-interpreter-exec console", which of
course ruins the whole interaction.

Similarly with output: if the debuggee happens to output text that
looks like GDB/MI output records, gdb-mi interprets that as if it came
from GDB.  E.g., try debugging a program that writes something like
'*stopped,reason="exited"' to its stdout: in my experiments, gdb-mi
decided that the program exited.

How is this supposed to work? how is gdb-mi supposed to distinguish
between I/O with GDB and I/O with a program being debugged?  That is,
if the user types some text into the gud buffer, how can gdb-mi know
whether to send it to GDB or to the debuggee?  What am I missing here?

TIA



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

* Re: gdb-mi and debugging interactive programs
  2012-08-12 18:12 gdb-mi and debugging interactive programs Eli Zaretskii
@ 2012-08-13 17:42 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2012-08-13 17:42 UTC (permalink / raw)
  To: emacs-devel, nickrob

> Date: Sun, 12 Aug 2012 21:12:43 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> How is this supposed to work? how is gdb-mi supposed to distinguish
> between I/O with GDB and I/O with a program being debugged?  That is,
> if the user types some text into the gud buffer, how can gdb-mi know
> whether to send it to GDB or to the debuggee?  What am I missing here?

To answer my own question here, it looks like the answer is in the
"set inferior-tty" command that gdb-mi issues at the beginning of the
session.  Alas, that command and what gdb-mi does with it depend on
PTYs being used to communicate with subprocesses, so I think it cannot
work on MS-Windows (which uses pipes instead).



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

end of thread, other threads:[~2012-08-13 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-12 18:12 gdb-mi and debugging interactive programs Eli Zaretskii
2012-08-13 17:42 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.