[all-commits] [llvm/llvm-project] e738a5: Reapply " [XRay] Add support for instrumentation o...
Sebastian Kreutzer via All-commits
all-commits at lists.llvm.org
Fri Oct 25 01:15:47 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e738a5d8e33911381dbd0e1bc5a0109e9ebb62f2
https://github.com/llvm/llvm-project/commit/e738a5d8e33911381dbd0e1bc5a0109e9ebb62f2
Author: Sebastian Kreutzer <SebastianKreutzer at gmx.net>
Date: 2024-10-25 (Fri, 25 Oct 2024)
Changed paths:
M clang/include/clang/Basic/CodeGenOptions.def
M clang/include/clang/Driver/Options.td
M clang/include/clang/Driver/XRayArgs.h
M clang/lib/Driver/ToolChains/CommonArgs.cpp
M clang/lib/Driver/XRayArgs.cpp
A clang/test/Driver/XRay/xray-shared.cpp
M compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
M compiler-rt/cmake/config-ix.cmake
M compiler-rt/include/xray/xray_interface.h
M compiler-rt/lib/xray/CMakeLists.txt
M compiler-rt/lib/xray/xray_AArch64.cpp
M compiler-rt/lib/xray/xray_arm.cpp
A compiler-rt/lib/xray/xray_dso_init.cpp
M compiler-rt/lib/xray/xray_hexagon.cpp
M compiler-rt/lib/xray/xray_init.cpp
M compiler-rt/lib/xray/xray_interface.cpp
M compiler-rt/lib/xray/xray_interface_internal.h
M compiler-rt/lib/xray/xray_loongarch64.cpp
M compiler-rt/lib/xray/xray_mips.cpp
M compiler-rt/lib/xray/xray_mips64.cpp
M compiler-rt/lib/xray/xray_powerpc64.cpp
M compiler-rt/lib/xray/xray_trampoline_x86_64.S
M compiler-rt/lib/xray/xray_x86_64.cpp
A compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
A compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp
A compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
A compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp
A compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
A compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp
Log Message:
-----------
Reapply " [XRay] Add support for instrumentation of DSOs on x86_64 (#90959)" (#113548)
This fixes remaining issues in my previous PR #90959.
Changes:
- Removed dependency on LLVM header in `xray_interface.cpp`
- Fixed XRay patching for some targets due to missing changes in
architecture-specific patching functions
- Addressed some remaining compiler warnings that I missed in the
previous patch
- Formatting
I have tested these changes on `x86_64` (natively), as well as
`ppc64le`, `aarch64` and `arm32` (cross-compiled and emulated using
qemu).
**Original description:**
This PR introduces shared library (DSO) support for XRay based on a
revised version of the implementation outlined in [this
RFC](https://discourse.llvm.org/t/rfc-upstreaming-dso-instrumentation-support-for-xray/73000).
The feature enables the patching and handling of events from DSOs,
supporting both libraries linked at startup or explicitly loaded, e.g.
via `dlopen`.
This patch adds the following:
- The `-fxray-shared` flag to enable the feature (turned off by default)
- A small runtime library that is linked into every instrumented DSO,
providing position-independent trampolines and code to register with the
main XRay runtime
- Changes to the XRay runtime to support management and patching of
multiple objects
These changes are fully backward compatible, i.e. running without
instrumented DSOs will produce identical traces (in terms of recorded
function IDs) to the previous implementation.
Due to my limited ability to test on other architectures, this feature
is only implemented and tested with x86_64. Extending support to other
architectures is fairly straightforward, requiring only a
position-independent implementation of the architecture-specific
trampoline implementation (see
`compiler-rt/lib/xray/xray_trampoline_x86_64.S` for reference).
This patch does not include any functionality to resolve function IDs
from DSOs for the provided logging/tracing modes. These modes still work
and will record calls from DSOs, but symbol resolution for these
functions in not available. Getting this to work properly requires
recording information about the loaded DSOs and should IMO be discussed
in a separate RFC, as there are mulitple feasible approaches.
---------
Co-authored-by: Sebastian Kreutzer <sebastian.kreutzer at tu-darmstadt.de>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list