From a53217d185adb428a8ad91e0b720d68a60a7916f Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 19 Dec 2016 00:47:40 +0000 Subject: [PATCH] [XRay] [compiler-rt] Fix format string; sanitizers' internal printf() doesn't support %ld. Summary: Getting rid of the distance number altogether because: - a person knowledgeable enough to know what the message means will also know how to do hexadecimal math (with the help of a calculator) - numbers outside INT_MIN - INT_MAX are hard to comprehend anyway This unbreaks the case when you dynamically link a library with XRay and it exits pre-main() with a not very informative static string. Author: pelikan Reviewers: dberris Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27894 llvm-svn: 290074 --- compiler-rt/lib/xray/xray_x86_64.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler-rt/lib/xray/xray_x86_64.cc b/compiler-rt/lib/xray/xray_x86_64.cc index 092e06db9694..09ca34c0db38 100644 --- a/compiler-rt/lib/xray/xray_x86_64.cc +++ b/compiler-rt/lib/xray/xray_x86_64.cc @@ -43,10 +43,8 @@ bool patchFunctionEntry(const bool Enable, const uint32_t FuncId, int64_t TrampolineOffset = reinterpret_cast(__xray_FunctionEntry) - (static_cast(Sled.Address) + 11); if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { - Report("XRay Entry trampoline (%p) too far from sled (%p); distance = " - "%ld\n", - __xray_FunctionEntry, reinterpret_cast(Sled.Address), - TrampolineOffset); + Report("XRay Entry trampoline (%p) too far from sled (%p)\n", + __xray_FunctionEntry, reinterpret_cast(Sled.Address)); return false; } if (Enable) { @@ -90,10 +88,8 @@ bool patchFunctionExit(const bool Enable, const uint32_t FuncId, int64_t TrampolineOffset = reinterpret_cast(__xray_FunctionExit) - (static_cast(Sled.Address) + 11); if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { - Report("XRay Exit trampoline (%p) too far from sled (%p); distance = " - "%ld\n", - __xray_FunctionExit, reinterpret_cast(Sled.Address), - TrampolineOffset); + Report("XRay Exit trampoline (%p) too far from sled (%p)\n", + __xray_FunctionExit, reinterpret_cast(Sled.Address)); return false; } if (Enable) { @@ -120,10 +116,8 @@ bool patchFunctionTailExit(const bool Enable, const uint32_t FuncId, reinterpret_cast(__xray_FunctionTailExit) - (static_cast(Sled.Address) + 11); if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { - Report("XRay Exit trampoline (%p) too far from sled (%p); distance = " - "%ld\n", - __xray_FunctionExit, reinterpret_cast(Sled.Address), - TrampolineOffset); + Report("XRay Exit trampoline (%p) too far from sled (%p)\n", + __xray_FunctionExit, reinterpret_cast(Sled.Address)); return false; } if (Enable) {