From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21339 invoked by alias); 25 Apr 2014 02:30:41 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 21288 invoked by uid 48); 25 Apr 2014 02:30:38 -0000 From: "asmwarrior at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug mi/15806] Some fields in async MI events get escaped twice Date: Fri, 25 Apr 2014 02:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: mi X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: asmwarrior at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q2/txt/msg00121.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=15806 --- Comment #9 from asmwarrior --- Hi, when look at this function: /* Print the character C on STREAM as part of the contents of a literal string whose delimiter is QUOTER. Note that this routine should only be call for printing things which are independent of the language of the program being debugged. */ static void printchar (int c, void (*do_fputs) (const char *, struct ui_file *), void (*do_fprintf) (struct ui_file *, const char *, ...) ATTRIBUTE_FPTR_PRINTF_2, struct ui_file *stream, int quoter) { c &= 0xFF; /* Avoid sign bit follies */ if (c < 0x20 || /* Low control chars */ (c >= 0x7F && c < 0xA0) || /* DEL, High controls */ (sevenbit_strings && c >= 0x80)) { /* high order bit set */ switch (c) { case '\n': do_fputs ("\\n", stream); break; case '\b': do_fputs ("\\b", stream); break; case '\t': do_fputs ("\\t", stream); break; case '\f': do_fputs ("\\f", stream); break; case '\r': do_fputs ("\\r", stream); break; case '\033': do_fputs ("\\e", stream); break; case '\007': do_fputs ("\\a", stream); break; default: do_fprintf (stream, "\\%.3o", (unsigned int) c); break; } } else { if (c == '\\' || c == quoter) do_fputs ("\\", stream); do_fprintf (stream, "%c", c); } } I think we can fix our issue by look at this condition: 1, when mi->event_channel = mi_console_file_new (raw_stdout, "=", 0); is created, look at the third argument, it is 0, which means the quoter is 0 2, look at my comment 1, I have a call stack shown, where when gdb_flush (mi->event_channel); is called, the deeper printchar will have the last argument quoter = 0. 3, when read the document, I see that "Print the character C on STREAM as part of the contents of a literal string whose delimiter is QUOTER", this means usually the QUOTER is " (for c string) or ' (for c char), but what about quoter == 0? 4, I think if quoter==0, we should not double the backslash. 5, So, we can change the if condition here is like: if (c == '\\' || (c == quoter && quoter != 0)) do_fputs ("\\", stream); 6, I initial guess is that if the quoter == 0, we even don't need to escape the \f \r \n (which is the first part of the printchar() function), but I may be wrong. Yuanhui Zhang(asmwarrior) -- You are receiving this mail because: You are on the CC list for the bug.