This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Patch: Adding tapset and example to make use of perl probe points
- From: Lukas Berk <lberk at redhat dot com>
- To: perl-devel at lists dot fedoraproject dot org
- Cc: systemtap at sources dot redhat dot com
- Date: Tue, 25 Jan 2011 16:55:24 -0500
- Subject: Patch: Adding tapset and example to make use of perl probe points
- Reply-to: Lukas Berk <lberk at redhat dot com>
This patch adds a systemtap tapset and example to be installed with
perl-devel. The benefit of this is being able to make use of the
recently enabled probe points. You are able to probe subroutine
call/return, the file the subroutine was defined in, and line number.
These new files are only installed if the user has the perl-devel
installed. Regular perl-5.12.3 users will not be effected by this change.
This patch was tested on Fedora 14 i386 and x86_64 as well as Fedora
Rawhide i386 and x86_64. No regressions were found. The changes were
tested by first upgrading perl-5.12.3-148 to perl-5.12.3-149 and
checking that no new files were installed. Once this had been ensured,
perl-devel-5.12.3-149 was installed, first checking that the files had
been placed in their correct locations, and subsequently that the tapset
and example both worked as expected.
Lukas Berk
diff --git a/perl-example.stp b/perl-example.stp
new file mode 100644
index 0000000..6a77b20
--- /dev/null
+++ b/perl-example.stp
@@ -0,0 +1,19 @@
+/*
+ Example of the perl systemtap tapset shows a nested view of perl
subroutine
+ calls and returns across the whole system.
+
+ To run:
+ stap perl-example.stp (for all perl processes)
+ For specific perl process:
+ stap perl-example.stp -c COMMAND
+*/
+
+probe perl.sub.call
+{
+ printf("%s => sub: %s, filename: %s, line: %d\n", thread_indent(1),
sub, filename, lineno)
+}
+
+probe perl.sub.return
+{
+ printf("%s <= sub: %s, filename: %s, line: %d\n",
thread_indent(-1), sub, filename, lineno)
+}
diff --git a/perl.spec b/perl.spec
index a3c79af..b95687d 100644
--- a/perl.spec
+++ b/perl.spec
@@ -19,7 +19,7 @@
Name: perl
Version: %{perl_version}
# release number must be even higher, becase dual-lived modules will be
broken otherwise
-Release: 148%{?dist}
+Release: 149%{?dist}
Epoch: %{perl_epoch}
Summary: Practical Extraction and Report Language
Group: Development/Languages
@@ -35,6 +35,11 @@ Source0:
http://www.cpan.org/src/5.0/perl-%{perl_version}.tar.gz
Source2: perl-5.8.0-libnet.cfg
Source3: macros.perl
+#Systemtap tapset and example that make use of systemtap-sdt-devel
+# build requirement. Written by lberk; Not yet upstream.
+Source4: perl.stp
+Source5: perl-example.stp
+
# Removes date check, Fedora/RHEL specific
Patch1: perl-perlbug-tag.patch
@@ -74,6 +79,7 @@ Patch9: perl-5.12.2-h2ph.patch
BuildRoot: %(mktemp -ud
%{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: db4-devel, gdbm-devel, groff, tcsh, zlib-devel,
systemtap-sdt-devel
+%global tapsetdir /usr/share/systemtap/tapset
# For tests
BuildRequires: procps, rsyslog
@@ -914,7 +920,8 @@ tarball from perl.org.
%patch7 -p1
%patch8 -p1
%patch9 -p1
-
+#copy the example script
+cp -a %{SOURCE5} .
#
# Candidates for doc recoding (need case by case review):
@@ -1154,6 +1161,19 @@ for package in Test-Simple; do
done
popd
+# Systemtap tapset install
+mkdir -p %{buildroot}%{tapsetdir}
+%ifarch %{multilib_64_archs}
+%global libperl_stp libperl%{perl_version}-64.stp
+%else
+%global libperl_stp libperl%{perl_version}-32.stp
+%endif
+
+sed \
+ -e "s|LIBRARY_PATH|%{archlib}/CORE/libperl.so|" \
+ %{SOURCE4} \
+ > %{buildroot}%{tapsetdir}/%{libperl_stp}
+
# TODO: Canonicalize test files (rewrite intrerpreter path, fix
permissions)
# XXX: We cannot rewrite ./perl before %%check phase. Otherwise the
test
# would run against system perl at build-time.
@@ -1522,6 +1542,8 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/xsubpp*
%{_mandir}/man1/perlxs*
%attr(0644,root,root) %{_sysconfdir}/rpm/macros.perl
+%{tapsetdir}/%{libperl_stp}
+%doc perl-example.stp
%files tests
%defattr(-,root,root,-)
@@ -1869,6 +1891,10 @@ rm -rf $RPM_BUILD_ROOT
# Old changelog entries are preserved in CVS.
%changelog
+* Tue Jan 25 2011 Lukas Berk <lberk@redhat.com> - 4:5.12.3-149
+- added systemtap tapset to make use of systemtap-sdt-devel
+- added an example systemtap script
+
* Mon Jan 24 2011 Marcela MaÅlÃÅovà <mmaslano@redhat.com> -
4:5.12.3-148
- stable update 5.12.3
- add COMPAT
diff --git a/perl.stp b/perl.stp
new file mode 100755
index 0000000..38122d2
--- /dev/null
+++ b/perl.stp
@@ -0,0 +1,26 @@
+ /*
+ This probe will fire when the perl script enters a subroutine.
+ */
+
+probe perl.sub.call = process("LIBRARY_PATH").mark("sub__entry")
+{
+
+ sub = user_string($arg1)
+ filename = user_string($arg2)
+ lineno = $arg3
+
+}
+
+/*
+ This probe will fire when the return from a subroutine has been
+ hit.
+ */
+
+probe perl.sub.return = process("LIBRARY_PATH").mark("sub__return")
+{
+
+ sub = user_string($arg1)
+ filename = user_string($arg2)
+ lineno = $arg3
+
+}