📄 ptt_glibc-2.3.6.patch
字号:
+#define __pthread_mutex_lock __pthread_mutex_lock_nt+#define pthread_mutex_lock pthread_mutex_lock_nt+#define __pthread_mutex_lock_internal __pthread_mutex_lock_nt_internal++#include "ptt_trace.h"+#undef PTT_TRACE+#define PTT_TRACE(...)+ +#include "pthread_mutex_lock.c"+ +strong_alias (__pthread_mutex_lock_nt, __pthread_mutex_lock_nt_internal)++#endif /* PTT_LIBPTHREAD */+diff -Naur ori_glibc/nptl/pthread_mutex_unlock.c new_glibc/nptl/pthread_mutex_unlock.c--- ori_glibc/nptl/pthread_mutex_unlock.c 2006-03-31 10:28:21.000000000 +0200+++ new_glibc/nptl/pthread_mutex_unlock.c 2006-05-10 11:33:33.000000000 +0200@@ -28,23 +28,49 @@ pthread_mutex_t *mutex; int decr; {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_IN */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_14, mutex);+#endif /* PTT_LIBPTHREAD */+ switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { case PTHREAD_MUTEX_RECURSIVE_NP: /* Recursive mutex. */ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */+ return EPERM;+ } if (--mutex->__data.__count != 0)+ { /* We still hold the mutex. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_COUNT_DEC, MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_16, mutex,+ mutex->__data.__count, mutex, 0);+#endif /* PTT_LIBPTHREAD */ return 0;+ } break; case PTHREAD_MUTEX_ERRORCHECK_NP: /* Error checking mutex. */ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid) || ! lll_mutex_islocked (mutex->__data.__lock))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */+ return EPERM;+ } break; default:@@ -57,13 +83,28 @@ /* Always reset the owner field. */ mutex->__data.__owner = 0;++#ifdef PTT_LIBPTHREAD+ /* MUTEX_OWNER_CHANGE */+ PTT_TRACE (PTT_LEVEL_MUTEX, TR_MUTEX_17, mutex, 0);+#endif /* PTT_LIBPTHREAD */+ if (decr) /* One less user. */ --mutex->__data.__nusers; /* Unlock. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_STATE_FREE */+ PTT_TRACE (PTT_LEVEL_MUTEX, TR_MUTEX_18, mutex, mutex->__data.__lock);+#endif /* PTT_LIBPTHREAD */+ lll_mutex_unlock (mutex->__data.__lock); +#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, 0);+#endif /* PTT_LIBPTHREAD */ return 0; } diff -Naur ori_glibc/nptl/pthread_mutex_unlock_nt.c new_glibc/nptl/pthread_mutex_unlock_nt.c--- ori_glibc/nptl/pthread_mutex_unlock_nt.c 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/pthread_mutex_unlock_nt.c 2006-03-31 10:28:33.000000000 +0200@@ -0,0 +1,34 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This 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.+ *+ * This 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 this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* pthread_mutex_unlock_nt: original pthread_mutex_unlock (without traces) */++#ifdef PTT_LIBPTHREAD++#define __pthread_mutex_unlock __pthread_mutex_unlock_nt+#define pthread_mutex_unlock pthread_mutex_unlock_nt+#define __pthread_mutex_unlock_internal __pthread_mutex_unlock_nt_internal+#define __pthread_mutex_unlock_usercnt __pthread_mutex_unlock_usercnt_nt++#include "ptt_trace.h"+#undef PTT_TRACE+#define PTT_TRACE(...)+ +#include "pthread_mutex_unlock.c"++#endif /* PTT_LIBPTHREAD */+diff -Naur ori_glibc/nptl/pthreadP.h new_glibc/nptl/pthreadP.h--- ori_glibc/nptl/pthreadP.h 2006-03-31 10:28:21.000000000 +0200+++ new_glibc/nptl/pthreadP.h 2006-03-31 10:28:33.000000000 +0200@@ -31,6 +31,9 @@ #include <internaltypes.h> #include <pthread-functions.h> #include <atomic.h>+#ifdef PTT_LIBPTHREAD+#include "ptt_module.h"+#endif /* PTT_LIBPTHREAD */ /* Atomic operations on TLS memory. */@@ -308,11 +311,19 @@ extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex) attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_mutex_lock_nt_internal (pthread_mutex_t *__mutex)+ attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex) attribute_hidden internal_function; extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex) attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_mutex_unlock_nt_internal (pthread_mutex_t *__mutex)+ attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex, int __decr) attribute_hidden internal_function;@@ -395,6 +406,11 @@ extern int __pthread_enable_asynccancel (void) attribute_hidden; extern void __pthread_disable_asynccancel (int oldtype) internal_function attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_enable_synccancel (void) attribute_hidden;+extern void __pthread_disable_synccancel (int oldtype)+ internal_function attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);diff -Naur ori_glibc/nptl/ptt_debug.h new_glibc/nptl/ptt_debug.h--- ori_glibc/nptl/ptt_debug.h 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/ptt_debug.h 2006-04-07 11:29:59.000000000 +0200@@ -0,0 +1,65 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This 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.+ *+ * This 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 this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* PTT internals trace mechanism macros+ * PTT_DBG = trace level of ptt internals+ * if not defined, ifdef PTT_TRACE_INFO, PTT_DBG = PTT_DBG_ALL+ * else PTT_DBG = PTT_DBG_NONE+ */ ++#ifdef PTT_NEW_FILES+#ifndef PTT_DEBUG_H +#define PTT_DEBUG_H ++/* trace the lowest level */+#define PTT_DBG_GENERAL 0x1+/* trace ptt_trace */+#define PTT_DBG_TRACE 0x2+/* trace ptt_initialize */+#define PTT_DBG_INIT 0x4+/* trace ptt_finish */+#define PTT_DBG_FINI 0x8+/* trace errors */+#define PTT_DBG_ERROR 0x10++/* don't trace ptt internals */+#define PTT_DBG_NONE 0+/* trace whole ptt internals */+#define PTT_DBG_ALL ( \+ PTT_DBG_GENERAL | PTT_DBG_TRACE | PTT_DBG_INIT | PTT_DBG_FINI | \+ PTT_DBG_ERROR)++/* default debug level */+#ifndef PTT_DBG+#ifdef PTT_TRACE_INFO+#define PTT_DBG PTT_DBG_ALL+#else /* ifndef PTT_TRACE_INFO */+#define PTT_DBG PTT_DBG_NONE+#endif /* PTT_TRACE_INFO */+#endif /* PTT_DBG */++/* define PTT_TRACE_INTERNALS */+#if (PTT_DBG == PTT_DBG_NONE)+#define PTT_TRACE_INTERNALS(x,...)+#else /* PTT_DBG != PTT_DBG_NONE */+#define PTT_TRACE_INTERNALS(level,...) \+ if (level & PTT_DBG) fprintf (stderr, __VA_ARGS__)+#endif /* PTT_DBG != PTT_DBG_NONE */++#endif /* PTT_DEBUG_H */+#endif /* PTT_NEW_FILES */+diff -Naur ori_glibc/nptl/ptt_module.c new_glibc/nptl/ptt_module.c--- ori_glibc/nptl/ptt_module.c 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/ptt_module.c 2006-06-22 14:48:19.000000000 +0200@@ -0,0 +1,510 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This 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.+ *+ * This 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 this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* PTT module to initialize PTT and write trace points in a shared buffer */++#ifdef PTT_NEW_FILES++#define _XOPEN_SOURCE 500++#include "ptt_types.h"+#include "ptt_trace.h"+#include "ptt_debug.h"+#include "pthreadP.h"+#include <stdio.h>+#include <stdlib.h>+#include <unistd.h>+#include <fcntl.h>+#include <stdarg.h>+#include <assert.h>+#include <pthread.h>+#include <sys/types.h>+#include <sys/mman.h>+#include <libc-symbols.h>+#include <atomic.h>+#include <hp-timing.h>++struct ptt_buffer* ptt_buf;+pid_t attribute_hidden ptt_trace_pid;++ptt_point_data_t attribute_hidden ptt_point_array[] = {+#if __WORDSIZE == 64+ {{}, 0, 7}, /* NULL */+ {{PTT_UINT}, 1, 8}, /* INIT */+ {{}, 0, 7}, /* FINI */+ {{PTT_PTR, PTT_PTR, PTT_INT}, 3, 12}, /* BAR_1 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* BAR_2 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* BAR_3 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* BAR_4 */+ {{PTT_PTR, PTT_PTR, PTT_UINT}, 3, 12}, /* BAR_5 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* BAR_6 */+ {{PTT_PTR, PTT_UINT, PTT_PTR, PTT_INT}, 4, 13}, /* BAR_7 */+ {{PTT_PTR, PTT_PTR, PTT_INT}, 3, 12}, /* BAR_8 */+ {{PTT_PTR, PTT_UINT}, 2, 10}, /* BAR_9 */+ {{PTT_PTR, PTT_UINT, PTT_PTR, PTT_INT}, 4, 13}, /* BAR_10 */+ {{PTT_PTR, PTT_UINT}, 2, 10}, /* BAR_11 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* BAR_12 */+ {{PTT_PTR}, 1, 9}, /* BAR_13 */+ {{PTT_PTR}, 1, 9}, /* BAR_14 */+ {{PTT_PTR}, 1, 9}, /* BAR_15 */+ {{PTT_PTR, PTT_PTR, PTT_INT}, 3, 12}, /* COND_1 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_2 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_3 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_4 */+ {{PTT_PTR, PTT_ULL}, 2, 11}, /* COND_5 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_6 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_7 */+ {{PTT_PTR, PTT_PTR, PTT_INT}, 3, 12}, /* COND_8 */+ {{PTT_PTR, PTT_PTR}, 2, 11}, /* COND_9 */+ {{PTT_PTR, PTT_PTR, PTT_ULL, PTT_UINT, PTT_PTR, PTT_INT}, 6, 17},+ {{PTT_PTR, PTT_PTR, PTT_PTR, PTT_INT}, 4, 14}, /* COND_11 */+ {{PTT_PTR, PTT_INT}, 2, 10}, /* COND_12 */+ {{PTT_PTR, PTT_PTR}, 2, 11}, /* COND_13 */+ {{PTT_PTR, PTT_ULL}, 2, 11}, /* COND_14 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -