Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Abhijit Halder <abhijit.k.halder@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] GDB session logging
Date: Wed, 14 Sep 2011 17:48:00 -0000	[thread overview]
Message-ID: <CAOhZP9ygX6RRSC_L3RDJtHzZ1Cv7CmXp3p_iSx-w-z8Q3Ldogg@mail.gmail.com> (raw)
In-Reply-To: <CAOhZP9y16xfMv-my93xG-0h_mekZV7iWzjbQS8EOiFyy=GYTKA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

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 #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 483 bytes --]

2011-09-13  Abhijit Halder  <abhijit.k.halder@gmail.com>

	Modify logging.

	* main.c (gdb_logfile): Define a new global variable.
	* defs.h (gdb_logfile): Of type GDB_FILE, will pass this around gdb
	to access the log file if presents.
	* top.c (execute_command): Log the command to be executed on file if
	logging is enabled.
	* cli/cli-logging.c (handle_redirections): Assign gdb_logfile the file
	streams associated with log-file.
	(pop_output_files): Reset gdb_logfile to NULL.

[-- Attachment #3: gdb-logging.patch --]
[-- Type: text/x-patch, Size: 2539 bytes --]

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"));

  reply	other threads:[~2011-09-14 16:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 14:37 Abhijit Halder
2011-09-14 17:48 ` Abhijit Halder [this message]
2011-09-15  6:30   ` [PATCH] " Pedro Alves
2011-09-15 11:55     ` Abhijit Halder

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=CAOhZP9ygX6RRSC_L3RDJtHzZ1Cv7CmXp3p_iSx-w-z8Q3Ldogg@mail.gmail.com \
    --to=abhijit.k.halder@gmail.com \
    --cc=gdb-patches@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: 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