Commit 3258b269 authored by pierre.langlois's avatar pierre.langlois Committed by Commit bot

[perf-prof] Adjust source position addresses according to ELF header size

The "perf inject" command will place the generated function into a .text
section, placed directly after the ELF header. As a result, source position
addresses need to be adjusted according to the size of the ELF header, which is
0x40 for 64 bit architectures and 0x34 on 32 bit architectures.

We would previously adjust the addresses with 0x40 regardless of the
architecture.

BUG=

Review-Url: https://codereview.chromium.org/2783203005
Cr-Commit-Position: refs/heads/master@{#44325}
parent a3be9e78
...@@ -322,13 +322,11 @@ void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) { ...@@ -322,13 +322,11 @@ void PerfJitLogger::LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared) {
SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle, SourcePositionInfo info(GetSourcePositionInfo(code_handle, function_handle,
iterator.source_position())); iterator.source_position()));
PerfJitDebugEntry entry; PerfJitDebugEntry entry;
// TODO(danno): There seems to be a bug in the dwarf handling of JIT code in // The entry point of the function will be placed straight after the ELF
// the perf tool. It seems to erroneously believe that the first instruction // header when processed by "perf inject". Adjust the position addresses
// of functions is at offset 0x40 when displayed in "perf report". To // accordingly.
// compensate for this, add a magic constant to the position addresses when entry.address_ = reinterpret_cast<intptr_t>(
// writing them out. code_start + iterator.code_offset() + kElfHeaderSize);
entry.address_ =
reinterpret_cast<intptr_t>(code_start + iterator.code_offset() + 0x40);
entry.line_number_ = info.line + 1; entry.line_number_ = info.line + 1;
entry.column_ = info.column + 1; entry.column_ = info.column + 1;
LogWriteBytes(reinterpret_cast<const char*>(&entry), sizeof(entry)); LogWriteBytes(reinterpret_cast<const char*>(&entry), sizeof(entry));
......
...@@ -91,6 +91,14 @@ class PerfJitLogger : public CodeEventLogger { ...@@ -91,6 +91,14 @@ class PerfJitLogger : public CodeEventLogger {
#endif #endif
} }
#if V8_TARGET_ARCH_32_BIT
static const int kElfHeaderSize = 0x34;
#elif V8_TARGET_ARCH_64_BIT
static const int kElfHeaderSize = 0x40;
#else
#error Unknown target architecture pointer size
#endif
// Per-process singleton file. We assume that there is one main isolate; // Per-process singleton file. We assume that there is one main isolate;
// to determine when it goes away, we keep reference count. // to determine when it goes away, we keep reference count.
static base::LazyRecursiveMutex file_mutex_; static base::LazyRecursiveMutex file_mutex_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment