public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "eliz at gnu dot org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug mi/29002] Console input broken in MI mode Date: Sun, 27 Mar 2022 09:48:44 +0000 [thread overview] Message-ID: <bug-29002-4717-RTZthFBupQ@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-29002-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=29002 --- Comment #3 from Eli Zaretskii <eliz at gnu dot org> --- But this is not the whole story. That commit also causes the Emacs gdb-mi front-end to GDB to become broken, at least on MS-Windows. What happens is that gdb-mi sends, via the GDB/MI interface, several commands in a sequence when the debugging session begins. Those commands are: 1-gdb-set new-console off 2-gdb-set interactive-mode on 3-gdb-set height 0 4-enable-pretty-printing 5-enable-frame-filters 6-file-list-exec-source-file 7-gdb-show prompt 8-stack-info-frame 9-thread-info 10-break-list 11-thread-info 12-break-list But when GDB responds to those commands, some of the responses have the first character of the TOKEN part stripped. Here's what Emacs receives in response (this is a single string sent to Emacs in one go): 1^done (gdb) 2^done (gdb) 3^done (gdb) ^done (gdb) 5^done (gdb) ^done,line=\"1189\",file=\"emacs.c\",fullname=\"d:\\\\gnu\\\\git\\\\emacs\\\\branch\\\\src\\\\emacs.c\",macro-info=\"1\" (gdb) 7^done,value=\"(gdb) \" (gdb) 8^error,msg=\"No registers.\" (gdb) ^done,threads=[] (gdb) 0^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"10\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0115dc0c\",func=\"terminate_due_to_signal\",file=\"emacs.c\",fullname=\"d:\\\\gnu\\\\git\\\\emacs\\\\branch\\\\src\\\\emacs.c\",line=\"400\",thread-groups=[\"i1\"],times=\"0\",original-location=\"terminate_due_to_signal\"}]} (gdb) 1^done,threads=[] (gdb) 12^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"10\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0115dc0c\",func=\"terminate_due_to_signal\",file=\"emacs.c\",fullname=\"d:\\\\gnu\\\\git\\\\emacs\\\\branch\\\\src\\\\emacs.c\",line=\"400\",thread-groups=[\"i1\"],times=\"0\",original-location=\"terminate_due_to_signal\"}]} Note that responses to 4, 6, and 9 don't have the TOKEN part, and responses to 10 and 11 have the first digit, 1, removed from TOKEN, so they appear as if the TOKEN were 0 (which is invalid) and 1 (which was already received, and so is not expected at this time). It turns out that restoring the "done_once" part of the offending commit fixes this problem as well. I'm guessing that the repeated calls to `setbuf` cause those characters to be lost, perhaps because `setbuf` flushes the stream, which for an input stream means it empties the buffer. And we do call `setbuf` in this scenario, because interaction between Emacs and GDB in this case is via pipes. In general, AFAIK the C standard allows to call `setvbuf` (and thus `setbuf`) only once, before any I/O operation was done for a given stream. But after the commit mentioned above, we call `setbuf` multiple times. So the proposed patch now changes to an almost full revert of the offending commit, see the attachment. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2022-03-27 9:48 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-27 5:33 [Bug mi/29002] New: " eliz at gnu dot org 2022-03-27 5:35 ` [Bug mi/29002] " eliz at gnu dot org 2022-03-27 6:20 ` eliz at gnu dot org 2022-03-27 6:23 ` eliz at gnu dot org 2022-03-27 9:48 ` eliz at gnu dot org [this message] 2022-03-27 9:52 ` eliz at gnu dot org 2022-04-24 15:43 ` cvs-commit at gcc dot gnu.org 2022-04-24 15:44 ` cvs-commit at gcc dot gnu.org 2022-04-24 15:46 ` brobecker at gnat dot com 2023-07-11 13:01 ` equationssolver at yahoo dot com 2023-07-11 13:11 ` equationssolver at yahoo dot com 2023-07-11 15:38 ` eliz at gnu dot org 2023-07-13 14:05 ` equationssolver at yahoo dot com
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=bug-29002-4717-RTZthFBupQ@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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).