]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Mon Sep 14 20:00:04 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
authorMichael Snyder <msnyder@vmware.com>
Tue, 15 Sep 1998 22:25:01 +0000 (22:25 +0000)
committerMichael Snyder <msnyder@vmware.com>
Tue, 15 Sep 1998 22:25:01 +0000 (22:25 +0000)
        * lib/<emc-support.exp trace-support.exp}: New files.
        * configure.in: add new test directory gdb.trace.
        * gdb.trace/{configure configure.in Makefile.in}: New files.
        * gdb.trace/{actions.c actions.exp gdb_c_test.c}: New files.
        * gdb.trace/{circ.c circ.exp limits.c limits.exp}: New files.
        * gdb.trace/{collection.c collection.exp tfind.exp }: New files.
        * gdb.trace/{backtrace.exp deltrace.exp infotrace.exp}: New files.
        * gdb.trace/{packetlen.exp passc-dyn.exp passcount.exp}: New files.
        * gdb.trace/{report.exp save-trace.exp tracecmd.exp}: New files.
        * gdb.trace/{while-dyn.exp while-stepping.exp}: New files.

26 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/configure.in
gdb/testsuite/gdb.trace/Makefile.in [new file with mode: 0644]
gdb/testsuite/gdb.trace/actions.c [new file with mode: 0644]
gdb/testsuite/gdb.trace/actions.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/backtrace.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/circ.c [new file with mode: 0644]
gdb/testsuite/gdb.trace/circ.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/collection.c [new file with mode: 0644]
gdb/testsuite/gdb.trace/collection.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/configure [new file with mode: 0755]
gdb/testsuite/gdb.trace/configure.in [new file with mode: 0644]
gdb/testsuite/gdb.trace/deltrace.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/infotrace.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/limits.c [new file with mode: 0644]
gdb/testsuite/gdb.trace/limits.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/packetlen.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/passc-dyn.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/passcount.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/report.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/save-trace.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/tfind.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/tracecmd.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/while-dyn.exp [new file with mode: 0644]
gdb/testsuite/gdb.trace/while-stepping.exp [new file with mode: 0644]
gdb/testsuite/lib/trace-support.exp [new file with mode: 0644]

index df78a4acb5c2ec24540712f936c24cc1ad125612..3fbf10109ad6007092fc0c8ce36806bf1cb7174e 100644 (file)
@@ -1,7 +1,17 @@
 Mon Sep 14 20:00:04 1998  Michael Snyder  <msnyder@cleaver.cygnus.com>
 
        * config/m68k-emc.exp: New file.
-
+       * lib/<emc-support.exp trace-support.exp}: New files.
+       * configure.in: add new test directory gdb.trace.
+       * gdb.trace/{configure configure.in Makefile.in}: New files.
+       * gdb.trace/{actions.c actions.exp gdb_c_test.c}: New files.
+       * gdb.trace/{circ.c circ.exp limits.c limits.exp}: New files.
+       * gdb.trace/{collection.c collection.exp tfind.exp }: New files.
+       * gdb.trace/{backtrace.exp deltrace.exp infotrace.exp}: New files.
+       * gdb.trace/{packetlen.exp passc-dyn.exp passcount.exp}: New files.
+       * gdb.trace/{report.exp save-trace.exp tracecmd.exp}: New files.
+       * gdb.trace/{while-dyn.exp while-stepping.exp}: New files.
+       
 Fri Sep 11 13:58:02 1998  Michael Snyder  <msnyder@cleaver.cygnus.com>
 
        * gdb.c++/classes.exp: Change all regular expressions to match
index 484526341833aaee88576407d4c670c47e542687..a0f51daec0ad3500bb8405d7856d8531c4bca21a 100644 (file)
@@ -13,7 +13,7 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
 AC_CANONICAL_SYSTEM
 
 # Directories to use in all configurations.
-configdirs="gdb.asm gdb.base gdb.c++ gdb.disasm gdb.chill gdb.threads"
+configdirs="gdb.asm gdb.base gdb.c++ gdb.disasm gdb.chill gdb.threads gdb.trace"
 
 # Directories to use for a configuration which uses stabs.
 stabsdirs="gdb.stabs"
diff --git a/gdb/testsuite/gdb.trace/Makefile.in b/gdb/testsuite/gdb.trace/Makefile.in
new file mode 100644 (file)
index 0000000..ab228dd
--- /dev/null
@@ -0,0 +1,20 @@
+#### host, target, and site specific Makefile frags come in here.
+
+VPATH = @srcdir@
+srcdir = @srcdir@
+
+.PHONY: all clean mostlyclean distclean realclean
+
+all: 
+       @echo "Nothing to be done for all..."   
+
+clean mostlyclean:
+       -rm -f *.o *.diff *~ *.bad core sh3 hppa mn10200 mn10300
+
+distclean maintainer-clean realclean: clean
+       -rm -f Makefile config.status config.log
+
+Makefile: $(srcdir)/Makefile.in $(srcdir)/configure.in
+       $(SHELL) ./config.status --recheck
+
+
diff --git a/gdb/testsuite/gdb.trace/actions.c b/gdb/testsuite/gdb.trace/actions.c
new file mode 100644 (file)
index 0000000..e8df614
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Test program for trace action commands
+ */
+
+static char   gdb_char_test;
+static short  gdb_short_test;
+static long   gdb_long_test;
+static char   gdb_arr_test[25];
+static struct GDB_STRUCT_TEST
+{
+  char   c;
+  short  s;
+  long   l;
+  int    bfield : 11;  /* collect bitfield */
+  char   arr[25];
+  struct GDB_STRUCT_TEST *next;
+} gdb_struct1_test, gdb_struct2_test, *gdb_structp_test, **gdb_structpp_test;
+
+static union GDB_UNION_TEST
+{
+  char   c;
+  short  s;
+  long   l;
+  int    bfield : 11;  /* collect bitfield */
+  char   arr[4];
+  union GDB_UNION_TEST *next;
+} gdb_union1_test;
+
+void gdb_recursion_test (int, int, int, int,  int,  int,  int);
+
+void gdb_recursion_test (int depth, 
+                        int q1, 
+                        int q2, 
+                        int q3, 
+                        int q4, 
+                        int q5, 
+                        int q6)
+{      /* gdb_recursion_test line 0 */
+  int q = q1;                                          /* gdbtestline 1 */
+
+  q1 = q2;                                             /* gdbtestline 2 */
+  q2 = q3;                                             /* gdbtestline 3 */
+  q3 = q4;                                             /* gdbtestline 4 */
+  q4 = q5;                                             /* gdbtestline 5 */
+  q5 = q6;                                             /* gdbtestline 6 */
+  q6 = q;                                              /* gdbtestline 7 */
+  if (depth--)                                         /* gdbtestline 8 */
+    gdb_recursion_test (depth, q1, q2, q3, q4, q5, q6);        /* gdbtestline 9 */
+}
+
+
+unsigned long   gdb_c_test( unsigned long *parm )
+
+{
+   char *p = "gdb_c_test";
+   char *rediculously_long_variable_name_with_equally_long_string_assignment;
+   register long local_reg = 7;
+   static unsigned long local_static, local_static_sizeof;
+   long local_long;
+   unsigned long *stack_ptr;
+   unsigned long end_of_stack;
+
+   rediculously_long_variable_name_with_equally_long_string_assignment = 
+     "rediculously long variable name with equally long string assignment";
+   local_static = 9;
+   local_static_sizeof = sizeof (struct GDB_STRUCT_TEST);
+   local_long = local_reg + 1;
+   stack_ptr  = (unsigned long *) &local_long;
+   end_of_stack = 
+     (unsigned long) &stack_ptr + sizeof(stack_ptr) + sizeof(end_of_stack) - 1;
+
+   gdb_char_test   = gdb_struct1_test.c = (char)   ((long) parm[1] & 0xff);
+   gdb_short_test  = gdb_struct1_test.s = (short)  ((long) parm[2] & 0xffff);
+   gdb_long_test   = gdb_struct1_test.l = (long)   ((long) parm[3] & 0xffffffff);
+   gdb_union1_test.l = (long) parm[4];
+   gdb_arr_test[0] = gdb_struct1_test.arr[0] = (char) ((long) parm[1] & 0xff);
+   gdb_arr_test[1] = gdb_struct1_test.arr[1] = (char) ((long) parm[2] & 0xff);
+   gdb_arr_test[2] = gdb_struct1_test.arr[2] = (char) ((long) parm[3] & 0xff);
+   gdb_arr_test[3] = gdb_struct1_test.arr[3] = (char) ((long) parm[4] & 0xff);
+   gdb_arr_test[4] = gdb_struct1_test.arr[4] = (char) ((long) parm[5] & 0xff);
+   gdb_arr_test[5] = gdb_struct1_test.arr[5] = (char) ((long) parm[6] & 0xff);
+   gdb_struct1_test.bfield = 144;
+   gdb_struct1_test.next = &gdb_struct2_test;
+   gdb_structp_test      = &gdb_struct1_test;
+   gdb_structpp_test     = &gdb_structp_test;
+
+   gdb_recursion_test (3, (long) parm[1], (long) parm[2], (long) parm[3],
+                      (long) parm[4], (long) parm[5], (long) parm[6]);
+
+   gdb_char_test = gdb_short_test = gdb_long_test = 0;
+   gdb_structp_test  = (void *) 0;
+   gdb_structpp_test = (void *) 0;
+   memset ((char *) &gdb_struct1_test, 0, sizeof (gdb_struct1_test));
+   memset ((char *) &gdb_struct2_test, 0, sizeof (gdb_struct2_test));
+   local_static_sizeof = 0;
+   local_static = 0;
+   return ( (unsigned long) 0 );
+}
+
+static void gdb_asm_test (void)
+{
+}
+
+static void begin ()   /* called before anything else */
+{
+}
+
+static void end ()     /* called after everything else */
+{
+}
+
+int
+main (argc, argv, envp)
+     int argc;
+     char *argv[], **envp;
+{
+  int i;
+  unsigned long myparms[10];
+
+#ifdef usestubs
+  set_debug_traps ();
+  breakpoint ();
+#endif
+
+  begin ();
+  for (i = 0; i < sizeof (myparms) / sizeof (myparms[0]); i++)
+    myparms[i] = i;
+
+  gdb_c_test (&myparms[0]);
+
+  end ();
+  return 0;
+}
+
diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
new file mode 100644 (file)
index 0000000..1a5eaab
--- /dev/null
@@ -0,0 +1,207 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    set binfile [board_info target d490_binfile];
+    set srcfile gdb_c_test.c
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+
+set baseline  [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+set testline1 [expr $baseline + 7]
+
+#
+# test actions command
+#
+
+gdb_delete_tracepoints
+set trcpt1 [gdb_gettpnum gdb_c_test];
+set trcpt2 [gdb_gettpnum gdb_asm_test];
+set trcpt3 [gdb_gettpnum $testline1];
+if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+# 5.1 actions of specified tracepoint
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" {
+       fail "5.1a: testsuite failure (tracepoint already has action)!"
+    }
+    -re "No tracepoints.*$gdb_prompt $" {
+       fail "5.1a: set three tracepoints, no actions (No tracepoints!)"
+    }
+    -re "$gdb_prompt $" {
+       pass "5.1a: set three tracepoints, no actions"
+    }
+}
+
+gdb_trace_setactions "5.1b: set actions for first tracepoint" \
+       "$trcpt1" \
+       "collect gdb_char_test" "^$"
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "Actions for.* $trcpt1:.*collect gdb_char_test.*$gdb_prompt $" {
+       pass "5.1c: verify actions set for first tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       fail "5.1c: verify actions set for first tracepoint"
+    }
+}
+
+gdb_trace_setactions "5.1d: set actions for second tracepoint" \
+       "$trcpt2" \
+       "collect gdb_short_test" "^$"
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "Actions for.* $trcpt2:.*collect gdb_short_test.*$gdb_prompt $" {
+       pass "5.1e: verify actions set for second tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       fail "5.1e: verify actions set for second tracepoint"
+    }
+}
+
+gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
+       "" \
+       "collect gdb_long_test" "^$"
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "Actions for.* $trcpt3:.*collect gdb_long_test.*$gdb_prompt $" {
+       pass "5.2b: verify actions set for last (default) tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       fail "5.2b: verify actions set for last (default) tracepoint"
+    }
+}
+
+# 5.3 replace actions set earlier
+
+gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
+       "$trcpt1" \
+       "collect gdb_struct1_test" "^$"
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "Actions for.* $trcpt1:.*collect gdb_struct1_test.*$gdb_prompt $" {
+       pass "5.3b: verify actions set for first tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       fail "5.3b: verify actions set for first tracepoint"
+    }
+}
+
+#
+# test end command (all by itself)
+#
+
+# 5.4 end outside of context
+
+gdb_test "end" "This command cannot be used at the top level." \
+                       "5.4: 'end' command out of context"
+
+# 5.5 empty actions (just an end with no other actions)
+
+gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
+       "$trcpt1"
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "No tracepoints.*$gdb_prompt $" {
+       fail "5.5c: verify NO actions for first tracepoint"
+    }
+    -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
+       fail "5.5c: verify NO actions for first tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       pass "5.5c: verify NO actions for first tracepoint"
+    }
+}
+
+# 5.6 actions for invalid tracepoint number
+
+gdb_test "actions [expr $trcpt2 + $trcpt3]" \
+    "No tracepoint number [expr $trcpt2 + $trcpt3]." \
+                       "5.6: actions for invalid tracepoint number"
+
+# 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
+#          "warning: .print gdb_c_test. is not a supported trace.*> $" \
+
+gdb_trace_setactions "5.7: invalid action" \
+       "$trcpt1" \
+       "print gdb_c_test" \
+       "warning: .print gdb_c_test. is not a supported trace"
+
+# 5.8 help actions (collect, while-stepping, end)
+
+gdb_test "help actions" \
+    "Specify the actions to be taken at a tracepoint.*" \
+                       "5.8a: help actions"
+
+gdb_test "help collect" \
+    "Specify one or more data items to be collected at a tracepoint.*" \
+                       "5.8b: help collect"
+
+gdb_test "help while-stepping" \
+    "Specify single-stepping behavior at a tracepoint.*" \
+                       "5.8c: help while-stepping"
+
+gdb_test "help end" "Ends a list of commands or actions.*" \
+                       "5.8d: help end"
+
diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp
new file mode 100644 (file)
index 0000000..e420029
--- /dev/null
@@ -0,0 +1,376 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp";
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor "$binfile"
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none"  "" ""
+    send_gdb "compare-sections CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# We generously give ourselves one "pass" if we successfully 
+# detect that this test cannot be run on this target!
+if { ![gdb_target_supports_trace] } then {
+    pass "Current target does not supporst trace"
+    return 1;
+
+}
+
+#
+# test backtraces in trace frames
+#
+
+set testline1 0
+set testline2 0
+set testline3 0
+set testline4 0
+set testline5 0
+set testline6 0
+
+set arg1 1
+set arg2 2
+set arg3 3
+set arg4 4
+set arg5 5
+set arg6 6
+
+set baseline [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+send_gdb "list $baseline, +12\n"
+gdb_expect {
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 1 " {
+       set testline1 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 2 " {
+       set testline2 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 3 " {
+       set testline3 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 4 " {
+       set testline4 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 5 " {
+       set testline5 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+).*gdbtestline 6 " {
+       set testline6 $expect_out(1,string)
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
+           gdb_suppress_entire_file "failed to locate test source lines:
+all tests in this module will fail."
+       }
+    }
+    default {
+           gdb_suppress_entire_file "failed to locate test source lines (def):
+all tests in this module will fail."
+    } 
+}
+
+#
+# Setup backtrace experiment.  This will involve:
+#   1) a tracepoint where nothing is collected
+#   2) a tracepoint where only regs are collected
+#   3) a tracepoint where regs, locals and args are collected
+#   4) a tracepoint where regs plus some amount of stack are collected.
+#
+
+gdb_delete_tracepoints
+set tdp2 [gdb_gettpnum $testline2]
+set tdp3 [gdb_gettpnum $testline3]
+set tdp4 [gdb_gettpnum $testline4]
+set tdp5 [gdb_gettpnum $testline5]
+set tdp6 [gdb_gettpnum $testline6]
+if {    $tdp2 <= 0 || $tdp3 <= 0 || \
+       $tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
+    fail "setting tracepoints failed"
+    return;
+}
+
+#gdb_trace_setactions "setup TP to collect FP" \
+#      "$tdp2" \
+#      "collect \$fp" ""
+#
+
+gdb_trace_setactions "8.6: setup TP to collect regs" \
+       "$tdp3" \
+       "collect \$regs" "^$"
+
+gdb_trace_setactions "8.6: setup TP to collect regs, args, and locals" \
+       "$tdp4" \
+       "collect \$regs, \$args, \$locs" "^$"
+
+gdb_trace_setactions "8.6: setup TP to collect stack mem cast expr" \
+       "$tdp6" \
+       "collect \$fp, \(\*\(void \*\*\) \(\$sp\)\) @ 64" "^$"
+
+gdb_test "tstart" "" ""
+
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6"
+    sleep 5
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+}
+
+gdb_test "tstop" "" ""
+
+proc gdb_backtrace_tdp_1 { msg } {
+    global gdb_prompt
+    
+    # We are in a trace frame at which we didn't collect anything
+    # except $PC.  Therefore we expect to be able to identify stack
+    # frame #0, but that's about all.  In particular we do not expect
+    # to be able to display the function's arguments or locals, and we
+    # do not expect to be able to identify the caller of this function.
+    
+    send_gdb "backtrace\n"
+    gdb_expect {
+       -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
+           pass "$msg"
+       }
+       -re ".*$gdb_prompt $" {
+           fail "$msg"
+       }
+       timeout { fail "$msg (timeout)" }
+    }
+}
+
+proc gdb_backtrace_tdp_2 { msg } {
+    global gdb_prompt
+
+    # We are in a trace frame at which we collected only the registers
+    # Therefore we expect to be able to identify stack frame #0, but
+    # we don't expect to be able to display its args unles they are
+    # passed in registers (which isn't the case for m68k), and we
+    # don't expect to be able to identify the caller's stack frame.
+
+    send_gdb "backtrace\n"
+    gdb_expect {
+       -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
+           pass "$msg"
+       }
+       -re ".*$gdb_prompt $" {
+           fail "$msg"
+       }
+       timeout { fail "$msg (timeout)" }
+    }
+}
+
+proc gdb_backtrace_tdp_3 { msg } {
+    global gdb_prompt
+
+    # We are in a trace frame at which we collected all registers, all
+    # arguments and all locals.  This means that the display of
+    # stack frame #0 should be complete (including argument values).
+
+    send_gdb "backtrace\n"
+    gdb_expect {
+       -re "#0\[\t \]+gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
+           pass "$msg"
+       }
+       -re "#0\[\t \]+gdb_recursion_test.*depth=Cannot access.*$gdb_prompt $" {
+           fail "$msg (failed to collect arguments)"
+       }
+       -re ".*$gdb_prompt $" {
+           fail "$msg"
+       }
+       timeout { fail "$msg (timeout)" }
+    }
+}
+
+proc gdb_backtrace_tdp_4 { msg depth } {
+    global gdb_prompt
+
+    # We are in a trace frame at which we collected all registers,
+    # plus a sizeable hunk of stack memory.  This should enable us to
+    # display at least several stack frames worth of backtrace.  We'll
+    # assume that if we can't display at least "depth" levels (with
+    # args), it counts as an error.
+
+    send_gdb "backtrace\n"
+    gdb_expect {
+       -re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
+           pass "$msg"
+       }
+       -re "#$depth\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
+           fail "$msg (args missing from #$depth stack frame)"
+       }
+       -re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
+           fail "$msg (fewer than $depth stack frames found)"
+       }
+       -re ".*$gdb_prompt $" {
+           fail "$msg"
+       }
+       timeout { fail "$msg (timeout)" }
+    }
+}
+
+#
+# begin backtrace test
+#
+
+set timeout 60
+
+gdb_tfind_test "init: make sure not debugging any trace frame" "none" "-1"
+
+gdb_tfind_test "8.6: find start frame" "start" "0"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp2:" ""
+gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 1, collect nothing"
+
+gdb_tfind_test "8.6: find frame 1"     "1" "1"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp3:" ""
+gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 1, collect regs"
+
+gdb_tfind_test "8.6: find frame 2"     "2" "2"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp4:" ""
+gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 1, collect args and locals"
+
+
+gdb_tfind_test "8.6: find frame 4"     "4" "4"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp6:" ""
+gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
+
+gdb_tfind_test "8.6: find frame 5"     "5" "5"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp2:" ""
+gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 2, collect nothing"
+
+gdb_tfind_test "8.6: find frame 6"     "6" "6"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp3:" ""
+gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 2, collect regs"
+
+gdb_tfind_test "8.6: find frame 7"     "7" "7"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp4:" ""
+gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 2, collect args and locals"
+
+
+gdb_tfind_test "8.6: find frame 9"     "9" "9"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp6:" ""
+gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
+
+gdb_tfind_test "8.6: find frame 10"    "10" "10"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp2:" ""
+gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 3, collect nothing"
+
+gdb_tfind_test "8.6: find frame 11"    "11" "11"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp3:" ""
+gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 3, collect regs"
+
+gdb_tfind_test "8.6: find frame 12"    "12" "12"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp4:" ""
+gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 3, collect args and locals"
+
+
+gdb_tfind_test "8.6: find frame 14"    "14" "14"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp6:" ""
+gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
+
+gdb_tfind_test "8.6: find frame 15"    "15" "15"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp2:" ""
+gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 4, collect nothing"
+
+gdb_tfind_test "8.6: find frame 16"    "16" "16"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp3:" ""
+gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 4, collect regs"
+
+gdb_tfind_test "8.6: find frame 17"    "17" "17"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp4:" ""
+gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 4, collect args and locals"
+
+
+gdb_tfind_test "8.6: find frame 19"    "19" "19"
+gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
+       "TDP $tdp6:" ""
+gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
+
+gdb_test "printf \"x \%d x\\n\", depth == 3" \
+       "x 0 x" \
+       "1.13: trace in recursion: depth not equal to 3"
+
+# Finished!
+gdb_test "tfind none" "" ""
diff --git a/gdb/testsuite/gdb.trace/circ.c b/gdb/testsuite/gdb.trace/circ.c
new file mode 100644 (file)
index 0000000..98a2ce6
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Test program for tracing; circular buffer
+ */
+
+int n = 6;
+
+int testload[13];
+
+static void func0(void)
+{
+}
+
+static void func1(void)
+{
+}
+
+static void func2(void)
+{
+}
+
+static void func3(void)
+{
+}
+
+static void func4(void)
+{
+}
+
+static void func5(void)
+{
+}
+
+static void func6(void)
+{
+}
+
+static void func7(void)
+{
+}
+
+static void func8(void)
+{
+}
+
+static void func9(void)
+{
+}
+
+static void begin ()   /* called before anything else */
+{
+}
+
+static void end ()     /* called after everything else */
+{
+}
+
+int
+main (argc, argv, envp)
+     int argc;
+     char *argv[], **envp;
+{
+  int i;
+
+#ifdef usestubs
+  set_debug_traps ();
+  breakpoint ();
+#endif
+
+  begin ();
+  for (i = 0; i < sizeof(testload) / sizeof(testload[0]); i++)
+    testload[i] = i + 1;
+
+  func0 ();
+  func1 ();
+  func2 ();
+  func3 ();
+  func4 ();
+  func5();
+  func6 ();
+  func7 ();
+  func8 ();
+  func9 ();
+
+  end ();
+
+#ifdef usestubs
+  breakpoint ();
+#endif
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.trace/circ.exp b/gdb/testsuite/gdb.trace/circ.exp
new file mode 100644 (file)
index 0000000..19267cb
--- /dev/null
@@ -0,0 +1,215 @@
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+if [istarget "m68k-*-elf"] then {
+    pass "Test not supported on this target"
+    return;
+}
+
+load_lib "trace-support.exp"
+
+if $tracelevel then {
+       strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "circ"
+set srcfile ${testfile}.c
+set binfile $objdir/$subdir/$testfile
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+       executable {debug additional_flags="-gdwarf"}] != "" } {
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Tests:
+# 1) Set up a trace experiment that will collect approximately 10 frames,
+#    requiring more than 512 but less than 1024 bytes of cache buffer.
+#    (most targets should have at least 1024 bytes of cache buffer!)
+#    Run and confirm that it collects all 10 frames.
+# 2) Artificially limit the trace buffer to 512 bytes, and rerun the
+#    experiment.  Confirm that the first several frames are collected,
+#    but that the last several are not.
+# 3) Set trace buffer to circular mode, still with the artificial limit
+#    of 512 bytes, and rerun the experiment.  Confirm that the last 
+#    several frames are collected, but the first several are not.
+#
+
+# return 0 for success, 1 for failure
+proc run_trace_experiment { pass } {
+    gdb_run_cmd 
+
+    if [gdb_test "tstart" \
+           "\[\r\n\]*" \
+           "start trace experiment, pass $pass"] then { return 1; }
+    if [gdb_test "continue" \
+           "Continuing.*Breakpoint \[0-9\]+, end.*" \
+           "run to end, pass $pass"] then { return 1; }
+    if [gdb_test "tstop" \
+           "\[\r\n\]*" \
+           "stop trace experiment, pass $pass"] then { return 1; }
+    return 0;
+}
+
+# return 0 for success, 1 for failure
+proc set_a_tracepoint { func } {
+    if [gdb_test "trace $func" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "set tracepoint at $func"] then {
+       return 1;
+    }
+    if [gdb_trace_setactions "set actions for $func" \
+           "" \
+           "collect testload" "^$"] then {
+       return 1;
+    }
+    return 0;
+}
+
+# return 0 for success, 1 for failure
+proc setup_tracepoints { } {
+    gdb_delete_tracepoints
+    if [set_a_tracepoint func0] then { return 1; }
+    if [set_a_tracepoint func1] then { return 1; }
+    if [set_a_tracepoint func2] then { return 1; }
+    if [set_a_tracepoint func3] then { return 1; }
+    if [set_a_tracepoint func4] then { return 1; }
+    if [set_a_tracepoint func5] then { return 1; }
+    if [set_a_tracepoint func6] then { return 1; }
+    if [set_a_tracepoint func7] then { return 1; }
+    if [set_a_tracepoint func8] then { return 1; }
+    if [set_a_tracepoint func9] then { return 1; }
+    return 0;
+}
+
+# return 0 for success, 1 for failure
+proc trace_buffer_normal { } {
+    if [gdb_test "maint packet QTBuffer:size:ffffffff" \
+           "received: .OK." ""] then { 
+       pass "This test cannot be run on this target"
+       return 1;
+    }
+    if [gdb_test "maint packet QTBuffer:circular:0" \
+           "received: .OK." ""] then { 
+       pass "This test cannot be run on this target"
+       return 1;
+    }
+    return 0;
+}
+
+# return 0 for success, 1 for failure
+proc gdb_trace_circular_tests { } {
+
+    # We generously give ourselves one "pass" if we successfully 
+    # detect that this test cannot be run on this target!
+    if { ![gdb_target_supports_trace] } then { 
+       pass "Current target does not supporst trace"
+       return 1;
+    }
+
+    if [trace_buffer_normal] then { return 1; }
+
+    gdb_test "break begin" "" ""
+    gdb_test "break end"   "" ""
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+
+    if [setup_tracepoints] then { return 1; }
+
+    # First, run the trace experiment with default attributes:
+    # Make sure it behaves as expected.
+    if [run_trace_experiment 1] then { return 1; }
+    if [gdb_test "tfind start" \
+           "#0  func0 .*" \
+           "find frame zero, pass 1"] then { return 1; }
+
+    if [gdb_test "tfind 9" \
+           "#0  func9 .*" \
+           "find frame nine, pass 1"] then { return 1; }
+
+    if [gdb_test "tfind none" \
+           "#0  end .*" \
+           "quit trace debugging, pass 1"] then { return 1; }
+
+    # Then, shrink the trace buffer so that it will not hold
+    # all ten trace frames.  Verify that frame zero is still
+    # collected, but frame nine is not.
+    if [gdb_test "maint packet QTBuffer:size:200" \
+           "received: .OK." "shrink the target trace buffer"] then { 
+       return 1;
+    }
+    if [run_trace_experiment 2] then { return 1; }
+    if [gdb_test "tfind start" \
+           "#0  func0 .*" \
+           "find frame zero, pass 2"] then { return 1; }
+
+    if [gdb_test "tfind 9" \
+           ".* failed to find .*" \
+           "fail to find frame nine, pass 2"] then { return 1; }
+
+    if [gdb_test "tfind none" \
+           "#0  end .*" \
+           "quit trace debugging, pass 2"] then { return 1; }
+
+    # Finally, make the buffer circular.  Now when it runs out of
+    # space, it should wrap around and overwrite the earliest frames.
+    # This means that:
+    #   1) frame zero will be overwritten and therefore unavailable
+    #   2) the earliest frame in the buffer will be other-than-zero
+    #   3) frame nine will be available (unlike on pass 2).
+    if [gdb_test "maint packet QTBuffer:circular:1" \
+           "received: .OK." "make the target trace buffer circular"] then { 
+       return 1;
+    }
+    if [run_trace_experiment 3] then { return 1; }
+    if [gdb_test "tfind start" \
+           "#0  func\[1-9\] .*" \
+           "first frame is NOT frame zero, pass 3"] then { return 1; }
+
+    if [gdb_test "tfind 9" \
+           "#0  func9 .*" \
+           "find frame nine, pass 3"] then { return 1; }
+
+    if [gdb_test "tfind none" \
+           "#0  end .*" \
+           "quit trace debugging, pass 3"] then { return 1; }
+
+    return 0;
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+if [target_info exists gdb_stub] {
+    gdb_step_for_stub;
+}
+# Body of test encased in a proc so we can return prematurely.
+if { ![gdb_trace_circular_tests] } then {
+    # Set trace buffer attributes back to normal
+    trace_buffer_normal;
+}
+
+# Finished!
+gdb_test "tfind none" "" ""
diff --git a/gdb/testsuite/gdb.trace/collection.c b/gdb/testsuite/gdb.trace/collection.c
new file mode 100644 (file)
index 0000000..3986332
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * Test program for trace collection
+ */
+
+/*
+ * Typedefs
+ */
+
+typedef struct TEST_STRUCT {
+  char   memberc;
+  int    memberi;
+  float  memberf;
+  double memberd;
+} test_struct;
+
+typedef int test_array [4];
+
+/* 
+ * Global variables to be collected
+ */
+
+char         globalc;
+int          globali;
+float        globalf;
+double       globald;
+test_struct  globalstruct;
+test_struct *globalp;
+int          globalarr[16];
+
+/*
+ * Additional globals used in arithmetic tests
+ */
+
+signed char  c0,  c1,  c2,  c3,  c4,  c5,  c6,  c7, 
+             c8,  c9,  c10, c11, c12, c13, c14, c15, cminus;
+signed short s0,  s1,  s2,  s3,  s4,  s5,  s6,  s7,
+             s8,  s9,  s10, s11, s12, s13, s14, s15, sminus;
+signed long  l0,  l1,  l2,  l3,  l4,  l5,  l6,  l7,
+             l8,  l9,  l10, l11, l12, l13, l14, l15, lminus;
+
+
+/*
+ * Test functions
+ */
+
+static void begin ()   /* called before anything else */
+{
+}
+
+static void end ()     /* called after everything else */
+{
+}
+
+/* Test collecting args. */
+int args_test_func (argc, argi, argf, argd, argstruct, argarray)
+     char   argc;
+     int    argi;
+     float  argf;
+     double argd;
+     test_struct argstruct;
+     int argarray[4];
+{
+  int i;
+
+  i =  (int) argc + argi + argf + argd + argstruct.memberi + argarray[1];
+
+  return i;
+}
+
+/* Test collecting struct args. */
+int argstruct_test_func (argstruct)
+     test_struct argstruct;
+{
+  return (int) argstruct.memberc + argstruct.memberi + 
+                 argstruct.memberf + argstruct.memberd;
+}
+
+/* Test collecting array args. */
+int argarray_test_func (argarray)
+     int argarray[4];
+{
+  return (int) argarray[0] + argarray[1] + argarray[2] + argarray[3];
+}
+
+
+
+int local_test_func ()                 /* test collecting locals */
+{
+  char        locc  = 11;
+  int         loci  = 12;
+  float       locf  = 13.3;
+  double      locd  = 14.4;
+  test_struct locst;
+  int         locar[4];
+  int         i;
+
+  locst.memberc  = 15;
+  locst.memberi  = 16;
+  locst.memberf  = 17.7;
+  locst.memberd  = 18.8;
+  locar[0] = 121;
+  locar[1] = 122;
+  locar[2] = 123;
+  locar[3] = 124;
+
+  i = /* Set_Tracepoint_Here */
+    (int) locc + loci + locf + locd + locst.memberi + locar[1];
+
+  return i;
+}
+
+int reglocal_test_func ()              /* test collecting register locals */
+{
+  register char        locc = 11;
+  register int         loci = 12;
+  register float       locf = 13.3;
+  register double      locd = 14.4;
+  register test_struct locst;
+  register int         locar[4];
+  int                  i;
+
+  locst.memberc  = 15;
+  locst.memberi  = 16;
+  locst.memberf  = 17.7;
+  locst.memberd  = 18.8;
+  locar[0] = 121;
+  locar[1] = 122;
+  locar[2] = 123;
+  locar[3] = 124;
+
+  i = /* Set_Tracepoint_Here */
+    (int) locc + loci + locf + locd + locst.memberi + locar[1];
+
+  return i;
+}
+
+int statlocal_test_func ()             /* test collecting static locals */
+{
+  static   char        locc;
+  static   int         loci;
+  static   float       locf;
+  static   double      locd;
+  static   test_struct locst;
+  static   int         locar[4];
+  int                  i;
+
+  locc = 11;
+  loci = 12;
+  locf = 13.3;
+  locd = 14.4;
+  locst.memberc = 15;
+  locst.memberi = 16;
+  locst.memberf = 17.7;
+  locst.memberd = 18.8;
+  locar[0] = 121;
+  locar[1] = 122;
+  locar[2] = 123;
+  locar[3] = 124;
+
+  i = /* Set_Tracepoint_Here */
+    (int) locc + loci + locf + locd + locst.memberi + locar[1];
+
+  /* Set static locals back to zero so collected values are clearly special. */
+  locc = 0;
+  loci = 0;
+  locf = 0;
+  locd = 0;
+  locst.memberc = 0;
+  locst.memberi = 0;
+  locst.memberf = 0;
+  locst.memberd = 0;
+  locar[0] = 0;
+  locar[1] = 0;
+  locar[2] = 0;
+  locar[3] = 0;
+
+  return i;
+}
+
+
+int globals_test_func ()
+{
+  int i = 0;
+
+  i += globalc + globali + globalf + globald;
+  i += globalstruct.memberc + globalstruct.memberi;
+  i += globalstruct.memberf + globalstruct.memberd;
+  i += globalarr[1];
+
+  return i;    /* Set_Tracepoint_Here */
+}
+
+int
+main (argc, argv, envp)
+     int argc;
+     char *argv[], **envp;
+{
+  int         i = 0;
+  test_struct mystruct;
+  int         myarray[4];
+
+#ifdef usestubs
+  set_debug_traps ();
+  breakpoint ();
+#endif
+
+  begin ();
+  /* Assign collectable values to global variables. */
+  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 1;
+  l2  = s2  = c2  = 2;     l3  = s3  = c3  = 3;
+  l4  = s4  = c4  = 4;     l5  = s5  = c5  = 5;
+  l6  = s6  = c6  = 6;     l7  = s7  = c7  = 7;
+  l8  = s8  = c8  = 8;     l9  = s9  = c9  = 9;
+  l10 = s10 = c10 = 10;    l11 = s11 = c11 = 11;
+  l12 = s12 = c12 = 12;    l13 = s13 = c13 = 13;
+  l14 = s14 = c14 = 14;    l15 = s15 = c15 = 15;
+  lminus = sminus = cminus = -2;
+  globalc = 71;
+  globali = 72;
+  globalf = 73.3;
+  globald = 74.4;
+  globalstruct.memberc = 81;
+  globalstruct.memberi = 82;
+  globalstruct.memberf = 83.3;
+  globalstruct.memberd = 84.4;
+  globalp = &globalstruct;
+
+  for (i = 0; i < 15; i++)
+    globalarr[i] = i;
+
+  mystruct.memberc = 101;
+  mystruct.memberi = 102;
+  mystruct.memberf = 103.3;
+  mystruct.memberd = 104.4;
+  myarray[0] = 111;
+  myarray[1] = 112;
+  myarray[2] = 113;
+  myarray[3] = 114;
+
+  /* Call test functions, so they can be traced and data collected.  */
+  i = 0;
+  i += args_test_func (1, 2, 3.3, 4.4, mystruct, myarray);
+  i += argstruct_test_func (mystruct);
+  i += argarray_test_func (myarray);
+  i += local_test_func ();
+  i += reglocal_test_func ();
+  i += statlocal_test_func ();
+  i += globals_test_func ();
+
+  /* Values of globals at end of test should be different from
+     values that they had when trace data was captured.  */
+
+  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 0;
+  l2  = s2  = c2  = 0;     l3  = s3  = c3  = 0;
+  l4  = s4  = c4  = 0;     l5  = s5  = c5  = 0;
+  l6  = s6  = c6  = 0;     l7  = s7  = c7  = 0;
+  l8  = s8  = c8  = 0;     l9  = s9  = c9  = 0;
+  l10 = s10 = c10 = 0;     l11 = s11 = c11 = 0;
+  l12 = s12 = c12 = 0;     l13 = s13 = c13 = 0;
+  l14 = s14 = c14 = 0;     l15 = s15 = c15 = 0;
+  lminus = sminus = cminus = 0;
+
+  /* Set 'em back to zero, so that the collected values will be
+     distinctly different from the "realtime" (end of test) values.  */
+
+  globalc = 0;
+  globali = 0;
+  globalf = 0;
+  globald = 0;
+  globalstruct.memberc = 0;
+  globalstruct.memberi = 0;
+  globalstruct.memberf = 0;
+  globalstruct.memberd = 0;
+  globalp = 0;
+  for (i = 0; i < 15; i++)
+    globalarr[i] = 0;
+
+  end ();
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp
new file mode 100644 (file)
index 0000000..a48e363
--- /dev/null
@@ -0,0 +1,623 @@
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+if [istarget "m68k-*-elf"] then {
+    pass "Test not supported on this target"
+    return;
+}
+
+load_lib "trace-support.exp"
+
+if $tracelevel then {
+       strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "collection"
+set srcfile ${testfile}.c
+set binfile $objdir/$subdir/$testfile
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+       executable {debug additional_flags="-gdwarf"}] != "" } {
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Tests: 
+# 1) $args
+# 2) function args by name
+# 3) $locs
+# 4) function locals by name
+# 5) $regs
+# 6) registers by name ($sp, $fp?)
+# 7) globals by name
+# 8) expressions (lots of different kinds: local and global)
+
+set ws "\[\r\n\t \]+"
+set cr "\[\r\n\]+"
+
+#
+# Utility procs
+#
+
+proc test_register { reg test_id } {
+    global cr
+    global gdb_prompt
+
+    send_gdb "print $reg\n"
+    gdb_expect {
+       -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt " {
+           fail "collect $test_id: collected $reg (zero)"
+       }
+       -re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt " {
+           pass "collect $test_id: collected $reg"
+       }
+       -re "\[Ee\]rror.*$gdb_prompt " {
+           fail "collect $test_id: collected $reg (error)"
+       }
+       timeout {
+           fail "collect $test_id: collected $reg (timeout)"
+       }
+    }
+}
+
+proc run_trace_experiment { msg test_func } {
+    gdb_run_cmd 
+    gdb_test "tstart" \
+           "\[\r\n\]+" \
+           "collect $msg: start trace experiment"
+    gdb_test "continue" \
+           "Continuing.*Breakpoint \[0-9\]+, end.*" \
+           "collect $msg: run trace experiment"
+    gdb_test "tstop" \
+           "\[\r\n\]+" \
+           "collect $msg: stop trace experiment"
+    gdb_test "tfind start" \
+           "#0  $test_func .*" \
+           "collect $msg: tfind test frame"
+}
+
+
+#
+# Test procs
+#
+
+proc gdb_collect_args_test { myargs msg } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    gdb_test "trace args_test_func" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $msg: set tracepoint"
+    gdb_trace_setactions "collect $msg: define actions" \
+           "" \
+           "collect $myargs" "^$"
+
+    # Begin the test.
+    run_trace_experiment $msg args_test_func
+
+    gdb_test "print argc" \
+           "\\$\[0-9\]+ = 1 '.001'$cr" \
+           "collect $msg: collected arg char"
+    gdb_test "print argi" \
+           "\\$\[0-9\]+ = 2$cr" \
+           "collect $msg: collected arg int"
+    gdb_test "print argf" \
+           "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*$cr" \
+           "collect $msg: collected arg float"
+    gdb_test "print argd" \
+           "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*$cr" \
+           "collect $msg: collected arg double"
+
+    # struct arg as one of several args (near end of list)
+    gdb_test "print argstruct.memberc" \
+           "\\$\[0-9\]+ = 101 'e'$cr" \
+           "collect $msg: collected arg struct member char"
+    gdb_test "print argstruct.memberi" \
+           "\\$\[0-9\]+ = 102$cr" \
+           "collect $msg: collected arg struct member int"
+    gdb_test "print argstruct.memberf" \
+           "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
+           "collect $msg: collected arg struct member float"
+    gdb_test "print argstruct.memberd" \
+           "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
+           "collect $msg: collected arg struct member double"
+
+    # array arg as one of several args (near end of list)
+    gdb_test "print argarray\[0\]" \
+           "\\$\[0-9\]+ = 111$cr" \
+           "collect $msg: collected argarray #0"
+    gdb_test "print argarray\[1\]" \
+           "\\$\[0-9\]+ = 112$cr" \
+           "collect $msg: collected argarray #1"
+    gdb_test "print argarray\[2\]" \
+           "\\$\[0-9\]+ = 113$cr" \
+           "collect $msg: collected argarray #2"
+    gdb_test "print argarray\[3\]" \
+           "\\$\[0-9\]+ = 114$cr" \
+           "collect $msg: collected argarray #3"
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $msg: cease trace debugging"
+}
+
+proc gdb_collect_argstruct_test { myargs msg } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    gdb_test "trace argstruct_test_func" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $msg: set tracepoint"
+    gdb_trace_setactions "collect $msg: define actions" \
+           "" \
+           "collect $myargs" "^$"
+
+    # Begin the test.
+    run_trace_experiment $msg argstruct_test_func
+
+    # struct argument as only argument
+    gdb_test "print argstruct.memberc" \
+           "\\$\[0-9\]+ = 101 'e'$cr" \
+           "collect $msg: collected arg struct member char"
+    gdb_test "print argstruct.memberi" \
+           "\\$\[0-9\]+ = 102$cr" \
+           "collect $msg: collected arg struct member int"
+    gdb_test "print argstruct.memberf" \
+           "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
+           "collect $msg: collected arg struct member float"
+    gdb_test "print argstruct.memberd" \
+           "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
+           "collect $msg: collected arg struct member double"
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $msg: cease trace debugging"
+}
+
+
+proc gdb_collect_argarray_test { myargs msg } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    gdb_test "trace argarray_test_func" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $msg: set tracepoint"
+    gdb_trace_setactions "collect $msg: define actions" \
+           "" \
+           "collect $myargs" "^$"
+
+    # Begin the test.
+    run_trace_experiment $msg argarray_test_func
+
+    # array arg as only argument
+    gdb_test "print argarray\[0\]" \
+           "\\$\[0-9\]+ = 111$cr" \
+           "collect $msg: collected argarray #0"
+    gdb_test "print argarray\[1\]" \
+           "\\$\[0-9\]+ = 112$cr" \
+           "collect $msg: collected argarray #1"
+    gdb_test "print argarray\[2\]" \
+           "\\$\[0-9\]+ = 113$cr" \
+           "collect $msg: collected argarray #2"
+    gdb_test "print argarray\[3\]" \
+           "\\$\[0-9\]+ = 114$cr" \
+           "collect $msg: collected argarray #3"
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $msg: cease trace debugging"
+}
+
+
+proc gdb_collect_locals_test { func mylocs msg } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Find the comment-identified line for setting this tracepoint.
+    set testline 0
+    send_gdb "list $func, +30\n"
+    gdb_expect {
+       -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
+           set testline $expect_out(1,string)
+           pass "collect $msg: find tracepoint line"
+       }
+       -re ".*$gdb_prompt " {
+           fail "collect $msg: find tracepoint line (skipping locals test)"
+           return
+       }
+       timeout {
+           fail "collect $msg: find tracepoint line (skipping locals test)"
+           return
+       }
+    }
+
+    gdb_test "trace $testline" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $msg: set tracepoint"
+    gdb_trace_setactions "collect $msg: define actions" \
+           "" \
+           "collect $mylocs" "^$"
+
+    # Begin the test.
+    run_trace_experiment $msg $func
+
+    gdb_test "print locc" \
+           "\\$\[0-9\]+ = 11 '.013'$cr" \
+           "collect $msg: collected local char"
+    gdb_test "print loci" \
+           "\\$\[0-9\]+ = 12$cr" \
+           "collect $msg: collected local int"
+    gdb_test "print locf" \
+           "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*$cr" \
+           "collect $msg: collected local float"
+    gdb_test "print locd" \
+           "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*$cr" \
+           "collect $msg: collected local double"
+
+    gdb_test "print locst.memberc" \
+           "\\$\[0-9\]+ = 15 '.017'$cr" \
+           "collect $msg: collected local member char"
+    gdb_test "print locst.memberi" \
+           "\\$\[0-9\]+ = 16$cr" \
+           "collect $msg: collected local member int"
+    gdb_test "print locst.memberf" \
+           "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*$cr" \
+           "collect $msg: collected local member float"
+    gdb_test "print locst.memberd" \
+           "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*$cr" \
+           "collect $msg: collected local member double"
+
+    gdb_test "print locar\[0\]" \
+           "\\$\[0-9\]+ = 121$cr" \
+           "collect $msg: collected locarray #0"
+    gdb_test "print locar\[1\]" \
+           "\\$\[0-9\]+ = 122$cr" \
+           "collect $msg: collected locarray #1"
+    gdb_test "print locar\[2\]" \
+           "\\$\[0-9\]+ = 123$cr" \
+           "collect $msg: collected locarray #2"
+    gdb_test "print locar\[3\]" \
+           "\\$\[0-9\]+ = 124$cr" \
+           "collect $msg: collected locarray #3"
+           
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $msg: cease trace debugging"
+}
+
+proc gdb_collect_registers_test { myregs } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # We'll simply re-use the args_test_function for this test
+    gdb_test "trace args_test_func" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $myregs: set tracepoint"
+    gdb_trace_setactions "collect $myregs: define actions" \
+           "" \
+           "collect $myregs" "^$"
+
+    # Begin the test.
+    run_trace_experiment $myregs args_test_func
+
+    test_register "\$fp" $myregs
+    test_register "\$sp" $myregs
+    test_register "\$pc" $myregs
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $myregs: cease trace debugging"
+}
+
+proc gdb_collect_expression_test { func expr val msg } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Find the comment-identified line for setting this tracepoint.
+    set testline 0
+    send_gdb "list $func, +30\n"
+    gdb_expect {
+       -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
+           set testline $expect_out(1,string)
+           pass "collect $msg: find tracepoint line"
+       }
+       -re ".*$gdb_prompt " {
+           fail "collect $msg: find tracepoint line (skipping locals test)"
+           return
+       }
+       timeout {
+           fail "collect $msg: find tracepoint line (skipping locals test)"
+           return
+       }
+    }
+
+    gdb_test "trace $testline" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect $msg: set tracepoint"
+    gdb_trace_setactions "collect $msg: define actions" \
+           "" \
+           "collect $expr" "^$"
+
+    # Begin the test.
+    run_trace_experiment $msg $func
+
+    gdb_test "print $expr" \
+           "\\$\[0-9\]+ = $val$cr" \
+           "collect $msg: got expected value '$val'"
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect $msg: cease trace debugging"
+}
+
+proc gdb_collect_globals_test { } {
+    global cr
+    global gdb_prompt
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Find the comment-identified line for setting this tracepoint.
+    set testline 0
+    send_gdb "list globals_test_func, +30\n"
+    gdb_expect {
+       -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
+           set testline $expect_out(1,string)
+           pass "collect globals: find tracepoint line"
+       }
+       -re ".*$gdb_prompt " {
+           fail "collect globals: find tracepoint line (skipping global test)"
+           return
+       }
+       timeout {
+           fail "collect globals: find tracepoint line (skipping global test)"
+           return
+       }
+    }
+
+    gdb_test "trace $testline" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "collect globals: set tracepoint"
+    gdb_trace_setactions "collect globals: define actions" \
+           "" \
+           "collect globalc, globali, globalf, globald" "^$" \
+           "collect globalstruct, globalp, globalarr" "^$"
+
+    # Begin the test.
+    run_trace_experiment "globals" globals_test_func
+
+    gdb_test "print globalc" \
+           "\\$\[0-9\]+ = 71 'G'$cr" \
+           "collect globals: collected global char"
+    gdb_test "print globali" \
+           "\\$\[0-9\]+ = 72$cr" \
+           "collect globals: collected global int"
+    gdb_test "print globalf" \
+           "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*$cr" \
+           "collect globals: collected global float"
+    gdb_test "print globald" \
+           "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*$cr" \
+           "collect globals: collected global double"
+
+    gdb_test "print globalstruct.memberc" \
+           "\\$\[0-9\]+ = 81 'Q'$cr" \
+           "collect globals: collected struct char member"
+    gdb_test "print globalstruct.memberi" \
+           "\\$\[0-9\]+ = 82$cr" \
+           "collect globals: collected struct member int"
+    gdb_test "print globalstruct.memberf" \
+           "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*$cr" \
+           "collect globals: collected struct member float"
+    gdb_test "print globalstruct.memberd" \
+           "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*$cr" \
+           "collect globals: collected struct member double"
+
+    gdb_test "print globalp == &globalstruct" \
+           "\\$\[0-9\]+ = 1$cr" \
+           "collect globals: collected global pointer"
+
+    gdb_test "print globalarr\[1\]" \
+           "\\$\[0-9\]+ = 1$cr" \
+           "collect globals: collected global array element #1"
+    gdb_test "print globalarr\[2\]" \
+           "\\$\[0-9\]+ = 2$cr" \
+           "collect globals: collected global array element #2"
+    gdb_test "print globalarr\[3\]" \
+           "\\$\[0-9\]+ = 3$cr" \
+           "collect globals: collected global array element #3"
+
+    gdb_test "tfind none" \
+           "#0  end .*" \
+           "collect globals: cease trace debugging"
+}
+
+proc gdb_trace_collection_test { } {
+    global gdb_prompt;
+
+    gdb_test "set width 0" "" ""
+    delete_breakpoints
+
+    # We generously give ourselves one "pass" if we successfully 
+    # detect that this test cannot be run on this target!
+    if { ![gdb_target_supports_trace] } then { 
+       pass "Current target does not supporst trace"
+       return 1;
+    }
+
+    gdb_test "break begin" "" ""
+    gdb_test "break end"   "" ""
+    gdb_collect_args_test "\$args" \
+           "args collectively"
+    gdb_collect_args_test "argc, argi, argf, argd, argstruct, argarray" \
+           "args individually"
+    gdb_collect_argstruct_test "\$args" \
+           "argstruct collectively"
+    gdb_collect_argstruct_test "argstruct" \
+           "argstruct individually"
+    gdb_collect_argarray_test "\$args" \
+           "argarray collectively"
+    gdb_collect_argarray_test "argarray" \
+           "argarray individually"
+    gdb_collect_locals_test local_test_func "\$locals" \
+           "auto locals collectively"
+    gdb_collect_locals_test local_test_func \
+           "locc, loci, locf, locd, locst, locar" \
+           "auto locals individually"
+    gdb_collect_locals_test reglocal_test_func "\$locals" \
+           "register locals collectively"
+    gdb_collect_locals_test reglocal_test_func \
+           "locc, loci, locf, locd, locst, locar" \
+           "register locals individually"
+    gdb_collect_locals_test statlocal_test_func "\$locals" \
+           "static locals collectively"
+    gdb_collect_locals_test statlocal_test_func \
+           "locc, loci, locf, locd, locst, locar" \
+           "static locals individually"
+    
+    gdb_collect_registers_test "\$regs"
+    gdb_collect_registers_test "\$fp, \$sp, \$pc"
+    gdb_collect_globals_test
+    
+    #
+    # Expression tests:
+    #
+    # *x       (**x, ...)
+    # x.y      (x.y.z, ...)
+    # x->y     (x->y->z, ...)
+    # x[2]     (x[2][3], ...) (const index)
+    # x[y]     (x[y][z], ...) (index to be char, short, long, float, double)
+    #  NOTE:
+    #  We test the following operators by using them in an array index
+    #  expression -- because the naked result of an operator is not really
+    #  collected.  To be sure the operator was evaluated correctly on the
+    #  target, we have to actually use the result eg. in an array offset
+    #  calculation.
+    # x[y +  z] (tests addition: y and z various combos of types, sclasses)
+    # x[y -  z] (tests subtraction) (ditto)
+    # x[y *  z] (tests multiplication) (ditto)
+    # x[y /  z] (tests division) (ditto)
+    # x[y %  z] (tests modulo division) (ditto)
+    # x[y == z] (tests equality relation) (ditto)              UNSUPPORTED
+    # x[y != z] (tests inequality relation) (ditto)            UNSUPPORTED
+    # x[y >  z] (tests greater-than relation) (ditto)          UNSUPPORTED
+    # x[y <  z] (tests less-than relation) (ditto)             UNSUPPORTED
+    # x[y >= z] (tests greater-than-or-equal relation) (ditto) UNSUPPORTED
+    # x[y <= z] (tests less-than-or-equal relation) (ditto)    UNSUPPORTED
+    # x[y && z] (tests logical and) (ditto)                    UNSUPPORTED
+    # x[y || z] (tests logical or) (ditto)                     UNSUPPORTED
+    # x[y &  z] (tests binary and) (ditto)                     UNSUPPORTED
+    # x[y |  z] (tests binary or) (ditto)                      UNSUPPORTED
+    # x[y ^  z] (tests binary xor) (ditto)                     UNSUPPORTED
+    # x[y ? z1 : z2] (tests ternary operator) (ditto)          UNSUPPORTED
+    # x[y << z] (tests shift-left) (ditto)                     UNSUPPORTED
+    # x[y >> z] (tests shift-right) (ditto)                    UNSUPPORTED
+    # x[y =  z] (tests assignment operator) (ditto)            UNSUPPORTED
+    # x[++y]    (tests pre-increment operator) (ditto)         UNSUPPORTED
+    # x[--y]    (tests pre-decrement operator) (ditto)         UNSUPPORTED
+    # x[y++]    (tests post-increment operator) (ditto)        UNSUPPORTED
+    # x[y--]    (tests post-decrement operator) (ditto)        UNSUPPORTED
+    # x[+y]     (tests unary plus) (ditto)
+    # x[-y]     (tests unary minus) (ditto)
+    # x[!y]     (tests logical not) (ditto)                    UNSUPPORTED
+    # x[~y]     (tests binary not) (ditto)                     UNSUPPORTED
+    # x[(y, z)] (tests comma expression) (ditto)
+    # cast expr
+    # stack data
+    
+    gdb_collect_expression_test globals_test_func \
+           "globalstruct.memberi"  "82"     "a.b"
+    gdb_collect_expression_test globals_test_func \
+           "globalp->memberc"      "81 'Q'" "a->b"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[2\]"        "2"      "a\[2\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l3\]"       "3"      "a\[b\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l3 + l2\]"  "5"      "a\[b + c\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l3 - l2\]"  "1"      "a\[b - c\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l3 * l2\]"  "6"      "a\[b * c\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l6 / l3\]"  "2"      "a\[b / c\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[l7 % l3\]"  "1"      "a\[b % c\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[+l1\]"      "1"      "a\[+b\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[-lminus\]"  "2"      "a\[-b\]"
+    gdb_collect_expression_test globals_test_func \
+           "globalarr\[\(l6, l7\)\]" "7"    "a\[\(b, c\)\]"
+
+}
+
+# Start with a fresh gdb.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+if [target_info exists gdb_stub] {
+    gdb_step_for_stub;
+}
+# Body of test encased in a proc so we can return prematurely.
+gdb_trace_collection_test
+
+# Finished!
+gdb_test "tfind none" "" ""
+
+
+
diff --git a/gdb/testsuite/gdb.trace/configure b/gdb/testsuite/gdb.trace/configure
new file mode 100755 (executable)
index 0000000..3ec60c2
--- /dev/null
@@ -0,0 +1,899 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12.1 
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  case "$ac_option" in
+  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) ac_optarg= ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case "$ac_option" in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build="$ac_optarg" ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file="$ac_optarg" ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    eval "enable_${ac_feature}=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix="$ac_optarg" ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
+    cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
+    exit 0 ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host="$ac_optarg" ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix="$ac_optarg" ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix="$ac_optarg" ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix="$ac_optarg" ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name="$ac_optarg" ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir="$ac_optarg" ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target="$ac_optarg" ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers)
+    echo "configure generated by autoconf version 2.12.1"
+    exit 0 ;;
+
+  -with-* | --with-*)
+    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_${ac_package}='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    eval "with_${ac_package}=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes="$ac_optarg" ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries="$ac_optarg" ;;
+
+  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+    ;;
+
+  *)
+    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+      echo "configure: warning: $ac_option: invalid host type" 1>&2
+    fi
+    if test "x$nonopt" != xNONE; then
+      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+    fi
+    nonopt="$ac_option"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+  case "$ac_arg" in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set.  These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=collect.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+  else
+    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+  fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    echo "loading site script $ac_site_file"
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+CC=${CC-cc}
+
+ac_aux_dir=
+for ac_dir in `cd $srcdir;pwd`/../../.. $srcdir/`cd $srcdir;pwd`/../../..; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { echo "configure: error: can not find install-sh or install.sh in `cd $srcdir;pwd`/../../.. $srcdir/`cd $srcdir;pwd`/../../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+#    configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+#    same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+#    as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:573: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+  case $nonopt in
+  NONE)
+    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+    else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+    fi ;;
+  *) host_alias=$nonopt ;;
+  esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:594: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+  case $nonopt in
+  NONE) target_alias=$host_alias ;;
+  *) target_alias=$nonopt ;;
+  esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:612: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+  case $nonopt in
+  NONE) build_alias=$host_alias ;;
+  *) build_alias=$nonopt ;;
+  esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_prefix=${target_alias}-
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[    `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+  case "\$ac_option" in
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+    echo "$CONFIG_STATUS generated by autoconf version 2.12.1"
+    exit 0 ;;
+  -help | --help | --hel | --he | --h)
+    echo "\$ac_cs_usage"; exit 0 ;;
+  *) echo "\$ac_cs_usage"; exit 1 ;;
+  esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+  if test $ac_beg -gt 1; then
+    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+  else
+    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+  fi
+  if test ! -s conftest.s$ac_file; then
+    ac_more_lines=false
+    rm -f conftest.s$ac_file
+  else
+    if test -z "$ac_sed_cmds"; then
+      ac_sed_cmds="sed -f conftest.s$ac_file"
+    else
+      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+    fi
+    ac_file=`expr $ac_file + 1`
+    ac_beg=$ac_end
+    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  fi
+done
+if test -z "$ac_sed_cmds"; then
+  ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+  # Remove last slash and all that follows it.  Not all systems have dirname.
+  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    # The file is in a subdirectory.
+    test ! -d "$ac_dir" && mkdir "$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case "$ac_given_srcdir" in
+  .)  srcdir=.
+      if test -z "$ac_dots"; then top_srcdir=.
+      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  *) # Relative path.
+    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+
+  echo creating "$ac_file"
+  rm -f "$ac_file"
+  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+  case "$ac_file" in
+  *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+  *) ac_comsub= ;;
+  esac
+
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/gdb/testsuite/gdb.trace/configure.in b/gdb/testsuite/gdb.trace/configure.in
new file mode 100644 (file)
index 0000000..77e36c7
--- /dev/null
@@ -0,0 +1,15 @@
+dnl Process this file file with autoconf to produce a configure script.
+dnl This file is a shell script fragment that supplies the information
+dnl necessary to tailor a template configure script into the configure
+dnl script appropriate for this directory.  For more information, check
+dnl any existing configure script.
+
+AC_PREREQ(2.5)
+AC_INIT(collect.c)
+
+CC=${CC-cc}
+AC_SUBST(CC)
+AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../../..)
+AC_CANONICAL_SYSTEM
+
+AC_OUTPUT(Makefile)
diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp
new file mode 100644 (file)
index 0000000..36da993
--- /dev/null
@@ -0,0 +1,269 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+set baseline [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+set testline1 [expr $baseline + 4]
+
+#
+# test "delete tracepoints" command
+#
+
+# 3.1 delete tracepoints (all)
+gdb_delete_tracepoints
+gdb_test "trace gdb_c_test"   "Tracepoint \[0-9\]+ at .*" "set tracepoint 1"
+gdb_test "trace gdb_asm_test" "Tracepoint \[0-9\]+ at .*" "set tracepoint 2"
+gdb_test "trace $testline1"   "Tracepoint \[0-9\]+ at .*" "set tracepoint 3"
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*\[0-9\]+\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_c_test.*\[0-9\]+\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*gdb_asm_test.*\[0-9\]+\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_recursion_test.*" \
+                       "3.1a: set three tracepoints"
+
+send_gdb "delete tracepoints\n"
+gdb_expect 30 {
+    -re "Delete all tracepoints.*y or n.*$" {
+       send_gdb "y\n"
+       gdb_expect 30 {
+           -re "$gdb_prompt $" {
+               pass "3.1b: delete all tracepoints"
+           }
+           timeout { fail "3.1b: delete all tracepoints (timeout)" }
+       }
+    }
+    -re "$gdb_prompt $" { # This should only happen if there are no tracepoints
+       fail "3.1b: delete all tracepoints (no tracepoints?)"
+    }
+    timeout { fail "3.1b: delete all tracepoints (timeout)" }
+}
+
+# 3.2 delete tracepoint <n>
+gdb_delete_tracepoints
+set trcpt1 [gdb_gettpnum gdb_c_test];
+set trcpt2 [gdb_gettpnum gdb_asm_test];
+set trcpt3 [gdb_gettpnum $testline1];
+if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in.*gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in.*gdb_recursion_test.*" \
+                       "3.2a: set three tracepoints"
+
+#gdb_test "delete tracepoint $trcpt1" "" ""
+send_gdb "delete tracepoint $trcpt1\n"
+gdb_expect {
+    -re "No tracepoint number.*$gdb_prompt $" {
+       fail "3.2b: delete first tracepoint"
+    }
+    -re ".*\[Ee\]rror.*$gdb_prompt $" {
+       fail "3.2b: delete first tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.2b: delete first tracepoint"
+    }
+    timeout {
+       fail "3.2b: delete first tracepoint (timeout)"
+    }
+}
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "$trcpt1\[\t \]+y\[\t \]+0x.*in.*gdb_c_test.*$gdb_prompt $" {
+       fail "3.2c: verify delete first tracepoint (argh)"
+    }
+    -re "$trcpt2\[\t \]+y.*gdb_asm_test.*\[\r\n\t ]+$trcpt3\[\t \]+y.* in gdb_recursion_test at .*$gdb_prompt $" {
+       pass "3.2c: verify delete first tracepoint"
+    }
+    -re ".*$gdb_prompt $" {
+       fail "3.2c: verify delete first tracepoint (mumble)" 
+    }
+    timeout {
+       fail "3.2c: verify delete first tracepoint (timeout)"
+    }
+}
+
+#gdb_test "delete tracepoint $trcpt2" "" ""
+send_gdb "delete tracepoint $trcpt2\n"
+gdb_expect {
+    -re "No tracepoint number.*$gdb_prompt $" {
+       fail "3.2d: delete second tracepoint"
+    }
+    -re ".*\[Ee\]rror.*$gdb_prompt $" {
+       fail "3.2d: delete second tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.2d: delete second tracepoint"
+    }
+    timeout {
+       fail "3.2d: delete second tracepoint (timeout)"
+    }
+}
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "$trcpt1\[\t \]+y\[\t \]+0x.*in.*gdb_c_test.*$gdb_prompt $" {
+       fail "3.2e: verify delete second tracepoint"
+    }
+    -re "$trcpt2\[\t \]+y\[\t \]+0x.*in gdb_asm_test.*$gdb_prompt $" {
+       fail "3.2e: verify delete second tracepoint"
+    }
+    -re "$trcpt3\[\t \]+y\[\t \]+0x.*in gdb_recursion_test.*$gdb_prompt $" {
+       pass "3.2e: verify delete second tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       fail "3.2e: verify delete second tracepoint" 
+    }
+    timeout {
+       fail "3.2e: verify delete second tracepoint (timeout)"
+    }
+}
+
+#gdb_test "delete tracepoint $trcpt3" "" ""
+send_gdb "delete tracepoint $trcpt3\n"
+gdb_expect {
+    -re "No tracepoint number.*$gdb_prompt $" {
+       fail "3.2f: delete third tracepoint"
+    }
+    -re ".*\[Ee\]rror.*$gdb_prompt $" {
+       fail "3.2f: delete third tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.2f: delete third tracepoint"
+    }
+    timeout {
+       fail "3.2f: delete third tracepoint (timeout)"
+    }
+}
+
+# send_gdb "ARF! \\n\n"
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "$trcpt3\[\t \]+y\[\t \]+0x.*in gdb_recursion_test.*$gdb_prompt $" {
+       fail "3.2g: verify delete third tracepoint"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.2g: verify delete third tracepoint"
+    }
+    timeout {
+       fail "3.2g: verify delete third tracepoint (timeout)" 
+    }
+}
+
+# 3.3 delete three tracepoints at once
+gdb_delete_tracepoints
+set trcpt1 [gdb_gettpnum gdb_c_test];
+set trcpt2 [gdb_gettpnum gdb_asm_test];
+set trcpt3 [gdb_gettpnum $testline1];
+if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_recursion_test.*" \
+                       "3.3a: set three tracepoints"
+
+#gdb_test "delete tracepoint $trcpt1 $trcpt2 $trcpt3" "" ""
+send_gdb "delete tracepoint $trcpt1 $trcpt2 $trcpt3\n"
+gdb_expect {
+    -re "No tracepoint number.*$gdb_prompt $" {
+       fail "3.3b: delete three tracepoints"
+    }
+    -re ".*\[Ee\]rror.*$gdb_prompt $" {
+       fail "3.3b: delete three tracepoints"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.3b: delete three tracepoints"
+    }
+    timeout {
+       fail "3.3b: delete three tracepoint (timeout)"
+    }
+}
+
+send_gdb "info tracepoints\n"
+gdb_expect {
+    -re "$trcpt1\[\t \]+y\[\t \]+0x.*in gdb_c_test.*$gdb_prompt $" {
+       fail "3.3c: verify delete three tracepoints (first one persists)"
+    }
+    -re "$trcpt2\[\t \]+y\[\t \]+0x.*in gdb_asm_test.*$gdb_prompt $" {
+       fail "3.3c: verify delete three tracepoints (second one persists)"
+    }
+    -re "$trcpt3\[\t \]+y\[\t \]+0x.*in gdb_recursion_test.*$gdb_prompt $" {
+       fail "3.3c: verify delete three tracepoints (third one persists)"
+    }
+    -re "$gdb_prompt $" {
+       pass "3.3c: verify delete three tracepoints" 
+    }
+    timeout { 
+       fail "3.3c: verify delete three tracepoints (timeout)"
+    }
+}
+
+# 3.4 delete invalid tracepoint number
+gdb_test "delete tracepoint [expr $trcpt2 + $trcpt3]" \
+    "No tracepoint number [expr $trcpt2 + $trcpt3]." \
+                       "3.4: delete invalid tracepoint number"
+
+# 3.5 delete tracepoint number zero
+gdb_test "delete tracepoint 0" "No tracepoint number 0." \
+                       "3.5: delete tracepoint number zero"
+
+# 3.6 help delete tracepoints
+gdb_test "help delete tracepoints" \
+    "Delete specified tracepoints.*" \
+                       "3.6: help delete tracepoints"
diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp
new file mode 100644 (file)
index 0000000..5b20799
--- /dev/null
@@ -0,0 +1,99 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+#
+# test "info tracepoints" command
+#
+
+gdb_delete_tracepoints
+set c_test_num [gdb_gettpnum gdb_c_test];
+set asm_test_num [gdb_gettpnum gdb_asm_test];
+if { $c_test_num <= 0 || $asm_test_num <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+# 2.1 info tracepoints (all)
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*$c_test_num\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_c_test.*$asm_test_num\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*gdb_asm_test.*" \
+    "2.1: info tracepoints (all)"
+
+# 2.2 info tracepoint (specific)
+gdb_test "info tracepoint $c_test_num" \
+    "$c_test_num\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*in gdb_c_test.*" \
+    "2.2a: info tracepoint $c_test_num (gdb_c_test)"
+
+gdb_test "info tracepoint $asm_test_num" \
+    "$asm_test_num\[\t \]+y\[\t \]+0x\[0-9a-fA-F\]+.*gdb_asm_test.*" \
+    "2.2b: info tracepoint $asm_test_num (gdb_asm_test)"
+
+# 2.3 info tracepoint (invalid tracepoint number)
+gdb_test "info tracepoint [expr $c_test_num + $asm_test_num]" \
+    "No tracepoint number [expr $c_test_num + $asm_test_num]." \
+    "2.3: info tracepoint (invalid tracepoint number)"
+
+# 2.4 info tracepoints (list of numbers)
+send_gdb "info tracepoints $c_test_num $asm_test_num \n"
+gdb_expect {
+    -re "Num Enb .*$gdb_prompt $" {
+       fail "2.4: info trace rejects multiple tracepoint numbers"
+    }
+    -re ".*$gdb_prompt $" {
+       pass "2.4: info trace rejects multiple tracepoint numbers"
+    }
+}
+
+# 2.5 help info trace
+gdb_test "help info tracepoints" \
+    "Status of tracepoints, or tracepoint number NUMBER.*" \
+    "2.5: help info tracepoints"
+
diff --git a/gdb/testsuite/gdb.trace/limits.c b/gdb/testsuite/gdb.trace/limits.c
new file mode 100644 (file)
index 0000000..d9c02e7
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Test program for tracing internal limits (number of tracepoints etc.)
+ */
+
+int n = 6;
+
+int arr[64];
+
+static void foo(int x)
+{
+}
+
+static void bar(int y)
+{
+}
+
+static void baz(int z)
+{
+}
+
+static void begin ()   /* called before anything else */
+{
+}
+
+static void end ()     /* called after everything else */
+{
+}
+
+int
+main (argc, argv, envp)
+     int argc;
+     char *argv[], **envp;
+{
+  int i;
+
+#ifdef usestubs
+  set_debug_traps ();
+  breakpoint ();
+#endif
+
+  begin ();
+  for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
+    arr[i] = i + 1;
+
+  foo (1);
+  bar (2);
+  baz (3);
+  end ();
+  return 0;
+}
+
diff --git a/gdb/testsuite/gdb.trace/limits.exp b/gdb/testsuite/gdb.trace/limits.exp
new file mode 100644 (file)
index 0000000..581f82d
--- /dev/null
@@ -0,0 +1,316 @@
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+if [istarget "m68k-*-elf"] then {
+    pass "Test not supported on this target"
+    return;
+}
+
+load_lib "trace-support.exp"
+
+if $tracelevel then {
+       strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "limits"
+set srcfile ${testfile}.c
+set binfile $objdir/$subdir/$testfile
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+       executable {debug additional_flags="-gdwarf"}] != "" } {
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Tests:
+# 1) Meet and exceed artificial limit on number of tracepoints
+# 2) Meet and exceed artificial limit on number of memranges
+# 3) Meet and exceed artificial limit on bytes  of bytecode data
+# [NOTE: number four is moved out into its own separate test module.]
+# 4) Meet and exceed artificial limit on bytes  of trace buffer storage
+#    (circular and non-circular modes).  However note that a more 
+#    thorough test of the circular mode can be made separately.
+
+set cr "\[\r\n\]+"
+
+proc gdb_tracepoint_limit_test { } {
+    global gdb_prompt
+    global cr
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Set three tracepoints
+    gdb_test "trace foo" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "tracepoint limit test: set first tracepoint"
+
+    gdb_test "trace bar" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "tracepoint limit test: set second tracepoint"
+
+    gdb_test "trace baz" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "tracepoint limit test: set third tracepoint"
+
+    # Set secret artificial tracepoint limit to four
+    gdb_test "maint packet QTLimit:tp:4" \
+           "received: .OK." \
+           "tracepoint limit test: set limit to four"
+
+    # Now sending three tracepoints should succeed.
+    send_gdb "tstart\n"
+    gdb_expect {
+       -re "$cr$gdb_prompt" {
+           pass "tracepoint limit test: send fewer than limit"
+       }
+       default {
+           fail "tracepoint limit test: send fewer than limit"
+       }
+    }
+
+    # Set secret artificial tracepoint limit to three
+    gdb_test "maint packet QTLimit:tp:3" \
+           "received: .OK." \
+           "tracepoint limit test: set limit to three"
+
+    # Now sending three tracepoints should still succeed.
+    send_gdb "tstart\n"
+    gdb_expect {
+       -re "$cr$gdb_prompt" {
+           pass "tracepoint limit test: send equal to limit"
+       }
+       default {
+           fail "tracepoint limit test: send equal to limit"
+       }
+    }
+
+    # Set secret artificial tracepoint limit to two
+    gdb_test "maint packet QTLimit:tp:2" \
+           "received: .OK." \
+           "tracepoint limit test: set limit to two"
+
+    # Now sending three tracepoints should fail.
+    gdb_test "tstart" \
+           ".*\[Ee\]rror.*" \
+           "tracepoint limit test: send more than limit"
+
+    # Clean up:
+    gdb_test "tstop" "" ""
+    gdb_test "maint packet QTLimit:tp:FFFFFFFF" "" ""
+}
+
+proc gdb_memrange_limit_test { } {
+    global gdb_prompt
+    global cr
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Set three tracepoints, and make 'em collect memranges
+    gdb_test "trace foo" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "memrange limit test: set first tracepoint"
+
+    gdb_trace_setactions "memrange limit test: set first actions" \
+           "" \
+           "collect \$arg" "^$"
+
+    gdb_test "trace bar" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "memrange limit test: set second tracepoint"
+
+    gdb_trace_setactions "memrange limit test: set second actions" \
+           "" \
+           "collect \$arg" "^$"
+
+    gdb_test "trace baz" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "memrange limit test: set third tracepoint"
+
+    gdb_trace_setactions "memrange limit test: set third actions" \
+           "" \
+           "collect \$arg" "^$"
+
+    # Set secret artificial memrange limit to four
+    gdb_test "maint packet QTLimit:memrange:4" \
+           "received: .OK." \
+           "memrange limit test: set limit to four"
+
+    # Now sending three memranges should still succeed.
+    send_gdb "tstart\n"
+    gdb_expect {
+       -re "$cr$gdb_prompt" {
+           pass "memrange limit test: send fewer than limit"
+       }
+       default {
+           fail "memrange limit test: send fewer than limit"
+       }
+    }
+
+    # Set secret artificial memrange limit to three
+    gdb_test "maint packet QTLimit:memrange:3" \
+           "received: .OK." \
+           "memrange limit test: set limit to three"
+
+    # Now sending three memranges should still succeed.
+    send_gdb "tstart\n"
+    gdb_expect {
+       -re "$cr$gdb_prompt" {
+           pass "memrange limit test: send equal to limit"
+       }
+       default {
+           fail "memrange limit test: send equal to limit"
+       }
+    }
+
+    # Set secret artificial memrange limit to two
+    gdb_test "maint packet QTLimit:memrange:2" \
+           "received: .OK." \
+           "memrange limit test: set limit to two"
+
+    # Now sending three memranges should fail.
+    gdb_test "tstart" \
+           ".*\[Ee\]rror.*" \
+           "memrange limit test: send more than limit"
+
+    # Clean up:
+    gdb_test "tstop" "" ""
+    gdb_test "maint packet QTLimit:memrange:FFFFFFFF" "" ""
+}
+
+
+proc gdb_bytecode_limit_test { } {
+    global gdb_prompt
+    global cr
+
+    # Make sure we're in a sane starting state.
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    gdb_delete_tracepoints
+
+    # Set three tracepoints
+    gdb_test "trace foo" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "bytecode limit test: set first tracepoint"
+
+    gdb_trace_setactions "bytecode limit test: set first actions" \
+           "" \
+           "collect x + n" "^$"
+
+    gdb_test "trace bar" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "bytecode limit test: set second tracepoint"
+
+    gdb_trace_setactions "bytecode limit test: set second actions" \
+           "" \
+           "collect y + n" "^$"
+
+    gdb_test "trace baz" \
+           "Tracepoint \[0-9\]+ at .*" \
+           "bytecode limit test: set third tracepoint"
+
+    gdb_trace_setactions "bytecode limit test: set third actions" \
+           "" \
+           "collect z + n" "^$"
+
+    # Set secret artificial bytecode limit to a large number
+    gdb_test "maint packet QTLimit:bytecode:400" \
+           "received: .OK." \
+           "bytecode limit test: set limit to large"
+
+    # Now sending three bytecodes should still succeed.
+    send_gdb "tstart\n"
+    gdb_expect {
+       -re "$cr$gdb_prompt" {
+           pass "bytecode limit test: send fewer than limit"
+       }
+       default {
+           fail "bytecode limit test: send fewer than limit"
+       }
+    }
+
+    # Set secret artificial bytecode limit to a small number
+    gdb_test "maint packet QTLimit:bytecode:40" \
+           "received: .OK." \
+           "bytecode limit test: set limit to small"
+
+    # Now sending three bytecodes should fail.
+    gdb_test "tstart" \
+           ".*\[Ee\]rror.*" \
+           "bytecode limit test: send more than limit"
+
+
+    # Clean up:
+    gdb_test "tstop" "" ""
+    gdb_test "maint packet QTLimit:bytecode:FFFFFFFF" "" ""
+}
+
+proc gdb_trace_limits_tests { } {
+    global gdb_prompt
+
+    # We generously give ourselves one "pass" if we successfully 
+    # detect that this test cannot be run on this target!
+
+    if { ![gdb_target_supports_trace] } then { 
+       pass "Current target does not supporst trace"
+       return 1;
+    }
+
+    if [gdb_test "maint packet QTLimit:tp:ffffffff" \
+           "received: .OK." ""] then { 
+       pass "This test cannot be run on this target"
+       return 1;
+    }
+
+    if [gdb_test "maint packet QTLimit:memrange:ffffffff" \
+           "received: .OK." ""] then { 
+       pass "This test cannot be run on this target"
+       return 1;
+    }
+
+    if [gdb_test "maint packet QTLimit:bytecode:ffffffff" \
+           "received: .OK." ""] then { 
+       pass "This test cannot be run on this target"
+       return;
+    }
+
+    gdb_tracepoint_limit_test
+    gdb_memrange_limit_test
+    gdb_bytecode_limit_test
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+if [target_info exists gdb_stub] {
+    gdb_step_for_stub;
+}
+# Body of test encased in a proc so we can return prematurely.
+gdb_trace_limits_tests
diff --git a/gdb/testsuite/gdb.trace/packetlen.exp b/gdb/testsuite/gdb.trace/packetlen.exp
new file mode 100644 (file)
index 0000000..edd7e6c
--- /dev/null
@@ -0,0 +1,100 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp"
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp"
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor "$binfile"
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none"  "" ""
+    send_gdb "compare-sections CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+#
+# Test collecting a whole bunch of stuff at a single tracepoint.
+# The test is whether this crashes GDB.
+#
+
+gdb_delete_tracepoints
+gdb_test "trace gdb_c_test" "" ""
+gdb_trace_setactions "setup collect actions" \
+       "" \
+       "collect parm\[0\], parm\[1\], parm\[2\], parm\[3\]" "^$" \
+       "collect parm\[4\], parm\[5\], parm\[6\], parm\[7\]" "^$" \
+       "collect p, local_reg, local_static, local_static_sizeof" "^$" \
+       "collect local_long, stack_ptr, end_of_stack" "^$" \
+       "collect gdb_char_test, gdb_short_test, gdb_long_test" "^$" \
+       "collect gdb_arr_test, gdb_struct1_test, gdb_struct2_test" "^$" \
+       "collect gdb_structp_test, gdb_structpp_test, gdb_union1_test" "^$" \
+       "end" ""
+
+gdb_test "tstart" "" "survive the long packet send"
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,1,2,3,4,5,6"
+    sleep 5
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+}
+
+gdb_test "tstop" "" "confirm: survived the long packet send"
+
diff --git a/gdb/testsuite/gdb.trace/passc-dyn.exp b/gdb/testsuite/gdb.trace/passc-dyn.exp
new file mode 100644 (file)
index 0000000..cf102de
--- /dev/null
@@ -0,0 +1,181 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp";
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor $binfile
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    send_gdb "compare-sections CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# We generously give ourselves one "pass" if we successfully 
+# detect that this test cannot be run on this target!
+if { ![gdb_target_supports_trace] } then {
+    pass "Current target does not supporst trace"
+    return 1;
+
+}
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+
+#
+# test passcount dynamically (live target)
+#
+
+set baseline [gdb_find_recursion_test_baseline $srcfile];
+
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+
+set testline2  [expr $baseline +  4]
+set testline3  [expr $baseline +  5]
+set testline4  [expr $baseline +  6]
+
+#
+# test passcount command semantics (live test)
+#
+
+## Set three tracepoints with three different passcounts.
+## Verify that the experiment stops after the one with the 
+## lowest passcount is hit.
+
+gdb_delete_tracepoints
+set tdp2 [gdb_gettpnum "$testline2"]
+set tdp3 [gdb_gettpnum "$testline3"]
+set tdp4 [gdb_gettpnum "$testline4"]
+if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
+       "4.5: set passcount for tracepoint $tdp2"
+gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
+       "4.5: set passcount for tracepoint $tdp3"
+gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
+       "4.5: set passcount for tracepoint $tdp4"
+
+gdb_test "tstart" "" ""
+
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,1,2,3,4,5,6"
+    sleep 5
+    gdb_emclaptop_command "85,7,8,9,A,B,C"
+    sleep 5
+    gdb_emclaptop_command "85,D,E,F,10,11,12"
+    sleep 5
+    # gdb_test "tstop"
+    ##
+    ## Note! Must NOT give the tstop command, because the passcount
+    ##       has already stopped the experiment.  You would not
+    ##       think this would be an error, but in EMC's mind it is...
+    ##
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+    gdb_test "tstop" "" ""
+}
+
+gdb_test "tfind none" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] {
+    gdb_suppress_entire_file "0: tfind none failed"
+}
+
+gdb_test "tfind tracepoint $tdp2" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] {
+    gdb_suppress_entire_file "1: first tfind failed"
+}
+
+gdb_test "tfind tracepoint $tdp3" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] {
+    gdb_suppress_entire_file "2: second tfind failed"
+}
+
+gdb_test "tfind tracepoint $tdp4" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] {
+    gdb_suppress_entire_file "3: third tfind failed"
+}
+
+gdb_test "tfind tracepoint $tdp2" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] {
+    gdb_suppress_entire_file "4: fourth tfind failed"
+}
+
+gdb_test "tfind tracepoint $tdp3" "" ""
+if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] {
+    gdb_suppress_entire_file "5: fifth tfind failed"
+}
+
+## We should now be at the last frame, because this frame's passcount
+## should have caused collection to stop.  If we do a tfind now, 
+## it should fail.
+
+gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
+
+# Finished!
+gdb_test "tfind none" "" ""
+
diff --git a/gdb/testsuite/gdb.trace/passcount.exp b/gdb/testsuite/gdb.trace/passcount.exp
new file mode 100644 (file)
index 0000000..6e4144b
--- /dev/null
@@ -0,0 +1,178 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+set baseline  [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+set testline1  [expr $baseline + 3]
+
+#
+# test "passcount" command
+#
+
+gdb_delete_tracepoints
+set trcpt1 [gdb_gettpnum gdb_c_test];
+set trcpt2 [gdb_gettpnum gdb_asm_test];
+set trcpt3 [gdb_gettpnum $testline1];
+if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+# 4.1 passcount of specified tracepoint
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*in gdb_recursion_test.*" \
+                       "4.1a: set three tracepoints, passcounts all zero"
+
+gdb_test "passcount 2 $trcpt1" \
+       "Setting tracepoint $trcpt1.s passcount to 2" \
+       "4.1b: set 1st tracepoint's passcount to two"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+2\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*in gdb_recursion_test.*" \
+       "4.1c: verify 1st tracepoint's passcount set to two"
+
+gdb_test "passcount 4 $trcpt2" \
+       "Setting tracepoint $trcpt2.s passcount to 4" \
+       "4.1d: set 2nd tracepoint's passcount to four"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+2\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*in gdb_recursion_test.*" \
+       "4.1c: verify 2nd tracepoint's passcount set to four"
+
+# 4.2 passcount of last (default) tracepoint
+
+gdb_test "passcount 6" \
+       "Setting tracepoint $trcpt3.s passcount to 6" \
+       "4.2b: set last (default) tp's passcount to six"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+2\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+6\[\t \]+.*in gdb_recursion_test.*" \
+       "4.2b: verify last (default) tp's passcount set to six"
+
+# 4.3 run until stopped explicitly by user
+#     [deferred to dynamic test section]
+
+# 4.4 reset the previously set passcounts to new values
+
+gdb_test "passcount 7" \
+       "Setting tracepoint $trcpt3.s passcount to 7" \
+       "4.4a: reset last (default) tp's passcount to seven"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+2\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+7\[\t \]+.*in gdb_recursion_test.*" \
+       "4.4a: verify reset last (default) tp's passcount to seven"
+
+gdb_test "passcount 5 $trcpt2" \
+       "Setting tracepoint $trcpt2.s passcount to 5" \
+       "4.4b: reset second tracepoint's passcount to five"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+2\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+5\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+7\[\t \]+.*in gdb_recursion_test.*" \
+       "4.4c: verify reset second tracepoint's passcount to five"
+
+# 4.20 <FIXME test number> passcount for "all"
+
+gdb_test "passcount 3 all" \
+       ".*$trcpt1.s pass.* 3.*$trcpt2.s pass.* 3.*$trcpt3.s pass.* 3" \
+       "4.20a: set all three passcounts to three"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+3\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+3\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+3\[\t \]+.*in gdb_recursion_test.*" \
+       "4.20a: set all three passcounts to three"
+
+gdb_test "passcount 4 all" \
+       ".*$trcpt1.s pass.* 4.*$trcpt2.s pass.* 4.*$trcpt3.s pass.* 4" \
+       "4.20a: reset all three passcounts to four"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*in gdb_recursion_test.*" \
+       "4.20b: reset all three passcounts to four"
+
+# 4.5 Verify trace stops on first "satisfied" passcount
+#     [deferred to dynamic test section]
+
+# 4.6 minimum passcount boundary condition
+
+gdb_test "passcount 0 $trcpt1" \
+       "Setting tracepoint $trcpt1.s passcount to 0" \
+       "4.6: set passcount to zero"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+0\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*in gdb_recursion_test.*" \
+       "4.6: set passcount to zero"
+
+# 4.7 (test a very large passcount)
+
+gdb_test "passcount 32767 $trcpt1" \
+       "Setting tracepoint $trcpt1.s passcount to 32767" \
+       "4.7: set passcount to large number (32767)"
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1\[\t \]+y\[\t \]+$hex\[\t \]+32767\[\t \]+.*in gdb_c_test.*$trcpt2\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*gdb_asm_test.*$trcpt3\[\t \]+y\[\t \]+$hex\[\t \]+4\[\t \]+.*in gdb_recursion_test.*" \
+       "4.7: set passcount to large number (32767)"
+
+# 4.8 set passcount for invalid tracepoint
+
+gdb_test "passcount 1 [expr $trcpt2 + $trcpt3]" \
+       "No tracepoint number [expr $trcpt2 + $trcpt3]." \
+       "4.8: invalid tracepoint number in passcount"
+
+# 4.9 help passcount
+gdb_test "help passcount" "Set the passcount for a tracepoint.*" \
+       "4.9: help passcount"
+
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
new file mode 100644 (file)
index 0000000..4df17e1
--- /dev/null
@@ -0,0 +1,421 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp";
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor $binfile
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none"  "" ""
+    send_gdb "compare-sections CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+            executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# We generously give ourselves one "pass" if we successfully 
+# detect that this test cannot be run on this target!
+if { ![gdb_target_supports_trace] } then {
+    pass "Current target does not supporst trace"
+    return 1;
+
+}
+
+set cr "\[\r\n\]+"
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+#
+# test general reporting of trace experiment results
+#
+
+set testline1 0
+set testline2 0
+set testline3 0
+set testline4 0
+set testline5 0
+set testline6 0
+
+set arg1 1
+set arg2 2
+set arg3 3
+set arg4 4
+set arg5 5
+set arg6 6
+
+set gdb_recursion_test_baseline [gdb_find_recursion_test_baseline $srcfile];
+if { $gdb_recursion_test_baseline == -1 } {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+send_gdb "list $gdb_recursion_test_baseline, +12\n"
+gdb_expect {
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 1 " {
+       set testline1 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 2 " {
+       set testline2 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 3 " {
+       set testline3 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 4 " {
+       set testline4 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 5 " {
+       set testline5 $expect_out(1,string)
+       exp_continue
+    }
+    -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 6 " {
+       set testline6 $expect_out(1,string)
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
+           gdb_suppress_entire_file "failed to locate test source lines:
+all tests in this module will fail."
+       }
+    }
+    default {
+           gdb_suppress_entire_file "failed to locate test source lines (def):
+all tests in this module will fail."
+    } 
+}
+
+#
+# Setup trace experiment.  This will involve:
+#   1) a tracepoint where nothing is collected
+#   2) a tracepoint where only regs are collected
+#   3) a tracepoint where only args are collected
+#   4) a tracepoint where only locals are collected
+#   5) a tracepoint where some amount of stack memory is collected.
+#   6) a tracepoint where some expressions are collected.
+#
+
+gdb_delete_tracepoints
+set tdp1 [gdb_gettpnum $testline1]
+set tdp2 [gdb_gettpnum $testline2]
+set tdp3 [gdb_gettpnum $testline3]
+set tdp4 [gdb_gettpnum $testline4]
+set tdp5 [gdb_gettpnum $testline5]
+set tdp6 [gdb_gettpnum $testline6]
+
+if {    $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
+       $tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
+    fail "setting tracepoints failed"
+    return;
+}
+
+gdb_trace_setactions "9.x: setup TP to collect regs" \
+       "$tdp2" \
+       "collect \$regs" "^$"
+
+
+gdb_trace_setactions "9.x: setup TP to collect args" \
+       "$tdp3" \
+       "collect \$args" "^$"
+
+gdb_trace_setactions "9.x: setup TP to collect locals" \
+       "$tdp4" \
+       "collect \$locs" "^$"
+
+gdb_trace_setactions "9.x: setup TP to collect stack memory" \
+       "$tdp5" \
+       "collect \$fp, \*\(void \*\*\) \$sp @ 64" "^$"
+
+gdb_trace_setactions "9.x: setup TP to collect expressions" \
+       "$tdp6" \
+       "collect gdb_char_test, gdb_short_test, gdb_long_test" "^$"
+
+gdb_test "tstart" "" ""
+
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6"
+    sleep 5
+    
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+}
+
+gdb_test "tstop" "" ""
+
+#
+# 9.1 test the tdump command
+#
+
+set timeout 60
+
+gdb_tfind_test "9.1: init: make sure not debugging any trace frame" "none" "-1"
+
+gdb_tfind_test "9.1: find frame for TP $tdp1" "tracepoint $tdp1" \
+       "\$tracepoint" "$tdp1"
+
+# Nothing was collected at tdp1, so this tdump should be empty.
+gdb_test "tdump" \
+       "Data collected at tracepoint $tdp1, trace frame $decimal:" \
+       "9.1: tdump, nothing collected"
+
+gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \
+       "\$tracepoint" "$tdp2"
+
+# regs were collected at tdp2.
+# How to match for the output of "info registers" on an unknown architecture?
+# For now, assume that every architecture has a register called "pc".
+gdb_test "tdump" \
+       "\[\r\n\]pc .*" \
+       "9.1: tdump, regs collected"
+
+gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \
+       "\$tracepoint" "$tdp3"
+
+# args were collected at tdp3
+gdb_test "tdump" \
+       "depth = 3.*q1 = 2.*q2 = 2.*q3 = 3.*q4 = 4.*q5 = 5.*q6 = 6" \
+       "9.1: tdump, args collected"
+
+gdb_tfind_test "9.1: find frame for TP $tdp4" "tracepoint $tdp4" \
+       "\$tracepoint" "$tdp4"
+
+# locals were collected at tdp4
+gdb_test "tdump" \
+       "q = 1" \
+       "9.1: tdump, locals collected"
+
+gdb_tfind_test "9.1: find frame for TP $tdp5" "tracepoint $tdp5" \
+       "\$tracepoint" "$tdp5"
+
+# stack was collected at tdp5, plus the frame pointer
+gdb_test "tdump" \
+       ".fp = .*sp @ 64 = .*" \
+       "9.1: tdump, memrange collected"
+
+gdb_tfind_test "9.1: find frame for TP $tdp6" "tracepoint $tdp6" \
+       "\$tracepoint" "$tdp6"
+
+# globals were collected at tdp6
+gdb_test "tdump" \
+       "gdb_char_test = 1.*gdb_short_test = 2.*gdb_long_test = 3" \
+       "9.1: tdump, global variables collected"
+
+# 9.2 test tdump with arguments
+#     [no go, tdump doesn't have any arguments]
+
+# 9.3 help tdump
+
+gdb_test "help tdump" "Print everything collected at the current.*" \
+       "9.3: help tdump"
+
+set linecount1 0
+set linecount2 0
+set linecount3 0
+set linecount4 0
+set linecount5 0
+set linecount6 0
+
+gdb_tfind_test "11.x, 12.1: find start frame" "start" "0"
+
+#
+# 11.x test built-in trace variables $trace_frame, $trace_line etc.
+#
+
+gdb_test "printf \"x %d x\\n\", \$trace_frame" "x 0 x" \
+       "11.1: test \$trace_frame"
+
+gdb_test "printf \"x %d x\\n\", \$tracepoint" "x $tdp1 x" \
+       "11.2: test \$tracepoint"
+
+gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \
+       "11.3: test \$trace_line"
+
+send_gdb "print \$trace_file\n"
+gdb_expect {
+    -re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
+       pass "11.4: test \$trace_file"
+    }
+    -re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
+       pass "11.4: test \$trace_file"
+    }
+    -re "$gdb_prompt $" {
+       fail "11.4: test \$trace_file"
+    }
+    timeout {
+       fail "11.4: test \$trace_file (timeout)"
+    }
+}
+
+#gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \
+#      "11.4: test \$trace_file"
+
+#
+# 12.x test report generation using arbitrary GDB commands, loops etc.
+#
+
+send_gdb "while \$trace_frame != -1\n  output \$trace_file\n  printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n  tfind\n  end\n"
+gdb_expect {
+    -re " line $testline1 .tracepoint .$tdp1" {
+       set linecount1 [expr $linecount1 + 1]
+       exp_continue
+    }
+    -re " line $testline2 .tracepoint .$tdp2" {
+       set linecount2 [expr $linecount2 + 1]
+       exp_continue
+    }
+    -re " line $testline3 .tracepoint .$tdp3" {
+       set linecount3 [expr $linecount3 + 1]
+       exp_continue
+    }
+    -re " line $testline4 .tracepoint .$tdp4" {
+       set linecount4 [expr $linecount4 + 1]
+       exp_continue
+    }
+    -re " line $testline5 .tracepoint .$tdp5" {
+       set linecount5 [expr $linecount5 + 1]
+       exp_continue
+    }
+    -re " line $testline6 .tracepoint .$tdp6" {
+       set linecount6 [expr $linecount6 + 1]
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($linecount1 < 4) || ($linecount2 < 4) || ($linecount3 < 4) || ($linecount4 < 4) || ($linecount5 < 4) || ($linecount6 < 4) } {
+           fail "12.1: trace report #1"
+       } else {
+           pass "12.1: trace report #1"
+       }
+    }
+    timeout {
+       fail "12.1: trace report #1 (timeout)"
+    }
+}
+
+gdb_tfind_test "12.2: find first TDP #2 frame" "tracepoint $tdp2" \
+       "\$tracepoint" "$tdp2"
+
+set linecount2 0
+
+send_gdb "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end\n"
+gdb_expect {
+    -re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" {
+       set linecount2 [expr $linecount2 + 1]
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($linecount2 < 4) } {
+           fail "12.2: trace report #2"
+       } else {
+           pass "12.2: trace report #2"
+       }
+    }
+    timeout {
+       fail "12.2: trace report #2 (timeout)"
+    }
+}
+
+gdb_tfind_test "12.3: find first TDP #3 frame" "tracepoint $tdp3" \
+       "\$tracepoint" "$tdp3"
+
+set linecount3 0
+
+send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end\n"
+gdb_expect {
+    -re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" {
+       set linecount3 [expr $linecount3 + 1]
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($linecount3 < 4) } {
+           fail "12.3: trace report #3"
+       } else {
+           pass "12.3: trace report #3"
+       }
+    }
+    timeout {
+       fail "12.3: trace report #3 (timeout)"
+    }
+}
+
+gdb_tfind_test "12.4: find first TDP #6 frame" "tracepoint $tdp6" \
+       "\$tracepoint" "$tdp6"
+
+set linecount6 0
+
+send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end\n"
+gdb_expect {
+    -re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" {
+       set linecount6 [expr $linecount6 + 1]
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { ($linecount6 < 4) } {
+           fail "12.4: trace report #4"
+       } else {
+           pass "12.4: trace report #4"
+       }
+    }
+    timeout {
+       fail "12.4: trace report #4 (timeout)"
+    }
+}
+
+# Finished!
+gdb_tfind_test "finished: make sure not debugging any trace frame" "none" "-1"
diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp
new file mode 100644 (file)
index 0000000..c2cfabd
--- /dev/null
@@ -0,0 +1,171 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+set baseline  [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+set testline1 [expr $baseline + 4]
+set testline2 [expr $baseline + 5]
+set testline3 [expr $baseline + 6]
+set testline4 [expr $baseline + 7]
+set testline5 [expr $baseline + 8]
+set testline6 [expr $baseline + 9]
+
+#
+# test save-trace command
+#
+
+# setup a set of tracepoints to save
+
+gdb_delete_tracepoints
+
+foreach x { 1 2 3 4 5 6 } {
+    set testline [expr \$testline$x];
+    set trcpt [gdb_gettpnum $testline];
+    set trcpt$x $trcpt;
+    gdb_test "passcount $x" \
+            "Setting tracepoint $trcpt.* to $x" \
+            "10.x: set passcount for tracepoint $trcpt"
+
+    gdb_trace_setactions "10.x: set actions for tracepoint $x" \
+           "" \
+           "collect q$x" "^$" \
+           "while-stepping $x" "^$" \
+           "collect q$x" "^$" \
+           "end" "^$"
+}
+
+
+proc gdb_verify_tracepoints { testname } {
+    global gdb_prompt;
+
+    set ws "\[\t \]+"
+    set nl "\[\r\n\]+"
+    set ourstate 1;
+    set result "pass";
+    send_gdb "info tracepoints\n";
+    gdb_expect 10 {
+       -re "y\[\t \]+0x\[0-9a-fA-F\]+\[\t \]+(\[0-9\]+)\[\t \]+(\[0-9\]+)\[\t \]+in gdb_recursion_test\[^\r\n\]+" {
+           if { $expect_out(1,string) != $expect_out(2,string) } {
+               #set result "fail";
+           }
+           if { $expect_out(1,string) != $ourstate } {
+               set result "fail";
+           }
+           incr ourstate;
+           exp_continue;
+       }
+       -re "$gdb_prompt $" {
+           if { $ourstate >= 6 } {
+               set result "pass";
+           } else {
+               set result "fail";
+           }
+       }
+       default {
+           set result "fail";
+       }
+    }
+    $result $testname;
+    return $result;
+}
+
+gdb_verify_tracepoints "10.x: verify trace setup";
+
+# 10.1 Save current tracepoint definitions to a file
+
+remote_file host delete savetrace.tr
+gdb_test "save-tracepoints savetrace.tr" \
+       "Tracepoints saved to file 'savetrace.tr'." \
+       "10.1: save tracepoint definitions"
+
+# 10.2 Read back tracepoint definitions
+
+gdb_delete_tracepoints
+gdb_test "info tracepoints" "No tracepoints." "10.2: delete tracepoints"
+gdb_test "source savetrace.tr" \
+       "Tracepoint \[0-9\]+ at .*" \
+       "10.2: read back saved tracepoints"
+gdb_verify_tracepoints "10.2: verify recovered tracepoints";
+remote_file host delete savetrace.tr
+
+# 10.3 repeat with a path to the file
+
+remote_file host delete $objdir/savetrace.tr
+gdb_test "save-tracepoints $objdir/savetrace.tr" \
+       "Tracepoints saved to file '$objdir/savetrace.tr'." \
+       "10.3: save tracepoint definitions, full path"
+
+gdb_delete_tracepoints
+gdb_test "info tracepoints" "No tracepoints." "10.3: delete tracepoints"
+gdb_test "source $objdir/savetrace.tr" \
+       "Tracepoint \[0-9\]+ at .*" \
+       "10.4: read saved tracepoints, full path"
+gdb_verify_tracepoints "10.3: verify recovered tracepoints, full path";
+remote_file host delete $objdir/savetrace.tr
+
+# 10.5 invalid filename
+#      [deferred -- not sure what a good invalid filename would be]
+
+# 10.6 save-trace (file already exists)
+#      [expect it to clobber the old one]
+
+# 10.7 help save-tracepoints
+
+gdb_test "help save-tracepoints" \
+       "Save current tracepoint definitions as a script.*" \
+       "10.7: help save-tracepoints"
diff --git a/gdb/testsuite/gdb.trace/tfind.exp b/gdb/testsuite/gdb.trace/tfind.exp
new file mode 100644 (file)
index 0000000..5d70951
--- /dev/null
@@ -0,0 +1,405 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp";
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor $binfile
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none" "" ""
+    send_gdb "compare-sections CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile -O1" \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# We generously give ourselves one "pass" if we successfully 
+# detect that this test cannot be run on this target!
+if { ![gdb_target_supports_trace] } then {
+    pass "Current target does not supporst trace"
+    return 1;
+
+}
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+set baseline  [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+set testline1 [expr $baseline + 1]
+set testline2 [expr $baseline + 5]
+set testline3 [expr $baseline + 6]
+set testline4 [expr $baseline + 7]
+set testline5 [expr $baseline + 8]
+
+#
+# test tfind command
+#
+
+gdb_delete_tracepoints
+set tdp1 [gdb_gettpnum "\*gdb_recursion_test"]
+set tdp2 [gdb_gettpnum $testline2]
+set tdp3 [gdb_gettpnum $testline3]
+set tdp4 [gdb_gettpnum $testline4]
+set tdp5 [gdb_gettpnum $testline5]
+if { $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
+     $tdp4 <= 0 || $tdp5 <= 0 } then {
+    fail "setting tracepoints"
+    return;
+}
+
+# 6.1 test tstart command
+send_gdb "tstart\n"
+gdb_expect {
+    -re "Trace can only be run on remote targets.*$gdb_prompt $" {
+       fail "6.1: tstart (not connected to remote?)"
+       return;
+    }
+    -re "Target does not support this command.*$gdb_prompt $" {
+       fail "6.1: tstart (connected to wrong target?)"
+       return;
+    }
+    -re "Target returns error code.*$gdb_prompt $" {
+       fail "6.1: tstart (connected to wrong target?)"
+       return;
+    }
+    -re "$gdb_prompt $" {
+       pass "6.1: tstart"
+    }
+    default {
+       fail "6.1: tstart (default)"
+       return;
+    }
+}
+
+# test tstatus (when trace on)
+gdb_test "tstatus" "\[Tt\]race is running.*" "test tstatus on"
+
+# 6.2 test help tstart
+gdb_test "help tstart" "Start trace data collection." "6.2: help tstart"
+
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,1,2,3,4,5,6"
+    sleep 5
+    
+    gdb_emclaptop_command "85,7,8,9,A,B,C"
+    sleep 5
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+}
+
+# 7.1 test tstop command
+send_gdb "tstop\n"
+gdb_expect {
+    -re "Trace can only be run on remote targets.*$gdb_prompt $" {
+       fail "7.1: tstop (not connected to remote?)"
+       return;
+    }
+    -re "Target does not support this command.*$gdb_prompt $" {
+       fail "7.1: tstop (connected to wrong target?)"
+       return;
+    }
+    -re "Target returns error code.*$gdb_prompt $" {
+       fail "7.1: tstop (connected to wrong target?)"
+       return;
+    }
+    -re "$gdb_prompt $" {
+       pass "7.1: tstop"
+    }
+    default {
+       fail "7.1: tstop (default)"
+       return;
+    }
+}
+
+# 7.2 test help tstop
+gdb_test "help tstop" "Stop trace data collection." "7.2: help tstop"
+
+# test tstatus (when trace off)
+gdb_test "tstatus" "\[Tt\]race.* not running.*" "test tstatus off"
+
+## record starting PC
+set save_pc [gdb_readexpr "(unsigned long) \$pc"];
+if { $save_pc == -1 } then {
+    fail "could not read PC"
+    return;
+}
+
+# 8.7  tfind start
+## check $trace_frame == 0
+gdb_tfind_test "8.7: tfind start command" "start" "0";
+## check $pc != startPC
+gdb_test "printf \"x \%d x\\n\", \$pc != $save_pc" \
+       "x 1 x" \
+       "8.7b: tfind start"
+
+# 8.8  tfind none
+## check $trace_frame == -1
+gdb_tfind_test "8.8: tfind none" "none" "-1";
+## check $pc == startPC
+gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
+       "x 1 x" \
+       "8.8b: tfind none (restores non-trace PC)"
+
+# 8.9  tfind end
+## check $trace_frame == -1
+gdb_tfind_test "8.9: tfind end, selects no frame" "end" "-1";
+## check $pc == startPC
+gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
+       "x 1 x" \
+       "8.9b: tfind end (restores non-tracing PC)"
+
+# 8.1  tfind n
+## check $trace_frame == n
+gdb_tfind_test "8.1: tfind 1" "1" "1"
+## check $trace_line corresponds to tracepoint for frame n
+gdb_test "print \$trace_line" "$testline2" "8.1b: tfind 1 (correct line)"
+
+# 8.28 tfind invalid n (big number)
+## check "not found" error
+## check $trace_frame != n
+gdb_test "tfind 32767" \
+       "failed to find.*" \
+       "8.28: tfind <n> command rejects invalid frame number"
+
+gdb_test "printf \"x \%d x\\n\", \$trace_frame == 32767" \
+       "x 0 x" \
+       "8.28: tfind <n> rejected bad input (32767)"
+
+# 8.31 tfind negative n
+## check error
+gdb_test "tfind -3" "invalid input.*" "8.31: tfind <n> rejects negative input"
+## check $trace_frame != -n
+gdb_test "printf \"x \%d x\\n\", \$trace_frame == -3" "x 0 x" \
+       "8.31: tfind <n> rejected negative input (-3)"
+
+# 8.10 tfind <no arg>
+## check $trace_frame += 1
+
+gdb_tfind_test "8.10: tfind start" "start" "0";
+gdb_test "print \$trace_line" "$baseline"  \
+       "8.10: tfind 0 (correct line $baseline)"
+gdb_tfind_test "8.10: tfind noargument 1" "" "1";
+gdb_test "print \$trace_line" "$testline2" \
+       "8.10: tfind 1 (correct line $testline2)"
+gdb_tfind_test "8.10: tfind noargument 2" "" "2";
+gdb_test "print \$trace_line" "$testline3" \
+       "8.10: tfind 2 (correct line $testline3)"
+gdb_tfind_test "8.10: tfind noargument 3" "" "3";
+gdb_test "print \$trace_line" "$testline4" \
+       "8.10: tfind 3 (correct line $testline4)"
+
+gdb_tfind_test "8.11: tfind 3" "3" "3";
+gdb_test "print \$trace_line" "$testline4" \
+       "8.11: tfind 3 (correct line $testline4)"
+gdb_tfind_test "8.11: tfind backward 2" "-" "2";
+gdb_test "print \$trace_line" "$testline3" \
+       "8.11: tfind 2 (correct line $testline3)"
+gdb_tfind_test "8.11: tfind backward 1" "-" "1";
+gdb_test "print \$trace_line" "$testline2" \
+       "8.11: tfind 1 (correct line $testline2)"
+gdb_tfind_test "8.11: tfind backward 0" "-" "0";
+gdb_test "print \$trace_line" "$baseline"  \
+       "8.11: tfind 0 (correct line $baseline)"
+
+gdb_tfind_test "8.12: tfind none" "none" "-1";
+gdb_tfind_test "8.12: tfind tracepoint <n>" "tracepoint $tdp2" \
+       "\$tracepoint" "$tdp2";
+gdb_test "print \$trace_line" "$testline2" \
+       "8.12: tfind tracepoint <n> (line $testline2)"
+
+gdb_tfind_test "8.25: tfind none" "none" "-1";
+gdb_test "tfind tracepoint 0" "failed to find.*" \
+       "8.25: tfind tracepoint rejects zero"
+gdb_test "tfind tracepoint 32767" "failed to find.*" \
+       "8.25: tfind tracepoint rejects nonexistant tracepoint (32767)"
+gdb_test "tfind tracepoint -1" "failed to find.*" \
+       "8.25: tfind tracepoint rejects nonexistant tracepoint (-1)"
+
+# 8.37 tfind tracepoint n where n no longer exists (but used to)
+gdb_test "delete trace $tdp2" "" ""
+gdb_tfind_test "8.37: tfind none" "none" "-1";
+gdb_tfind_test "8.37: tfind deleted tracepoint" \
+       "tracepoint $tdp2" \
+       "\$tracepoint" "$tdp2";
+gdb_test "print \$trace_line" "$testline2" \
+       "8.37: tfind deleted tracepoint (line $testline2)"
+
+# 8.13 tfind tracepoint <no arg>
+## check $tracepoint same before and after, $trace_frame changed
+
+gdb_tfind_test "8.13: tfind none" "none" "-1";
+gdb_tfind_test "8.13: tracepoint $tdp1" "tracepoint $tdp1" \
+       "\$tracepoint" "$tdp1";
+gdb_test "print \$trace_line" "$baseline" \
+       "8.13: tfind tracepoint $tdp1 (line $baseline)"
+gdb_test "set \$save_frame = \$trace_frame" "" ""
+gdb_tfind_test "8.13: tracepoint <no arg>" "tracepoint" \
+       "\$tracepoint" "$tdp1";
+gdb_test "printf \"x \%d x\\n\", \$trace_frame == \$save_frame" \
+       "x 0 x" \
+       "8.13: tracepoint <no arg>, tracepoint number unchanged"]
+
+# 1.12 set tracepoint in prologue
+#
+# tdp1 was set at *gdb_recursion_test (ie. the hard address of the
+# function, before the prologue).  Test to see that it succeeded.
+# Current pc should be equal to the address of the function.
+
+gdb_test "printf \"x \%d x\\n\", \$pc == gdb_recursion_test" \
+       "x 1 x" \
+       "1.12: set tracepoint in prologue"
+
+# 8.14 tfind pc x
+## check pc == x, $trace_frame != -1
+gdb_tfind_test "8.14: tfind 3" "3" "3"
+gdb_test "print \$trace_line" "$testline4" \
+       "8.14: tfind 3 (line $testline4)"
+
+gdb_test "set \$test_pc = \$pc" "" ""
+gdb_tfind_test "8.14: tfind none" "none" "-1"
+gdb_tfind_test "8.14: tfind pc" "pc \$test_pc" "\$trace_frame != -1" "1";
+gdb_test "print \$trace_line" "$testline4" \
+       "8.14: tfind pc x (line $testline4)"
+gdb_test "printf \"x \%d x\\n\", \$pc == \$test_pc" \
+       "x 1 x" \
+       "8.14: tfind pc x"
+
+# 8.15 tfind pc <no arg>
+## check pc same before and after, $trace_frame changed
+gdb_tfind_test "8.15: tfind 3" "3" "3"
+gdb_test "print \$trace_line" "$testline4" \
+       "8.15: tfind 3 (line $testline4)"
+gdb_test "set \$test_pc = \$pc" "" ""
+gdb_tfind_test "8.15: tfind pc" "pc" "\$pc == \$test_pc" "1"
+gdb_test "print \$trace_line" "$testline4" \
+       "8.15: tfind pc (line $testline4)"
+gdb_test "printf \"x \%d x\\n\", \$trace_frame != 3" "x 1 x" \
+       "8.15: trace frame didn't change"
+
+# 8.26 tfind pc invalid x
+## check error, pc != x (trace_frame unchanged?)
+gdb_tfind_test "8.26: tfind start" "start" "0"
+gdb_test "tfind pc  0" "failed to find.*" "8.26: tfind pc zero"
+gdb_test "tfind pc -1" "failed to find.*" "8.26: tfind pc -1"
+
+# 8.16 tfind line n
+## check #trace_frame != -1, $trace_line == n
+gdb_tfind_test "8.16: tfind none" "none" "-1"
+gdb_tfind_test "8.16: tfind line $testline3" \
+       "line $testline3" \
+       "\$trace_line == $testline3" "1"
+
+# 8.17 tfind line <no arg> (# 8.19, 8.20)
+## check $trace_line changed, no error, pc changed, frame changed, tdp changed
+gdb_tfind_test "8.17: tfind none" "none" "-1"
+gdb_tfind_test "8.17: tfind line $testline3" "line $testline3" "\$trace_line == $testline3" "1"
+gdb_tfind_test "8.17: tfind line <no arg>" "line" "\$trace_line != $testline3" "1"
+
+# 8.36 tfind and disassembly
+gdb_tfind_test "8.36: tfind start" "start" "0"
+set timeout 60
+send_gdb "disassemble gdb_c_test\n"
+# look for disassembly of function label
+gdb_expect {
+    -re "<gdb_c_test>:.*$gdb_prompt $"      { pass "8.36: trace disassembly" }
+    -re ".*$gdb_prompt $"                   { fail "8.36: trace disassembly" }
+    timeout                       { fail "8.36: trace disassembly (timeout)" }
+}
+
+gdb_test "tfind line 0" \
+       "out of range.*|failed to find.*" \
+       "8.18: tfind line 0";
+gdb_test "tfind line 32767" \
+       "out of range.*|failed to find.*" \
+       "8.27: tfind line 32767";
+gdb_test "tfind line NoSuChFiLe.c:$baseline" \
+       "No source file named.*" \
+       "8.27: tfind line in bad source file";
+
+# 8.32 tfind invalid subcommand (tfind foo) 
+## check error
+gdb_test "tfind NoSuChOpTiOn 21" \
+       "No symbol.*|\[Ww\]arning.*|\[Ee\]rror.*" \
+       "8.32: tfind with bad subcommand"
+
+# 8.38 test help tfind
+gdb_test "help tfind"       "Select a trace frame.*"      \
+       "8.38: help tfind"
+gdb_test "help tfind pc"    "Select a trace frame by PC.*" \
+       "8.38: help tfind PC"
+gdb_test "help tfind end"   "Synonym for 'none'.*"        \
+       "8.38: help tfind end"
+gdb_test "help tfind none"  "De-select any trace frame.*" \
+       "8.38: help tfind none"
+gdb_test "help tfind line"  "Select a trace frame by source line.*" \
+       "8.38: help tfind line"
+gdb_test "help tfind start" "Select the first trace frame.*" \
+       "8.38: help tfind start"
+gdb_test "help tfind range" "Select a trace frame whose PC is in.*" \
+       "8.38: help tfind range"
+gdb_test "help tfind trace" "Select a trace frame by tracepoint number.*" \
+       "8.38: help tfind tracepoint"
+
+# Finished!
+gdb_tfind_test "8.17: tfind none" "none" "-1"
diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp
new file mode 100644 (file)
index 0000000..2276195
--- /dev/null
@@ -0,0 +1,269 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+# define relative source line numbers:
+# all subsequent line numbers are relative to this first one (baseline)
+set baseline  [gdb_find_recursion_test_baseline $srcfile];
+if { $baseline == -1 } then {
+    fail "Could not find gdb_recursion_test function"
+    return;
+}
+
+set testline1 [expr $baseline + 1]
+set testline2 [expr $baseline + 3]
+
+#
+# test "help tracepoints"
+#
+
+set helpcnt 0;
+send_gdb "help tracepoints\n"
+gdb_expect {
+    -re "Tracing of program execution without stopping the program." {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "actions -- Specify the actions to be taken at a tracepoint" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "collect -- Specify one or more data items to be collected" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "delete tracepoints -- Delete specified tracepoints" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "end -- Ends a list of.*actions" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "info tracepoints -- Status of tracepoints" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "passcount -- Set the passcount for a tracepoint" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "save-tracepoints -- Save current tracepoint definitions" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tdump -- Print everything collected at the current tracepoint" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind -- Select a trace frame" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind end -- Synonym for 'none'" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind line -- Select a trace frame by line number" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind none -- De-select any trace frame and resume 'live' debugging" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind outside -- Select a trace frame whose PC is outside" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind pc -- Select a trace frame by PC" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind range -- Select a trace frame whose PC is in the given" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind start -- Select the first trace frame in the trace buffer" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tfind tracepoint -- Select a trace frame by tracepoint number" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "trace -- Set a tracepoint at a specified line or function or addr" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tstart -- Start trace data collection" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tstatus -- Display the status of the current trace data collection" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "tstop -- Stop trace data collection" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re "while-stepping -- Specify single-stepping behavior at a tracepoint" {
+       incr helpcnt;
+       exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+       if { $helpcnt == 21 } {
+           pass "1.0: help tracepoints"
+       } else {
+           warning "$helpcnt";
+           fail "1.0: help tracepoints"
+       }
+    }
+}
+
+#
+# test trace command:
+#
+
+# 1.1 trace source line
+gdb_delete_tracepoints
+gdb_test "trace $srcfile:$testline2" \
+       "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
+       "1.1a: set tracepoint at sourceline"
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2" \
+       "1.1b: trace sourcefile:line"
+
+# 1.2 trace invalid source line
+gdb_delete_tracepoints
+gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
+       "1.2a: trace invalid line in sourcefile"
+gdb_test "info trace" "No tracepoints.*" \
+       "1.2b: reject invalid line in srcfile"
+
+# 1.3 trace line in invalid source file
+gdb_delete_tracepoints
+gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \
+       "1.3a: trace invalid source file"
+gdb_test "info trace" "No tracepoints.*" \
+       "1.3b: reject invalid srcfile"
+
+# 1.4 trace function by name
+gdb_delete_tracepoints
+gdb_test "trace gdb_recursion_test" \
+       "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
+       "1.4a: trace function by name"
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1" \
+       "1.4b: trace function by name"
+
+# 1.5 trace non-existant function
+gdb_delete_tracepoints
+gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \
+       "1.5a: trace invalid function"
+gdb_test "info trace" "No tracepoints.*" \
+       "1.5b: reject invalid srcfile"
+
+# 1.6 trace at a specific address
+#     Collect the address of "gdb_asm_test", and use that.
+send_gdb "print gdb_asm_test\n"
+gdb_expect {
+    -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
+       set asm_test_addr $expect_out(1,string)
+    }
+    timeout { }
+}
+
+gdb_delete_tracepoints
+gdb_test "trace \*0x$asm_test_addr" \
+       "Tracepoint $decimal at .*$asm_test_addr.*" \
+       "1.6a: trace at specific address"
+gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \
+       "1.6b: verify trace at specific address"
+
+# 1.7 trace at function's exact address
+#     Collect the address of the function for comparison
+send_gdb "print gdb_recursion_test\n"
+gdb_expect {
+    -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
+       set c_test_addr $expect_out(1,string)
+    }
+    timeout { }
+}
+
+gdb_delete_tracepoints
+gdb_test "trace \*gdb_recursion_test" \
+       "Tracepoint $decimal at .*$c_test_addr.*" \
+       "1.7a: trace at function label (before prologue)"
+gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline" \
+       "1.7b: verify trace at specific address"
+
+# 1.8 trace at invalid address
+# no address is invalid
+
+# 1.9 trace no arguments
+gdb_test "trace" "trace command requires an argument" \
+       "1.9: trace <no arguments>"
+
+# 1.10 set large number of tracepoints
+# deferred to limits test module
+
+# 1.11 tracepoint conditions
+# conditions on tracepoints not implemented
+
+# 1.12 set tracepoint in prologue
+# [see tfind.exp]
+
+# 1.13 trace on recursion
+# interesting only in "live" session: see backtrace.exp for live test.
+
+# 1.14 help trace
+gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace"
+
+
diff --git a/gdb/testsuite/gdb.trace/while-dyn.exp b/gdb/testsuite/gdb.trace/while-dyn.exp
new file mode 100644 (file)
index 0000000..1ad5f49
--- /dev/null
@@ -0,0 +1,124 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp"
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    load_lib "emc-support.exp"
+    set testfile "gdb_c_test"
+    set srcfile  $testfile.c
+    set binfile [board_info target d490_binfile];
+    gdb_test "set remotetimeout 6" "" ""
+    set timeout 500
+    gdb_target_monitor "$binfile"
+    # Give a TSTOP and ignore errors, to make sure any previous trace is off
+    gdb_test "tstop" "" ""
+    gdb_test "tfind none"  "" ""
+    send_gdb "compare-section CS\n"
+    gdb_expect {
+       -re "MIS-MATCHED.*$gdb_prompt $" {
+           gdb_suppress_entire_file "Symbol file does not match target!
+           all tests in this module will fail.";
+       }
+       -re ".*$gdb_prompt $" { }
+    }
+} else {
+    set testfile "actions"
+    set srcfile $testfile.c
+    set binfile $objdir/$subdir/$testfile
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+    gdb_load $binfile
+    gdb_test "tstop"       "" ""
+    gdb_test "tfind none"  "" ""
+    runto_main
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# We generously give ourselves one "pass" if we successfully 
+# detect that this test cannot be run on this target!
+if { ![gdb_target_supports_trace] } then {
+    pass "Current target does not supporst trace"
+    return 1;
+
+}
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+#
+# test while-stepping dynamically (live target)
+#
+
+## verify number of trace frames collected matches stepcount
+
+gdb_delete_tracepoints
+gdb_test "trace gdb_c_test" \
+       "Tracepoint $decimal at .*" \
+       "Set tracepoint at gdb_c_test"
+
+gdb_trace_setactions "5.12: define while-stepping <stepcount>" \
+       "" \
+       "collect \$fp" "^$" \
+       "while-stepping 5" "^$" \
+       "collect p" "^$" \
+       "end" "^$" \
+       "end" ""
+
+gdb_test "tstart" "" ""
+
+if [istarget "m68k-*-elf"] then {
+    gdb_emclaptop_command "85,1,2,3,4,5,6"
+    sleep 5
+} else {
+    gdb_test "break end" "" ""
+    gdb_test "continue" \
+           "Continuing.*Breakpoint $decimal, end.*" \
+           "run trace experiment"
+}
+
+gdb_test "tstop" "" ""
+
+gdb_tfind_test "5.12: frame 5 should be the last one collected" "5" "5"
+
+send_gdb "tfind 6\n"
+gdb_expect {
+    -re "failed to find.*$gdb_prompt $" {
+       pass "5.12: trace stopped after 5 stepping frames"
+    }
+    -re ".*$gdb_prompt $" {
+       fail "5.12: trace stopped after 5 stepping frames"
+    }
+}
+
+gdb_test "tfind none" "" ""
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
new file mode 100644 (file)
index 0000000..6b860c0
--- /dev/null
@@ -0,0 +1,116 @@
+#   Copyright (C) 1998 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@cygnus.com)
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+if [istarget "m68k-*-elf"] then {
+    set srcfile gdb_c_test.c
+    set binfile [board_info target d490_binfile];
+} else {
+    set testfile "actions"
+    set srcfile ${testfile}.c
+    set binfile ${objdir}/${subdir}/${testfile}
+    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
+           executable {debug additional_flags="-gdwarf"}] != "" } {
+       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+gdb_reinitialize_dir $srcdir/$subdir
+
+# If testing on a remote host, download the source file.
+remote_download host $srcdir/$subdir/$srcfile
+
+gdb_file_cmd $binfile
+
+#
+# test while-stepping command
+#
+
+gdb_delete_tracepoints
+set trcpt1 [gdb_gettpnum gdb_c_test]
+if { $trcpt1 <= 0 } then {
+    fail "Could not find gdb_c_test function"
+    return;
+}
+
+# 5.12 basic while-stepping command (collect regs)
+
+gdb_test "info tracepoints" \
+       "Num Enb Address    PassC StepC What.*$trcpt1.*0x.*\[\t \]+\[0-9\]+\[\t \]+0\[\t \]+.*in gdb_c_test.*" \
+       "5.12: set a tracepoint, stepcount is zero"
+
+set stepcount 12
+
+gdb_trace_setactions "5.12: set stepcount to $stepcount" \
+       "" \
+       "while-stepping $stepcount" "" \
+       "collect \$regs" "^$" \
+       "end" ""
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*$trcpt1.*0x.*\[\t \]+\[0-9\]+\[\t \]+$stepcount\[\t \]+.*in gdb_c_test.*" \
+       "5.12: confirm stepcount set to $stepcount"
+
+gdb_test "info tracepoints" \
+    "Num Enb Address    PassC StepC What.*
+.*while-stepping $stepcount.*" \
+       "5.12: info trace shows \"while-stepping\""
+
+
+# 5.13 step out of context while collecting local variable
+#      [deferred to dynamic test section]
+
+proc while_stepping_bogus_arg { bogus msgstring } {
+    global gdb_prompt;
+
+    gdb_trace_setactions "$msgstring" \
+           "" \
+           "while-stepping $bogus" "\[Ee\]rror|\[Ww\]arning"
+}
+
+# 5.14 while-stepping (no argument)
+
+while_stepping_bogus_arg "" "5.14: while-stepping null stepcount"
+
+# 5.15 while-stepping (zero stepcount)
+
+while_stepping_bogus_arg "0" "5.15: while-stepping rejects zero stepcount"
+
+# 5.16 while-stepping without collecting anything
+gdb_trace_setactions "5.16: step without collecting anything" \
+       "" \
+       "while-stepping $stepcount" "^$" \
+       "end" ""
+
+gdb_test "info tracepoints" \
+       ".*$trcpt1.*0x.*\[\t \]+\[0-9\]+\[\t \]+$stepcount\[\t \]+.*in gdb_c_test.*\[ \t\]+Actions for tracepoint $trcpt1:.*\[ \t\]+while-stepping $stepcount.*\[ \t\]+end.*\[ \t\]+end.*" \
+       "5.16: confirm actions, step without collecting anything"
+
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
new file mode 100644 (file)
index 0000000..4765791
--- /dev/null
@@ -0,0 +1,307 @@
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+
+#
+# Support procedures for trace testing
+#
+
+
+#
+# Procedure: gdb_target_supports_trace
+# Returns true if GDB is connected to a target that supports tracing.
+# Allows tests to abort early if not running on a trace-aware target.
+#
+
+proc gdb_target_supports_trace { } {
+    global gdb_prompt
+
+    send_gdb "tstatus\n"
+    gdb_expect {
+       -re "\[Tt\]race can only be run on.*$gdb_prompt $" {
+           return 0
+       }
+       -re "\[Tt\]race can not be run on.*$gdb_prompt $" {
+           return 0
+       }
+       -re "\[Tt\]arget does not support.*$gdb_prompt $" {
+           return 0
+       }
+       -re ".*\[Ee\]rror.*$gdb_prompt $" {
+           return 0
+       }
+       -re ".*\[Ww\]arning.*$gdb_prompt $" {
+           return 0
+       }
+       -re ".*$gdb_prompt $" {
+           return 1
+       }
+       timeout {
+           return 0
+       }
+    }
+}
+
+
+#
+# Procedure: gdb_delete_tracepoints
+# Many of the tests depend on setting tracepoints at various places and
+# running until that tracepoint is reached.  At times, we want to start
+# with a clean slate with respect to tracepoints, so this utility proc 
+# lets us do this without duplicating this code everywhere.
+#
+
+proc gdb_delete_tracepoints {} {
+    global gdb_prompt
+
+    send_gdb "delete tracepoints\n"
+    gdb_expect 30 {
+       -re "Delete all tracepoints.*y or n.*$" {
+           send_gdb "y\n";
+           exp_continue
+       }
+       -re ".*$gdb_prompt $" { # This happens if there were no tracepoints }
+       timeout { 
+           perror "Delete all tracepoints in delete_tracepoints (timeout)" 
+           return 
+       }
+    }
+    send_gdb "info tracepoints\n"
+    gdb_expect 30 {
+        -re "No tracepoints.*$gdb_prompt $" {}
+        -re "$gdb_prompt $" { perror "tracepoints not deleted" ; return }
+        timeout { perror "info tracepoints (timeout)" ; return }
+    }
+}
+
+#
+# Procedure: gdb_trace_setactions
+#   Define actions for a tracepoint.
+#   Arguments:
+#      testname   -- identifying string for pass/fail output
+#      tracepoint -- to which tracepoint do these actions apply? (optional)
+#      args       -- list of actions to be defined.
+#   Returns:
+#      zero       -- success
+#      non-zero   -- failure
+
+proc gdb_trace_setactions { testname tracepoint args } {
+    global gdb_prompt;
+
+    set state 0;
+    set passfail "pass";
+    send_gdb "actions $tracepoint\n";
+    set expected_result "";
+    gdb_expect 5 {
+       -re "No tracepoint number .*$gdb_prompt $" {
+           fail $testname
+           return 1;
+       }
+       -re "Enter actions for tracepoint $tracepoint.*>" {
+           if { [llength $args] > 0 } {
+               set lastcommand "[lindex $args $state]";
+               send_gdb "[lindex $args $state]\n";
+               incr state;
+               set expected_result [lindex $args $state];
+               incr state;
+           } else {
+               send_gdb "end\n";
+           }
+           exp_continue;
+       }
+       -re "\(.*\)\[\r\n\]+\[ \t]*> $" {
+           if { $expected_result != "" } {
+               regsub "^\[^\r\n\]+\[\r\n\]+" "$expect_out(1,string)" "" out;
+               if ![regexp $expected_result $out] {
+                   set passfail "fail";
+               }
+               set expected_result "";
+           }
+           if { $state < [llength $args] } {
+               send_gdb "[lindex $args $state]\n";
+               incr state;
+               set expected_result [lindex $args $state];
+               incr state;
+           } else {
+               send_gdb "end\n";
+               set expected_result "";
+           }
+           exp_continue;
+       }
+       -re "\(.*\)$gdb_prompt $" {
+           if { $expected_result != "" } {
+               if ![regexp $expected_result $expect_out(1,string)] {
+                   set passfail "fail";
+               }
+               set expected_result "";
+           }
+           if { [llength $args] < $state } {
+               set passfail "fail";
+           }
+       }
+       default {
+           set passfail "fail";
+       }
+    }
+    if { $testname != "" } {
+       $passfail $testname;
+    }
+    if { $passfail == "pass" } then { 
+       return 0;
+    } else {
+       return 1;
+    }
+}
+
+#
+# Procedure: gdb_tfind_test
+#   Find a specified trace frame.
+#   Arguments: 
+#      testname   -- identifying string for pass/fail output
+#      tfind_arg  -- frame (line, PC, etc.) identifier
+#      exp_res    -- Expected result of frame test
+#      args       -- Test expression
+#   Returns:
+#      zero       -- success
+#      non-zero   -- failure
+#
+
+proc gdb_tfind_test { testname tfind_arg exp_res args } {
+    global gdb_prompt;
+
+    if { "$args" != "" } {
+       set expr "$exp_res";
+       set exp_res "$args";
+    } else {
+       set expr "(int) \$trace_frame";
+    }
+    set passfail "fail";
+
+    gdb_test "tfind $tfind_arg" "" ""
+    send_gdb "printf \"x \%d x\\n\", $expr\n";
+    gdb_expect 10 {
+       -re "x (-*\[0-9\]+) x" {
+           if { $expect_out(1,string) == $exp_res } {
+               set passfail "pass";
+           }
+           exp_continue;
+       }
+       -re "$gdb_prompt $" { }
+    }
+    $passfail "$testname";
+    if { $passfail == "pass" } then { 
+       return 0;
+    } else {
+       return 1;
+    }
+}
+
+#
+# Procedure: gdb_readexpr
+#   Arguments:
+#      gdb_expr    -- the expression whose value is desired
+#   Returns:
+#      the value of gdb_expr, as evaluated by gdb.
+#       [FIXME: returns -1 on error, which is sometimes a legit value]
+#
+
+proc gdb_readexpr { gdb_expr } {
+    global gdb_prompt;
+
+    set result -1;
+    send_gdb "print $gdb_expr\n"
+    gdb_expect 5 {
+       -re "\[$\].*= (\[0-9\]+).*$gdb_prompt $" {
+           set result $expect_out(1,string);
+       }
+       -re "$gdb_prompt $" { }
+       default { }
+    }
+    return $result;
+}
+
+#
+# Procedure: gdb_gettpnum
+#   Arguments:
+#      tracepoint (optional): if supplied, set a tracepoint here.
+#   Returns:
+#      the tracepoint ID of the most recently set tracepoint.
+#
+
+proc gdb_gettpnum { tracepoint } {
+    global gdb_prompt;
+
+    if { $tracepoint != "" } {
+       gdb_test "trace $tracepoint" "" ""
+    }
+    return [gdb_readexpr "\$tpnum"];
+}
+
+
+#
+# Procedure: gdb_find_function_baseline
+#   Arguments:
+#      func_name -- name of source function
+#   Returns:
+#      Sourcefile line of function definition (open curly brace),
+#      or -1 on failure.  Caller must check return value.
+#   Note:
+#      Works only for open curly brace at beginning of source line!
+#
+
+proc gdb_find_function_baseline { func_name } {
+    global gdb_prompt;
+
+    set baseline -1;
+
+    send_gdb "list $func_name\n"
+#    gdb_expect {
+#      -re "\[\r\n\]\[\{\].*$gdb_prompt $" {
+#          set baseline 1
+#        }
+#    }
+}
+
+#
+# Procedure: gdb_find_function_baseline
+#   Arguments:
+#      filename: name of source file of desired function.
+#   Returns:
+#      Sourcefile line of function definition (open curly brace),
+#      or -1 on failure.  Caller must check return value.
+#   Note:
+#      Works only for open curly brace at beginning of source line!
+#
+
+proc gdb_find_recursion_test_baseline { filename } {
+    global gdb_prompt;
+
+    set baseline -1;
+
+    gdb_test "list $filename:1" "" ""
+    send_gdb "search gdb_recursion_test line 0\n"
+    gdb_expect {
+       -re "(\[0-9\]+)\[\t \]+\{.*line 0.*$gdb_prompt $" {
+           set baseline $expect_out(1,string);
+       }
+       -re "$gdb_prompt $" { }
+       default { }
+    }
+    return $baseline;
+}