From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28623 invoked by alias); 8 Oct 2014 19:30:13 -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 28614 invoked by uid 89); 8 Oct 2014 19:30:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,LIKELY_SPAM_BODY,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 08 Oct 2014 19:30:11 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s98JP9VY011518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 8 Oct 2014 15:25:09 -0400 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s98JP6B0017759 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Wed, 8 Oct 2014 15:25:08 -0400 From: Sergio Durigan Junior To: "Jose E. Marchesi" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 7/9] Simple testsuite for DTrace USDT probes. References: <1411724905-31234-1-git-send-email-jose.marchesi@oracle.com> <1411724905-31234-8-git-send-email-jose.marchesi@oracle.com> X-URL: http://blog.sergiodj.net Date: Wed, 08 Oct 2014 19:30:00 -0000 In-Reply-To: <1411724905-31234-8-git-send-email-jose.marchesi@oracle.com> (Jose E. Marchesi's message of "Fri, 26 Sep 2014 11:48:23 +0200") Message-ID: <878ukqbbzh.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00170.txt.bz2 On Friday, September 26 2014, Jose E. Marchesi wrote: > This patch adds some simple tests testing the support for DTrace USDT > probes. The testsuite will be skipped as unsupported in case the user > does not have DTrace installed on her system. The tests included in > the test suite test breakpointing on DTrace probes, enabling and > disabling probes, printing of probe arguments of several types and > also breakpointing on several probes with the same name. Thanks. As you know, I had some issues trying to test this on my machine, since I don't have access to dtrace from Oracle. Just one nitpick below. > gdb/testsuite: > > 2014-09-26 Jose E. Marchesi > > * gdb.base/dtrace-probe.exp: New file. > (dtrace_build_test_program): New function. > (dtrace_test): Likewise. > > * gdb.base/dtrace-probe.d: New file. > (test): New DTrace provider with two probes: `progress-counter' > and `two-locations'. > > * gdb.base/dtrace-probe.c: New file. > (main): New function. > --- > gdb/testsuite/ChangeLog | 13 +++ > gdb/testsuite/gdb.base/dtrace-probe.c | 38 ++++++++ > gdb/testsuite/gdb.base/dtrace-probe.d | 21 +++++ > gdb/testsuite/gdb.base/dtrace-probe.exp | 156 +++++++++++++++++++++++++++++++ > 4 files changed, 228 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/dtrace-probe.c > create mode 100644 gdb/testsuite/gdb.base/dtrace-probe.d > create mode 100644 gdb/testsuite/gdb.base/dtrace-probe.exp > > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index c93d7cf..5e3f472 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,5 +1,18 @@ > 2014-09-26 Jose E. Marchesi > > + * gdb.base/dtrace-probe.exp: New file. > + (dtrace_build_test_program): New function. > + (dtrace_test): Likewise. > + > + * gdb.base/dtrace-probe.d: New file. > + (test): New DTrace provider with two probes: `progress-counter' > + and `two-locations'. > + > + * gdb.base/dtrace-probe.c: New file. > + (main): New function. > + > +2014-09-26 Jose E. Marchesi > + > * gdb.base/stap-probe.exp (stap_test): Remove "SystemTap" from > expected message when trying to access $_probe_* convenience > variables while not on a probe. > diff --git a/gdb/testsuite/gdb.base/dtrace-probe.c b/gdb/testsuite/gdb.base/dtrace-probe.c > new file mode 100644 > index 0000000..45a77c5 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/dtrace-probe.c > @@ -0,0 +1,38 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2014 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 . */ > + > +#include "dtrace-probe.h" > + > +int > +main () > +{ > + char *name = "application"; > + > + TEST_TWO_LOCATIONS (); > + > + int i = 0; > + while (i < 10) > + { > + i++; > + if (TEST_PROGRESS_COUNTER_ENABLED ()) > + TEST_PROGRESS_COUNTER (name, i); > + } > + > + TEST_TWO_LOCATIONS (); > + > + return 0; /* last break here */ > +} > diff --git a/gdb/testsuite/gdb.base/dtrace-probe.d b/gdb/testsuite/gdb.base/dtrace-probe.d > new file mode 100644 > index 0000000..df8e6bb > --- /dev/null > +++ b/gdb/testsuite/gdb.base/dtrace-probe.d > @@ -0,0 +1,21 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2014 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 . */ > + > +provider test { > + probe progress__counter (char *name, int); > + probe two__locations (); > +}; > diff --git a/gdb/testsuite/gdb.base/dtrace-probe.exp b/gdb/testsuite/gdb.base/dtrace-probe.exp > new file mode 100644 > index 0000000..55af85d > --- /dev/null > +++ b/gdb/testsuite/gdb.base/dtrace-probe.exp > @@ -0,0 +1,156 @@ > +# Copyright (C) 2014 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 . > + > +standard_testfile > + > +# Generate the test program with DTrace USDT probes. > +# This returns -1 on failure to build, 0 otherwise > +proc dtrace_build_test_program {} { > + global testfile hex srcdir subdir srcfile binfile > + > + # Make sure that dtrace is installed, it is the real one (not the > + # script installed by SystemTap, for example) and of the right > + # version (>= 0.4.0). > + > + set dtrace "dtrace" > + > + set result [catch "exec $dtrace -V" output] > + if {$result != 0 || ![regexp {^dtrace: Sun D [0-9]\.[0-9]\.[0-9]$} $output]} { > + untested dtrace-probe.exp > + return -1 > + } > + > + # Generate the demo program, which contains USDT probes. This > + # involves running the `dtrace' program in order to generate some > + # auxiliary files: a header file and an object file with the ELF > + # sections containing the probes information. > + > + set dscript_file "${srcdir}/${subdir}/${testfile}.d" > + set out_header_file "${srcdir}/${subdir}/${testfile}.h" > + set result \ > + [catch "exec $dtrace -h -s $dscript_file -o $out_header_file" output] > + verbose -log $output > + if {$result != 0} { > + fail "invoke dtrace -h to generate the header file for USDT probes" > + return -1 > + } > + > + standard_testfile .c This is unecessary, I believe. You already called standard_testfile above. > + > + if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != ""} { > + fail "compile ${binfile}.o" > + return -1 > + } > + > + set result \ > + [catch "exec $dtrace -G -s $dscript_file ${binfile}.o -o ${binfile}-p.o" output] > + verbose -log $output > + if {$result != 0} { > + fail "invoke dtrace -G to generate the object file with probe information" > + return -1 > + } > + > + if {[gdb_compile "${binfile}.o ${binfile}-p.o" ${binfile} executable {debug}] != ""} { > + fail "compile ${binfile}" > + return -1 > + } > +} > + > +# Run the tests. > +# This returns -1 on failure to compile or start, 0 otherwise. > +proc dtrace_test {} { > + global testfile hex srcfile binfile > + > + if {[dtrace_build_test_program] == -1} { > + return -1 > + } > + > + clean_restart ${binfile} > + > + if ![runto_main] { > + return -1 > + } > + > + gdb_test "print \$_probe_argc" "No probe at PC $hex" \ > + "check argument not at probe point" > + > + # Test the 'info probes' command. > + gdb_test "info probes dtrace" \ > + "test *progress-counter *$hex +no.*test *two-locations *$hex +always.*test *two-locations *$hex +always.*" \ > + "info probes dtrace" > + > + # Disabling the probe test:two-locations shall have no effect, > + # since no is-enabled probes are defined for it in the object > + # file. > + > + gdb_test "disable probe test two-locations" \ > + "Probe test:two-locations cannot be disabled.*" \ > + "disable probe test two-locations" > + > + # On the other hand, the probe test:progress-counter can be > + # enabled and then disabled again. > + > + gdb_test "enable probe test progress-counter" \ > + "Probe test:progress-counter enabled.*" \ > + "enable probe test progress-counter" > + > + gdb_test "disable probe test progress-counter" \ > + "Probe test:progress-counter disabled.*" \ > + "disable probe test progress-counter" > + > + # Since test:progress-counter is disabled we can run to the second > + # instance of the test:two-locations probe. > + > + if {![runto "-probe-dtrace test:two-locations"]} { > + fail "run to the first test:two-locations probe point" > + } > + gdb_test "continue" \ > + "Breakpoint \[0-9\]+, main \\(\\) at.*TEST_TWO_LOCATIONS.*" \ > + "run to the second test:two-locations probe point" > + > + # Go back to the breakpoint on main() and enable the > + # test:progress-counter probe. Set a breakpoint on it and see > + # that it gets reached. > + > + if ![runto_main] { > + return -1 > + } > + > + gdb_test "enable probe test progress-counter" \ > + "Probe test:progress-counter enabled.*" \ > + "enable probe test progress-counter" > + > + gdb_test "break -probe-dtrace test:progress-counter" \ > + ".*Breakpoint \[0-9\]+ .*" "set breakpoint in test:progress-counter" > + gdb_continue_to_breakpoint "test:progress-counter" > + > + # Test probe arguments. > + gdb_test "print \$_probe_argc" " = 2" \ > + "print \$_probe_argc for probe progress-counter" > + gdb_test "print \$_probe_arg0" \ > + " = $hex \"application\"" \ > + "print \$_probe_arg0 for probe progress-counter" > + gdb_test "print \$_probe_arg1" " = 1" \ > + "print \$_probe_arg1 for probe progress-counter" > + > + # Set a breakpoint with multiple probe locations. > + gdb_test "break -pdtrace test:two-locations" \ > + "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ > + "set multii-location probe breakpoint (probe two-locations)" > + > + return 0 > +} > + > +dtrace_test > -- > 1.7.10.4 Other than that, the testcase looks good to me. -- Sergio GPG key ID: 0x65FC5E36 Please send encrypted e-mail if possible http://sergiodj.net/