Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* GDB session logging
@ 2011-09-13 14:37 Abhijit Halder
  2011-09-14 17:48 ` [PATCH] " Abhijit Halder
  0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Halder @ 2011-09-13 14:37 UTC (permalink / raw)
  To: gdb-patches

Hi,

I can see that by using the following GDB commands I can enable logging:
(gdb) set logging file gdb-session.log
(gdb) set logging on

My concern here is that the file gdb-session.log contains only the
command output and not the command itself. After I complete my
debugging if I want to create a debug report out of my session log I
cannot do that as most of the output does not make sense to me. I
cannot remember which output of which command and in which context. I
believe we should log the command as well along with the command
output. There should be provision for logging only the command (along
with any error thrown by the command) and not the output of that
command.

Thanks,
Abhijit Halder


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] GDB session logging
  2011-09-13 14:37 GDB session logging Abhijit Halder
@ 2011-09-14 17:48 ` Abhijit Halder
  2011-09-15  6:30   ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Halder @ 2011-09-14 17:48 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] GDB session logging
  2011-09-14 17:48 ` [PATCH] " Abhijit Halder
@ 2011-09-15  6:30   ` Pedro Alves
  2011-09-15 11:55     ` Abhijit Halder
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2011-09-15  6:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Abhijit Halder

On Wednesday 14 September 2011 17:48:15, Abhijit Halder wrote:
> +/* Unlike standerd GDB logger stream, dump data only to the log-file.  */
> +extern struct ui_file *gdb_logfile;

Typo standard.  I don't understand the comment.

> @@ -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;

This is always NULL here.

Please make sure the output log makes sense with trace-commands
enabled.

I don't think printing the prompt and the command as you're
doing works correctly.  E.g., you'll print the prompt and
the command even for commands in a breakpoint's command list.
You want to print whatever the _user_ typed in, right?
That is, from a level higher up, in event-top.c:command_handler,
and event-top.c:display_gdb_prompt.

But then that does leave out from the log commands that were
run from "(gdb) define"d commands, and breakpoint command
lists, etc.  But that's what "set trace-commands" does.

So, should we really change what we log backwards incompatibly?
I'd say if you want the log of the whole complete session as
you saw it the first time, you just do logging elsewhere, say,
in your terminal, instead of within gdb.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] GDB session logging
  2011-09-15  6:30   ` Pedro Alves
@ 2011-09-15 11:55     ` Abhijit Halder
  0 siblings, 0 replies; 4+ messages in thread
From: Abhijit Halder @ 2011-09-15 11:55 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Wed, Sep 14, 2011 at 11:18 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> On Wednesday 14 September 2011 17:48:15, Abhijit Halder wrote:
>> +/* Unlike standerd GDB logger stream, dump data only to the log-file.  */
>> +extern struct ui_file *gdb_logfile;
>
> Typo standard.  I don't understand the comment.
>
>> @@ -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;
>
> This is always NULL here.
>
> Please make sure the output log makes sense with trace-commands
> enabled.
>
> I don't think printing the prompt and the command as you're
> doing works correctly.  E.g., you'll print the prompt and
> the command even for commands in a breakpoint's command list.
> You want to print whatever the _user_ typed in, right?
> That is, from a level higher up, in event-top.c:command_handler,
> and event-top.c:display_gdb_prompt.
>
> But then that does leave out from the log commands that were
> run from "(gdb) define"d commands, and breakpoint command
> lists, etc.  But that's what "set trace-commands" does.
>
> So, should we really change what we log backwards incompatibly?
> I'd say if you want the log of the whole complete session as
> you saw it the first time, you just do logging elsewhere, say,
> in your terminal, instead of within gdb.
>
Yes I also was not sure about the acceptability of this feature when I
started working on this. Okay, I am NOT resubmitting the patch with
suggested corrections as we will not achieve much with this feature
and further there is backward compatibility issue.

By the way, thanks for reviewing this patch.

Regards,
Abhijit Halder
> --
> Pedro Alves
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-15  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-13 14:37 GDB session logging Abhijit Halder
2011-09-14 17:48 ` [PATCH] " Abhijit Halder
2011-09-15  6:30   ` Pedro Alves
2011-09-15 11:55     ` Abhijit Halder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox