diff options
| author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2016-07-11 20:32:12 +0530 |
|---|---|---|
| committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2016-07-11 20:32:12 +0530 |
| commit | c10f90dcef42092a96007fed7e77f9d470e5bb76 (patch) | |
| tree | d4e260bbfec4a61d50a17f3be8fc64a0b7b01b4b | |
| parent | 26c2910ac6889dd21f128d9071418492d544a2dc (diff) | |
| download | glibc-c10f90dcef42092a96007fed7e77f9d470e5bb76.tar.xz glibc-c10f90dcef42092a96007fed7e77f9d470e5bb76.zip | |
Revert "Add pretty printers for the NPTL lock types"
This reverts commit 62ce266b0b261def2c6329be9814ffdcc11964d6.
The change is not mature enough because it needs the following fixes:
1. Redirect test output to a file like other tests
2. Eliminate the need to use a .gdbinit because distributions will
break without it. I should have caught that but I was in too much
of a hurry to get the patch in :/
3. Feature checking during configure to determine things like minimum
required gdb version, python-pexpect version, etc. to make sure
that tests work correctly.
| -rw-r--r-- | ChangeLog | 27 | ||||
| -rw-r--r-- | Makeconfig | 14 | ||||
| -rw-r--r-- | Makerules | 46 | ||||
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | Rules | 5 | ||||
| -rw-r--r-- | nptl/Makefile | 1 | ||||
| -rw-r--r-- | nptl/nptl-printers.py | 593 | ||||
| -rw-r--r-- | nptl/nptl_lock_constants.pysym | 75 | ||||
| -rw-r--r-- | pretty-printers/Makefile | 82 | ||||
| -rw-r--r-- | pretty-printers/README | 130 | ||||
| -rw-r--r-- | pretty-printers/test-condvar-attributes.c | 94 | ||||
| -rw-r--r-- | pretty-printers/test-condvar-attributes.py | 60 | ||||
| -rw-r--r-- | pretty-printers/test-condvar-printer.c | 57 | ||||
| -rw-r--r-- | pretty-printers/test-condvar-printer.py | 45 | ||||
| -rw-r--r-- | pretty-printers/test-mutex-attributes.c | 144 | ||||
| -rw-r--r-- | pretty-printers/test-mutex-attributes.py | 90 | ||||
| -rw-r--r-- | pretty-printers/test-mutex-printer.c | 151 | ||||
| -rw-r--r-- | pretty-printers/test-mutex-printer.py | 92 | ||||
| -rw-r--r-- | pretty-printers/test-rwlock-attributes.c | 98 | ||||
| -rw-r--r-- | pretty-printers/test-rwlock-attributes.py | 62 | ||||
| -rw-r--r-- | pretty-printers/test-rwlock-printer.c | 78 | ||||
| -rw-r--r-- | pretty-printers/test-rwlock-printer.py | 59 | ||||
| -rw-r--r-- | pretty-printers/test_common.py | 315 | ||||
| -rw-r--r-- | scripts/gen-py-const.awk | 118 |
24 files changed, 1 insertions, 2438 deletions
@@ -34,33 +34,6 @@ * sysdeps/unix/sysv/linux/pwritev64.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwritev64): Likewise. -2016-07-08 Martin Galvan <martin.galvan@tallertechnologies.com> - - * Makeconfig (build-hardcoded-path-in-tests): Set to 'yes' - for shared builds if tests-need-hardcoded-path is defined. - (all-subdirs): Add pretty-printers. - * Makerules ($(py-const)): New rule. - * Rules (others): Add $(py-const), if defined. - * nptl/Makefile (gen-py-const-headers): Define. - * nptl/nptl-printers.py: New file. - * nptl/nptl_lock_constants.pysym: Likewise. - * pretty-printers/Makefile: Likewise. - * pretty-printers/README: Likewise. - * pretty-printers/test-condvar-attributes.c: Likewise. - * pretty-printers/test-condvar-attributes.p: Likewise. - * pretty-printers/test-condvar-printer.c: Likewise. - * pretty-printers/test-condvar-printer.py: Likewise. - * pretty-printers/test-mutex-attributes.c: Likewise. - * pretty-printers/test-mutex-attributes.py: Likewise. - * pretty-printers/test-mutex-printer.c: Likewise. - * pretty-printers/test-mutex-printer.py: Likewise. - * pretty-printers/test-rwlock-attributes.c: Likewise. - * pretty-printers/test-rwlock-attributes.py: Likewise. - * pretty-printers/test-rwlock-printer.c: Likewise. - * pretty-printers/test-rwlock-printer.py: Likewise. - * pretty-printers/test_common.py: Likewise. - * scripts/gen-py-const.awk: Likewise. - 2016-07-08 Chris Metcalf <cmetcalf@mellanox.com> * sysdeps/unix/sysv/linux/tile/kernel-features.h diff --git a/Makeconfig b/Makeconfig index 58bd3b3a1c..03fd89c13e 100644 --- a/Makeconfig +++ b/Makeconfig @@ -472,18 +472,6 @@ else +link-tests = $(+link-static-tests) endif endif - -# Some modules may have test programs that must always link against the newly -# built libraries instead of the installed ones. Such modules must define -# tests-need-hardcoded-path in their Makefile before including Makerules. -# This will cause the test programs to be linked with -rpath instead of -# -rpath-link, and their dynamic linker will be set to the built ld.so. -ifeq (yes,$(build-shared)) -ifdef tests-need-hardcoded-path -build-hardcoded-path-in-tests := yes -endif -endif - ifeq (yes,$(build-shared)) ifndef rtld-LDFLAGS rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name) @@ -1109,7 +1097,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \ grp pwd posix io termios resource misc socket sysvipc gmon \ gnulib iconv iconvdata wctype manual shadow gshadow po argp \ crypt localedata timezone rt conform debug mathvec \ - $(add-on-subdirs) dlfcn elf pretty-printers + $(add-on-subdirs) dlfcn elf ifndef avoid-generated # sysd-sorted itself will contain rules making the sysd-sorted target @@ -214,52 +214,6 @@ sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \ -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g' endif -ifdef gen-py-const-headers -# We'll use a static pattern rule to match .pysym files with their -# corresponding generated .py files. -# The generated .py files go in the submodule's dir in the glibc source dir. -py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers)) -py-const-dir := $(objpfx) -py-const := $(addprefix $(py-const-dir),$(py-const-files)) -py-const-script := $(..)scripts/gen-py-const.awk - -# This is a hack we use to generate .py files with constants for Python -# pretty printers. It works the same way as gen-as-const. -# See scripts/gen-py-const.awk for details on how the awk | gcc mechanism -# works. -# -# $@.tmp and $@.tmp2 are temporary files we use to store the partial contents -# of the target file. We do this instead of just writing on $@ because, if the -# build process terminates prematurely, re-running Make wouldn't run this rule -# since Make would see that the target file already exists (despite it being -# incomplete). -# -# The sed line replaces "@name@SOME_NAME@value@SOME_VALUE@" strings from the -# output of 'gcc -S' with "SOME_NAME = SOME_VALUE" strings. -# The '-n' option, combined with the '/p' command, makes sed output only the -# modified lines instead of the whole input file. The output is redirected -# to a .py file; we'll import it in the pretty printers file to read -# the constants generated by gen-py-const.awk. -# The regex has two capturing groups, for SOME_NAME and SOME_VALUE -# respectively. Notice SOME_VALUE may be prepended by a special character, -# depending on the assembly syntax (e.g. immediates are prefixed by a '$' -# in AT&T x86, and by a '#' in ARM). We discard it using a complemented set -# before the second capturing group. -$(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \ - $(common-before-compile) - $(make-target-directory) - $(AWK) -f $(py-const-script) $< \ - | $(CC) -S -o $@.tmp $(CFLAGS) $(CPPFLAGS) -x c - - echo '# GENERATED FILE\n' > $@.tmp2 - echo '# Constant definitions for pretty printers.' >> $@.tmp2 - echo '# See gen-py-const.awk for details.\n' >> $@.tmp2 - sed -n -r 's/^.*@name@([^@]+)@value@[^[:xdigit:]Xx-]*([[:xdigit:]Xx-]+)@.*/\1 = \2/p' \ - $@.tmp >> $@.tmp2 - mv -f $@.tmp2 $@ - rm -f $@.tmp - -generated += $(py-const) -endif # gen-py-const-headers ifdef gen-as-const-headers # Generating headers for assembly constants. @@ -47,9 +47,6 @@ Version 2.24 direction of negative infinity. These are currently enabled as GNU extensions. -* Initial support is added for pretty printing of pthread variables in gdb. - See pretty-printers/README for details on how to use it. - Security related changes: * An unnecessary stack copy in _nss_dns_getnetbyname_r was removed. It @@ -98,11 +98,6 @@ tests: $(tests:%=$(objpfx)%.out) $(tests-special) xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special) endif -# Generate constant files for Python pretty printers if required. -ifdef py-const -others: $(py-const) -endif - tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special)) xtests-special-notdir = $(patsubst $(objpfx)%, %, $(xtests-special)) tests: diff --git a/nptl/Makefile b/nptl/Makefile index 09e09ddf4f..0d8aadebed 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -307,7 +307,6 @@ gen-as-const-headers = pthread-errnos.sym \ unwindbuf.sym \ lowlevelrobustlock.sym pthread-pi-defines.sym -gen-py-const-headers = nptl_lock_constants.pysym LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst diff --git a/nptl/nptl-printers.py b/nptl/nptl-printers.py deleted file mode 100644 index f64216fb57..0000000000 --- a/nptl/nptl-printers.py +++ /dev/null @@ -1,593 +0,0 @@ -# Pretty printers for the NPTL lock types. -# -# Copyright (C) 2016 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, see -# <http://www.gnu.org/licenses/>. - -"""This file contains the gdb pretty printers for the following types: - - * pthread_mutex_t - * pthread_mutexattr_t - * pthread_cond_t - * pthread_condattr_t - * pthread_rwlock_t - * pthread_rwlockattr_t - -You can check which printers are registered and enabled by issuing the -'info pretty-printer' gdb command. Printers should trigger automatically when -trying to print a variable of one of the types mentioned above. -""" - -from __future__ import print_function - -import gdb -from nptl_lock_constants import * - -MUTEX_TYPES = { - PTHREAD_MUTEX_NORMAL: ('Type', 'Normal'), - PTHREAD_MUTEX_RECURSIVE: ('Type', 'Recursive'), - PTHREAD_MUTEX_ERRORCHECK: ('Type', 'Error check'), - PTHREAD_MUTEX_ADAPTIVE_NP: ('Type', 'Adaptive') -} - -class MutexPrinter(object): - """Pretty printer for pthread_mutex_t.""" - - def __init__(self, mutex): - """Initialize the printer's internal data structures. - - Args: - mutex: A gdb.value representing a pthread_mutex_t. - """ - - data = mutex['__data'] - self.lock = data['__lock'] - self.count = data['__count'] - self.owner = data['__owner'] - self.kind = data['__kind'] - self.values = [] - self.read_values() - - def to_string(self): - """gdb API function. - - This is called from gdb when we try to print a pthread_mutex_t. - """ - - return 'pthread_mutex_t' - - def children(self): - """gdb API function. - - This is called from gdb when we try to print a pthread_mutex_t. - """ - - return self.values - - def read_values(self): - """Read the mutex's info and store it in self.values. - - The data contained in self.values will be returned by the Iterator - created in self.children. - """ - - self.read_type() - self.read_status() - self.read_attributes() - self.read_misc_info() - - def read_type(self): - """Read the mutex's type.""" - - mutex_type = self.kind & PTHREAD_MUTEX_KIND_MASK - - # mutex_type must be casted to int because it's a gdb.Value - self.values.append(MUTEX_TYPES[int(mutex_type)]) - - def read_status(self): - """Read the mutex's status. - - For architectures which support lock elision, this method reads - whether the mutex appears as locked in memory (i.e. it may show it as - unlocked even after calling pthread_mutex_lock). - """ - - if self.kind == PTHREAD_MUTEX_DESTROYED: - self.values.append(('Status', 'Destroyed')) - elif self.kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP: - self.read_status_robust() - else: - self.read_status_no_robust() - - def read_status_robust(self): - """Read the status of a robust mutex. - - In glibc robust mutexes are implemented in a very different way than - non-robust ones. This method reads their locking status, - whether it may have waiters, their registered owner (if any), - whether the owner is alive or not, and the status of the state - they're protecting. - """ - - if self.lock == PTHREAD_MUTEX_UNLOCKED: - self.values.append(('Status', 'Unlocked')) - else: - if self.lock & FUTEX_WAITERS: - self.values.append(('Status', 'Locked, possibly with waiters')) - else: - self.values.append(('Status', - 'Locked, possibly with no waiters')) - - if self.lock & FUTEX_OWNER_DIED: - self.values.append(('Owner ID', '%d (dead)' % self.owner)) - else: - self.values.append(('Owner ID', self.lock & FUTEX_TID_MASK)) - - if self.owner == PTHREAD_MUTEX_INCONSISTENT: - self.values.append(('State protected by this mutex', - 'Inconsistent')) - elif self.owner == PTHREAD_MUTEX_NOTRECOVERABLE: - self.values.append(('State protected by this mutex', - 'Not recoverable')) - - def read_status_no_robust(self): - """Read the status of a non-robust mutex. - - Read info on whether the mutex is locked, if it may have waiters - and its owner (if any). - """ - - lock_value = self.lock - - if self.kind & PTHREAD_MUTEX_PRIO_PROTECT_NP: - lock_value &= ~(PTHREAD_MUTEX_PRIO_CEILING_MASK) - - if lock_value == PTHREAD_MUTEX_UNLOCKED: - self.values.append(('Status', 'Unlocked')) - else: - if self.kind & PTHREAD_MUTEX_PRIO_INHERIT_NP: - waiters = self.lock & FUTEX_WAITERS - owner = self.lock & FUTEX_TID_MASK - else: - # Mutex protocol is PP or none - waiters = (self.lock != PTHREAD_MUTEX_LOCKED_NO_WAITERS) - owner = self.owner - - if waiters: - self.values.append(('Status', 'Locked, possibly with waiters')) - else: - self.values.append(('Status', - 'Locked, possibly with no waiters')) - - self.values.append(('Owner ID', owner)) - - def read_attributes(self): - """Read the mutex's attributes.""" - - if self.kind != PTHREAD_MUTEX_DESTROYED: - if self.kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP: - self.values.append(('Robust', 'Yes')) - else: - self.values.append(('Robust', 'No')) - - # In glibc, robust mutexes always have their pshared flag set to - # 'shared' regardless of what the pshared flag of their - # mutexattr was. Therefore a robust mutex will act as shared - # even if it was initialized with a 'private' mutexattr. - if self.kind & PTHREAD_MUTEX_PSHARED_BIT: - self.values.append(('Shared', 'Yes')) - else: - self.values.append(('Shared', 'No')) - - if self.kind & PTHREAD_MUTEX_PRIO_INHERIT_NP: - self.values.append(('Protocol', 'Priority inherit')) - elif self.kind & PTHREAD_MUTEX_PRIO_PROTECT_NP: - prio_ceiling = ((self.lock & PTHREAD_MUTEX_PRIO_CEILING_MASK) - >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT) - - self.values.append(('Protocol', 'Priority protect')) - self.values.append(('Priority ceiling', prio_ceiling)) - else: - # PTHREAD_PRIO_NONE - self.values.append(('Protocol', 'None')) - - def read_misc_info(self): - """Read miscellaneous info on the mutex. - - For now this reads the number of times a recursive mutex was locked - by the same thread. - """ - - mutex_type = self.kind & PTHREAD_MUTEX_KIND_MASK - - if mutex_type == PTHREAD_MUTEX_RECURSIVE and self.count > 1: - self.values.append(('Times locked recursively', self.count)) - -class MutexAttributesPrinter(object): - """Pretty printer for pthread_mutexattr_t. - - In the NPTL this is a type that's always casted to struct pthread_mutexattr - which has a single 'mutexkind' field containing the actual attributes. - """ - - def __init__(self, mutexattr): - """Initialize the printer's internal data structures. - - Args: - mutexattr: A gdb.value representing a pthread_mutexattr_t. - """ - - mutexattr_struct = gdb.lookup_type('struct pthread_mutexattr') - self.mutexattr = mutexattr.cast(mutexattr_struct)['mutexkind'] - self.values = [] - self.read_values() - - def to_string(self): - """gdb API function. - - This is called from gdb when we try to print a pthread_mutexattr_t. - """ - - return 'pthread_mutexattr_t' - - def children(self): - """gdb API function. - - This is called from gdb when we try to print a pthread_mutexattr_t. - """ - - return self.values - - def read_values(self): - """Read the mutexattr's info and store it in self.values. - - The data contained in self.values will be returned by the Iterator - created in self.children. - """ - - mutexattr_type = (self.mutexattr - & ~PTHREAD_MUTEXATTR_FLAG_BITS - & ~PTHREAD_MUTEX_NO_ELISION_NP) - - # mutexattr_type must be casted to int because it's a gdb.Value - self.values.append(MUTEX_TYPES[int(mutexattr_type)]) - - if self.mutexattr & PTHREAD_MUTEXATTR_FLAG_ROBUST: - self.values.append(('Robust', 'Yes')) - else: - self.values.append(('Robust', 'No')) - - if self.mutexattr & PTHREAD_MUTEXATTR_FLAG_PSHARED: - self.values.append(('Shared', 'Yes')) - else: - self.values.append(('Shared', 'No')) - - protocol = ((self.mutexattr & PTHREAD_MUTEXATTR_PROTOCOL_MASK) >> - PTHREAD_MUTEXATTR_PROTOCOL_SHIFT) - - if protocol == PTHREAD_PRIO_NONE: - self.values.append(('Protocol', 'None')) - elif protocol == PTHREAD_PRIO_INHERIT: - self.values.append(('Protocol', 'Priority inherit')) - elif protocol == PTHREAD_PRIO_PROTECT: - self.values.append(('Protocol', 'Priority protect')) - -CLOCK_IDS = { - CLOCK_REALTIME: 'CLOCK_REALTIME', - CLOCK_MONOTONIC: 'CLOCK_MONOTONIC', - CLOCK_PROCESS_CPUTIME_ID: 'CLOCK_PROCESS_CPUTIME_ID', - CLOCK_THREAD_CPUTIME_ID: 'CLOCK_THREAD_CPUTIME_ID', - CLOCK_MONOTONIC_RAW: 'CLOCK_MONOTONIC_RAW', - CLOCK_REALTIME_COARSE: 'CLOCK_REALTIME_COARSE', - CLOCK_MONOTONIC_COARSE: 'CLOCK_MONOTONIC_COARSE' -} - -class ConditionVariablePrinter(object): - """Pretty printer for pthread_cond_t.""" - - def __init__(self, cond): - """Initialize the printer's internal data structures. - - Args: - cond: A gdb.value representing a pthread_cond_t. |
