[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
This commit is contained in:
Dean Michael Berris 2016-12-19 00:47:40 +00:00
parent 375aa90291
commit a53217d185

View File

@ -43,10 +43,8 @@ bool patchFunctionEntry(const bool Enable, const uint32_t FuncId,
int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionEntry) - int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionEntry) -
(static_cast<int64_t>(Sled.Address) + 11); (static_cast<int64_t>(Sled.Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Entry trampoline (%p) too far from sled (%p); distance = " Report("XRay Entry trampoline (%p) too far from sled (%p)\n",
"%ld\n", __xray_FunctionEntry, reinterpret_cast<void *>(Sled.Address));
__xray_FunctionEntry, reinterpret_cast<void *>(Sled.Address),
TrampolineOffset);
return false; return false;
} }
if (Enable) { if (Enable) {
@ -90,10 +88,8 @@ bool patchFunctionExit(const bool Enable, const uint32_t FuncId,
int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionExit) - int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionExit) -
(static_cast<int64_t>(Sled.Address) + 11); (static_cast<int64_t>(Sled.Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Exit trampoline (%p) too far from sled (%p); distance = " Report("XRay Exit trampoline (%p) too far from sled (%p)\n",
"%ld\n", __xray_FunctionExit, reinterpret_cast<void *>(Sled.Address));
__xray_FunctionExit, reinterpret_cast<void *>(Sled.Address),
TrampolineOffset);
return false; return false;
} }
if (Enable) { if (Enable) {
@ -120,10 +116,8 @@ bool patchFunctionTailExit(const bool Enable, const uint32_t FuncId,
reinterpret_cast<int64_t>(__xray_FunctionTailExit) - reinterpret_cast<int64_t>(__xray_FunctionTailExit) -
(static_cast<int64_t>(Sled.Address) + 11); (static_cast<int64_t>(Sled.Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) { if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Exit trampoline (%p) too far from sled (%p); distance = " Report("XRay Exit trampoline (%p) too far from sled (%p)\n",
"%ld\n", __xray_FunctionExit, reinterpret_cast<void *>(Sled.Address));
__xray_FunctionExit, reinterpret_cast<void *>(Sled.Address),
TrampolineOffset);
return false; return false;
} }
if (Enable) { if (Enable) {