[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)
Jan Patrick Lehr via cfe-commits
cfe-commits at lists.llvm.org
Fri May 3 12:26:01 PDT 2024
================
@@ -50,14 +52,72 @@ atomic_uint8_t XRayInitialized{0};
// This should always be updated before XRayInitialized is updated.
SpinMutex XRayInstrMapMutex;
-XRaySledMap XRayInstrMap;
+// XRaySledMap XRayInstrMap;
+// Contains maps for the main executable as well as DSOs.
+// std::vector<XRaySledMap> XRayInstrMaps;
+XRaySledMap *XRayInstrMaps;
+atomic_uint32_t XRayNumObjects;
// Global flag to determine whether the flags have been initialized.
atomic_uint8_t XRayFlagsInitialized{0};
// A mutex to allow only one thread to initialize the XRay data structures.
SpinMutex XRayInitMutex;
+int32_t
+__xray_register_sleds(const XRaySledEntry *SledsBegin,
+ const XRaySledEntry *SledsEnd,
+ const XRayFunctionSledIndex *FnIndexBegin,
+ const XRayFunctionSledIndex *FnIndexEnd, bool FromDSO,
+ XRayTrampolines Trampolines) XRAY_NEVER_INSTRUMENT {
+ if (!SledsBegin || !SledsEnd) {
+ return -1;
+ }
+ XRaySledMap SledMap;
+ SledMap.FromDSO = FromDSO;
+ SledMap.Loaded = true;
+ SledMap.Trampolines = Trampolines;
+ SledMap.Sleds = SledsBegin;
+ SledMap.Entries = SledsEnd - SledsBegin;
+ if (FnIndexBegin != nullptr) {
+ SledMap.SledsIndex = FnIndexBegin;
+ SledMap.Functions = FnIndexEnd - FnIndexBegin;
+ } else {
+ size_t CountFunctions = 0;
+ uint64_t LastFnAddr = 0;
+
+ for (std::size_t I = 0; I < SledMap.Entries; I++) {
+ const auto &Sled = SledMap.Sleds[I];
+ const auto Function = Sled.function();
+ if (Function != LastFnAddr) {
+ CountFunctions++;
+ LastFnAddr = Function;
+ }
+ }
+
+ SledMap.Functions = CountFunctions;
+ }
+ if (SledMap.Functions >= XRayMaxFunctions) {
+ Report("Too many functions! Maximum is %ld\n", XRayMaxFunctions);
+ return -1;
+ }
+
+ if (Verbosity()) {
----------------
jplehr wrote:
No curly here
https://github.com/llvm/llvm-project/pull/90959
More information about the cfe-commits
mailing list