From c5caf3e9c6ee19fc23555c50bbc27b7f242587a0 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 21 Aug 2017 00:14:06 +0000 Subject: [PATCH] [XRay][tools] Support new kinds of instrumentation map entries Summary: When extracting the instrumentation map from a binary, we should be able to recognize the new kinds of instrumentation sleds we've been emitting with the compiler using -fxray-instrument. This change adds a test for all the kinds of sleds we currently support (sans the tail-call sled, which is a bit harder to force in a simple prebuilt input). Reviewers: kpw, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36819 llvm-svn: 311305 --- llvm/include/llvm/XRay/InstrumentationMap.h | 6 +++++- llvm/lib/XRay/InstrumentationMap.cpp | 3 ++- llvm/test/tools/llvm-xray/X86/Inputs/all-sleds.o | Bin 0 -> 2640 bytes .../llvm-xray/X86/extract-all-sledtypes.txt | 11 +++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 llvm/test/tools/llvm-xray/X86/Inputs/all-sleds.o create mode 100644 llvm/test/tools/llvm-xray/X86/extract-all-sledtypes.txt diff --git a/llvm/include/llvm/XRay/InstrumentationMap.h b/llvm/include/llvm/XRay/InstrumentationMap.h index 0342da0a2f0fa..42bfca36a20bc 100644 --- a/llvm/include/llvm/XRay/InstrumentationMap.h +++ b/llvm/include/llvm/XRay/InstrumentationMap.h @@ -38,7 +38,7 @@ Expected loadInstrumentationMap(StringRef Filename); struct SledEntry { /// Each entry here represents the kinds of supported instrumentation map /// entries. - enum class FunctionKinds { ENTRY, EXIT, TAIL }; + enum class FunctionKinds { ENTRY, EXIT, TAIL, LOG_ARGS_ENTER, CUSTOM_EVENT }; /// The address of the sled. uint64_t Address; @@ -106,6 +106,10 @@ template <> struct ScalarEnumerationTraits { IO.enumCase(Kind, "function-enter", xray::SledEntry::FunctionKinds::ENTRY); IO.enumCase(Kind, "function-exit", xray::SledEntry::FunctionKinds::EXIT); IO.enumCase(Kind, "tail-exit", xray::SledEntry::FunctionKinds::TAIL); + IO.enumCase(Kind, "log-args-enter", + xray::SledEntry::FunctionKinds::LOG_ARGS_ENTER); + IO.enumCase(Kind, "custom-event", + xray::SledEntry::FunctionKinds::CUSTOM_EVENT); } }; diff --git a/llvm/lib/XRay/InstrumentationMap.cpp b/llvm/lib/XRay/InstrumentationMap.cpp index d9ce255bc6887..a7d6600b0d8ab 100644 --- a/llvm/lib/XRay/InstrumentationMap.cpp +++ b/llvm/lib/XRay/InstrumentationMap.cpp @@ -104,7 +104,8 @@ loadELF64(StringRef Filename, object::OwningBinary &ObjFile, static constexpr SledEntry::FunctionKinds Kinds[] = { SledEntry::FunctionKinds::ENTRY, SledEntry::FunctionKinds::EXIT, SledEntry::FunctionKinds::TAIL, - }; + SledEntry::FunctionKinds::LOG_ARGS_ENTER, + SledEntry::FunctionKinds::CUSTOM_EVENT}; if (Kind >= sizeof(Kinds)) return errorCodeToError( std::make_error_code(std::errc::executable_format_error)); diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/all-sleds.o b/llvm/test/tools/llvm-xray/X86/Inputs/all-sleds.o new file mode 100644 index 0000000000000000000000000000000000000000..d36d2bb82264886879ffc4b94a9c2ff734c2562e GIT binary patch literal 2640 zcmbtVO=uHQ5PoT@ZPETvJO~xKAVPZRnj+Q~MS``uhayF66-C!I*|epbP04Q4L@X8& zY3QZLf)|e-JyyIFJSYm{&7-}Df{1$SL8vpEnPhmZ_RxXNy!qyPGxKI=UmlK6Txv-q z6iY&#S51pir9K{Pt~1dxqq>0ky(8b<|5&LOrKYUfm)oz+hTYwNQR#lGw!CAlE$>KP z9>k1-KwK@JwaIB;cA~fYx>b8KZPh+}L;Q{{<1n+KpA|6QFcqgT+ug%&9s>|QekP)pEphorAO1J2aJ^G zl?x{YHavjgk5G=p{i`Zb=}Gh*ZfjqM1|0?b82S28PjvM>X&LLpaY5e*Vj#!yNBD5h zHN-&9;*ap5`7e0~j#l-1SNA^!AfehDFis0g5~njpk`O6Qk|GZKdtuQFaV80fYKAp7 z2XU6D2Vh(v+#pAEepugvr-v}995Qg`4hTn;)|jCKoY2ci@00yp;F7;3aOAI$ z{Z`t{Jf3&styZ)iC8 zQ<){#b1EgLYUh1>E>}_Z&7m_{$MXWaem6u{LmA;w$6Io$fj#F3@ckFy#&C1!81afT zwo{r3Cd>73X6RNzW!q8MvFL^wk1iN9TP)x{ku?ft7n}uU`o+*SFJGA&3_>S64}oJV z86TdXcDzNGQn|BszT^~K1tkv#o|_BIY*v|2Vd&fgT`feqRLnV{LrvI+`UHDrzd6)4 zeUv{LAdT-$$`lxg>9ds~(i&-2JV$Kfdz16W_$n2ZCIIg@oB^Isp1TKtVg5((NO@1j zHfh|8qSwC!SX};1%0EdPFhBD2{CMuT{4Z!9*U$O&^CK-Te>?Sm9sDSmA9LyXzXFCa zI6f>R*{1yRe*ql?*Gce;_X=WMCp&%+k?%Fec|U7>zr1D+>JxfF