summaryrefslogtreecommitdiff
path: root/test/xray
Commit message (Collapse)AuthorAgeFilesLines
* [XRay] Fixing one test case for FreeBSDDavid Carlier2019-08-281-0/+10
| | | | | | | | | | Reviewers: dberris Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D66867 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@370209 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for FreeBSD's LD_32_LIBRARY_PATHDimitry Andric2019-08-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Because the dynamic linker for 32-bit executables on 64-bit FreeBSD uses the environment variable `LD_32_LIBRARY_PATH` instead of `LD_LIBRARY_PATH` to find needed dynamic libraries, running the 32-bit parts of the dynamic ASan tests will fail with errors similar to: ``` ld-elf32.so.1: Shared object "libclang_rt.asan-i386.so" not found, required by "Asan-i386-inline-Dynamic-Test" ``` This adds support for setting up `LD_32_LIBRARY_PATH` for the unit and regression tests. It will likely also require a minor change to the `TestingConfig` class in `llvm/utils/lit/lit`. Reviewers: emaste, kcc, rnk, arichardson Reviewed By: arichardson Subscribers: kubamracek, krytarowski, fedor.sergeev, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65772 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@368516 91177308-0d34-0410-b5e6-96231b3b80d8
* compiler-rt: Rename .cc file in test/xray to .cppFangrui Song2019-08-0229-1/+1
| | | | | | | | | Like r367463, but for test/xray. Update test/xray/lit.cfg.py config.suffixes to remove .cc (we actually don't have .c tests now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367652 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.*Reid Kleckner2019-06-274-5/+5
| | | | | | | | | | | | | These lit configuration files are really Python source code. Using the .py file extension helps editors and tools use the correct language mode. LLVM and Clang already use this convention for lit configuration, this change simply applies it to all of compiler-rt. Reviewers: vitalybuka, dberris Differential Revision: https://reviews.llvm.org/D63658 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@364591 91177308-0d34-0410-b5e6-96231b3b80d8
* Add libc++ to link XRay test cases if libc++ is used to build CLANGXing Xue2019-05-061-1/+9
| | | | | | | | | | | | | | Summary: When libc++ is used to build CLANG, its XRay libraries libclang_rt.xray-*.a have dependencies on libc++. Therefore, libc++ is needed to link and run XRay test cases. For Linux -rpath is also needed to specify where to load libc++. This change sets macro LLVM_LIBCXX_USED to 1 if libc++ is actually used in the build. XRay tests then check the flag and add -L<llvm_shlib_dir> -lc++ and -Wl,-rpath=<llvm_shlib_dir> if needed. Reviewers: hubert.reinterpretcast, amyk, dberris, jasonliu, sfertile, EricWF Subscribers: dberris, mgorny, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61016 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@360060 91177308-0d34-0410-b5e6-96231b3b80d8
* Add header <atomic> which is needed to compile with some older library versions.Douglas Yung2018-11-211-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@347382 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Add a test for re-initialising FDR mode (NFC)Dean Michael Berris2018-11-211-0/+72
| | | | | | | This change adds an end-to-end test that ensures FDR mode can be re-initialised safely in the face of multiple threads being traced. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@347368 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Update XRayRecord to support Custom/Typed EventsDean Michael Berris2018-11-065-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change cuts across LLVM and compiler-rt to add support for rendering custom events in the XRayRecord type, to allow for including user-provided annotations in the output YAML (as raw bytes). This work enables us to add custom event and typed event records into the `llvm::xray::Trace` type for user-provided events. This can then be programmatically handled through the C++ API and can be included in some of the tooling as well. For now we support printing the raw data we encounter in the custom events in the converted output. Future work will allow us to start interpreting these custom and typed events through a yet-to-be-defined API for extending the trace analysis library. Reviewers: mboerger Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D54139 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@346214 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable XRay test fork_basic_logging for NetBSDKamil Rytarowski2018-11-061-0/+3
| | | | | | | This code has not been ported so far. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@346196 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Fix fdr-thread-order.cc when current directory contains ↵Fangrui Song2018-09-281-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fdr-thread-order.cc Summary: Currently, cd test/xray/TestCases/Posix $build/bin/llvm-lit fdr-thread-order.cc fails because `rm fdr-thread-order.*` deletes the .cc file. This patch uses: * %t as temporary directory name containing log files * %t.exe as executable name It does not delete %t after the test finishes for debugging convenience. This matches the behavior of tests of various other LLVM components. Log files will not clog up because the temporary directory (unique among test files but the same among multiple invocations of a test) is cleaned at the beginning of the test. Reviewers: dberris, mboerger, eizan Reviewed By: dberris Subscribers: delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D52638 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@343295 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Fix argv0-log-file-name.cc race when tests are executed parallellyFangrui Song2018-09-271-1/+1
| | | | | | | `rm xray-log.*` may delete log files of other tests and cause them to fail, when tests are executed parallelly. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@343282 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Add LD_LIBRARY_PATH to env variables for Unit TestsDean Michael Berris2018-09-271-0/+8
| | | | | | | | | | | | | | | | | Summary: This change allows us to use the library path from which the LLVM libraries are installed, in case the LLVM installation generates shared libraries. This should address llvm.org/PR39070. Reviewers: mboerger, eizan Subscribers: mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52597 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@343280 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Remove the unused variablePetr Hosek2018-09-151-2/+0
| | | | | | | This broke the fdr-single-thread test after FDRLoggingOptions struct has been removed in r342318. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342320 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Remove the deprecated __xray_log_init APIPetr Hosek2018-09-154-14/+3
| | | | | | | | | This API has been deprecated three months ago and shouldn't be used anymore, all clients should migrate to the new string based API. Differential Revision: https://reviews.llvm.org/D51606 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342318 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][clang] Emit "never-instrument" attributeDean Michael Berris2018-09-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | Summary: Before this change, we only emit the XRay attributes in LLVM IR when the -fxray-instrument flag is provided. This may cause issues with thinlto when the final binary is being built/linked with -fxray-instrument, and the constitutent LLVM IR gets re-lowered with xray instrumentation. With this change, we can honour the "never-instrument "attributes provided in the source code and preserve those in the IR. This way, even in thinlto builds, we retain the attributes which say whether functions should never be XRay instrumented. This change addresses llvm.org/PR38922. Reviewers: mboerger, eizan Subscribers: mehdi_amini, dexonsmith, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D52015 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342200 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Profiling Mode: Include file header in buffersDean Michael Berris2018-07-312-4/+8
| | | | | | | | | | | | | | | | | Summary: This change provides access to the file header even in the in-memory buffer processing. This allows in-memory processing of the buffers to also check the version, and the format, of the profile data. Reviewers: eizan, kpw Reviewed By: eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50037 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@338347 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay tests] Don't filter test-critical callsJeremy Morse2018-07-251-1/+1
| | | | | | | | | | | By default, xray filters events that takes less than 5uS from its log. In this existing test, should printf complete very quickly this will lead to test-critical function calls being filtered (i.e. print_parent_tid). Given that we're not testing the filtering feature, disable it for this test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337929 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply "[XRay] Remove scheduling dependency in fork_basic_logging.cc"Matthew Voss2018-07-231-4/+4
| | | | | | | | | | | | | | | | | | | | | Summary: Continuation of https://reviews.llvm.org/D49501 Second part of the test has an scheduling order when there shouldn't be. Reviewers: dberris, ormris Reviewed By: dberris, ormris Subscribers: TWeaver Differential Revision: https://reviews.llvm.org/D49559 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337745 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Profiling: No files when emptyDean Michael Berris2018-07-192-2/+2
| | | | | | | | | This change makes it so that the profiling mode implementation will only write files when there are buffers to write. Before this change, we'd always open a file even if there were no profiles collected when flushing. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337443 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove scheduling dependency from XRay :: Posix/fork_basic_logging.ccMatthew Voss2018-07-191-2/+2
| | | | | | | | | | | | | | | | | | | Summary: We've been seeing intermittent failures on our internal bots and we suspect this may be due to the OS scheduling the child process to run before the parent process. This version ensures that the parent and child can be run in either order. Reviewers: Maknee, dberris Reviewed By: dberris Subscribers: delcypher, #sanitizers, Maknee, llvm-commits Differential Revision: https://reviews.llvm.org/D49501 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337432 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] FDR Mode: Allow multiple runsDean Michael Berris2018-07-181-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix a bug in FDR mode which didn't allow for re-initialising the logging in the same process. This change ensures that: - When we flush the FDR mode logging, that the state of the logging implementation is `XRAY_LOG_UNINITIALIZED`. - Fix up the thread-local initialisation to use aligned storage and `pthread_getspecific` as well as `pthread_setspecific` for the thread-specific data. - Actually use the pointer provided to the thread-exit cleanup handling, instead of assuming that the thread has thread-local data associated with it, and reaching at thread-exit time. In this change we also have an explicit test for two consecutive sessions for FDR mode tracing, and ensuring both sessions succeed. Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49359 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337341 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Add PID field to llvm-xray tool and add PID metadata ↵Dean Michael Berris2018-07-134-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | record entry in FDR mode Summary: llvm-xray changes: - account-mode - process-id {...} shows after thread-id - convert-mode - process {...} shows after thread - parses FDR and basic mode pid entries - Checks version number for FDR log parsing. Basic logging changes: - Update header version from 2 -> 3 FDR logging changes: - Update header version from 2 -> 3 - in writeBufferPreamble, there is an additional PID Metadata record (after thread id record and tsc record) Test cases changes: - fdr-mode.cc, fdr-single-thread.cc, fdr-thread-order.cc modified to catch process id output in the log. Reviewers: dberris Reviewed By: dberris Subscribers: hiraditya, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49153 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336974 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Profiling Mode: Flush logs on exitDean Michael Berris2018-07-132-2/+2
| | | | | | | | | | | | | | | | | Summary: This change adds support for writing out profiles at program exit. Depends on D48653. Reviewers: kpw, eizan Reviewed By: kpw Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48956 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336969 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Fixup: require x86_64 for profiling mode testsDean Michael Berris2018-07-122-2/+4
| | | | | | | This constrains the build environments we are testing/supporting for the runtime tests until we can be sure xray works in more platforms. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336878 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] basic mode PID and TID always fetchDean Michael Berris2018-07-111-0/+100
| | | | | | | | | | | | | | Summary: XRayRecords now includes a PID field. Basic handlers fetch pid and tid each time they are called instead of caching the value. Added a testcase that calls fork and checks if the child TID is different from the parent TID to verify that the processes' TID are different in the trace. Reviewers: dberris, Maknee Reviewed By: dberris, Maknee Subscribers: kpw, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49025 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336769 91177308-0d34-0410-b5e6-96231b3b80d8
* [UBsan] Enable subset of unit tests for OpenBSDDavid Carlier2018-06-301-1/+1
| | | | | | | | | | | | Reviewers: kubamracek, krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D48805 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336053 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for multiarch runtimes layoutPetr Hosek2018-06-281-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This change adds a support for multiarch style runtimes layout, so in addition to the existing layout where runtimes get installed to: lib/clang/$version/lib/$os Clang now allows runtimes to be installed to: lib/clang/$version/$target/lib This also includes libc++, libc++abi and libunwind; today those are assumed to be in Clang library directory built for host, with the new layout it is possible to install libc++, libc++abi and libunwind into the runtime directory built for different targets. The use of new layout is enabled by setting the LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both projects and runtimes layouts. The runtimes CMake build has been further modified to use the new layout when building runtimes for multiple targets. Differential Revision: https://reviews.llvm.org/D45604 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335809 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] rm GLOB || true -> rm -fFangrui Song2018-06-1912-21/+21
| | | | | | | | | | | | Summary: `rm -f` does not write diagnostic message when there is no file argument. Reviewers: dberris Subscribers: delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D48311 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335025 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][profiler] Part 5: Profiler File WritingDean Michael Berris2018-06-122-10/+19
| | | | | | | | | | | | | | | | | | | | | | | Summary: This is part of the larger XRay Profiling Mode effort. This patch implements the profile writing mechanism, to allow profiles collected through the profiler mode to be persisted to files. Follow-on patches would allow us to load these profiles and start converting/analysing them through the `llvm-xray` tool. Depends on D44620. Reviewers: echristo, kpw, pelikan Reviewed By: kpw Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45998 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334472 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][profiler] Part 4: Profiler Mode WiringDean Michael Berris2018-06-123-1/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part of the larger XRay Profiling Mode effort. This patch implements the wiring required to enable us to actually select the `xray-profiling` mode, and install the handlers to start measuring the time and frequency of the function calls in call stacks. The current way to get the profile information is by working with the XRay API to `__xray_process_buffers(...)`. In subsequent changes we'll implement profile saving to files, similar to how the FDR and basic modes operate, as well as means for converting this format into those that can be loaded/visualised as flame graphs. We will also be extending the accounting tool in LLVM to support stack-based function call accounting. We also continue with the implementation to support building small histograms of latencies for the `FunctionCallTrie::Node` type, to allow us to actually approximate the distribution of latencies per function. Depends on D45758 and D46998. Reviewers: eizan, kpw, pelikan Reviewed By: kpw Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D44620 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334469 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Remove reliance on C++ ABI featuresDean Michael Berris2018-06-081-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes http://llvm.org/PR32274. This change adds a test to ensure that we're able to link XRay modes and the runtime to binaries that don't need to depend on the C++ standard library or a C++ ABI library. In particular, we ensure that this will work with C programs compiled+linked with XRay. To make the test pass, we need to change a few things in the XRay runtime implementations to remove the reliance on C++ ABI features. In particular, we change the thread-safe function-local-static initialisation to use pthread_* instead of the C++ features that ensure non-trivial thread-local/function-local-static initialisation. Depends on D47696. Reviewers: dblaikie, jfb, kpw, eizan Reviewed By: kpw Subscribers: echristo, eizan, kpw, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D46998 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334262 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay] Fix supposely failing test for FreeBSDDavid Carlier2018-06-011-1/+1
| | | | | | | | | | | | | | One test was marked as XFAIL for FreeBSD however still running when launching make check-xray Reviewers: krytarowski, vitalybuka Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D47622 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@333733 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Support in-memory processing of FDR mode logsDean Michael Berris2018-05-141-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change allows for handling the in-memory data associated with the FDR mode implementation through the new `__xray_log_process_buffers` API. With this change, we can now allow users to process the data in-memory of the process instead of through writing files. This for example allows users to stream the data of the FDR logging implementation through network sockets, or through other mechanisms instead of saving them to local files. We introduce an FDR-specific flag, for "no_file_flush" which lets the flushing logic skip opening/writing to files. This option can be defaulted to `true` when building the compiler-rt XRay runtime through the `XRAY_FDR_OPTIONS` preprocessor macro. Reviewers: kpw, echristo, pelikan, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46574 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332208 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Support string-based config for Basic mode.Dean Michael Berris2018-05-041-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This addresses http://llvm.org/PR36790. This change allows the XRay Basic Mode implementation to use the string-based initialization routine provided through `__xray_log_init_mode(...)`. In the process, we've also deprecated some flags defined for the `XRAY_OPTIONS` environment variable. We then introduce another environment variable that can control the XRay Basic Mode implementation through `XRAY_BASIC_OPTIONS`. We also rename files from `xray_inmemory_log` to `xray_basic_logging` to be more in line with the mode implementation. Depends on D46174. Reviewers: echristo, kpw, pelikan, eizan Reviewed By: kpw Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D46246 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331507 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Support string-based config for FDR modeDean Michael Berris2018-05-041-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | Summary: In this chage we add support for the string-based configuration mechanism for configuring FDR mode. We deprecate most of the `xray_fdr_log_*` flags that are set with the `XRAY_OPTIONS` environment variable. Instead we make the FDR implementation take defaults from the `XRAY_FDR_OPTIONS` environment variable, and use the flags defined in `xray_fdr_flags.{h,cc,inc}` for the options we support. This change addresses http://llvm.org/PR36790. Depends on D46173. Reviewers: eizan, pelikan, kpw, echristo Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D46174 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331506 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt+docs] Introduce __xray_log_init_mode(...).Dean Michael Berris2018-05-041-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This addresses http://llvm.org/PR36790. The change Deprecates a number of functions and types in `include/xray/xray_log_interface.h` to recommend using string-based configuration of XRay through the __xray_log_init_mode(...) function. In particular, this deprecates the following: - `__xray_set_log_impl(...)` -- users should instead use the `__xray_log_register_mode(...)` and `__xray_log_select_mode(...)` APIs. - `__xray_log_init(...)` -- users should instead use the `__xray_log_init_mode(...)` function, which also requires using the `__xray_log_register_mode(...)` and `__xray_log_select_mode(...)` functionality. - `__xray::FDRLoggingOptions` -- in following patches, we'll be migrating the FDR logging implementations (and tests) to use the string-based configuration. In later stages we'll remove the `__xray::FDRLoggingOptions` type, and ask users to migrate to using the string-based configuration mechanism instead. - `__xray::BasicLoggingOptions` -- same as `__xray::FDRLoggingOptions`, we'll be removing this type later and instead rely exclusively on the string-based configuration API. We also update the documentation to reflect the new advice and remove some of the deprecated notes. Reviewers: eizan, kpw, echristo, pelikan Reviewed By: kpw Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46173 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331503 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Add APIs for processing logs in memoryDean Michael Berris2018-03-071-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change adds APIs to allow logging implementations to provide a function for iterating through in-memory buffers (if they hold in-memory buffers) and a way for users to generically deal with these buffers in-process. These APIs are: - __xray_log_set_buffer_iterator(...) and __xray_log_remove_buffer_iterator(): installs and removes an iterator function that takes an XRayBuffer and yields the next one. - __xray_log_process_buffers(...): takes a function pointer that can take a mode identifier (string) and an XRayBuffer to process this data as they see fit. The intent is to have the FDR mode implementation's buffers be available through this `__xray_log_process_buffers(...)` API, so that they can be streamed from memory instead of flushed to disk (useful for getting the data to a network, or doing in-process analysis). Basic mode logging will not support this mechanism as it's designed to write the data mostly to disk. Future implementations will may depend on this API as well, to allow for programmatically working through the XRay buffers exposed to the users in some fashion. Reviewers: eizan, kpw, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43495 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@326866 91177308-0d34-0410-b5e6-96231b3b80d8
* Try to fix the syntax in testKamil Rytarowski2018-02-221-1/+1
| | | | | | | | | | | | | | | Reported on a buildbot: Error in XFAIL list: couldn't parse text: '| arm || aarch64 || mips' in expression: 'freebsd | arm || aarch64 || mips' Add || in the place of | Fallout from D43382 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325751 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove empty filesKamil Rytarowski2018-02-2220-0/+0
| | | | | | | Left over after D43382 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325744 91177308-0d34-0410-b5e6-96231b3b80d8
* Xray instrumentation / enabling more testsKamil Rytarowski2018-02-2241-907/+910
| | | | | | | | | | | | | | | | | Summary: The Unix subdirectory mostly allows only on Linux x86_64 but now we can target x86_64 arch in general. Patch by David CARLIER Reviewers: krytarowski, dberris, emaste Reviewed By: krytarowski, dberris, emaste Subscribers: emaste, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43382 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325743 91177308-0d34-0410-b5e6-96231b3b80d8
* Add initial XRay support for NetBSDKamil Rytarowski2018-02-161-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Reuse the existing FreeBSD code as it is. Sponsored by <The NetBSD Foundation> Reviewers: dberris, rnk, vitalybuka Reviewed By: dberris Subscribers: mclow.lists, emaste, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D43370 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325345 91177308-0d34-0410-b5e6-96231b3b80d8
* Reintroduce FreeBSD support in test/xrayKamil Rytarowski2018-02-161-3/+8
| | | | | | | | | | | Tested by Douglas Yung. The original patch from D43278 has been reverted. New patch by myself. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325315 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert part of SVN r. 325240 in lit.cfgKamil Rytarowski2018-02-161-9/+3
| | | | | | | | | | | | | | The original change broke a llvm-clang-lld-x86_64-debian setup. This change will be investigated and reintroduced in future. Original commit: "Add Xray instrumentation support to FreeBSD" https://reviews.llvm.org/D43278 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325309 91177308-0d34-0410-b5e6-96231b3b80d8
* Add Xray instrumentation support to FreeBSDKamil Rytarowski2018-02-151-3/+9
| | | | | | | | | | | | | | | | | | | | Summary: - Enabling the build. - Using assembly for the cpuid parts. - Using thr_self FreeBSD call to get the thread id Patch by: David CARLIER Reviewers: dberris, rnk, krytarowski Reviewed By: dberris, krytarowski Subscribers: emaste, stevecheckoway, nglevin, srhines, kubamracek, dberris, mgorny, krytarowski, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43278 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325240 91177308-0d34-0410-b5e6-96231b3b80d8
* [xray] Don't try to run XRay unit tests on DarwinKuba Mracek2018-01-281-5/+7
| | | | | | | | | | This gets rid of a lit warning (input './projects/compiler-rt/test/xray/Unit' contained no tests). Differential Revision: https://reviews.llvm.org/D42597 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@323613 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Coalesce calls to mprotect to reduce patching overheadDean Michael Berris2017-12-141-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this change, XRay would conservatively patch sections of the code one sled at a time. Upon testing/profiling, this turns out to take an inordinate amount of time and cycles. For an instrumented clang binary, the cycles spent both in the patching/unpatching routine constituted 4% of the cycles -- this didn't count the time spent in the kernel while performing the mprotect calls in quick succession. With this change, we're coalescing the number of calls to mprotect from being linear to the number of instrumentation points, to now being a lower constant when patching all the sleds through `__xray_patch()` or `__xray_unpatch()`. In the case of calling `__xray_patch_function()` or `__xray_unpatch_function()` we're now doing an mprotect call once for all the sleds for that function (reduction of at least 2x calls to mprotect). Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41153 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320664 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Implement XRay Basic Mode FilteringDean Michael Berris2017-12-051-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change implements the basic mode filtering similar to what we do in FDR mode. The implementation is slightly simpler in basic-mode filtering because we have less details to remember, but the idea is the same. At a high level, we do the following to decide when to filter function call records: - We maintain a per-thread "shadow stack" which keeps track of the XRay instrumented functions we've encountered in a thread's execution. - We push an entry onto the stack when we enter an XRay instrumented function, and note the CPU, TSC, and type of entry (whether we have payload or not when entering). - When we encounter an exit event, we determine whether the function being exited is the same function we've entered recently, was executing in the same CPU, and the delta of the recent TSC and the recorded TSC at the top of the stack is less than the equivalent amount of microseconds we're configured to ignore -- then we un-wind the record offset an appropriate number of times (so we can overwrite the records later). We also support limiting the stack depth of the recorded functions, so that we don't arbitrarily write deep function call stacks. Reviewers: eizan, pelikan, kpw, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40828 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319762 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Implement logging implementation registrationDean Michael Berris2017-12-051-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change allows for registration of multiple logging implementations through a central mechanism in XRay, mapping an implementation to a "mode". Modes are strings that are used as keys to determine which implementation to install through a single API. This mechanism allows users to choose which implementation to install either from the environment variable 'XRAY_OPTIONS' with the `xray_mode=` flag, or programmatically using the `__xray_select_mode(...)` function. Here, we introduce two API functions for the XRay logging: __xray_log_register_mode(Mode, Impl): Associates an XRayLogImpl to a string Mode. We can only have one implementation associated with a given Mode. __xray_log_select_mode(Mode): Finds the associated Impl for Mode and installs it as if by calling `__xray_set_log_impl(...)`. Along with these changes, we also deprecate the xray_naive_log and xray_fdr_log flags and encourage users to instead use the xray_mode flag. Reviewers: kpw, dblaikie, eizan, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40703 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319759 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt] Migrate basic mode logging to the XRay frameworkDean Michael Berris2017-11-212-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, XRay's basic (naive mode) logging would be initialised and installed in an adhoc manner. This patch ports the implementation of the basic (naive mode) logging implementation to use the common XRay framework. We also make the following changes to reduce the variance between the usage model of basic mode from FDR (flight data recorder) mode: - Allow programmatic control of the size of the buffers dedicated to per-thread records. This removes some hard-coded constants and turns them into runtime-controllable flags and through an Options structure. - Default the `xray_naive_log` option to false. For now, the only way to start basic mode is to set the environment variable, or set the default at build-time compiler options. Because of this change we've had to update a couple of tests relying on basic mode being always on. - Removed the reliance on a non-trivially destructible per-thread resource manager. We use a similar trick done in D39526 to use pthread_key_create() and pthread_setspecific() to ensure that the per-thread cleanup handling is performed at thread-exit time. We also radically simplify the code structure for basic mode, to move most of the implementation in the `__xray` namespace. Reviewers: pelikan, eizan, kpw Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40164 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318734 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][compiler-rt][x86_64] Align the stack before and after calling handlersDean Michael Berris2017-11-151-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This change fixes the XRay trampolines aside from the __xray_CustomEvent trampoline to align the stack to 16-byte boundaries before calling the handler. Before this change we've not been explicitly aligning the stack to 16-byte boundaries, which makes it dangerous when calling handlers that leave the stack in a state that isn't strictly 16-byte aligned after calling the handlers. We add a test that makes sure we can handle these cases appropriately after the changes, and prevents us from regressing the state moving forward. Fixes http://llvm.org/PR35294. Reviewers: pelikan, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40004 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318261 91177308-0d34-0410-b5e6-96231b3b80d8