From: Yao Qi <qiyaoltc@gmail.com>
To: Wei-cheng Wang <cole945@gmail.com>
Cc: uweigand@de.ibm.com, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/5 v4] Fix argument to compiled_cond, and add cases for compiled-condition.
Date: Wed, 16 Sep 2015 16:15:00 -0000 [thread overview]
Message-ID: <86lhc61gsz.fsf@gmail.com> (raw)
In-Reply-To: <1435422102-39438-3-git-send-email-cole945@gmail.com> (Wei-cheng Wang's message of "Sun, 28 Jun 2015 00:21:40 +0800")
Wei-cheng Wang <cole945@gmail.com> writes:
> * Fix generating emit-reg op by passing register buffer to compiled_cond.
> * Add a new function for testing compiled-cond by checking whether
> based on a given CONDEXP, a list of expected values should be collected.
>
> ---
>
> gdb/gdbserver/ChangeLog
>
> 2015-06-27 Wei-cheng Wang <cole945@gmail.com>
>
> * tracepoint.c (eval_result_type): Change prototype.
> (condition_true_at_tracepoint): Fix argument to compiled_cond.
>
> gdb/testsuite/ChangeLog
>
> 2015-06-27 Wei-cheng Wang <cole945@gmail.com>
>
> * gdb.trace/ftrace.exp: (test_ftrace_condition) New function
> for testing bytecode compilation.
It was approved by Pedro, and I test this patch again on x86_64-linux,
no regressions. Wei-cheng Wang has already had copyright assignment. I'll
push this patch in as below.
--
Yao (齐尧)
From 93f470eba920b53d6bc1d46f855aec4398c1b8b7 Mon Sep 17 00:00:00 2001
From: Wei-cheng Wang <cole945@gmail.com>
Date: Wed, 16 Sep 2015 16:20:51 +0100
Subject: [PATCH] Fix argument to compiled_cond, and add cases for
compiled-condition.
This patch fixes the argument passed to compiled_cond. It should be
regs buffer instead of tracepoint_hit_ctx. Test case is added as
well for testing compiled-cond.
gdb/gdbserver/ChangeLog
2015-09-16 Wei-cheng Wang <cole945@gmail.com>
* tracepoint.c (eval_result_type): Change prototype.
(condition_true_at_tracepoint): Fix argument to compiled_cond.
gdb/testsuite/ChangeLog
2015-09-16 Wei-cheng Wang <cole945@gmail.com>
* gdb.trace/ftrace.exp: (test_ftrace_condition) New function
for testing bytecode compilation.
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index fd010ae..5e34eba 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -695,7 +695,7 @@ enum tracepoint_type
struct tracepoint_hit_ctx;
-typedef enum eval_result_type (*condfn) (struct tracepoint_hit_ctx *,
+typedef enum eval_result_type (*condfn) (unsigned char *,
ULONGEST *);
/* The definition of a tracepoint. */
@@ -4907,7 +4907,10 @@ condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
used. */
#ifdef IN_PROCESS_AGENT
if (tpoint->compiled_cond)
- err = ((condfn) (uintptr_t) (tpoint->compiled_cond)) (ctx, &value);
+ {
+ struct fast_tracepoint_ctx *fctx = (struct fast_tracepoint_ctx *) ctx;
+ err = ((condfn) (uintptr_t) (tpoint->compiled_cond)) (fctx->regs, &value);
+ }
else
#endif
{
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index f2d8002..a8eb515 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -178,6 +178,42 @@ proc test_fast_tracepoints {} {
}
}
+# Test compiled-condition
+# CONDEXP is the condition expression to be compiled.
+# VAR is the variable to be collected for testing.
+# LIST is a list of expected values of VAR should be collected
+# based on the CONDEXP.
+proc test_ftrace_condition { condexp var list } \
+{ with_test_prefix "ond $condexp" \
+{
+ global executable
+ global hex
+
+ clean_restart ${executable}
+ if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+ }
+
+ gdb_test "break end" ".*" ""
+ gdb_test "tvariable \$tsv = 0"
+ gdb_test "ftrace set_point if $condexp" "Fast tracepoint .*"
+ gdb_trace_setactions "set action for tracepoint .*" "" \
+ "collect $var" "^$"
+
+ gdb_test_no_output "tstart" ""
+ gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" ""
+ gdb_test_no_output "tstop" ""
+
+ set i 0
+ foreach expval $list {
+ gdb_test "tfind" "Found trace frame $i, tracepoint .*" "tfind frame $i"
+ gdb_test "print $var" "\\$\[0-9\]+ = $expval\[\r\n\]" "expect $expval"
+ set i [expr $i + 1]
+ }
+ gdb_test "tfind" "Target failed to find requested trace frame\."
+}}
+
gdb_reinitialize_dir $srcdir/$subdir
if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } {
@@ -186,3 +222,31 @@ if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } {
}
test_fast_tracepoints
+
+# Test conditional goto and simple expression.
+test_ftrace_condition "globvar > 7" "globvar" { 8 9 10 }
+test_ftrace_condition "globvar < 4" "globvar" { 1 2 3 }
+test_ftrace_condition "globvar >= 7" "globvar" { 7 8 9 10 }
+test_ftrace_condition "globvar <= 4" "globvar" { 1 2 3 4 }
+test_ftrace_condition "globvar == 5" "globvar" { 5 }
+test_ftrace_condition "globvar != 5" "globvar" { 1 2 3 4 6 7 8 9 10 }
+test_ftrace_condition "globvar > 3 && globvar < 7" "globvar" { 4 5 6 }
+test_ftrace_condition "globvar < 3 || globvar > 7" "globvar" { 1 2 8 9 10 }
+test_ftrace_condition "(globvar << 2) + 1 == 29" "globvar" { 7 }
+test_ftrace_condition "(globvar >> 2) == 2" "globvar" { 8 9 10 }
+
+# Test emit_call by accessing trace state variables.
+test_ftrace_condition "(\$tsv = \$tsv + 2) > 10" "globvar" { 6 7 8 9 10 }
+
+# This expression is used for testing emit_reg.
+if [is_amd64_regs_target] {
+ set arg0exp "\$rdi"
+} elseif [is_x86_like_target] {
+ set arg0exp "*(int *) (\$ebp + 8)"
+} else {
+ set arg0exp ""
+}
+
+if { "$arg0exp" != "" } {
+ test_ftrace_condition "($arg0exp > 500)" "globvar" { 6 7 8 9 10 }
+}
next prev parent reply other threads:[~2015-09-16 16:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-27 16:21 [PATCH 1/5 v4] Remove tracepoint_action ops Wei-cheng Wang
2015-06-27 16:22 ` [PATCH 5/5 v4] Allow target to decide where to map jump-pad Wei-cheng Wang
2015-07-03 16:38 ` Ulrich Weigand
2015-06-27 16:22 ` [PATCH 3/5 v4] Fix argument to compiled_cond, and add cases for compiled-condition Wei-cheng Wang
2015-06-30 9:57 ` Pedro Alves
2015-09-14 14:04 ` Pierre Langlois
2015-09-16 16:15 ` Yao Qi [this message]
2015-06-27 16:22 ` [PATCH 2/5 v4] powerpc: Support z-point type in gdbserver Wei-cheng Wang
2015-07-03 15:17 ` Ulrich Weigand
2016-02-24 12:05 ` Marcin Kościelnicki
2016-02-24 17:37 ` Ulrich Weigand
2016-02-24 17:39 ` Marcin Kościelnicki
2015-06-27 16:22 ` [PATCH 4/5 v4] Tracepoint for ppc64 Wei-cheng Wang
2015-06-28 6:21 ` Wei-cheng Wang
2015-06-29 15:54 ` Pierre Langlois
2015-07-03 16:37 ` Ulrich Weigand
2015-06-30 9:57 ` [PATCH 1/5 v4] Remove tracepoint_action ops Pedro Alves
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=86lhc61gsz.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=cole945@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).