public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] systemtap.spec
@ 2009-01-12 21:33 Stan Cox
  2009-01-12 22:04 ` Masami Hiramatsu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Stan Cox @ 2009-01-12 21:33 UTC (permalink / raw)
  To: systemtap

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

This adds a subpackage 'static-user' that installs /usr/include/sdt.h
and /usr/bin/dtrace which enables postgres to build with stap support,
assuming that it is built with -g.   Subpackage name suggestions or
other comments?





[-- Attachment #2: specfile.patch --]
[-- Type: text/x-patch, Size: 3367 bytes --]

* Makefile.am (oldincludedir): New.
  (oldinclude_HEADERS): New.
  (bin_SCRIPTS): Add dtrace
* dtrace: New file.
* systemtap.spec: Add package static-user.


RENAMED runtime/sduprobes.h TO runtime/sdt.h

diff --git a/Makefile.am b/Makefile.am
index 38a2eda..4ad842f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@
 AUTOMAKE_OPTIONS = no-dist
 
 pkglibexecdir = ${libexecdir}/${PACKAGE}
+oldincludedir = ${includedir}/sys
 
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DPKGDATADIR='"${pkgdatadir}"' -DPKGLIBDIR='"$(pkglibexecdir)"'
 
@@ -15,6 +16,7 @@ man_MANS =  stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/st
 
 bin_PROGRAMS = stap staprun
 bin_SCRIPTS = stap-report
+oldinclude_HEADERS = runtime/sdt.h
 if BUILD_SERVER
 man_MANS += stap-server.8 
 bin_PROGRAMS += stap-client-connect stap-server-connect
@@ -22,6 +24,7 @@ bin_SCRIPTS += stap-client stap-serverd stap-server stap-find-servers \
 	       stap-start-server stap-find-or-start-server stap-stop-server \
 	       stap-gen-server-cert stap-add-server-cert
 endif
+bin_SCRIPTS += dtrace
 stap_SOURCES = main.cxx \
 	parse.cxx staptree.cxx elaborate.cxx translate.cxx \
 	tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \
diff --git a/dtrace b/dtrace
new file mode 100755
index 0000000..b8a1237
--- /dev/null
+++ b/dtrace
@@ -0,0 +1,35 @@
+# This is a stub to handle a Makefile which does:
+# $(DTRACE) $(DTRACEFLAGS) -G -s $^ -o $@
+# which is a step that builds DTrace provider and probe definitions
+
+usage() {
+echo "Usage $0 -s file.d {-o file} file1.o file2.o ..."
+}
+
+if [ -z "$1" ] ; then
+   usage
+   exit
+fi
+while test ! -z "$1" ; do
+   if [ $(expr "$1" : "-o") -gt 0 ] ; then 
+      shift
+      filename=$1
+   elif [ $(expr "$1" : "-s") -gt 0 ] ; then
+      shift
+      s_filename=$1      
+   fi
+   shift
+done
+
+if [ -z "$filename" ] ; then
+   if [ ! -z "$s_filename" ] ; then
+      filename=$(basename $s_filename .d).o
+   else
+      usage
+      exit
+   fi
+fi
+
+echo "_dtrace_ () {}" >| /tmp/$$.c 
+gcc -c /tmp/$$.c -o $filename
+rm /tmp/$$.c
diff --git a/systemtap.spec b/systemtap.spec
index b7dc6b6..26616f4 100644
--- a/systemtap.spec
+++ b/systemtap.spec
@@ -102,6 +102,16 @@ SystemTap server is the server component of an instrumentation
 system for systems running Linux 2.6.  Developers can write
 instrumentation to collect data on the operation of the system.
 
+%package static-user
+Summary: Static probe support tools
+Group: Development/System
+License: GPLv2+
+URL: http://sourceware.org/systemtap/
+Requires: systemtap
+
+%description static-user
+Support tools to allow applications to use static probes.
+
 %prep
 %setup -q %{?setup_elfutils}
 
@@ -257,6 +267,11 @@ exit 0
 %{_bindir}/stap-server-connect
 %{_mandir}/man8/stap-server.8*
 
+%files static-user
+%defattr(-,root,root)
+%{_bindir}/dtrace
+%{_includedir}/sys/sdt.h
+
 %changelog
 * Thu Nov 13 2008 Frank Ch. Eigler <fche@redhat.com> - 0.8-1
 - Upstream release.
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index 354256d..34bd33a 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -9,7 +9,7 @@ set fp [open $sup_srcpath "w"]
 puts $fp "
 #include <stdlib.h>
 #define USE_STAP_PROBE 1
-#include \"sduprobes.h\"
+#include \"sdt.h\"
 
 foo ()
 {

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] systemtap.spec
  2009-01-12 21:33 [PATCH] systemtap.spec Stan Cox
@ 2009-01-12 22:04 ` Masami Hiramatsu
  2009-01-12 22:12   ` Roland McGrath
  2009-01-12 22:40 ` William Cohen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Masami Hiramatsu @ 2009-01-12 22:04 UTC (permalink / raw)
  To: Stan Cox; +Cc: systemtap

Hi,

Stan Cox wrote:
> This adds a subpackage 'static-user' that installs /usr/include/sdt.h
> and /usr/bin/dtrace which enables postgres to build with stap support,
> assuming that it is built with -g.   Subpackage name suggestions or
> other comments?

What about systemtap-sdt and systemtap-sdt-devel?
IMHO, header files (and *.a libs) should be separated in -devel package.


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] systemtap.spec
  2009-01-12 22:04 ` Masami Hiramatsu
@ 2009-01-12 22:12   ` Roland McGrath
  0 siblings, 0 replies; 8+ messages in thread
From: Roland McGrath @ 2009-01-12 22:12 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Stan Cox, systemtap

> Stan Cox wrote:
> > This adds a subpackage 'static-user' that installs /usr/include/sdt.h
> > and /usr/bin/dtrace which enables postgres to build with stap support,
> > assuming that it is built with -g.   Subpackage name suggestions or
> > other comments?
> 
> What about systemtap-sdt and systemtap-sdt-devel?
> IMHO, header files (and *.a libs) should be separated in -devel package.

The build-time script that goes with the headers being in the same package
seems fine to me, since it's a script.  For biarch to be happy, you usually
want the common parts (headers and here, the script) to be in a -headers
package and only the machine-specific nonoverlapping files in -devel
(which requires -headers = %{version}-%{release}).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] systemtap.spec
  2009-01-12 21:33 [PATCH] systemtap.spec Stan Cox
  2009-01-12 22:04 ` Masami Hiramatsu
@ 2009-01-12 22:40 ` William Cohen
  2009-01-14  5:01 ` Probing user-space markers in RPM installed binaries William Cohen
  2009-01-15  7:40 ` [PATCH] systemtap.spec Stan Cox
  3 siblings, 0 replies; 8+ messages in thread
From: William Cohen @ 2009-01-12 22:40 UTC (permalink / raw)
  To: Stan Cox; +Cc: systemtap

Stan Cox wrote:
> This adds a subpackage 'static-user' that installs /usr/include/sdt.h
> and /usr/bin/dtrace which enables postgres to build with stap support,
> assuming that it is built with -g.   Subpackage name suggestions or
> other comments?

Hi Stan,

Looking through the patch shouldn't there be a sdt.h file in the patch?
I don't see the sdt.h file in the upstream git or in the patch.

static in the rpm name might be confused with rpms that include .a files. Maybe
user-markers-devel, which is getting a bit long.

-Will

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Probing user-space markers in RPM installed binaries
  2009-01-12 21:33 [PATCH] systemtap.spec Stan Cox
  2009-01-12 22:04 ` Masami Hiramatsu
  2009-01-12 22:40 ` William Cohen
@ 2009-01-14  5:01 ` William Cohen
  2009-01-14  7:46   ` Roland McGrath
  2009-01-15  7:40 ` [PATCH] systemtap.spec Stan Cox
  3 siblings, 1 reply; 8+ messages in thread
From: William Cohen @ 2009-01-14  5:01 UTC (permalink / raw)
  To: Stan Cox; +Cc: systemtap




I did an experiment this evening to see if can get user-space probing
to work with executables in RPMs. Summary: I was able to get things to
work on Fedora 10 machine with the 2.6.27.9-159.fc10.x86_64 kernel and
postgresql-8.3.5-1.fc10 on an x86_64 machine with only minor tweaks to
the postgresql spec file.

Downloaded the latest git version of systemtap that included Stan's
checkins with sdt.h and dtrace. Did the usual configure in a build
directory and then created a tarball with:

make dist-gzip

Copied the systemtap-0.8.tar.gz into the rpm SOURCES directory and
copied the systemtap.spec into the rpm SPEC directory.  Built the rpms with:

rpmbuild -ba systemtap.spec

With the recent Stan's recent checkin the rpmbuild will generate
systemtap-sdt-devel rpm. Install systemtap-sdt-devel and the other
systemtap rpms on the machine. The systemtap-sdt-devel rpm will be
needed when building the other RPMs with userspace markers.

The changes for the postgresql spec file were very modest:

--- postgresql.spec	2008-11-02 13:23:29.000000000 -0500
+++ postgresql.spec.new	2009-01-13 23:15:07.000000000 -0500
@@ -75,6 +75,7 @@
  %{!?pam:%define pam 1}
  %{!?pgfts:%define pgfts 1}
  %{!?runselftest:%define runselftest 1}
+%{!?sdt:%define sdt 1}

  # Python major version.
  %{!?python_sitearch: %define python_sitearch %(%{__python} -c "from 
distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
@@ -157,6 +158,10 @@
  BuildRequires: pam-devel
  %endif

+%if %sdt
+BuildRequires: systemtap-sdt-devel
+%endif
+
  # main package requires -libs subpackage
  Requires: postgresql-libs = %{version}-%{release}

@@ -439,6 +444,9 @@
  %if %pgfts
  	--enable-thread-safety \
  %endif
+%if %sdt
+	--enable-dtrace \
+%endif
  	--with-system-tzdata=/usr/share/zoneinfo \
  	--sysconfdir=/etc/sysconfig/pgsql \
  	--datadir=/usr/share/pgsql \


The postgresql RPM are built now can be built with userspace markers
with the following line:

rpmbuild -ba postgresql.spec --define 'sdt 1'

Install the resulting binary rpms. Access to the arguments of the
markers REQUIRES the postgressql-debuginfo RPM to be installed.

The example from the wiki page
(http://sourceware.org/systemtap/wiki/UsingStaticUserMarkers) needs to
be tweaked because the binaries is installed in /usr/bin/postgresql:


probe process("/usr/bin/postgres").mark("transaction__start")
{
   printf("%s %#x\n", "transaction__start", $arg1);
}
probe process("/usr/bin/postgres").mark("transaction__commit")
{
   printf("%s %#x\n", "transaction__commit", $arg1);
}
probe process("/usr/bin/postgres").mark("transaction__abort")
{
   printf("%s %#x\n", "transaction__abort", $arg1);
}
probe process("/usr/bin/postgres").mark("lock__startwait")
{
   printf("%s %#x %#x\n", "lock__startwait", $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lock__endwait")
{
   printf("%s %#x %#x\n", "lock__endwait", $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lwlock__endwait")
{
   printf("%s %#x %#x\n", "lwlock__endwait", $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lwlock__acquire")
{
   printf("%s %#x %#x\n", "lwlock__acquire", $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lwlock__condacquire__fail")
{
   printf("%s %#x %#x\n", "lwlock__condacquire__fail",
          $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lwlock__condacquire")
{
   printf("%s %#x %#x\n", "lwlock__condacquire", $arg1, $arg2);
}
probe process("/usr/bin/postgres").mark("lwlock__release")
{
   printf("%s %#x\n", "lwlock__release", $arg1);
}


Inialize the postgresql database:

/usr/bin/initdb -D /tmp/data


Then run the little experiment with:

PGDATA=/tmp/data stap -c '/usr/bin/postgres' postgres.stp

Get the following output (hit control-c to stop):

lwlock__release 0x0
lwlock__acquire 0x20 0x0
lwlock__release 0x20
lwlock__acquire 0x79 0x0
lwlock__release 0x79
lwlock__acquire 0x7a 0x1
lwlock__release 0x7a
lwlock__acquire 0x7a 0x1
lwlock__release 0x7a
lwlock__acquire 0x7a 0x1
lwlock__release 0x7a
lwlock__acquire 0x7a 0x1
lwlock__release 0x7a
lwlock__acquire 0x3 0x0
lwlock__release 0x3
lwlock__acquire 0x23 0x1

-Will

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Probing user-space markers in RPM installed binaries
  2009-01-14  5:01 ` Probing user-space markers in RPM installed binaries William Cohen
@ 2009-01-14  7:46   ` Roland McGrath
  2009-01-14 19:16     ` William Cohen
  0 siblings, 1 reply; 8+ messages in thread
From: Roland McGrath @ 2009-01-14  7:46 UTC (permalink / raw)
  To: William Cohen; +Cc: Stan Cox, systemtap

> make dist-gzip
> 
> Copied the systemtap-0.8.tar.gz into the rpm SOURCES directory and
> copied the systemtap.spec into the rpm SPEC directory.  Built the rpms with:
> 
> rpmbuild -ba systemtap.spec

You can do: rpmbuild -ta systemtap*.tar.gz
(when the tarfile contains systemtap.sec)

> The changes for the postgresql spec file were very modest:

Nice.

> +%{!?sdt:%define sdt 1}

You can use _with_sdt in place of sdt here ...

> rpmbuild -ba postgresql.spec --define 'sdt 1'

... then it's --with-sdt instead of --define.

> Install the resulting binary rpms. Access to the arguments of the


Thanks,
Roland

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Probing user-space markers in RPM installed binaries
  2009-01-14  7:46   ` Roland McGrath
@ 2009-01-14 19:16     ` William Cohen
  0 siblings, 0 replies; 8+ messages in thread
From: William Cohen @ 2009-01-14 19:16 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Stan Cox, systemtap

Roland McGrath wrote:
>> make dist-gzip
>>
>> Copied the systemtap-0.8.tar.gz into the rpm SOURCES directory and
>> copied the systemtap.spec into the rpm SPEC directory.  Built the rpms with:
>>
>> rpmbuild -ba systemtap.spec
> 
> You can do: rpmbuild -ta systemtap*.tar.gz
> (when the tarfile contains systemtap.sec)

Hi Roland,

Thanks for the "rpmbuild -ta" shortcut. Past workflow for fedora and rhel 
maintainence programmed me to use "rpmbuld -ba"

> 
>> The changes for the postgresql spec file were very modest:
> 
> Nice.
> 
>> +%{!?sdt:%define sdt 1}
> 
> You can use _with_sdt in place of sdt here ...
> 
>> rpmbuild -ba postgresql.spec --define 'sdt 1'
> 
> ... then it's --with-sdt instead of --define.

Yes, the --with-sdt would be a bit cleaner. I was just aping other options 
already in the postgresql. The xorg-X11-server.spec has --with-* approach.

Thanks for the comments, Roland.

-Will
> 
>> Install the resulting binary rpms. Access to the arguments of the
> 
> 
> Thanks,
> Roland

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] systemtap.spec
  2009-01-12 21:33 [PATCH] systemtap.spec Stan Cox
                   ` (2 preceding siblings ...)
  2009-01-14  5:01 ` Probing user-space markers in RPM installed binaries William Cohen
@ 2009-01-15  7:40 ` Stan Cox
  3 siblings, 0 replies; 8+ messages in thread
From: Stan Cox @ 2009-01-15  7:40 UTC (permalink / raw)
  To: systemtap

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

This adds a subpackage 'static-user' that installs /usr/include/sdt.h
and /usr/bin/dtrace which enables postgres to build with stap support,
assuming that it is built with -g.   Subpackage name suggestions or
other comments?





[-- Attachment #2: specfile.patch --]
[-- Type: text/x-patch, Size: 3367 bytes --]

* Makefile.am (oldincludedir): New.
  (oldinclude_HEADERS): New.
  (bin_SCRIPTS): Add dtrace
* dtrace: New file.
* systemtap.spec: Add package static-user.


RENAMED runtime/sduprobes.h TO runtime/sdt.h

diff --git a/Makefile.am b/Makefile.am
index 38a2eda..4ad842f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@
 AUTOMAKE_OPTIONS = no-dist
 
 pkglibexecdir = ${libexecdir}/${PACKAGE}
+oldincludedir = ${includedir}/sys
 
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DPKGDATADIR='"${pkgdatadir}"' -DPKGLIBDIR='"$(pkglibexecdir)"'
 
@@ -15,6 +16,7 @@ man_MANS =  stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/st
 
 bin_PROGRAMS = stap staprun
 bin_SCRIPTS = stap-report
+oldinclude_HEADERS = runtime/sdt.h
 if BUILD_SERVER
 man_MANS += stap-server.8 
 bin_PROGRAMS += stap-client-connect stap-server-connect
@@ -22,6 +24,7 @@ bin_SCRIPTS += stap-client stap-serverd stap-server stap-find-servers \
 	       stap-start-server stap-find-or-start-server stap-stop-server \
 	       stap-gen-server-cert stap-add-server-cert
 endif
+bin_SCRIPTS += dtrace
 stap_SOURCES = main.cxx \
 	parse.cxx staptree.cxx elaborate.cxx translate.cxx \
 	tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \
diff --git a/dtrace b/dtrace
new file mode 100755
index 0000000..b8a1237
--- /dev/null
+++ b/dtrace
@@ -0,0 +1,35 @@
+# This is a stub to handle a Makefile which does:
+# $(DTRACE) $(DTRACEFLAGS) -G -s $^ -o $@
+# which is a step that builds DTrace provider and probe definitions
+
+usage() {
+echo "Usage $0 -s file.d {-o file} file1.o file2.o ..."
+}
+
+if [ -z "$1" ] ; then
+   usage
+   exit
+fi
+while test ! -z "$1" ; do
+   if [ $(expr "$1" : "-o") -gt 0 ] ; then 
+      shift
+      filename=$1
+   elif [ $(expr "$1" : "-s") -gt 0 ] ; then
+      shift
+      s_filename=$1      
+   fi
+   shift
+done
+
+if [ -z "$filename" ] ; then
+   if [ ! -z "$s_filename" ] ; then
+      filename=$(basename $s_filename .d).o
+   else
+      usage
+      exit
+   fi
+fi
+
+echo "_dtrace_ () {}" >| /tmp/$$.c 
+gcc -c /tmp/$$.c -o $filename
+rm /tmp/$$.c
diff --git a/systemtap.spec b/systemtap.spec
index b7dc6b6..26616f4 100644
--- a/systemtap.spec
+++ b/systemtap.spec
@@ -102,6 +102,16 @@ SystemTap server is the server component of an instrumentation
 system for systems running Linux 2.6.  Developers can write
 instrumentation to collect data on the operation of the system.
 
+%package static-user
+Summary: Static probe support tools
+Group: Development/System
+License: GPLv2+
+URL: http://sourceware.org/systemtap/
+Requires: systemtap
+
+%description static-user
+Support tools to allow applications to use static probes.
+
 %prep
 %setup -q %{?setup_elfutils}
 
@@ -257,6 +267,11 @@ exit 0
 %{_bindir}/stap-server-connect
 %{_mandir}/man8/stap-server.8*
 
+%files static-user
+%defattr(-,root,root)
+%{_bindir}/dtrace
+%{_includedir}/sys/sdt.h
+
 %changelog
 * Thu Nov 13 2008 Frank Ch. Eigler <fche@redhat.com> - 0.8-1
 - Upstream release.
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index 354256d..34bd33a 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -9,7 +9,7 @@ set fp [open $sup_srcpath "w"]
 puts $fp "
 #include <stdlib.h>
 #define USE_STAP_PROBE 1
-#include \"sduprobes.h\"
+#include \"sdt.h\"
 
 foo ()
 {

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-14 22:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-12 21:33 [PATCH] systemtap.spec Stan Cox
2009-01-12 22:04 ` Masami Hiramatsu
2009-01-12 22:12   ` Roland McGrath
2009-01-12 22:40 ` William Cohen
2009-01-14  5:01 ` Probing user-space markers in RPM installed binaries William Cohen
2009-01-14  7:46   ` Roland McGrath
2009-01-14 19:16     ` William Cohen
2009-01-15  7:40 ` [PATCH] systemtap.spec Stan Cox

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).