aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-02-19 13:36:17 -0700
committerTom Tromey <tromey@adacore.com>2019-03-05 08:55:51 -0700
commitc119e04082b5b3ee907a8d02b42fae2aee0c4fbb (patch)
tree84cb046b4bafde19a2caf1590cb71450d2daab56 /gdb/cli
parent895dafa679db7af79576dcd177a6d91d65657ee8 (diff)
downloadgdb-c119e04082b5b3ee907a8d02b42fae2aee0c4fbb.zip
gdb-c119e04082b5b3ee907a8d02b42fae2aee0c4fbb.tar.gz
gdb-c119e04082b5b3ee907a8d02b42fae2aee0c4fbb.tar.bz2
Remove excess calls to gdb_flush
A customer noticed some mildly odd MI output, where CLI output was split into multiple MI strings at unusual boundaries, like this: ~"$1 = (b => true" ~", p => 0x407260" This is technically correct according to the MI spec, but still unusual, in that there's no particular reason for the string to be split where it is. I tracked this down to a call to gdb_flush in generic_val_print. Then, I went through all calls to gdb_flush and removed the ones I thought were superfluous. In particular: * Any call in the value-printing code; * Likewise the type-printing code (just a single call); and * Any call that immediately followed a printf that obviously ended with a newline, my belief being that gdb's standard output streams are line buffered (by inheriting the behavior from stdio) Regression tested on x86-64 Fedora 29. I didn't add a new test case. I tend to think we don't necessarily want to specify this behavior in the tests. Let me know what you think of this. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat_target::attach) (windows_nat_target::detach): Don't call gdb_flush. * valprint.c (generic_val_print, val_print, val_print_string): Don't call gdb_flush. * utils.c (defaulted_query): Don't call gdb_flush. * typeprint.c (print_type_scalar): Don't call gdb_flush. * target.c (target_announce_detach): Don't call gdb_flush. * sparc64-tdep.c (adi_print_versions): Don't call gdb_flush. * remote.c (extended_remote_target::attach): Don't call gdb_flush. * procfs.c (procfs_target::detach): Don't call gdb_flush. * printcmd.c (do_examine): Don't call gdb_flush. (info_display_command): Don't call gdb_flush. * p-valprint.c (pascal_val_print): Don't call gdb_flush. * nto-procfs.c (nto_procfs_target::attach): Don't call gdb_flush. * memattr.c (info_mem_command): Don't call gdb_flush. * mdebugread.c (mdebug_build_psymtabs): Don't call gdb_flush. * m2-valprint.c (m2_val_print): Don't call gdb_flush. * infrun.c (follow_exec, handle_command): Don't call gdb_flush. * inf-ptrace.c (inf_ptrace_target::attach): Don't call gdb_flush. * hppa-tdep.c (unwind_command): Don't call gdb_flush. * gnu-nat.c (gnu_nat_target::attach): Don't call gdb_flush. (gnu_nat_target::detach): Don't call gdb_flush. * f-valprint.c (f_val_print): Don't call gdb_flush. * darwin-nat.c (darwin_nat_target::attach): Don't call gdb_flush. * cli/cli-script.c (read_command_lines): Don't call gdb_flush. * cli/cli-cmds.c (shell_escape, print_disassembly): Don't call gdb_flush. * c-valprint.c (c_val_print): Don't call gdb_flush. * ada-valprint.c (ada_print_scalar): Don't call gdb_flush.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c14
-rw-r--r--gdb/cli/cli-script.c5
2 files changed, 4 insertions, 15 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index fa99503..5dc94a5 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -709,16 +709,10 @@ shell_escape (const char *arg, int from_tty)
arg = "inferior shell";
if (rc == -1)
- {
- fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", arg,
- safe_strerror (errno));
- gdb_flush (gdb_stderr);
- }
+ fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", arg,
+ safe_strerror (errno));
else if (rc)
- {
- fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
- gdb_flush (gdb_stderr);
- }
+ fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
#ifdef GLOBAL_CURDIR
/* Make sure to return to the directory GDB thinks it is, in case
the shell command we just ran changed it. */
@@ -743,7 +737,6 @@ shell_escape (const char *arg, int from_tty)
fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
safe_strerror (errno));
- gdb_flush (gdb_stderr);
_exit (0177);
}
@@ -1130,7 +1123,6 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
}
}
printf_filtered ("End of assembler dump.\n");
- gdb_flush (gdb_stdout);
}
#if defined(TUI)
else
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 85f00c7..e2fa880 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1186,10 +1186,7 @@ read_command_lines (const char *prompt_arg, int from_tty, int parse_commands,
END_MESSAGE);
}
else
- {
- printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
- gdb_flush (gdb_stdout);
- }
+ printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
}