From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67975 invoked by alias); 16 Sep 2015 16:15:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 67959 invoked by uid 89); 16 Sep 2015 16:15:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 16 Sep 2015 16:15:46 +0000 Received: by wicgb1 with SMTP id gb1so81278112wic.1 for ; Wed, 16 Sep 2015 09:15:43 -0700 (PDT) X-Received: by 10.194.60.115 with SMTP id g19mr52082816wjr.29.1442420143388; Wed, 16 Sep 2015 09:15:43 -0700 (PDT) Received: from E107787-LIN ([195.154.84.196]) by smtp.gmail.com with ESMTPSA id x7sm5251908wia.5.2015.09.16.09.15.42 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 16 Sep 2015 09:15:42 -0700 (PDT) From: Yao Qi To: Wei-cheng Wang 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. References: <1435422102-39438-1-git-send-email-cole945@gmail.com> <1435422102-39438-3-git-send-email-cole945@gmail.com> Date: Wed, 16 Sep 2015 16:15:00 -0000 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") Message-ID: <86lhc61gsz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00381.txt.bz2 Wei-cheng Wang 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 > > * 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 > > * 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. --=20 Yao (=E9=BD=90=E5=B0=A7) =46rom 93f470eba920b53d6bc1d46f855aec4398c1b8b7 Mon Sep 17 00:00:00 2001 From: Wei-cheng Wang 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 * 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 * 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 =20 struct tracepoint_hit_ctx; =20 -typedef enum eval_result_type (*condfn) (struct tracepoint_hit_ctx *, +typedef enum eval_result_type (*condfn) (unsigned char *, ULONGEST *); =20 /* 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 =3D ((condfn) (uintptr_t) (tpoint->compiled_cond)) (ctx, &value); + { + struct fast_tracepoint_ctx *fctx =3D (struct fast_tracepoint_ctx *) = ctx; + err =3D ((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/f= trace.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 {} { } } =20 +# 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 =3D 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\]+ =3D $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 =20 if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] !=3D 0 }= { @@ -186,3 +222,31 @@ if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "I= PA loaded"] !=3D 0 } { } =20 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 >=3D 7" "globvar" { 7 8 9 10 } +test_ftrace_condition "globvar <=3D 4" "globvar" { 1 2 3 4 } +test_ftrace_condition "globvar =3D=3D 5" "globvar" { 5 } +test_ftrace_condition "globvar !=3D 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 =3D=3D 29" "globvar" { 7 } +test_ftrace_condition "(globvar >> 2) =3D=3D 2" "globvar" { 8 9 10 } + +# Test emit_call by accessing trace state variables. +test_ftrace_condition "(\$tsv =3D \$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" !=3D "" } { + test_ftrace_condition "($arg0exp > 500)" "globvar" { 6 7 8 9 10 } +}