Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA 10/10] Implement -trace-save.
@ 2009-08-05  8:37 Vladimir Prus
  2009-08-05 10:38 ` Vladimir Prus
  0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Prus @ 2009-08-05  8:37 UTC (permalink / raw)
  To: gdb-patches


- Volodya

	* mi-cmds.h (mi_cmds_trace_save): Declare.
	* mi-cmds.c (mi_cmds): Register -trace-save.
	* mi/mi-main.c (mi_cmd_trace_save): New.
	* remote.c (remote_save_trace_data): Take const parameter.
	* target.h (struct target_ops::to_save_trace_data): Take
	const parameter.
	* target.c (update_current_target): Adjust to the above.
	* tracepoint.c (trave_save): New, extracted from
	(trace_save_command): ...this.
	(tfile_trace_find): Remove message that is unnecessary now
	that 'tfind' reports found frame.
	* tracepoint.h (trace_save): Declare.
---
 gdb/mi/mi-cmds.c |    2 +-
 gdb/mi/mi-cmds.h |    1 +
 gdb/mi/mi-main.c |   26 ++++++++++++++++++++
 gdb/remote.c     |    2 +-
 gdb/target.c     |    2 +-
 gdb/target.h     |    2 +-
 gdb/tracepoint.c |   70 +++++++++++++++++++++++++++++++++--------------------
 gdb/tracepoint.h |    2 +
 8 files changed, 76 insertions(+), 31 deletions(-)

diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index b68cdca..096ffb3 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -144,7 +144,7 @@ struct mi_cmd mi_cmds[] =
   { "trace-find", { NULL, 0 }, mi_cmd_trace_find },
   { "trace-frame-number", { NULL, 0 }, NULL },
   { "trace-list-variables", { NULL, 0 }, mi_cmd_trace_list_variables },
-  { "trace-save", { NULL, 0 }, NULL },
+  { "trace-save", { NULL, 0 }, mi_cmd_trace_save },
   { "trace-start", { NULL, 0 }, mi_cmd_trace_start },
   { "trace-status", { NULL, 0 }, mi_cmd_trace_status },
   { "trace-stop", { NULL, 0 }, mi_cmd_trace_stop },
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 75d0bb3..a77a3df 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -88,6 +88,7 @@ extern mi_cmd_argv_ftype mi_cmd_thread_select;
 extern mi_cmd_argv_ftype mi_cmd_trace_define_variable;
 extern mi_cmd_argv_ftype mi_cmd_trace_find;
 extern mi_cmd_argv_ftype mi_cmd_trace_list_variables;
+extern mi_cmd_argv_ftype mi_cmd_trace_save;
 extern mi_cmd_argv_ftype mi_cmd_trace_start;
 extern mi_cmd_argv_ftype mi_cmd_trace_status;
 extern mi_cmd_argv_ftype mi_cmd_trace_stop;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 52edb80..bc58112 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1705,6 +1705,32 @@ mi_cmd_trace_list_variables (char *command, char **argv, int argc)
 }
 
 void
+mi_cmd_trace_save (char *command, char **argv, int argc)
+{
+  int target_saves = 0;
+  char *filename;
+
+  if (argc != 1 && argc != 2)
+    error (_("Usage: -trace-save [-r] filename"));
+
+  if (argc == 2)
+    {
+      filename = argv[1];
+      if (strcmp (argv[0], "-r") == 0)
+	target_saves = 1;
+      else
+	error (_("Invalid option: %s"), argv[0]);
+    }
+  else
+    {
+      filename = argv[0];
+    }
+
+  trace_save (filename, target_saves);
+}
+
+
+void
 mi_cmd_trace_start (char *command, char **argv, int argc)
 {
   start_tracing ();
diff --git a/gdb/remote.c b/gdb/remote.c
index 26f2ca4..c12c9d3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9271,7 +9271,7 @@ remote_get_trace_state_variable_value (int tsvnum, LONGEST *val)
 }
 
 static int
-remote_save_trace_data (char *filename)
+remote_save_trace_data (const char *filename)
 {
   struct remote_state *rs = get_remote_state ();
   char *p, *reply;
diff --git a/gdb/target.c b/gdb/target.c
index 4d2dedb..0f49d45 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -694,7 +694,7 @@ update_current_target (void)
 	    (int (*) (int, LONGEST *))
 	    return_zero);
   de_fault (to_save_trace_data,
-	    (int (*) (char *))
+	    (int (*) (const char *))
 	    tcomplain);
   de_fault (to_upload_tracepoints,
 	    (int (*) (struct uploaded_tp **))
diff --git a/gdb/target.h b/gdb/target.h
index 0ad0493..583b1fa 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -552,7 +552,7 @@ struct target_ops
     int (*to_trace_find) (enum trace_find_type type, int num,
 			  ULONGEST addr1, ULONGEST addr2, int *tpp);
     int (*to_get_trace_state_variable_value) (int tsv, LONGEST *val);
-    int (*to_save_trace_data) (char *filename);
+    int (*to_save_trace_data) (const char *filename);
     int (*to_upload_tracepoints) (struct uploaded_tp **utpp);
     int (*to_upload_trace_state_variables) (struct uploaded_tsv **utsvp);
     LONGEST (*to_get_raw_trace_data) (gdb_byte *buf,
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 8224e7c..592ee7d 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2323,13 +2323,16 @@ trace_dump_command (char *args, int from_tty)
 
 extern int trace_regblock_size;
 
-static void
-trace_save_command (char *args, int from_tty)
+/** Save tracepoint data to file named FILENAME.
+    If TARGET_DOES_SAVE is non-zero, the save is
+    performed on the target, otherwise GDB obtains
+    all trace data and saves it locally.  */
+
+void
+trace_save (const char *filename, int target_does_save)
 {
-  char **argv;
-  char *filename = NULL, *pathname;
-  int target_does_save = 0;
   struct cleanup *cleanup;
+  char *pathname;
   struct trace_status *ts = current_trace_status ();
   int err, status;
   FILE *fp;
@@ -2340,25 +2343,6 @@ trace_save_command (char *args, int from_tty)
 #define MAX_TRACE_UPLOAD 2000
   gdb_byte buf[MAX_TRACE_UPLOAD];
 
-  if (args == NULL)
-    error_no_arg (_("file in which to save trace data"));
-
-  argv = gdb_buildargv (args);
-  make_cleanup_freeargv (argv);
-
-  for (; *argv; ++argv)
-    {
-      if (strcmp (*argv, "-r") == 0)
-	target_does_save = 1;
-      else if (**argv == '-')
-	error (_("unknown option `%s'"), *argv);
-      else
-	filename = *argv;
-    }
-
-  if (!filename)
-    error_no_arg (_("file in which to save trace data"));
-
   /* If the target is to save the data to a file on its own, then just
      send the command and be done with it.  */
   if (target_does_save)
@@ -2374,13 +2358,13 @@ trace_save_command (char *args, int from_tty)
      target is losing, we can get out without touching files.  */
   status = target_get_trace_status (ts);
 
-  pathname = tilde_expand (args);
+  pathname = tilde_expand (filename);
   cleanup = make_cleanup (xfree, pathname);
 
   fp = fopen (pathname, "w");
   if (!fp)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
-	   args, safe_strerror (errno));
+	   filename, safe_strerror (errno));
   make_cleanup_fclose (fp);
 
   /* Write a file header, with a high-bit-set char to indicate a
@@ -2449,8 +2433,41 @@ trace_save_command (char *args, int from_tty)
   fwrite (&gotten, 4, 1, fp);
 
   do_cleanups (cleanup);
+}
+
+static void
+trace_save_command (char *args, int from_tty)
+{
+  int target_does_save = 0;
+  char **argv;
+  char *filename = NULL;
+  struct cleanup *back_to;
+
+  if (args == NULL)
+    error_no_arg (_("file in which to save trace data"));
+
+  argv = gdb_buildargv (args);
+  back_to = make_cleanup_freeargv (argv);
+
+  for (; *argv; ++argv)
+    {
+      if (strcmp (*argv, "-r") == 0)
+	target_does_save = 1;
+      else if (**argv == '-')
+	error (_("unknown option `%s'"), *argv);
+      else
+	filename = *argv;
+    }
+
+  if (!filename)
+    error_no_arg (_("file in which to save trace data"));
+
+  trace_save (filename, target_does_save);
+
   if (from_tty)
     printf_filtered (_("Trace data saved to file '%s'.\n"), args);
+
+  do_cleanups (back_to);
 }
 
 /* Tell the target what to do with an ongoing tracing run if GDB
@@ -2950,7 +2967,6 @@ tfile_trace_find (enum trace_find_type type, int num,
 	}
       if (found)
 	{
-	  printf_filtered ("Found traceframe %d.\n", tfnum);
 	  if (tpp)
 	    *tpp = tpnum;
 	  cur_offset = offset;
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 18a5da5..3ec02ee 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -167,4 +167,6 @@ extern void tfind_1 (enum trace_find_type type, int num,
 		     ULONGEST addr1, ULONGEST addr2,
 		     int from_tty);
 
+extern void trace_save (const char *filename, int target_does_save);
+
 #endif	/* TRACEPOINT_H */
-- 
1.6.3.2


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

* Re: [RFA 10/10] Implement -trace-save.
  2009-08-05  8:37 [RFA 10/10] Implement -trace-save Vladimir Prus
@ 2009-08-05 10:38 ` Vladimir Prus
  2009-08-06 14:23   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Prus @ 2009-08-05 10:38 UTC (permalink / raw)
  To: gdb-patches

Vladimir Prus wrote:

> 
> - Volodya
> 
> * mi-cmds.h (mi_cmds_trace_save): Declare.
> * mi-cmds.c (mi_cmds): Register -trace-save.
> * mi/mi-main.c (mi_cmd_trace_save): New.
> * remote.c (remote_save_trace_data): Take const parameter.
> * target.h (struct target_ops::to_save_trace_data): Take
> const parameter.
> * target.c (update_current_target): Adjust to the above.
> * tracepoint.c (trave_save): New, extracted from
> (trace_save_command): ...this.
> (tfile_trace_find): Remove message that is unnecessary now
> that 'tfind' reports found frame.
> * tracepoint.h (trace_save): Declare.

This email was accidentally sent. Please ignore it for a while.

Sorry,
Volodya



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

* Re: [RFA 10/10] Implement -trace-save.
  2009-08-05 10:38 ` Vladimir Prus
@ 2009-08-06 14:23   ` Thiago Jung Bauermann
  2009-08-06 16:01     ` Thiago Jung Bauermann
  2009-08-06 20:18     ` Vladimir Prus
  0 siblings, 2 replies; 5+ messages in thread
From: Thiago Jung Bauermann @ 2009-08-06 14:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Vladimir Prus, gdb-patches

Em Quarta-feira 05 Agosto 2009 07:38:07 Vladimir Prus escreveu:
> This email was accidentally sent. Please ignore it for a while.

Will you tell us when we can stop ignoring it? :-D
-- 
[]'s
Thiago Jung Bauermann


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

* Re: [RFA 10/10] Implement -trace-save.
  2009-08-06 14:23   ` Thiago Jung Bauermann
@ 2009-08-06 16:01     ` Thiago Jung Bauermann
  2009-08-06 20:18     ` Vladimir Prus
  1 sibling, 0 replies; 5+ messages in thread
From: Thiago Jung Bauermann @ 2009-08-06 16:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Vladimir Prus, gdb-patches

Em Quarta-feira 05 Agosto 2009 07:38:07 Vladimir Prus escreveu:
> This email was accidentally sent. Please ignore it for a while.

Will you tell us when we can stop ignoring it? :-D
-- 
[]'s
Thiago Jung Bauermann


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

* Re: [RFA 10/10] Implement -trace-save.
  2009-08-06 14:23   ` Thiago Jung Bauermann
  2009-08-06 16:01     ` Thiago Jung Bauermann
@ 2009-08-06 20:18     ` Vladimir Prus
  1 sibling, 0 replies; 5+ messages in thread
From: Vladimir Prus @ 2009-08-06 20:18 UTC (permalink / raw)
  To: gdb-patches

Thiago Jung Bauermann wrote:

> Em Quarta-feira 05 Agosto 2009 07:38:07 Vladimir Prus escreveu:
>> This email was accidentally sent. Please ignore it for a while.
> 
> Will you tell us when we can stop ignoring it? :-D

I am sure you won't miss a spam storm consisting of 10 (*) MI tracepoint
patches, and untold number of core tracepoint patches ;-)

- Volodya

(*) 12 now, actually.







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

end of thread, other threads:[~2009-08-06 19:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-05  8:37 [RFA 10/10] Implement -trace-save Vladimir Prus
2009-08-05 10:38 ` Vladimir Prus
2009-08-06 14:23   ` Thiago Jung Bauermann
2009-08-06 16:01     ` Thiago Jung Bauermann
2009-08-06 20:18     ` Vladimir Prus

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