public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Update save-tracepoints for new features
@ 2010-03-30 23:29 Stan Shebs
  2010-03-30 23:33 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Stan Shebs @ 2010-03-30 23:29 UTC (permalink / raw)
  To: gdb-patches

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

This patch simply teaches save-tracepoints about recent features.

Stan

2010-03-30  Stan Shebs  <stan@codesourcery.com>

    * breakpoint.c (tracepoint_save_command): Include variables,
     conditionals, tracepoint types, and default-collect.
    * tracepoint.c (save_trace_state_variables): New function.
    * tracepoint.h (save_trace_state_variables): Declare it.

    * gdb.trace/save-trace.exp: Test save/restore of default-collect
    and tracepoint conditionals.
    (gdb_verify_tracepoints): Delete unused return.


[-- Attachment #2: savetrace-patch-1 --]
[-- Type: text/plain, Size: 6120 bytes --]

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.472
diff -p -r1.472 breakpoint.c
*** breakpoint.c	29 Mar 2010 23:45:05 -0000	1.472
--- breakpoint.c	30 Mar 2010 23:18:17 -0000
*************** tracepoint_save_command (char *args, int
*** 10626,10631 ****
--- 10626,10632 ----
    char tmp[40];
    struct cleanup *cleanup;
    struct ui_file *fp;
+   extern char *default_collect;
  
    if (args == 0 || *args == 0)
      error (_("Argument required (file name in which to save tracepoints)"));
*************** tracepoint_save_command (char *args, int
*** 10649,10665 ****
      error (_("Unable to open file '%s' for saving tracepoints (%s)"),
  	   args, safe_strerror (errno));
    make_cleanup_ui_file_delete (fp);
!   
    ALL_TRACEPOINTS (tp)
    {
      if (tp->addr_string)
!       fprintf_unfiltered (fp, "trace %s\n", tp->addr_string);
      else
        {
  	sprintf_vma (tmp, tp->loc->address);
! 	fprintf_unfiltered (fp, "trace *0x%s\n", tmp);
        }
  
      if (tp->pass_count)
        fprintf_unfiltered (fp, "  passcount %d\n", tp->pass_count);
  
--- 10650,10678 ----
      error (_("Unable to open file '%s' for saving tracepoints (%s)"),
  	   args, safe_strerror (errno));
    make_cleanup_ui_file_delete (fp);
! 
!   save_trace_state_variables (fp);
! 
    ALL_TRACEPOINTS (tp)
    {
+     if (tp->type == bp_fast_tracepoint)
+       fprintf_unfiltered (fp, "ftrace");
+     else
+       fprintf_unfiltered (fp, "trace");
+ 
      if (tp->addr_string)
!       fprintf_unfiltered (fp, " %s", tp->addr_string);
      else
        {
  	sprintf_vma (tmp, tp->loc->address);
! 	fprintf_unfiltered (fp, " *0x%s", tmp);
        }
  
+     if (tp->cond_string)
+       fprintf_unfiltered (fp, " if %s", tp->cond_string);
+ 
+     fprintf_unfiltered (fp, "\n");
+ 
      if (tp->pass_count)
        fprintf_unfiltered (fp, "  passcount %d\n", tp->pass_count);
  
*************** tracepoint_save_command (char *args, int
*** 10682,10687 ****
--- 10695,10704 ----
  	fprintf_unfiltered (fp, "  end\n");
        }
    }
+ 
+   if (*default_collect)
+     fprintf_unfiltered (fp, "set default-collect %s\n", default_collect);
+ 
    do_cleanups (cleanup);
    if (from_tty)
      printf_filtered (_("Tracepoints saved to file '%s'.\n"), args);
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.164
diff -p -r1.164 tracepoint.c
*** tracepoint.c	30 Mar 2010 00:19:43 -0000	1.164
--- tracepoint.c	30 Mar 2010 23:18:17 -0000
*************** tvariables_info (char *args, int from_tt
*** 479,484 ****
--- 479,501 ----
    tvariables_info_1 ();
  }
  
+ /* Stash definitions of tsvs into the given file.  */
+ 
+ void
+ save_trace_state_variables (struct ui_file *fp)
+ {
+   struct trace_state_variable *tsv;
+   int ix;
+ 
+   for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
+     {
+       fprintf_unfiltered (fp, "tvariable $%s", tsv->name);
+       if (tsv->initial_value)
+ 	fprintf_unfiltered (fp, " = %s", plongest (tsv->initial_value));
+       fprintf_unfiltered (fp, "\n");
+     }
+ }
+ 
  /* ACTIONS functions: */
  
  /* The three functions:
Index: tracepoint.h
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.h,v
retrieving revision 1.31
diff -p -r1.31 tracepoint.h
*** tracepoint.h	29 Mar 2010 23:45:06 -0000	1.31
--- tracepoint.h	30 Mar 2010 23:18:17 -0000
*************** extern void stop_tracing (void);
*** 207,212 ****
--- 207,213 ----
  extern void trace_status_mi (int on_stop);
  
  extern void tvariables_info_1 (void);
+ extern void save_trace_state_variables (struct ui_file *fp);
  
  extern void tfind_1 (enum trace_find_type type, int num,
  		     ULONGEST addr1, ULONGEST addr2,
Index: testsuite/gdb.trace/save-trace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.trace/save-trace.exp,v
retrieving revision 1.14
diff -p -r1.14 save-trace.exp
*** testsuite/gdb.trace/save-trace.exp	1 Jan 2010 07:32:07 -0000	1.14
--- testsuite/gdb.trace/save-trace.exp	30 Mar 2010 23:18:17 -0000
*************** foreach x { 1 2 3 4 5 6 } {
*** 73,78 ****
--- 73,82 ----
  	     "Setting tracepoint $trcpt.* to $x" \
  	     "10.x: set passcount for tracepoint $trcpt"
  
+     gdb_test "condition $trcpt $x - 1 == $x / 2" \
+ 	     "" \
+ 	     "10.x: set condition for tracepoint $trcpt"
+ 
      gdb_trace_setactions "10.x: set actions for tracepoint $x" \
  	    "" \
  	    "collect q$x" "^$" \
*************** foreach x { 1 2 3 4 5 6 } {
*** 81,86 ****
--- 85,93 ----
  	    "end" "^$"
  }
  
+ gdb_test "set default-collect gdb_char_test, gdb_long_test - 100" \
+     "" \
+     "10: set default-collect"
  
  proc gdb_verify_tracepoints { testname } {
      global gdb_prompt;
*************** proc gdb_verify_tracepoints { testname }
*** 91,97 ****
      set result "pass";
      send_gdb "info tracepoints\n";
      gdb_expect 10 {
! 	-re "\[0-9\]+\[\t \]+tracepoint\[\t \]+keep y\[\t \]+0x\[0-9a-fA-F\]+ in gdb_recursion_test\[^\r\n\]+" {
  #	    if { $expect_out(1,string) != $ourstate } {
  #		set result "fail";
  #	    }
--- 98,104 ----
      set result "pass";
      send_gdb "info tracepoints\n";
      gdb_expect 10 {
! 	-re "\[0-9\]+\[\t \]+tracepoint\[\t \]+keep y\[\t \]+0x\[0-9a-fA-F\]+ in gdb_recursion_test\[^\r\n\]+\r\n\[ \t]+trace only if \[0-9\] - 1 == \[0-9\] / 2" {
  #	    if { $expect_out(1,string) != $ourstate } {
  #		set result "fail";
  #	    }
*************** proc gdb_verify_tracepoints { testname }
*** 110,116 ****
  	}
      }
      $result $testname;
!     return $result;
  }
  
  gdb_verify_tracepoints "10.x: verify trace setup";
--- 117,126 ----
  	}
      }
      $result $testname;
! 
!     gdb_test "show default-collect" \
! 	"The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
! 	"10: show default-collect"
  }
  
  gdb_verify_tracepoints "10.x: verify trace setup";

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

* Re: [PATCH] Update save-tracepoints for new features
  2010-03-30 23:29 [PATCH] Update save-tracepoints for new features Stan Shebs
@ 2010-03-30 23:33 ` Pedro Alves
  2010-03-31 18:01   ` Stan Shebs
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-03-30 23:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Stan Shebs

On Wednesday 31 March 2010 00:28:51, Stan Shebs wrote:
> *************** tracepoint_save_command (char *args, int
> *** 10626,10631 ****
> --- 10626,10632 ----
>     char tmp[40];
>     struct cleanup *cleanup;
>     struct ui_file *fp;
> +   extern char *default_collect;

This is declared in tracepoint.h.

-- 
Pedro Alves

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

* Re: [PATCH] Update save-tracepoints for new features
  2010-03-30 23:33 ` Pedro Alves
@ 2010-03-31 18:01   ` Stan Shebs
  0 siblings, 0 replies; 3+ messages in thread
From: Stan Shebs @ 2010-03-31 18:01 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Stan Shebs

Pedro Alves wrote:
> On Wednesday 31 March 2010 00:28:51, Stan Shebs wrote:
>   
>> *************** tracepoint_save_command (char *args, int
>> *** 10626,10631 ****
>> --- 10626,10632 ----
>>     char tmp[40];
>>     struct cleanup *cleanup;
>>     struct ui_file *fp;
>> +   extern char *default_collect;
>>     
>
> This is declared in tracepoint.h.
>   

I left it in there just for you. :-)  Committed with that change.

Stan

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

end of thread, other threads:[~2010-03-31 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-30 23:29 [PATCH] Update save-tracepoints for new features Stan Shebs
2010-03-30 23:33 ` Pedro Alves
2010-03-31 18:01   ` Stan Shebs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).