Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stan Shebs <stan@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Update save-tracepoints for new features
Date: Tue, 30 Mar 2010 23:29:00 -0000	[thread overview]
Message-ID: <4BB28933.60708@codesourcery.com> (raw)

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

             reply	other threads:[~2010-03-30 23:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-30 23:29 Stan Shebs [this message]
2010-03-30 23:33 ` Pedro Alves
2010-03-31 18:01   ` Stan Shebs

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=4BB28933.60708@codesourcery.com \
    --to=stan@codesourcery.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