This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, roland/systemtap, created. glibc-2.13-32-gcb06f34
- From: roland at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 21 Feb 2011 23:19:35 -0000
- Subject: GNU C Library master sources branch, roland/systemtap, created. glibc-2.13-32-gcb06f34
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, roland/systemtap has been created
at cb06f34d252fca76b9de618860787b40653c84b7 (commit)
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=cb06f34d252fca76b9de618860787b40653c84b7
commit cb06f34d252fca76b9de618860787b40653c84b7
Author: Rayson Ho <rho@redhat.com>
Date: Wed Feb 16 12:46:14 2011 -0800
Add systemtap static probe points in generic and x86_64 pthread code.
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index da1aac7..337b26b 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,31 @@
+2011-02-09 Rayson Ho <rho@redhat.com>
+
+ * DESIGN-systemtap-probes.txt: New file.
+ * pthread_cond_broadcast.c: SystemTap probes.
+ * pthread_cond_init.c: Likewise.
+ * pthread_cond_signal.c: Likewise.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_cond_destroy.c: Likewise.
+ * pthread_create.c: Likewise.
+ * pthread_join.c: Likewise.
+ * pthread_mutex_destroy.c: Likewise.
+ * pthread_mutex_init.c: Likewise.
+ * pthread_mutex_lock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * pthread_rwlock_destroy.c: Likewise.
+ * pthread_rwlock_rdlock.c: Likewise.
+ * pthread_rwlock_unlock.c: Likewise.
+ * pthread_rwlock_wrlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+
2010-07-23 Roland McGrath <roland@redhat.com>
* pthread_create.c (start_thread): Define pthread_start LIBC_PROBE.
diff --git a/nptl/DESIGN-systemtap-probes.txt b/nptl/DESIGN-systemtap-probes.txt
new file mode 100644
index 0000000..16d7c45
--- /dev/null
+++ b/nptl/DESIGN-systemtap-probes.txt
@@ -0,0 +1,89 @@
+Systemtap is a dynamic tracing/instrumenting tool available on Linux. Probes
+that are not fired at run time have close to zero overhead.
+
+The following probes are available for NPTL:
+
+Thread creation & Join Probes
+=============================
+pthread_create - probe for pthread_create
+ arg1 = pointer (pthread_t*) to thread
+ arg2 = pointer (pthread_attr_t*) to attr
+ arg3 = pointer (void *) to start_routine
+ arg4 = arguments to start_routine
+pthread_start - probe for actual thread creation
+ arg1 = struct pthread (members include thread ID, process ID)
+ arg2 = address of start_routine
+ arg3 = pointer to the list of arguments
+pthread_join - probe for pthread_join
+ arg1 = thread ID
+pthread_join_ret - probe for pthread_join return
+ arg1 = thread ID
+ arg2 = return value
+
+Lock-related Probes
+===================
+mutex_init - probe for pthread_mutex_init
+ arg1 = address of mutex lock
+mutex_acquired - probe for succ. return of pthread_mutex_lock
+ arg1 = address of mutex lock
+mutex_timedlock_acquired - probe for succ. return of pthread_mutex_timedlock
+ arg1 = address of mutex lock
+mutex_entry - probe for entry to the pthread_mutex_lock function
+ arg1 = address of mutex lock
+mutex_timedlock_entry - probe for entry to the pthread_mutex_timedlock function
+ arg1 = address of mutex lock, arg2 = address of timespec
+mutex_release - probe for pthread_mutex_unlock after the successful release of a
+ mutex lock
+ arg1 = address of mutex lock
+mutex_destroy - probe for pthread_mutex_destroy
+ arg1 = address of mutex lock
+
+wrlock_entry - probe for entry to the pthread_rwlock_wrlock function
+ arg1 = address of rw lock
+rdlock_entry - probe for entry to the pthread_rwlock_rdlock function
+ arg1 = address of rw lock
+
+rwlock_destroy - probe for pthread_rwlock_destroy
+ arg1 = address of rw lock
+wrlock_acquire_write - probe for pthread_rwlock_wrlock (after getting the lock)
+ arg1 = address of rw lock
+rdlock_acquire_read - probe for pthread_rwlock_rdlock after successfully getting
+ the lock
+ arg1 = address of rw lock
+rwlock_unlock - probe for pthread_rwlock_unlock
+ arg1 = address of rw lock
+
+lll_lock_wait - probe in low-level (assembly language) locking code, only fired
+ when futex/FUTEX_WAIT is called (i.e. when trying to acquire a
+ contented lock)
+ arg1 = pointer to futex
+ arg2 = flags passed to the futex system call
+lll_lock_wait_private - probe in low-level (assembly language) locking code,
+ only fired when futex/FUTEX_WAIT is called (i.e. when
+ trying to acquire a contented lock)
+ arg1 = pointer to futex
+
+lll_futex_wake - probe in low-level (assembly language) locking code, only fired
+ when futex (FUTEX_WAKE) is called
+ arg1 = pointer to futex
+ arg2 = number of processes to wake
+ arg3 = additional flags
+
+Condition variable Probes
+=========================
+cond_init - probe for pthread_cond_init
+ arg1 = condition
+ arg2 = attr
+cond_destroy - probe for pthread_cond_destroy
+ arg1 = cond
+cond_wait - probe for pthread_cond_wait
+ arg1 = condition
+ arg2 = mutex lock
+cond_timedwait - probe for pthread_cond_timedwait
+ arg1 = condition
+ arg2 = mutex lock
+ arg3 = timespec
+cond_signal - probe for pthread_cond_signal
+ arg1 = condition
+cond_broadcast - probe for pthread_cond_broadcast
+ arg1 = condition
diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c
index 22523c2..a2e462f 100644
--- a/nptl/pthread_cond_broadcast.c
+++ b/nptl/pthread_cond_broadcast.c
@@ -23,6 +23,7 @@
#include <lowlevellock.h>
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
#include <shlib-compat.h>
#include <kernel-features.h>
@@ -32,6 +33,8 @@ int
__pthread_cond_broadcast (cond)
pthread_cond_t *cond;
{
+ LIBC_PROBE (cond_broadcast, 1, cond);
+
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
/* Make sure we are alone. */
diff --git a/nptl/pthread_cond_destroy.c b/nptl/pthread_cond_destroy.c
index 35135a6..a28d061 100644
--- a/nptl/pthread_cond_destroy.c
+++ b/nptl/pthread_cond_destroy.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <shlib-compat.h>
#include "pthreadP.h"
+#include <stap-probe.h>
int
@@ -29,6 +30,8 @@ __pthread_cond_destroy (cond)
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
+ LIBC_PROBE (cond_destroy, 1, cond);
+
/* Make sure we are alone. */
lll_lock (cond->__data.__lock, pshared);
diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c
index 65c01b1..caec6ca 100644
--- a/nptl/pthread_cond_init.c
+++ b/nptl/pthread_cond_init.c
@@ -20,6 +20,7 @@
#include <shlib-compat.h>
#include "pthreadP.h"
+#include <stap-probe.h>
int
@@ -42,6 +43,8 @@ __pthread_cond_init (cond, cond_attr)
? NULL : (void *) ~0l);
cond->__data.__broadcast_seq = 0;
+ LIBC_PROBE (cond_init, 2, cond, cond_attr);
+
return 0;
}
versioned_symbol (libpthread, __pthread_cond_init,
diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c
index 023bbb5..414e6bc 100644
--- a/nptl/pthread_cond_signal.c
+++ b/nptl/pthread_cond_signal.c
@@ -26,6 +26,7 @@
#include <shlib-compat.h>
#include <kernel-features.h>
+#include <stap-probe.h>
int
@@ -35,6 +36,8 @@ __pthread_cond_signal (cond)
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
+ LIBC_PROBE (cond_signal, 1, cond);
+
/* Make sure we are alone. */
lll_lock (cond->__data.__lock, pshared);
diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
index 467a03a..3d4c583 100644
--- a/nptl/pthread_cond_wait.c
+++ b/nptl/pthread_cond_wait.c
@@ -25,6 +25,7 @@
#include <pthreadP.h>
#include <shlib-compat.h>
+#include <stap-probe.h>
struct _condvar_cleanup_buffer
@@ -101,6 +102,8 @@ __pthread_cond_wait (cond, mutex)
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
+ LIBC_PROBE (cond_wait, 2, cond, mutex);
+
/* Make sure we are alone. */
lll_lock (cond->__data.__lock, pshared);
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 4075dd9..d3f5f06 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -556,6 +556,8 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
/* Pass the descriptor to the caller. */
*newthread = (pthread_t) pd;
+ LIBC_PROBE (pthread_create, 4, newthread, attr, start_routine, arg);
+
/* Start the thread. */
return create_thread (pd, iattr, STACK_VARIABLES_ARGS);
}
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 6a87a8b..609e2cf 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -23,6 +23,8 @@
#include <atomic.h>
#include "pthreadP.h"
+#include <stap-probe.h>
+
static void
cleanup (void *arg)
@@ -55,6 +57,8 @@ pthread_join (threadid, thread_return)
struct pthread *self = THREAD_SELF;
int result = 0;
+ LIBC_PROBE (pthread_join, 1, threadid);
+
/* During the wait we change to asynchronous cancellation. If we
are canceled the thread we are waiting for must be marked as
un-wait-ed for again. */
@@ -110,5 +114,7 @@ pthread_join (threadid, thread_return)
__free_tcb (pd);
}
+ LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd->result);
+
return result;
}
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index e2c9f8a..45c80b8 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -20,11 +20,15 @@
#include <errno.h>
#include "pthreadP.h"
+#include <stap-probe.h>
+
int
__pthread_mutex_destroy (mutex)
pthread_mutex_t *mutex;
{
+ LIBC_PROBE (mutex_destroy, 1, mutex);
+
if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
&& mutex->__data.__nusers != 0)
return EBUSY;
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index d9b1ef0..a025a38 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -24,6 +24,8 @@
#include <kernel-features.h>
#include "pthreadP.h"
+#include <stap-probe.h>
+
static const struct pthread_mutexattr default_attr =
{
/* Default is a normal mutex, not shared between processes. */
@@ -135,6 +137,8 @@ __pthread_mutex_init (mutex, mutexattr)
// mutex->__spins = 0; already done by memset
// mutex->__next = NULL; already done by memset
+ LIBC_PROBE (mutex_init, 1, mutex);
+
return 0;
}
strong_alias (__pthread_mutex_init, pthread_mutex_init)
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 50dc188..2054680 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -24,6 +24,7 @@
#include <not-cancel.h>
#include "pthreadP.h"
#include <lowlevellock.h>
+#include <stap-probe.h>
#ifndef LLL_MUTEX_LOCK
@@ -48,6 +49,9 @@ __pthread_mutex_lock (mutex)
assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
unsigned int type = PTHREAD_MUTEX_TYPE (mutex);
+
+ LIBC_PROBE (mutex_entry, 1, mutex);
+
if (__builtin_expect (type & ~PTHREAD_MUTEX_KIND_MASK_NP, 0))
return __pthread_mutex_lock_full (mutex);
@@ -127,6 +131,8 @@ __pthread_mutex_lock (mutex)
++mutex->__data.__nusers;
#endif
+ LIBC_PROBE (mutex_acquired, 1, mutex);
+
return 0;
}
@@ -467,6 +473,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
++mutex->__data.__nusers;
#endif
+ LIBC_PROBE (mutex_acquired, 1, mutex);
+
return 0;
}
#ifndef __pthread_mutex_lock
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 8d0db79..55d1802 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -24,6 +24,8 @@
#include <lowlevellock.h>
#include <not-cancel.h>
+#include <stap-probe.h>
+
int
pthread_mutex_timedlock (mutex, abstime)
@@ -34,6 +36,8 @@ pthread_mutex_timedlock (mutex, abstime)
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
int result = 0;
+ LIBC_PROBE (mutex_timedlock_entry, 2, mutex, abstime);
+
/* We must not check ABSTIME here. If the thread does not block
abstime must not be checked for a valid value. */
@@ -172,6 +176,8 @@ pthread_mutex_timedlock (mutex, abstime)
++mutex->__data.__count;
+ LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
return 0;
}
}
@@ -242,6 +248,8 @@ pthread_mutex_timedlock (mutex, abstime)
++mutex->__data.__count;
+ LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
return 0;
}
}
@@ -377,6 +385,8 @@ pthread_mutex_timedlock (mutex, abstime)
++mutex->__data.__count;
+ LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
+
return 0;
}
}
@@ -477,6 +487,8 @@ pthread_mutex_timedlock (mutex, abstime)
/* Record the ownership. */
mutex->__data.__owner = id;
++mutex->__data.__nusers;
+
+ LIBC_PROBE (mutex_timedlock_acquired, 1, mutex);
}
out:
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index f9fe10b..479e500 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "pthreadP.h"
#include <lowlevellock.h>
+#include <stap-probe.h>
static int
internal_function
@@ -50,6 +51,9 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
/* Unlock. */
lll_unlock (mutex->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex));
+
+ LIBC_PROBE (mutex_release, 1, mutex);
+
return 0;
}
else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
@@ -272,6 +276,9 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
PTHREAD_MUTEX_PSHARED (mutex));
int oldprio = newval >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ LIBC_PROBE (mutex_release, 1, mutex);
+
return __pthread_tpp_change_priority (oldprio, -1);
default:
@@ -279,6 +286,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
return EINVAL;
}
+ LIBC_PROBE (mutex_release, 1, mutex);
return 0;
}
diff --git a/nptl/pthread_rwlock_destroy.c b/nptl/pthread_rwlock_destroy.c
index 28fd24b..84aa693 100644
--- a/nptl/pthread_rwlock_destroy.c
+++ b/nptl/pthread_rwlock_destroy.c
@@ -18,12 +18,15 @@
02111-1307 USA. */
#include "pthreadP.h"
+#include <stap-probe.h>
int
__pthread_rwlock_destroy (rwlock)
pthread_rwlock_t *rwlock;
{
+ LIBC_PROBE (rwlock_destroy, 1, rwlock);
+
/* Nothing to be done. For now. */
return 0;
}
diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c
index 2feac57..09bad14 100644
--- a/nptl/pthread_rwlock_rdlock.c
+++ b/nptl/pthread_rwlock_rdlock.c
@@ -22,6 +22,7 @@
#include <lowlevellock.h>
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
/* Acquire read lock for RWLOCK. */
@@ -31,6 +32,8 @@ __pthread_rwlock_rdlock (rwlock)
{
int result = 0;
+ LIBC_PROBE (rdlock_entry, 1, rwlock);
+
/* Make sure we are alone. */
lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
@@ -49,6 +52,8 @@ __pthread_rwlock_rdlock (rwlock)
--rwlock->__data.__nr_readers;
result = EAGAIN;
}
+ else
+ LIBC_PROBE (rdlock_acquire_read, 1, rwlock);
break;
}
diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c
index a7ef71a..a6e8d87 100644
--- a/nptl/pthread_rwlock_unlock.c
+++ b/nptl/pthread_rwlock_unlock.c
@@ -22,11 +22,14 @@
#include <lowlevellock.h>
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
/* Unlock RWLOCK. */
int
__pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
{
+ LIBC_PROBE (rwlock_unlock, 1, rwlock);
+
lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
if (rwlock->__data.__writer)
rwlock->__data.__writer = 0;
diff --git a/nptl/pthread_rwlock_wrlock.c b/nptl/pthread_rwlock_wrlock.c
index 9d5f135..c099852 100644
--- a/nptl/pthread_rwlock_wrlock.c
+++ b/nptl/pthread_rwlock_wrlock.c
@@ -22,6 +22,7 @@
#include <lowlevellock.h>
#include <pthread.h>
#include <pthreadP.h>
+#include <stap-probe.h>
/* Acquire write lock for RWLOCK. */
@@ -31,6 +32,8 @@ __pthread_rwlock_wrlock (rwlock)
{
int result = 0;
+ LIBC_PROBE (wrlock_entry, 1, rwlock);
+
/* Make sure we are alone. */
lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
@@ -41,6 +44,8 @@ __pthread_rwlock_wrlock (rwlock)
{
/* Mark self as writer. */
rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+
+ LIBC_PROBE (wrlock_acquire_write, 1, rwlock);
break;
}
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index 3195db2..ea132f5 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -22,6 +22,8 @@
#include <kernel-features.h>
#include <lowlevellock.h>
+#include <stap-probe.h>
+
.text
#ifdef __ASSUME_PRIVATE_FUTEX
@@ -91,7 +93,8 @@ __lll_lock_wait_private:
cmpl %edx, %eax /* NB: %edx == 2 */
jne 2f
-1: movl $SYS_futex, %eax
+1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
+ movl $SYS_futex, %eax
syscall
2: movl %edx, %eax
@@ -130,7 +133,8 @@ __lll_lock_wait:
cmpl %edx, %eax /* NB: %edx == 2 */
jne 2f
-1: movl $SYS_futex, %eax
+1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
+ movl $SYS_futex, %eax
syscall
2: movl %edx, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index 9b15bfb..da7b019 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -20,6 +20,8 @@
#ifndef _LOWLEVELLOCK_H
#define _LOWLEVELLOCK_H 1
+#include <stap-probe.h>
+
#ifndef __ASSEMBLER__
# include <time.h>
# include <sys/param.h>
@@ -227,6 +229,7 @@ LLL_STUB_UNWIND_INFO_END
do { \
int __ignore; \
register __typeof (nr) _nr __asm ("edx") = (nr); \
+ LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
__asm __volatile ("syscall" \
: "=a" (__ignore) \
: "0" (SYS_futex), "D" (futex), \
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
index 224a560..6037449 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
@@ -25,7 +25,7 @@
#include <kernel-features.h>
#include <pthread-pi-defines.h>
#include <pthread-errnos.h>
-
+#include <stap-probe.h>
.text
@@ -35,6 +35,8 @@
.align 16
__pthread_cond_broadcast:
+ LIBC_PROBE (cond_broadcast, 1, %rdi)
+
/* Get internal lock. */
movl $1, %esi
xorl %eax, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
index d1d83a8..80a61a4 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
@@ -24,6 +24,7 @@
#include <pthread-pi-defines.h>
#include <kernel-features.h>
#include <pthread-errnos.h>
+#include <stap-probe.h>
.text
@@ -34,6 +35,8 @@
.align 16
__pthread_cond_signal:
+ LIBC_PROBE (cond_signal, 1, %rdi)
+
/* Get internal lock. */
movq %rdi, %r8
movl $1, %esi
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
index e6535fb..5b4eea7 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -23,6 +23,7 @@
#include <lowlevelcond.h>
#include <pthread-pi-defines.h>
#include <pthread-errnos.h>
+#include <stap-probe.h>
#include <kernel-features.h>
@@ -71,6 +72,8 @@ __pthread_cond_timedwait:
cfi_adjust_cfa_offset(FRAME_SIZE)
cfi_remember_state
+ LIBC_PROBE (cond_timedwait, 3, %rdi, %rsi, %rdx)
+
cmpq $1000000000, 8(%rdx)
movl $EINVAL, %eax
jae 48f
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
index f5b929e..68cd8ac 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
@@ -23,6 +23,7 @@
#include <lowlevelcond.h>
#include <tcb-offsets.h>
#include <pthread-pi-defines.h>
+#include <stap-probe.h>
#include <kernel-features.h>
@@ -65,6 +66,8 @@ __pthread_cond_wait:
+--------------------------+
*/
+ LIBC_PROBE (cond_wait, 2, %rdi, %rsi)
+
cmpq $-1, dep_mutex(%rdi)
/* Prepare structure passed to cancellation handler. */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
index 35eb09c..1e794a9 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
@@ -22,7 +22,7 @@
#include <lowlevelrwlock.h>
#include <pthread-errnos.h>
#include <kernel-features.h>
-
+#include <stap-probe.h>
.text
@@ -31,6 +31,9 @@
.align 16
__pthread_rwlock_rdlock:
cfi_startproc
+
+ LIBC_PROBE (rdlock_entry, 1, %rdi)
+
xorq %r10, %r10
/* Get the lock. */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
index be6b8d8..9cc1197 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
@@ -22,7 +22,7 @@
#include <lowlevelrwlock.h>
#include <pthread-errnos.h>
#include <kernel-features.h>
-
+#include <stap-probe.h>
.text
@@ -31,6 +31,9 @@
.align 16
__pthread_rwlock_wrlock:
cfi_startproc
+
+ LIBC_PROBE (wrlock_entry, 1, %rdi)
+
xorq %r10, %r10
/* Get the lock. */
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6dc872b25c67b0c25cdb7dc22dbe0a24e0928b8c
commit 6dc872b25c67b0c25cdb7dc22dbe0a24e0928b8c
Author: Roland McGrath <roland@redhat.com>
Date: Wed Feb 9 19:51:46 2011 -0800
Add systemtap static probe points in setjmp/longjmp on x86.
diff --git a/ChangeLog b/ChangeLog
index 915100a..b76477c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-02-09 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/__longjmp.S: Add a static probe here.
+ * sysdeps/x86_64/setjmp.S: Likewise.
+ * sysdeps/i386/bsd-setjmp.S: Likewise.
+ * sysdeps/i386/bsd-_setjmp.S: Likewise.
+ * sysdeps/i386/setjmp.S: Likewise.
+ * sysdeps/i386/__longjmp.S: Likewise.
+
2011-02-08 Roland McGrath <roland@redhat.com>
* include/stap-probe.h: New file.
diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S
index 5ff7a73..6630217 100644
--- a/sysdeps/i386/__longjmp.S
+++ b/sysdeps/i386/__longjmp.S
@@ -1,5 +1,5 @@
/* longjmp for i386.
- Copyright (C) 1995-1998,2000,2002,2005,2006,2009
+ Copyright (C) 1995-1998,2000,2002,2005,2006,2009,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -21,6 +21,7 @@
#include <sysdep.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
+#include <stap-probe.h>
.text
ENTRY (__longjmp)
@@ -33,6 +34,7 @@ ENTRY (__longjmp)
movl (JB_SP*4)(%eax), %ecx
PTR_DEMANGLE (%edx)
PTR_DEMANGLE (%ecx)
+ LIBC_PROBE (longjmp, 3, 4@%eax, -4@8(%esp), 4@%edx)
cfi_def_cfa(%eax, 0)
cfi_register(%eip, %edx)
cfi_register(%esp, %ecx)
@@ -50,6 +52,7 @@ ENTRY (__longjmp)
cfi_restore(%edi)
cfi_restore(%ebp)
+ LIBC_PROBE (longjmp_target, 3, 4@%eax, -4@8(%esp), 4@%edx)
movl 8(%esp), %eax /* Second argument is return value. */
movl %ecx, %esp
#else
@@ -57,12 +60,14 @@ ENTRY (__longjmp)
movl 8(%esp), %eax /* Second argument is return value. */
/* Save the return address now. */
movl (JB_PC*4)(%ecx), %edx
+ LIBC_PROBE (longjmp, 3, 4@%ecx, -4@%eax, 4@%edx)
/* Restore registers. */
movl (JB_BX*4)(%ecx), %ebx
movl (JB_SI*4)(%ecx), %esi
movl (JB_DI*4)(%ecx), %edi
movl (JB_BP*4)(%ecx), %ebp
movl (JB_SP*4)(%ecx), %esp
+ LIBC_PROBE (longjmp_target, 3, 4@%ecx, -4@%ecx, 4@%edx)
#endif
/* Jump to saved PC. */
jmp *%edx
diff --git a/sysdeps/i386/bsd-_setjmp.S b/sysdeps/i386/bsd-_setjmp.S
index ee329ee..9de5a08 100644
--- a/sysdeps/i386/bsd-_setjmp.S
+++ b/sysdeps/i386/bsd-_setjmp.S
@@ -1,5 +1,6 @@
/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. i386 version.
- Copyright (C) 1994-1997,2000-2002,2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1994-1997,2000-2002,2005,2006,2011
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,6 +26,7 @@
#include <jmpbuf-offsets.h>
#include "bp-sym.h"
#include "bp-asm.h"
+#include <stap-probe.h>
#define PARMS LINKAGE /* no space for saved regs */
#define JMPBUF PARMS
@@ -47,6 +49,7 @@ ENTRY (BP_SYM (_setjmp))
#endif
movl %ecx, (JB_SP*4)(%edx)
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
+ LIBC_PROBE (setjmp, 3, 4@%edx, -4@$0, 4@%ecx)
#ifdef PTR_MANGLE
PTR_MANGLE (%ecx)
#endif
diff --git a/sysdeps/i386/bsd-setjmp.S b/sysdeps/i386/bsd-setjmp.S
index c9af0e1..c7804d0 100644
--- a/sysdeps/i386/bsd-setjmp.S
+++ b/sysdeps/i386/bsd-setjmp.S
@@ -1,5 +1,6 @@
/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. i386 version.
- Copyright (C) 1994-1997,2000,2001,2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1994-1997,2000,2001,2005,2006,2011
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,6 +26,7 @@
#include <jmpbuf-offsets.h>
#include "bp-sym.h"
#include "bp-asm.h"
+#include <stap-probe.h>
#define PARMS LINKAGE /* no space for saved regs */
#define JMPBUF PARMS
@@ -49,6 +51,7 @@ ENTRY (BP_SYM (setjmp))
#endif
movl %ecx, (JB_SP*4)(%eax)
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
+ LIBC_PROBE (setjmp, 3, 4@%eax, -4@$1, 4@%ecx)
#ifdef PTR_MANGLE
PTR_MANGLE (%ecx)
#endif
diff --git a/sysdeps/i386/setjmp.S b/sysdeps/i386/setjmp.S
index 56c3994..2b5fab9 100644
--- a/sysdeps/i386/setjmp.S
+++ b/sysdeps/i386/setjmp.S
@@ -1,5 +1,5 @@
/* setjmp for i386.
- Copyright (C) 1995,1996,1997,2000,2001,2005,2006
+ Copyright (C) 1995,1996,1997,2000,2001,2005,2006,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -23,6 +23,7 @@
#include <asm-syntax.h>
#include "bp-sym.h"
#include "bp-asm.h"
+#include <stap-probe.h>
#define PARMS LINKAGE /* no space for saved regs */
#define JMPBUF PARMS
@@ -44,6 +45,7 @@ ENTRY (BP_SYM (__sigsetjmp))
#endif
movl %ecx, (JB_SP*4)(%eax)
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
+ LIBC_PROBE (setjmp, 3, 4@%eax, -4@SIGMSK(%esp), 4@%ecx)
#ifdef PTR_MANGLE
PTR_MANGLE (%ecx)
#endif
diff --git a/sysdeps/x86_64/__longjmp.S b/sysdeps/x86_64/__longjmp.S
index b045c04..38b801e 100644
--- a/sysdeps/x86_64/__longjmp.S
+++ b/sysdeps/x86_64/__longjmp.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
+/* Copyright (C) 2001,2004,2005,2006,2009,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@
#include <sysdep.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
+#include <stap-probe.h>
/* Jump to the position specified by ENV, causing the
setjmp call there to return VAL, or 1 if VAL is 0.
@@ -34,6 +35,7 @@ ENTRY(__longjmp)
PTR_DEMANGLE (%r9)
PTR_DEMANGLE (%rdx)
#endif
+ LIBC_PROBE (longjmp, 3, 8@%rdi, -4@%esi, 8@%rdx)
/* We add unwind information for the target here. */
cfi_def_cfa(%rdi, 0)
cfi_register(%rsp,%r8)
@@ -53,5 +55,6 @@ ENTRY(__longjmp)
mov %esi, %eax
movq %r8,%rsp
movq %r9,%rbp
+ LIBC_PROBE (longjmp_target, 3, 8@%rdi, -4@%eax, 8@%rdx)
jmpq *%rdx
END (__longjmp)
diff --git a/sysdeps/x86_64/setjmp.S b/sysdeps/x86_64/setjmp.S
index a66b0e6..58d5b17 100644
--- a/sysdeps/x86_64/setjmp.S
+++ b/sysdeps/x86_64/setjmp.S
@@ -1,5 +1,5 @@
/* setjmp for x86-64.
- Copyright (C) 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001,2003,2005,2006,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,7 @@
#include <sysdep.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
+#include <stap-probe.h>
ENTRY (__sigsetjmp)
/* Save registers. */
@@ -41,6 +42,7 @@ ENTRY (__sigsetjmp)
#endif
movq %rdx, (JB_RSP*8)(%rdi)
movq (%rsp), %rax /* Save PC we are returning to now. */
+ LIBC_PROBE (setjmp, 3, 8@%rdi, -4@%esi, 8@%rax)
#ifdef PTR_MANGLE
PTR_MANGLE (%rax)
#endif
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=481292e0c24d1647b50f8e30469240068bfcfbbe
commit 481292e0c24d1647b50f8e30469240068bfcfbbe
Author: Roland McGrath <roland@redhat.com>
Date: Fri Jul 23 02:32:50 2010 -0700
Add --enable-systemtap configuration to define static probe points.
diff --git a/ChangeLog b/ChangeLog
index 7d05dbe..915100a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-08 Roland McGrath <roland@redhat.com>
+
+ * include/stap-probe.h: New file.
+ * configure.in: Handle --enable-systemtap.
+ * configure: Regenerated.
+ * config.h.in (USE_STAP_PROBE): New #undef.
+ * extra-lib.mk (CPPFLAGS-$(lib)): Add -DIN_LIB=$(lib).
+ * elf/Makefile (CPPFLAGS-.os): Add -DIN_LIB=rtld.
+ * elf/rtld-Rules (rtld-CPPFLAGS): Likewise.
+
2011-01-27 Petr Baudis <pasky@suse.cz>
Ulrich Drepper <drepper@gmail.com>
diff --git a/config.h.in b/config.h.in
index 9e797eb..7a3cd6a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -204,6 +204,9 @@
/* Define if `.ctors' and `.dtors' sections shouldn't be used. */
#undef NO_CTORS_DTORS_SECTIONS
+/* Define if Systemtap <sys/sdt.h> probes should be defined. */
+#undef USE_STAP_PROBE
+
/*
*/
diff --git a/configure b/configure
index fdfa5ef..d247dd5 100755
--- a/configure
+++ b/configure
@@ -784,6 +784,7 @@ enable_all_warnings
enable_multi_arch
enable_experimental_malloc
enable_nss_crypt
+enable_systemtap
with_cpu
'
ac_precious_vars='build_alias
@@ -1444,6 +1445,7 @@ Optional Features:
--enable-experimental-malloc
enable experimental malloc features
--enable-nss-crypt enable libcrypt to use nss
+ --enable-systemtap enable systemtap static probe points [default=no]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -3823,6 +3825,51 @@ else
fi
+# Check whether --enable-systemtap was given.
+if test "${enable_systemtap+set}" = set; then :
+ enableval=$enable_systemtap; systemtap=$enableval
+else
+ systemtap=no
+fi
+
+if test x$systemtap != xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for systemtap static probe support" >&5
+$as_echo_n "checking for systemtap static probe support... " >&6; }
+if test "${libc_cv_sdt+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ old_CFLAGS="$CFLAGS"
+ CFLAGS="-std=gnu99 $CFLAGS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/sdt.h>
+void foo (int i, void *p)
+{
+ asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
+ :: STAP_PROBE_ASM_OPERANDS (2, i, p));
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ libc_cv_sdt=yes
+else
+ libc_cv_sdt=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$old_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sdt" >&5
+$as_echo "$libc_cv_sdt" >&6; }
+ if test $libc_cv_sdt = yes; then
+ $as_echo "#define USE_STAP_PROBE 1" >>confdefs.h
+
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "systemtap support needs sys/sdt.h with asm support
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+fi
+
# The way shlib-versions is used to generate soversions.mk uses a
# fairly simplistic model for name recognition that can't distinguish
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
diff --git a/configure.in b/configure.in
index e5ff6bd..2b94596 100644
--- a/configure.in
+++ b/configure.in
@@ -316,6 +316,29 @@ else
fi
AC_SUBST(libc_cv_nss_crypt)
+AC_ARG_ENABLE([systemtap],
+ [AS_HELP_STRING([--enable-systemtap],
+ [enable systemtap static probe points @<:@default=no@:>@])],
+ [systemtap=$enableval],
+ [systemtap=no])
+if test x$systemtap != xno; then
+ AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
+ old_CFLAGS="$CFLAGS"
+ CFLAGS="-std=gnu99 $CFLAGS"
+ AC_COMPILE_IFELSE([#include <sys/sdt.h>
+void foo (int i, void *p)
+{
+ asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
+ :: STAP_PROBE_ASM_OPERANDS (2, i, p));
+}], [libc_cv_sdt=yes], [libc_cv_sdt=no])
+ CFLAGS="$old_CFLAGS"])
+ if test $libc_cv_sdt = yes; then
+ AC_DEFINE([USE_STAP_PROBE])
+ else
+ AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
+ fi
+fi
+
# The way shlib-versions is used to generate soversions.mk uses a
# fairly simplistic model for name recognition that can't distinguish
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
diff --git a/elf/Makefile b/elf/Makefile
index 36ea9b8..90bc797 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -472,7 +472,8 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
CFLAGS-cache.c = $(SYSCONF-FLAGS)
-CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
+CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
+ -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
generated += $(addsuffix .so,$(strip $(modules-names)))
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
index cd83c85..c040b2f 100644
--- a/elf/rtld-Rules
+++ b/elf/rtld-Rules
@@ -1,7 +1,7 @@
# Subroutine makefile for compiling libc modules linked into dynamic linker.
# Copyright (C) 2002,2003,2005,2006,2008,2010,2011
-# Free Software Foundation, Inc.
+# Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -131,6 +131,6 @@ ifdef rtld-depfiles
endif
# This here is the whole point of all the shenanigans.
-rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
+rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
endif
diff --git a/extra-lib.mk b/extra-lib.mk
index 775eb23..7f8516e 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
endif
-CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
+CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
diff --git a/include/stap-probe.h b/include/stap-probe.h
new file mode 100644
index 0000000..be1bc1c
--- /dev/null
+++ b/include/stap-probe.h
@@ -0,0 +1,140 @@
+/* Macros for defining Systemtap <sys/sdt.h> static probe points.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STAP_PROBE_H
+#define _STAP_PROBE_H 1
+
+#ifdef USE_STAP_PROBE
+
+# include <sys/sdt.h>
+
+/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
+
+ Without USE_STAP_PROBE, that does nothing but evaluates all
+ its arguments (to prevent bit rot, unlike e.g. assert).
+
+ Systemtap's header defines the macros STAP_PROBE (provider, name) and
+ STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
+ in the IN_LIB name (libc, libpthread, etc.) automagically. */
+
+# ifndef NOT_IN_libc
+# define IN_LIB libc
+# elif !defined IN_LIB
+/* This is intentionally defined with extra unquoted commas in it so
+ that macro substitution will bomb out when it is used. We don't
+ just use #error here, so that this header can be included by
+ other headers that use LIBC_PROBE inside their own macros. We
+ only want such headers to fail to compile if those macros are
+ actually used in a context where IN_LIB has not been defined. */
+# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
+# endif
+
+# define LIBC_PROBE(name, n, ...) \
+ LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__)
+
+# define LIBC_PROBE_1(lib, name, n, ...) \
+ STAP_PROBE##n (lib, name, ## __VA_ARGS__)
+
+# define STAP_PROBE0 STAP_PROBE
+
+# define LIBC_PROBE_ASM(name, template) \
+ STAP_PROBE_ASM (IN_LIB, name, template)
+
+# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
+
+#else /* Not USE_STAP_PROBE. */
+
+# ifndef __ASSEMBLER__
+# define LIBC_PROBE(name, n, ...) DUMMY_PROBE##n (__VA_ARGS__)
+# else
+# define LIBC_PROBE(name, n, ...) /* Nothing. */
+# endif
+
+# define LIBC_PROBE_ASM(name, template) /* Nothing. */
+# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
+
+/* This silliness lets us evaluate all the arguments for each arity
+ of probe. My kingdom for a real macro system. */
+
+# define DUMMY_PROBE0() do {} while (0)
+# define DUMMY_PROBE1(a1) do {} while ((void) (a1), 0)
+# define DUMMY_PROBE2(a1, a2) do {} while ((void) (a1), \
+ (void) (a2), 0)
+# define DUMMY_PROBE3(a1, a2, a3) do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), 0)
+# define DUMMY_PROBE4(a1, a2, a3, a4) do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), 0)
+# define DUMMY_PROBE5(a1, a2, a3, a4, a5) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), 0)
+# define DUMMY_PROBE6(a1, a2, a3, a4, a5, a6) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), \
+ (void) (a6), 0)
+# define DUMMY_PROBE7(a1, a2, a3, a4, a5, a6, a7) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), \
+ (void) (a6), \
+ (void) (a7), 0)
+# define DUMMY_PROBE8(a1, a2, a3, a4, a5, a6, a7, a8) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), \
+ (void) (a6), \
+ (void) (a7), \
+ (void) (a8), 0)
+# define DUMMY_PROBE9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), \
+ (void) (a6), \
+ (void) (a7), \
+ (void) (a8), \
+ (void) (a9), 0)
+# define DUMMY_PROBE10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
+ do {} while ((void) (a1), \
+ (void) (a2), \
+ (void) (a3), \
+ (void) (a4), \
+ (void) (a5), \
+ (void) (a6), \
+ (void) (a7), \
+ (void) (a8), \
+ (void) (a9), \
+ (void) (a10), 0)
+
+#endif /* USE_STAP_PROBE. */
+
+#endif /* stap-probe.h */
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 802abcd..da1aac7 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-23 Roland McGrath <roland@redhat.com>
+
+ * pthread_create.c (start_thread): Define pthread_start LIBC_PROBE.
+
2011-01-19 Roland McGrath <roland@redhat.com>
* pthread_cond_wait.c (__pthread_cond_wait): Fix comment typo.
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 34d83f9..4075dd9 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -31,6 +31,8 @@
#include <shlib-compat.h>
+#include <stap-probe.h>
+
/* Local function to start thread and handle cleanup. */
static int start_thread (void *arg);
@@ -296,6 +298,8 @@ start_thread (void *arg)
CANCEL_RESET (oldtype);
}
+ LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
+
/* Run the code the user provided. */
#ifdef CALL_THREAD_FCT
THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources