]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
./
authorDaniel Jacobowitz <drow@false.org>
Wed, 2 Jul 2003 20:52:33 +0000 (20:52 +0000)
committerDaniel Jacobowitz <drow@false.org>
Wed, 2 Jul 2003 20:52:33 +0000 (20:52 +0000)
* cli/cli-logging.c: New file.
* cli-out.c (struct ui_out_data): Add original_stream.
(cli_redirect): New function.
(cli_ui_out_impl): Add cli_redirect.
(cli_out_new): Initialize original_stream.
* ui-out.c (default_ui_out_impl): Add NULL for redirect member.
(uo_redirect, ui_out_redirect): New.
* ui-out.h (struct ui_out_impl): Add redirect member.
(redirect_ftype): New.
(ui_out_redirect): Add prototype.
* Makefile.in: Add rules for cli-logging.c.
* NEWS: Mention "set logging".
mi/
* mi-out.c (mi_ui_out_impl): Add NULL for redirect member.
tui/
* tui-out.c (tui_ui_out_impl): Add NULL for redirect member.
doc/
* gdb.texinfo (Logging output): New chapter.

12 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/NEWS
gdb/cli-out.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/mi/ChangeLog
gdb/mi/mi-out.c
gdb/tui/ChangeLog
gdb/tui/tui-out.c
gdb/ui-out.c
gdb/ui-out.h

index 6401554bdc4f571d09851dcfaa2e7e091d7e252c..e036bdba7a28ab0ad331875dd3c5d26a30601c99 100644 (file)
@@ -1,3 +1,23 @@
+2003-07-02  Daniel Jacobowitz  <drow@mvista.com>
+
+       * cli/cli-logging.c (pop_output_files): Add void to function
+       definition.
+
+2003-07-02  Daniel Jacobowitz  <drow@mvista.com>
+
+       * cli/cli-logging.c: New file.
+       * cli-out.c (struct ui_out_data): Add original_stream.
+       (cli_redirect): New function.
+       (cli_ui_out_impl): Add cli_redirect.
+       (cli_out_new): Initialize original_stream.
+       * ui-out.c (default_ui_out_impl): Add NULL for redirect member.
+       (uo_redirect, ui_out_redirect): New.
+       * ui-out.h (struct ui_out_impl): Add redirect member.
+       (redirect_ftype): New.
+       (ui_out_redirect): Add prototype.
+       * Makefile.in: Add rules for cli-logging.c.
+       * NEWS: Mention "set logging".
+
 2003-07-02  Jim Blandy  <jimb@redhat.com>
 
        * s390-tdep.c (struct frame_extra_info): new member:
index ea4ff9d4fd3093bd171a8b6e46ca3367be70eea1..e0f80b8e13306c0df06a1cf2079510f5a572d861 100644 (file)
@@ -146,10 +146,12 @@ TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
 SUBDIR_CLI_OBS = \
        cli-dump.o \
        cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-utils.o \
+       cli-logging.o \
        cli-interp.o
 SUBDIR_CLI_SRCS = \
        cli/cli-dump.c \
        cli/cli-decode.c cli/cli-script.c cli/cli-cmds.c cli/cli-setshow.c \
+       cli/cli-logging.c \
        cli/cli-interp.c \
        cli/cli-utils.c
 SUBDIR_CLI_DEPS =
@@ -2410,7 +2412,7 @@ z8k-tdep.o: z8k-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(gdbcmd_h) \
 # gdb/cli/ dependencies
 #
 # Need to explicitly specify the compile rule as make will do nothing
-# or try to compile the object file into the mi directory.
+# or try to compile the object file into the cli directory.
 
 cli-cmds.o: $(srcdir)/cli/cli-cmds.c $(defs_h) $(completer_h) $(target_h) \
        $(gdb_wait_h) $(gdb_regex_h) $(gdb_string_h) $(filenames_h) \
@@ -2429,6 +2431,8 @@ cli-dump.o: $(srcdir)/cli/cli-dump.c $(defs_h) $(gdb_string_h) \
 cli-interp.o: $(srcdir)/cli/cli-interp.c $(defs_h) $(interps_h) $(wrapper_h) \
        $(event_top_h) $(ui_out_h) $(cli_out_h) $(top_h) $(gdb_string_h)
        $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-interp.c
+cli-logging.o: $(srcdir)/cli/cli-logging.c $(defs_h) $(ui_out_h) $(gdbcmd_h)
+       $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-logging.c
 cli-script.o: $(srcdir)/cli/cli-script.c $(defs_h) $(value_h) $(language_h) \
        $(ui_out_h) $(gdb_string_h) $(top_h) $(cli_cmds_h) $(cli_decode_h) \
        $(cli_script_h)
index f8bcf8a04522f2e00b36e8eeecfa5114ddb8232b..d7931234fa8c8c214768df64692901b9b3de2fc0 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes in GDB 6.0:
 
+* GDB supports logging output to a file
+
+There are two new commands, "set logging" and "show logging", which can be
+used to capture GDB's output to a file.
+
 * The meaning of "detach" has changed for gdbserver
 
 The "detach" command will now resume the application, as documented.  To
index 38bf36ffaf21858662899051e8e5ed5746d349af..2e5a3c16b1668d1590946fa8c5b87bf0f62849f0 100644 (file)
@@ -31,6 +31,7 @@
 struct ui_out_data
   {
     struct ui_file *stream;
+    struct ui_file *original_stream;
     int suppress_output;
   };
 typedef struct ui_out_data cli_out_data;
@@ -64,6 +65,7 @@ static void cli_message (struct ui_out *uiout, int verbosity,
                         const char *format, va_list args);
 static void cli_wrap_hint (struct ui_out *uiout, char *identstring);
 static void cli_flush (struct ui_out *uiout);
+static int cli_redirect (struct ui_out *uiout, struct ui_file *outstream);
 
 /* This is the CLI ui-out implementation functions vector */
 
@@ -87,6 +89,7 @@ static struct ui_out_impl cli_ui_out_impl =
   cli_message,
   cli_wrap_hint,
   cli_flush,
+  cli_redirect,
   0, /* Does not need MI hacks (i.e. needs CLI hacks).  */
 };
 
@@ -324,6 +327,24 @@ cli_flush (struct ui_out *uiout)
   gdb_flush (data->stream);
 }
 
+int
+cli_redirect (struct ui_out *uiout, struct ui_file *outstream)
+{
+  struct ui_out_data *data = ui_out_data (uiout);
+  if (outstream != NULL)
+    {
+      data->original_stream = data->stream;
+      data->stream = outstream;
+    }
+  else if (data->original_stream != NULL)
+    {
+      data->stream = data->original_stream;
+      data->original_stream = NULL;
+    }
+
+  return 0;
+}
+
 /* local functions */
 
 /* Like cli_field_fmt, but takes a variable number of args
@@ -362,6 +383,7 @@ cli_out_new (struct ui_file *stream)
 
   cli_out_data *data = XMALLOC (cli_out_data);
   data->stream = stream;
+  data->original_stream = NULL;
   data->suppress_output = 0;
   return ui_out_new (&cli_ui_out_impl, data, flags);
 }
index 3d396013241900558b0408febe765e268d49e687..edd7be275358b105629d20487746a1929e9bff31 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-02  Daniel Jacobowitz  <drow@mvista.com>
+
+       * gdb.texinfo (Logging output): New chapter.
+
 2003-06-24  Joel Brobecker  <brobecker@gnat.com>
 
        * gdb.texinfo (Unsupported languages): New section.
index 05715e137df11ac4aa6e1f20ba19ea2b585403a3..e6da37c3b80fc718a6baa421cae35c06d2080183 100644 (file)
@@ -757,6 +757,7 @@ type @kbd{quit} or @kbd{C-d} to exit.
 * Invoking GDB::                How to start @value{GDBN}
 * Quitting GDB::                How to quit @value{GDBN}
 * Shell Commands::              How to use shell commands inside @value{GDBN}
+* Logging output::              How to log @value{GDBN}'s output to a file
 @end menu
 
 @node Invoking GDB
@@ -1210,6 +1211,32 @@ Execute the @code{make} program with the specified
 arguments.  This is equivalent to @samp{shell make @var{make-args}}.
 @end table
 
+@node Logging output
+@section Logging output
+@cindex logging @value{GDBN} output
+
+You may want to save the output of @value{GDBN} commands to a file.
+There are several commands to control @value{GDBN}'s logging.
+
+@table @code
+@kindex set logging
+@item set logging on
+Enable logging.
+@item set logging off
+Disable logging.
+@item set logging file @var{file}
+Change the name of the current logfile.  The default logfile is @file{gdb.txt}.
+@item set logging overwrite [on|off]
+By default, @value{GDBN} will append to the logfile.  Set @code{overwrite} if
+you want @code{set logging on} to overwrite the logfile instead.
+@item set logging redirect [on|off]
+By default, @value{GDBN} output will go to both the terminal and the logfile.
+Set @code{redirect} if you want output to go only to the log file.
+@kindex show logging
+@item show logging
+Show the current values of the logging settings.
+@end table
+
 @node Commands
 @chapter @value{GDBN} Commands
 
index ed861f023bc8ea080c7c1dac3b69f6405e9aafca..31fd26f0efde180bb77249df2ad740b8b7399cb8 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-02  Daniel Jacobowitz  <drow@mvista.com>
+
+       * mi-out.c (mi_ui_out_impl): Add NULL for redirect member.
+
 2003-06-17  Daniel Jacobowitz  <drow@mvista.com>
 
         * mi-cmds.c (mi_cmds): Add "-target-disconnect".
index 2aac5289829ae6ed05d6bab5e1b89fc67b104726..637ceb42ca1823df22952c55442479ba9692d9b1 100644 (file)
@@ -86,6 +86,7 @@ struct ui_out_impl mi_ui_out_impl =
   mi_message,
   mi_wrap_hint,
   mi_flush,
+  NULL,
   1, /* Needs MI hacks.  */
 };
 
index 9ab34614aa0de99cdd49c0e5fda06d9d8ece8f71..e90e946d9ddbeea59b6eefb451677e83b53b07a4 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-02  Daniel Jacobowitz  <drow@mvista.com>
+
+       * tui-out.c (tui_ui_out_impl): Add NULL for redirect member.
+
 2003-06-22  Daniel Jacobowitz  <drow@mvista.com>
 
        * tui-hooks.c: Update include order.
index 94fda09b14c2baa9f2eb6d22f22f7b2e94f6c5b8..e1be56a6b00064b99a8f098404ae36b917d836f6 100644 (file)
@@ -90,6 +90,7 @@ static struct ui_out_impl tui_ui_out_impl =
   tui_message,
   tui_wrap_hint,
   tui_flush,
+  NULL,
   0, /* Does not need MI hacks (i.e. needs CLI hacks).  */
 };
 
index 71e6d6ac070ead3a98529ba8955435b20a0944a2..5fb8eaa69e80e74d95fbb0117072066c68e2c2a6 100644 (file)
@@ -206,6 +206,7 @@ struct ui_out_impl default_ui_out_impl =
   default_message,
   default_wrap_hint,
   default_flush,
+  NULL,
   0, /* Does not need MI hacks.  */
 };
 
@@ -254,6 +255,7 @@ static void uo_message (struct ui_out *uiout, int verbosity,
                        const char *format, va_list args);
 static void uo_wrap_hint (struct ui_out *uiout, char *identstring);
 static void uo_flush (struct ui_out *uiout);
+static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream);
 
 /* Prototypes for local functions */
 
@@ -638,6 +640,12 @@ ui_out_flush (struct ui_out *uiout)
   uo_flush (uiout);
 }
 
+int
+ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream)
+{
+  return uo_redirect (uiout, outstream);
+}
+
 /* set the flags specified by the mask given */
 int
 ui_out_set_flags (struct ui_out *uiout, int mask)
@@ -981,6 +989,15 @@ uo_flush (struct ui_out *uiout)
   uiout->impl->flush (uiout);
 }
 
+int
+uo_redirect (struct ui_out *uiout, struct ui_file *outstream)
+{
+  if (!uiout->impl->redirect)
+    return -1;
+  uiout->impl->redirect (uiout, outstream);
+  return 0;
+}
+
 /* local functions */
 
 /* list of column headers manipulation routines */
index a52c3453722874a008507aa67fdf66054991a88e..3102e750ca5db400a2634a66303ddafac419d303 100644 (file)
@@ -231,6 +231,8 @@ typedef void (message_ftype) (struct ui_out * uiout, int verbosity,
                              const char *format, va_list args);
 typedef void (wrap_hint_ftype) (struct ui_out * uiout, char *identstring);
 typedef void (flush_ftype) (struct ui_out * uiout);
+typedef int (redirect_ftype) (struct ui_out * uiout,
+                             struct ui_file * outstream);
 
 /* ui-out-impl */
 
@@ -254,6 +256,7 @@ struct ui_out_impl
     message_ftype *message;
     wrap_hint_ftype *wrap_hint;
     flush_ftype *flush;
+    redirect_ftype *redirect;
     int is_mi_like_p;
   };
 
@@ -266,4 +269,8 @@ extern struct ui_out *ui_out_new (struct ui_out_impl *impl,
                                  struct ui_out_data *data,
                                  int flags);
 
+/* Redirect the ouptut of a ui_out object temporarily.  */
+
+extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream);
+
 #endif /* UI_OUT_H */