about summary refs log tree commit diff
path: root/scripts/gen-py-const.awk
Commit message (Collapse)AuthorAgeFilesLines
* Use gen-as-const.py to process .pysym files.Joseph Myers2018-12-101-118/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch eliminates the gen-py-const.awk variant of gen-as-const, switching to use of gnu-as-const.py (with a new --python option) to process .pysym files (i.e., to generate nptl_lock_constants.py), as the syntax of those files is identical to that of .sym files. Note that the generated nptl_lock_constants.py is *not* identical to the version generated by the awk script. Apart from the trivial changes (comment referencing the new script, and output being sorted), the constant FUTEX_WAITERS, PTHREAD_MUTEXATTR_FLAG_BITS, PTHREAD_MUTEXATTR_FLAG_PSHARED and PTHREAD_MUTEX_PRIO_CEILING_MASK are now output as positive rather than negative constants (on x86_64 anyway; maybe not necessarily on 32-bit systems): < FUTEX_WAITERS = -2147483648 --- > FUTEX_WAITERS = 2147483648 < PTHREAD_MUTEXATTR_FLAG_BITS = -251662336 < PTHREAD_MUTEXATTR_FLAG_PSHARED = -2147483648 --- > PTHREAD_MUTEXATTR_FLAG_BITS = 4043304960 > PTHREAD_MUTEXATTR_FLAG_PSHARED = 2147483648 < PTHREAD_MUTEX_PRIO_CEILING_MASK = -524288 --- > PTHREAD_MUTEX_PRIO_CEILING_MASK = 4294443008 This is because gen-as-const has a cast of the constant value to long int, which gen-py-const lacks. I think the positive values are more logically correct, since the constants in question are in fact unsigned in C. But to reliably produce gen-as-const.py output for constants that always (in C and Python) reflects the signedness of values with the high bit of "long int" set would mean more complicated logic needs to be used in computing values. The more correct positive values by themselves produce a failure of nptl/test-mutexattr-printers, because masking with ~PTHREAD_MUTEXATTR_FLAG_BITS & ~PTHREAD_MUTEX_NO_ELISION_NP now leaves a bit -1 << 32 in the Python value, resulting in a KeyError exception. To avoid that, places masking with ~ of one of the constants in question are changed to mask with 0xffffffff as well (this reflects how ~ in Python applies to an infinite-precision integer whereas ~ in C does not do any promotions beyond the width of int). Tested for x86_64. * scripts/gen-as-const.py (main): Handle --python option. * scripts/gen-py-const.awk: Remove. * Makerules (py-const-script): Use gen-as-const.py. ($(py-const)): Likewise. * nptl/nptl-printers.py (MutexPrinter.read_status_no_robust): Mask with 0xffffffff together with ~(PTHREAD_MUTEX_PRIO_CEILING_MASK). (MutexAttributesPrinter.read_values): Mask with 0xffffffff together with ~PTHREAD_MUTEXATTR_FLAG_BITS and ~PTHREAD_MUTEX_NO_ELISION_NP. * manual/README.pretty-printers: Update reference to gen-py-const.awk.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-011-1/+1
|
* Add pretty printers for the NPTL lock typesMartin Galvan2016-12-081-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds pretty printers for the following NPTL types: - pthread_mutex_t - pthread_mutexattr_t - pthread_cond_t - pthread_condattr_t - pthread_rwlock_t - pthread_rwlockattr_t To load the pretty printers into your gdb session, do the following: python import sys sys.path.insert(0, '/path/to/glibc/build/nptl/pretty-printers') end source /path/to/glibc/source/pretty-printers/nptl-printers.py 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. The printers are architecture-independent, and were tested on an AMD64 running Ubuntu 14.04 and an x86 VM running Fedora 24. In order to work, the printers need to know the values of various flags that are scattered throughout pthread.h and pthreadP.h as enums and #defines. Since replicating these constants in the printers file itself would create a maintenance burden, I wrote a script called gen-py-const.awk that Makerules uses to extract the constants. This script is pretty much the same as gen-as-const.awk, except it doesn't cast the constant values to 'long' and is thorougly documented. The constants need only to be enumerated in a .pysym file, which is then referenced by a Make variable called gen-py-const-headers. As for the install directory, I discussed this with Mike Frysinger and Siddhesh Poyarekar, and we agreed that it can be handled in a separate patch, and shouldn't block merging of this one. In addition, I've written a series of test cases for the pretty printers. Each lock type (mutex, condvar and rwlock) has two test programs, one for itself and other for its related 'attributes' object. Each test program in turn has a PExpect-based Python script that drives gdb and compares its output to the expected printer's. The tests run on the glibc host, which is assumed to have both gdb and PExpect; if either is absent the tests will fail with code 77 (UNSUPPORTED). For cross-testing you should use cross-test-ssh.sh as test-wrapper. I've tested the printers on both native builds and a cross build using a Beaglebone Black running Debian, with the build system's filesystem shared with the board through NFS. Finally, I've written a README that explains all this and more. * INSTALL: Regenerated. * Makeconfig: Add comments and whitespace to make the control flow clearer. (+link-printers-tests, +link-pie-printers-tests, CFLAGS-printers-tests, installed-rtld-LDFLAGS, built-rtld-LDFLAGS, link-libc-rpath, link-libc-tests-after-rpath-link, link-libc-printers-tests): New. (rtld-LDFLAGS, rtld-tests-LDFLAGS, link-libc-tests-rpath-link, link-libc-tests): Use the new variables as required. * Makerules ($(py-const)): New rule. generated: Add $(py-const). * README.pretty-printers: New file. * Rules (tests-printers-programs, tests-printers-out, py-env): New. (others): Depend on $(py-const). (tests): Depend on $(tests-printers-programs) or $(tests-printers-out), as required. Pass $(tests-printers) to merge-test-results.sh. * manual/install.texi: Add requirements for testing the pretty printers. * nptl/Makefile (gen-py-const-headers, pretty-printers, tests-printers, CFLAGS-test-mutexattr-printers.c CFLAGS-test-mutex-printers.c, CFLAGS-test-condattr-printers.c, CFLAGS-test-cond-printers.c, CFLAGS-test-rwlockattr-printers.c CFLAGS-test-rwlock-printers.c, tests-printers-libs): Define. * nptl/nptl-printers.py: New file. * nptl/nptl_lock_constants.pysym: Likewise. * nptl/test-cond-printers.c: Likewise. * nptl/test-cond-printers.py: Likewise. * nptl/test-condattr-printers.c: Likewise. * nptl/test-condattr-printers.py: Likewise. * nptl/test-mutex-printers.c: Likewise. * nptl/test-mutex-printers.py: Likewise. * nptl/test-mutexattr-printers.c: Likewise. * nptl/test-mutexattr-printers.py: Likewise. * nptl/test-rwlock-printers.c: Likewise. * nptl/test-rwlock-printers.py: Likewise. * nptl/test-rwlockattr-printers.c: Likewise. * nptl/test-rwlockattr-printers.py: Likewise. * scripts/gen-py-const.awk: Likewise. * scripts/test_printers_common.py: Likewise. * scripts/test_printers_exceptions.py: Likewise.
* Revert "Add pretty printers for the NPTL lock types"Siddhesh Poyarekar2016-07-111-118/+0
| | | | | | | | | | | | | | | | 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.
* Add pretty printers for the NPTL lock typesMartin Galvan2016-07-081-0/+118
This patch adds pretty printers for the following NPTL types: - pthread_mutex_t - pthread_mutexattr_t - pthread_cond_t - pthread_condattr_t - pthread_rwlock_t - pthread_rwlockattr_t To load the pretty printers into your gdb session, do the following: python import sys sys.path.insert(0, '/path/to/glibc/build/nptl/pretty-printers') end source /path/to/glibc/source/pretty-printers/nptl-printers.py 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. The printers are architecture-independent, and were manually tested on both the gdb CLI and Eclipse CDT. In order to work, the printers need to know the values of various flags that are scattered throughout pthread.h and pthreadP.h as enums and #defines. Since replicating these constants in the printers file itself would create a maintenance burden, I wrote a script called gen-py-const.awk that Makerules uses to extract the constants. This script is pretty much the same as gen-as-const.awk, except it doesn't cast the constant values to 'long' and is thorougly documented. The constants need only to be enumerated in a .pysym file, which is then referenced by a Make variable called gen-py-const-headers. As for the install directory, I discussed this with Mike Frysinger and Siddhesh Poyarekar, and we agreed that it can be handled in a separate patch, and it shouldn't block merging of this one. In addition, I've written a series of test cases for the pretty printers. Each lock type (mutex, condvar and rwlock) has two test programs, one for itself and other for its related 'attributes' object. Each test program in turn has a PExpect-based Python script that drives gdb and compares its output to the expected printer's. The tests run on the glibc host, which is assumed to have both gdb and PExpect; if either is absent the tests will fail with code 77 (UNSUPPORTED). For cross-testing you should use cross-test-ssh.sh as test-wrapper. I've tested the printers on both a native build and a cross build using a Beaglebone Black, with the build system's filesystem shared with the board through NFS. Finally, I've written a README that explains all this and more. Hopefully this should be good to go in now. Thanks. ChangeLog: 2016-07-04 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.