Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>,
	Tom Tromey <tromey@redhat.com>
Subject: [PATCH] Add CTF support to GDB [5] Add test for CTF function
Date: Mon, 14 Jan 2013 03:49:00 -0000	[thread overview]
Message-ID: <CANFwon2=EmBWtGqx5ygrmMNt0MBM0oLbjOZ2VMsx5+S9TErP7w@mail.gmail.com> (raw)

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

Hi,

According to the comments from Tom.  I make a patch to add test for
CTF function.
This test will test both "tsave -ctf" and "target ctf" function.  You
can use following command call it:
make check RUNTESTFLAGS="--target_board=native-gdbserver ctf.exp"

Thanks,
Hui

2013-01-14  Hui Zhu  <hui_zhu@mentor.com>

	* gdb.trace/Makefile.in (PROGS): Add ctf.
	* gdb.trace/ctf.c: New file.
	* gdb.trace/ctf.exp: New file.

[-- Attachment #2: ctf-test.txt --]
[-- Type: text/plain, Size: 3617 bytes --]

--- a/testsuite/gdb.trace/Makefile.in
+++ b/testsuite/gdb.trace/Makefile.in
@@ -5,7 +5,7 @@ srcdir = @srcdir@
 
 PROGS = ax backtrace deltrace disconnected-tracing infotrace packetlen \
 	passc-dyn passcount report save-trace tfile tfind tracecmd tsv \
-	unavailable while-dyn while-stepping
+	unavailable while-dyn while-stepping ctf
 
 all info install-info dvi install uninstall installcheck check:
 	@echo "Nothing to be done for $@..."
--- /dev/null
+++ b/testsuite/gdb.trace/ctf.c
@@ -0,0 +1,33 @@
+typedef char test_t1;
+typedef test_t1 test_t2;
+typedef test_t2 test_t3;
+
+void
+end (void)
+{}
+
+int
+main ()
+{
+  int i;
+  int a = 0;
+  test_t3 b = 1;
+  test_t3 c[][4] = {"123", "456", "789", "123", "456", "789"};
+  struct
+    {
+      int a;
+      int b;
+    } d[2][2] = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
+
+  for (i = 0; i < 10; i++)
+    {
+      ++a;
+      ++b;
+      ++c[0][1];
+      ++d[0][1].a;
+    }
+
+  end ();
+
+  return 0;
+}
--- /dev/null
+++ b/testsuite/gdb.trace/ctf.exp
@@ -0,0 +1,91 @@
+#   Copyright 2013 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 3 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, see <http://www.gnu.org/licenses/>.
+
+load_lib "trace-support.exp";
+
+standard_testfile
+set executable $testfile
+set expfile $testfile.exp
+set ctfdir $testfile.ctf
+
+if [prepare_for_testing $expfile $executable $srcfile \
+        {debug nowarnings}] {
+    untested "failed to prepare for trace tests"
+    return -1
+}
+
+if ![runto_main] {
+    fail "can't run to main to check for trace support"
+    return -1
+}
+
+if ![gdb_target_supports_trace] {
+    unsupported "target does not support trace"
+    return -1;
+}
+
+
+#Test "tsave -ctf"
+
+gdb_test "trace 24" "Tracepoint \[0-9\]+ at .*"
+gdb_trace_setactions "set action for line 24" "" \
+	"collect \$local" "^$"
+gdb_test "trace 25" "Tracepoint \[0-9\]+ at .*"
+gdb_trace_setactions "set action for line 25" "" \
+	"collect \$reg" "^$"
+
+gdb_test_no_output "tstart"
+
+gdb_test "break end" "Breakpoint ${decimal} at .*"
+gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
+gdb_test_no_output "tstop"
+
+gdb_test "tsave -ctf $ctfdir" "Trace data saved to directory \'$ctfdir\'."
+
+set ret [exec whereis babeltrace]
+if { [string compare "babeltrace:" $ret] == 0 } then {
+    unsupported "babeltrace check ctf directory"
+} else {
+    set ret [catch {exec babeltrace $ctfdir} results]
+    if { $ret != 0 } then {
+	fail "babeltrace open ctf directory"
+	return -1
+    }
+}
+
+
+#Test "target ctf"
+
+gdb_test_no_output "set confirm off"
+gdb_test_no_output "target ctf $ctfdir"
+
+gdb_test "tfind 0" ".*Found trace frame 0.*"
+gdb_test "tdump" ".*b = 1.*a = 0.*i = 0.*"
+gdb_test "print \$b" ".* = 1.*"
+gdb_test "print \$a" ".* = 0.*"
+gdb_test "print \$i" ".* = 0.*"
+
+gdb_test "tfind 1" ".*Found trace frame 1.*"
+
+gdb_test "tfind 2" ".*Found trace frame 2.*"
+gdb_test "tdump" ".*b = 2.*a = 1.*i = 1.*"
+gdb_test "print \$b" ".* = 2.*"
+gdb_test "print \$a" ".* = 1.*"
+gdb_test "print \$i" ".* = 1.*"
+
+
+#Clean
+
+exec rm -rf $ctfdir

             reply	other threads:[~2013-01-14  3:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14  3:49 Hui Zhu [this message]
2013-01-14 12:44 ` Yao Qi
2013-01-15 11:19   ` Hui Zhu
2013-01-15 13:49     ` Yao Qi
2013-01-16  7:39       ` Hui Zhu
2013-01-16  9:52         ` Yao Qi
2013-01-18  1:23           ` Hui Zhu
2013-01-18  2:07             ` Yao Qi
2013-01-18 15:28             ` Tom Tromey
2013-01-25 11:10               ` Hui Zhu
2013-02-11 12:55                 ` Hui Zhu
2013-02-18 10:39                 ` Yao Qi
2013-02-19  6:57                   ` Hui Zhu
2013-01-14 13:30 ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANFwon2=EmBWtGqx5ygrmMNt0MBM0oLbjOZ2VMsx5+S9TErP7w@mail.gmail.com' \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox