[all-commits] [llvm/llvm-project] a44020: [XRay] Add support for instrumentation of DSOs on ...
Sebastian Kreutzer via All-commits
all-commits at lists.llvm.org
Fri Oct 11 02:23:57 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a4402039bffd788b9af82435fd5a2fb311fdc6e8
https://github.com/llvm/llvm-project/commit/a4402039bffd788b9af82435fd5a2fb311fdc6e8
Author: Sebastian Kreutzer <SebastianKreutzer at gmx.net>
Date: 2024-10-11 (Fri, 11 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
A compiler-rt/lib/xray/xray_dso_init.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_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:
-----------
[XRay] Add support for instrumentation of DSOs on x86_64 (#90959)
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.
@petrhosek @jplehr
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