public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] Implement write_async_safe for mi_console_file (PR 22299) Date: Sat, 07 Apr 2018 18:34:00 -0000 [thread overview] Message-ID: <7c4e78cf63f6436ae43e8289badba78d81e2eb2c@gdb-build> (raw) *** TEST RESULTS FOR COMMIT 7c4e78cf63f6436ae43e8289badba78d81e2eb2c *** Author: Simon Marchi <simon.marchi@polymtl.ca> Branch: master Commit: 7c4e78cf63f6436ae43e8289badba78d81e2eb2c Implement write_async_safe for mi_console_file (PR 22299) Enabling "set debug lin-lwp 1" with the MI interpreter doesn't work. When the sigchld_handler function wants to print a debug output ("sigchld\n"), it uses ui_file_write_async_safe. This ends up in the default implementation of ui_file::write_async_safe, which aborts GDB. This patch implements the write_async_safe method for mi_console_file. The "normal" MI output is line buffered, which means the output accumulates in m_buffer until a \n is written, at which point it's flushed in m_raw. The implementation of write_async_safe provided by this patch bypasses this buffer and writes directly to m_raw. There are two reasons for this: (1) Appending to m_buffer (therefore to an std::string) is probably not async-safe, as it may allocate memory. (2) We may have a partial output already in m_buffer, so that would lead to some nested MI output, not so great. There is probably still a chance to have bad MI output, if sigchld_handler is invoked in the middle of mi_console_file's flush, and the line being flushed is only partially sent to m_raw. The solution would probably be to block signals during flushing. Since this is only used for debug output, I don't know if it's worth the effort to do that. To implement write_async_safe, I needed to use the fputstrn_unfiltered, which does the necessary escaping (e.g. replace \n with \\n). I started by adding printchar's callback parameters to fputstrn_unfiltered, to be able to pass async-safe versions of them. It's not easy to provide an async-safe version of do_fprintf, but it turns out that we can easily replace printchar's callbacks with a single do_fputc quite easily. The async-safe version of do_fputc simply calls the underlying ui_file's write_async_safe method. gdb/ChangeLog: PR mi/22299 * mi/mi-console.c (do_fputc_async_safe): New. (mi_console_file::write_async_safe): New. (mi_console_file::flush): Adjust calls to fputstrn_unfiltered. * mi/mi-console.h (class mi_console_file) <write_async_safe>: New. * ui-file.c (ui_file::putstrn): Adjust call to fputstrn_unfiltered. * utils.c (printchar): Replace do_fputs and do_fprintf parameters by do_fputc. (fputstr_filtered): Adjust call to printchar. (fputstr_unfiltered): Likewise. (fputstrn_filtered): Likewise. (fputstrn_unfiltered): Add do_fputc parameter, pass to printchar. * utils.h (do_fputc_ftype): New typedef. (fputstrn_unfiltered): Add do_fputc parameter.
next reply other threads:[~2018-04-07 18:34 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-07 18:34 sergiodj+buildbot [this message] 2018-04-07 18:34 ` Failures on RHEL-s390x-m64, branch master sergiodj+buildbot 2018-04-07 21:16 ` Failures on Fedora-x86_64-m64, " sergiodj+buildbot 2018-04-07 21:20 ` Failures on Fedora-x86_64-native-gdbserver-m32, " sergiodj+buildbot 2018-04-07 21:25 ` Failures on Debian-s390x-m64, " sergiodj+buildbot 2018-04-07 21:34 ` Failures on Fedora-x86_64-cc-with-index, " sergiodj+buildbot 2018-04-07 21:52 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " sergiodj+buildbot 2018-04-07 21:54 ` Failures on Fedora-i686, " sergiodj+buildbot 2018-04-07 22:08 ` Failures on Fedora-x86_64-m32, " sergiodj+buildbot 2018-04-07 22:10 ` Failures on Debian-s390x-native-gdbserver-m64, " sergiodj+buildbot 2018-04-07 23:08 ` Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, " sergiodj+buildbot 2018-04-07 23:35 ` Failures on Ubuntu-AArch32-native-gdbserver-m32, " sergiodj+buildbot 2018-04-08 0:01 ` Failures on Ubuntu-AArch32-m32, " sergiodj+buildbot
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=7c4e78cf63f6436ae43e8289badba78d81e2eb2c@gdb-build \ --to=sergiodj+buildbot@sergiodj.net \ --cc=gdb-testers@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).