From: Cleber Rosa <crosa@redhat.com>
To: gdb-patches@sourceware.org
Cc: areis@redhat.com, palves@redhat.com, Cleber Rosa <crosa@redhat.com>
Subject: [PATCH 4/4] GDB/MI: inferior standard I/O redirection
Date: Mon, 05 Oct 2015 11:54:00 -0000 [thread overview]
Message-ID: <1444045617-14526-5-git-send-email-crosa@redhat.com> (raw)
In-Reply-To: <1444045617-14526-1-git-send-email-crosa@redhat.com>
This introduces the following MI commands:
* -inferior-stdin-set
* -inferior-stdin-show
* -inferior-stdout-set
* -inferior-stdout-show
* -inferior-stderr-set
* -inferior-stderr-show
Which are the MI version of the inferior standard I/O redirection
commands:
* set inferior-stdin (aliased as stdin)
* show inferior-stdin
* set inferior-stdout (aliased as stdout)
* show inferior-stdout
* set inferior-stderr (aliased as stderr)
gdb/doc/ChangeLog:
2015-10-05 Cleber Rosa <crosa@redhat.com>
* gdb.texinfo (info): Add documentation about the
-inferior-stdin-set, inferior-stdin-show, -inferior-stdout-set,
inferior-stdout-show, -inferior-stderr-set, inferior-stderr-show
commands.
gdb/ChangeLog:
2015-10-05 Cleber Rosa <crosa@redhat.com>
* mi/mi-cmd-env.c (mi_cmd_inferior_std_show_helper): New utility
function.
(mi_cmd_inferior_stdin_set): New function.
(mi_cmd_inferior_stdin_show): Likewise.
(mi_cmd_inferior_stdout_set): Likewise.
(mi_cmd_inferior_stdout_show): Likewise.
(mi_cmd_inferior_stderr_set): Likewise.
(mi_cmd_inferior_stderr_show): Likewise.
* mi/mi-cmds.c (struct mi_cmds): Add inferior-stdin-set,
inferior-stdin-show, inferior-stdout-set, inferior-stdout-show,
inferior-stderr-set, inferior-stderr-show.
* mi/mi-cmds.h: Add mi_cmd_inferior_stdin_set,
mi_cmd_inferior_stdin_show,
mi_cmd_inferior_stdout_set,mi_cmd_inferior_stdout_show,
mi_cmd_inferior_stderr_set and mi_cmd_inferior_stderr_show
declarations.
gdb/testsuite/ChangeLog:
2015-10-05 Cleber Rosa <crosa@redhat.com>
* gdb.mi/mi-basics.exp (test_setshow_inferior_std): New tests for
commands -inferior-stdin-set, -inferior-stdin-show,
-inferior-stdin-set, -inferior-stdin-show, -inferior-stdin-set and
-inferior-stdin-show.
---
gdb/doc/gdb.texinfo | 153 +++++++++++++++++++++++++++++++++++++
gdb/mi/mi-cmd-env.c | 77 +++++++++++++++++++
gdb/mi/mi-cmds.c | 6 ++
gdb/mi/mi-cmds.h | 6 ++
gdb/testsuite/gdb.mi/mi-basics.exp | 62 +++++++++++++++
5 files changed, 304 insertions(+)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 39d5a1c..d6f77a8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -32144,6 +32144,159 @@ The corresponding @value{GDBN} command is @samp{show inferior-tty}.
(gdb)
@end smallexample
+@subheading The @code{-inferior-stdin-set} Command
+@findex -inferior-stdin-set
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stdin-set /tmp/answers
+@end smallexample
+
+Set standard input for future runs of the program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{set inferior-stdin} /tmp/answers.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stdin-set /tmp/answers
+^done
+(gdb)
+@end smallexample
+
+@subheading The @code{-inferior-stdin-show} Command
+@findex -inferior-stdin-show
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stdin-show
+@end smallexample
+
+Show standard input to be used on future runs of program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{show inferior-stdin}.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stdin-set /tmp/answers
+^done
+(gdb)
+-inferior-stdin-show
+^done,inferior_stdin="/tmp/answers"
+(gdb)
+@end smallexample
+
+@subheading The @code{-inferior-stdout-set} Command
+@findex -inferior-stdout-set
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stdout-set /tmp/output
+@end smallexample
+
+Set standard output for future runs of the program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{set inferior-stdout} /tmp/output.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stdout-set /tmp/output
+^done
+(gdb)
+@end smallexample
+
+@subheading The @code{-inferior-stdout-show} Command
+@findex -inferior-stdout-show
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stdout-show
+@end smallexample
+
+Show standard output to be used on future runs of program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{show inferior-stdout}.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stdout-set /tmp/output
+^done
+(gdb)
+-inferior-stdout-show
+^done,inferior_stdout="/tmp/output"
+(gdb)
+@end smallexample
+
+@subheading The @code{-inferior-stderr-set} Command
+@findex -inferior-stderr-set
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stderr-set /dev/null
+@end smallexample
+
+Set standard error for future runs of the program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{set inferior-stderr} /dev/null.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stderr-set /dev/null
+^done
+(gdb)
+@end smallexample
+
+@subheading The @code{-inferior-stderr-show} Command
+@findex -inferior-stderr-show
+
+@subheading Synopsis
+
+@smallexample
+-inferior-stderr-show
+@end smallexample
+
+Show standard error to be used on future runs of program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{show inferior-stderr}.
+
+@subheading Example
+
+@smallexample
+(gdb)
+-inferior-stderr-set /dev/null
+^done
+(gdb)
+-inferior-stderr-show
+^done,inferior_stderr="/dev/null"
+(gdb)
+@end smallexample
+
@subheading The @code{-enable-timings} Command
@findex -enable-timings
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index fad9297..610070d 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -268,6 +268,83 @@ mi_cmd_inferior_tty_show (char *command, char **argv, int argc)
"inferior_tty_terminal", inferior_io_terminal);
}
+/* Helper function to simplify mi_cmd_inferior_std{in,out,err}_show. */
+
+static void
+mi_cmd_inferior_std_show_helper(char *command,
+ char **argv,
+ int argc,
+ char *field_name,
+ const char *inferior_std_name)
+{
+ if ( !mi_valid_noargs ("-inferior-stdin-show", argc, argv))
+ error (_("%s: Usage: No args"), command);
+
+ if (inferior_std_name)
+ ui_out_field_string (current_uiout,
+ field_name, inferior_std_name);
+}
+
+/* Set the inferior stdin file name. */
+
+void
+mi_cmd_inferior_stdin_set (char *command, char **argv, int argc)
+{
+ set_inferior_io_stdin (argv[0]);
+}
+
+/* Print the inferior stdin file name. */
+
+void
+mi_cmd_inferior_stdin_show (char *command, char **argv, int argc)
+{
+ mi_cmd_inferior_std_show_helper("-inferior-stdin-show",
+ argv,
+ argc,
+ "inferior_stdin",
+ get_inferior_io_stdin ());
+}
+
+/* Set the inferior stdout file name. */
+
+void
+mi_cmd_inferior_stdout_set (char *command, char **argv, int argc)
+{
+ set_inferior_io_stdout (argv[0]);
+}
+
+/* Print the inferior stdout file name. */
+
+void
+mi_cmd_inferior_stdout_show (char *command, char **argv, int argc)
+{
+ mi_cmd_inferior_std_show_helper("-inferior-stdout-show",
+ argv,
+ argc,
+ "inferior_stdout",
+ get_inferior_io_stdout ());
+}
+
+/* Set the inferior stderr file name. */
+
+void
+mi_cmd_inferior_stderr_set (char *command, char **argv, int argc)
+{
+ set_inferior_io_stderr (argv[0]);
+}
+
+/* Print the inferior stderr file name. */
+
+void
+mi_cmd_inferior_stderr_show (char *command, char **argv, int argc)
+{
+ mi_cmd_inferior_std_show_helper("-inferior-stderr-show",
+ argv,
+ argc,
+ "inferior_stderr",
+ get_inferior_io_stderr ());
+}
+
void
_initialize_mi_cmd_env (void)
{
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 2d8af2f..388b5b1 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -123,6 +123,12 @@ static struct mi_cmd mi_cmds[] =
DEF_MI_CMD_CLI ("gdb-version", "show version", 0),
DEF_MI_CMD_MI ("inferior-tty-set", mi_cmd_inferior_tty_set),
DEF_MI_CMD_MI ("inferior-tty-show", mi_cmd_inferior_tty_show),
+ DEF_MI_CMD_MI ("inferior-stdin-set", mi_cmd_inferior_stdin_set),
+ DEF_MI_CMD_MI ("inferior-stdin-show", mi_cmd_inferior_stdin_show),
+ DEF_MI_CMD_MI ("inferior-stdout-set", mi_cmd_inferior_stdout_set),
+ DEF_MI_CMD_MI ("inferior-stdout-show", mi_cmd_inferior_stdout_show),
+ DEF_MI_CMD_MI ("inferior-stderr-set", mi_cmd_inferior_stderr_set),
+ DEF_MI_CMD_MI ("inferior-stderr-show", mi_cmd_inferior_stderr_show),
DEF_MI_CMD_MI ("info-ada-exceptions", mi_cmd_info_ada_exceptions),
DEF_MI_CMD_MI ("info-gdb-mi-command", mi_cmd_info_gdb_mi_command),
DEF_MI_CMD_MI ("info-os", mi_cmd_info_os),
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 55141f3..8ffb65f 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -73,6 +73,12 @@ extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set;
extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stdin_set;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stdin_show;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stdout_set;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stdout_show;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stderr_set;
+extern mi_cmd_argv_ftype mi_cmd_inferior_stderr_show;
extern mi_cmd_argv_ftype mi_cmd_info_ada_exceptions;
extern mi_cmd_argv_ftype mi_cmd_info_gdb_mi_command;
extern mi_cmd_argv_ftype mi_cmd_info_os;
diff --git a/gdb/testsuite/gdb.mi/mi-basics.exp b/gdb/testsuite/gdb.mi/mi-basics.exp
index 476dbdc..89f7d68 100644
--- a/gdb/testsuite/gdb.mi/mi-basics.exp
+++ b/gdb/testsuite/gdb.mi/mi-basics.exp
@@ -264,6 +264,67 @@ proc test_setshow_inferior_tty {} {
"make sure show takes no arguments"
}
+proc test_setshow_inferior_std {} {
+ global mi_gdb_prompt
+
+ # Test that the commands,
+ # -inferior-stdin-set
+ # -inferior-stdin-show
+ # -inferior-stdin-set
+ # -inferior-stdin-show
+ # -inferior-stdin-set
+ # -inferior-stdin-show
+ # are setting/getting the same data in GDB.
+
+ mi_gdb_test "301-inferior-stdin-show" \
+ "301\\\^done" \
+ "initial stdin is not set"
+
+ mi_gdb_test "302-inferior-stdin-set /foo/bar" \
+ "302\\\^done" \
+ "set stdin to /foo/bar"
+
+ mi_gdb_test "303-inferior-stdin-show" \
+ "303\\\^done,inferior_stdin=\"/foo/bar\"" \
+ "std was set correctly"
+
+ mi_gdb_test "304-inferior-stdin-show should-take-no-args" \
+ "304\\\^error,msg=\"-inferior-stdin-show: Usage: No args\"" \
+ "make sure show takes no arguments"
+
+ mi_gdb_test "305-inferior-stdout-show" \
+ "305\\\^done" \
+ "initial stdout is not set"
+
+ mi_gdb_test "306-inferior-stdout-set /foo/bar" \
+ "306\\\^done" \
+ "set stdout to /foo/bar"
+
+ mi_gdb_test "307-inferior-stdout-show" \
+ "307\\\^done,inferior_stdout=\"/foo/bar\"" \
+ "std was set correctly"
+
+ mi_gdb_test "308-inferior-stdout-show should-take-no-args" \
+ "308\\\^error,msg=\"-inferior-stdout-show: Usage: No args\"" \
+ "make sure show takes no arguments"
+
+ mi_gdb_test "309-inferior-stderr-show" \
+ "309\\\^done" \
+ "initial stderr is not set"
+
+ mi_gdb_test "310-inferior-stderr-set /foo/bar" \
+ "310\\\^done" \
+ "set stderr to /foo/bar"
+
+ mi_gdb_test "311-inferior-stderr-show" \
+ "311\\\^done,inferior_stderr=\"/foo/bar\"" \
+ "std was set correctly"
+
+ mi_gdb_test "312-inferior-stderr-show should-take-no-args" \
+ "312\\\^error,msg=\"-inferior-stderr-show: Usage: No args\"" \
+ "make sure show takes no arguments"
+}
+
if { [test_mi_interpreter_selection]
&& [test_exec_and_symbol_mi_operatons] } {
test_breakpoints_deletion
@@ -271,6 +332,7 @@ if { [test_mi_interpreter_selection]
test_cwd_specification
test_path_specification
test_setshow_inferior_tty
+ test_setshow_inferior_std
}
mi_gdb_exit
--
2.4.3
next prev parent reply other threads:[~2015-10-05 11:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-05 11:47 [PATCH 0/4]: GDB: " Cleber Rosa
2015-10-05 11:47 ` [PATCH 2/4] GDB/MI: fix and simplify mi_valid_noargs utility function Cleber Rosa
2015-10-21 11:19 ` Pedro Alves
2015-10-05 11:47 ` [PATCH 3/4] GDB/MI: add test for command -inferior-tty-show Cleber Rosa
2015-10-21 11:19 ` Pedro Alves
2015-10-05 11:47 ` [PATCH 1/4] GDB: inferior standard I/O redirection Cleber Rosa
2015-10-05 12:23 ` Eli Zaretskii
2015-10-21 11:18 ` Pedro Alves
2015-10-05 11:54 ` Cleber Rosa [this message]
2015-10-05 12:26 ` [PATCH 4/4] GDB/MI: " Eli Zaretskii
2015-10-21 11:19 ` Pedro Alves
2015-10-22 10:55 ` Vladimir Prus
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=1444045617-14526-5-git-send-email-crosa@redhat.com \
--to=crosa@redhat.com \
--cc=areis@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/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: link
Be 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