This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] GDB session logging


This patch is to log along with the output of a command into a
log-file also the command itself when log is enabled. Please review
the patch.

Regards,
Abhijit Halder

Attachment: ChangeLog.txt
Description: Text document

Index: gdb/defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.301
diff -u -p -r1.301 defs.h
--- gdb/defs.h	9 Sep 2011 19:41:13 -0000	1.301
+++ gdb/defs.h	14 Sep 2011 15:49:29 -0000
@@ -467,6 +467,9 @@ extern struct ui_file *gdb_stdtarg;
 extern struct ui_file *gdb_stdtargerr;
 extern struct ui_file *gdb_stdtargin;
 
+/* Unlike standerd GDB logger stream, dump data only to the log-file.  */
+extern struct ui_file *gdb_logfile;
+
 #include "ui-file.h"
 
 /* More generic printf like operations.  Filtered versions may return
Index: gdb/main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.96
diff -u -p -r1.96 main.c
--- gdb/main.c	2 Sep 2011 16:56:29 -0000	1.96
+++ gdb/main.c	14 Sep 2011 15:49:29 -0000
@@ -74,6 +74,8 @@ struct ui_file *gdb_stdtargin;
 struct ui_file *gdb_stdtarg;
 struct ui_file *gdb_stdtargerr;
 
+struct ui_file *gdb_logfile;
+
 /* True if --batch or --batch-silent was seen.  */
 int batch_flag = 0;
 
Index: gdb/top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.207
diff -u -p -r1.207 top.c
--- gdb/top.c	6 Sep 2011 14:48:59 -0000	1.207
+++ gdb/top.c	14 Sep 2011 15:49:31 -0000
@@ -401,6 +401,9 @@ execute_command (char *p, int from_tty)
       /* If trace-commands is set then this will print this command.  */
       print_command_trace (p);
 
+      if (gdb_logfile)
+        fprintf_unfiltered (gdb_logfile, "%s%s\n", get_prompt (), line);
+
       c = lookup_cmd (&p, cmdlist, "", 0, 1);
 
       /* Pass null arg rather than an empty one.  */
Index: gdb/cli/cli-logging.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-logging.c,v
retrieving revision 1.30
diff -u -p -r1.30 cli-logging.c
--- gdb/cli/cli-logging.c	4 Aug 2011 19:10:13 -0000	1.30
+++ gdb/cli/cli-logging.c	14 Sep 2011 15:49:31 -0000
@@ -166,6 +166,7 @@ pop_output_files (void)
   saved_output.log = NULL;
   saved_output.targ = NULL;
   saved_output.targerr = NULL;
+  gdb_logfile = logging_no_redirect_file;
 
   ui_out_redirect (current_uiout, NULL);
 }
@@ -194,6 +195,7 @@ handle_redirections (int from_tty)
     {
       struct ui_file *no_redirect_file = output;
 
+      gdb_logfile = no_redirect_file;
       output = tee_file_new (gdb_stdout, 0, no_redirect_file, 0);
       if (output == NULL)
 	perror_with_name (_("set logging"));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]