From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: gdb-mi and debugging interactive programs Date: Sun, 12 Aug 2012 21:12:43 +0300 Message-ID: <83fw7s6ktg.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1344795176 12054 80.91.229.3 (12 Aug 2012 18:12:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 12 Aug 2012 18:12:56 +0000 (UTC) To: emacs-devel@gnu.org, Nick Roberts Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 12 20:12:56 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T0cel-0007tq-AU for ged-emacs-devel@m.gmane.org; Sun, 12 Aug 2012 20:12:55 +0200 Original-Received: from localhost ([::1]:41881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0cek-0008TM-C7 for ged-emacs-devel@m.gmane.org; Sun, 12 Aug 2012 14:12:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0ceg-0008TG-VC for emacs-devel@gnu.org; Sun, 12 Aug 2012 14:12:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0cef-0005JS-Sw for emacs-devel@gnu.org; Sun, 12 Aug 2012 14:12:50 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:53154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0cef-0005JJ-L6 for emacs-devel@gnu.org; Sun, 12 Aug 2012 14:12:49 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0M8N00M00MJOYZ00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Sun, 12 Aug 2012 21:12:43 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8N00MQ1ML75JG0@a-mtaout22.012.net.il>; Sun, 12 Aug 2012 21:12:43 +0300 (IDT) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152454 Archived-At: 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