summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorBrian Robbins <brianrob@microsoft.com>2019-08-29 10:06:48 -0700
committerGitHub <noreply@github.com>2019-08-29 10:06:48 -0700
commitb4dccce31967d39e3e1071816069f24c6523c17a (patch)
tree267374e835a8fa5078b7ee36b008d2dc4f82d3fc /src/vm
parent661e8d85b538329f325da552ed560cab03f4f40a (diff)
downloadcoreclr-b4dccce31967d39e3e1071816069f24c6523c17a.tar.gz
coreclr-b4dccce31967d39e3e1071816069f24c6523c17a.tar.bz2
coreclr-b4dccce31967d39e3e1071816069f24c6523c17a.zip
Emit RVA Instead of File Offset by Default in Native Image PerfMap Files (#26423)
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/perfinfo.cpp4
-rw-r--r--src/vm/perfmap.cpp25
-rw-r--r--src/vm/perfmap.h7
3 files changed, 31 insertions, 5 deletions
diff --git a/src/vm/perfinfo.cpp b/src/vm/perfinfo.cpp
index 3c8841b010..7075137010 100644
--- a/src/vm/perfinfo.cpp
+++ b/src/vm/perfinfo.cpp
@@ -41,7 +41,9 @@ void PerfInfo::LogImage(PEFile* pFile, WCHAR* guid)
SString value;
const SString& path = pFile->GetPath();
- value.Printf("%S%c%S", path.GetUnicode(), sDelimiter, guid);
+ PEImageLayout *pLoadedLayout = pFile->GetLoaded();
+ SIZE_T baseAddr = (SIZE_T)pLoadedLayout->GetBase();
+ value.Printf("%S%c%S%c%p", path.GetUnicode(), sDelimiter, guid, sDelimiter, baseAddr);
SString command;
command.Printf("%s", "ImageLoad");
diff --git a/src/vm/perfmap.cpp b/src/vm/perfmap.cpp
index ae2a5b07db..bc49bfef69 100644
--- a/src/vm/perfmap.cpp
+++ b/src/vm/perfmap.cpp
@@ -336,6 +336,14 @@ NativeImagePerfMap::NativeImagePerfMap(Assembly * pAssembly, BSTR pDestPath)
// Open the perf map file.
OpenFile(sDestPerfMapPath);
+
+ // Determine whether to emit RVAs or file offsets based on the specified configuration.
+ m_EmitRVAs = true;
+ CLRConfigStringHolder wszFormat(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_NativeImagePerfMapFormat));
+ if(wszFormat != NULL && (wcsncmp(wszFormat, strOFFSET, wcslen(strOFFSET)) == 0))
+ {
+ m_EmitRVAs = false;
+ }
}
// Log data to the perfmap for the specified module.
@@ -371,7 +379,7 @@ void NativeImagePerfMap::LogDataForModule(Module * pModule)
}
// Log a pre-compiled method to the perfmap.
-void NativeImagePerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode, PEImageLayout * pLoadedLayout, const char *optimizationTier)
+void NativeImagePerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode, PEImageLayout *pLoadedLayout, const char *optimizationTier)
{
STANDARD_VM_CONTRACT;
@@ -387,14 +395,25 @@ void NativeImagePerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode,
// NGEN can split code between hot and cold sections which are separate in memory.
// Emit an entry for each section if it is used.
+ PCODE addr;
if (methodRegionInfo.hotSize > 0)
{
- LogMethod(pMethod, pLoadedLayout->RvaToOffset((PCODE)methodRegionInfo.hotStartAddress - baseAddr), methodRegionInfo.hotSize, optimizationTier);
+ addr = (PCODE)methodRegionInfo.hotStartAddress - baseAddr;
+ if (!m_EmitRVAs)
+ {
+ addr = pLoadedLayout->RvaToOffset(addr);
+ }
+ LogMethod(pMethod, addr, methodRegionInfo.hotSize, optimizationTier);
}
if (methodRegionInfo.coldSize > 0)
{
- LogMethod(pMethod, pLoadedLayout->RvaToOffset((PCODE)methodRegionInfo.coldStartAddress - baseAddr), methodRegionInfo.coldSize, optimizationTier);
+ addr = (PCODE)methodRegionInfo.coldStartAddress - baseAddr;
+ if (!m_EmitRVAs)
+ {
+ addr = pLoadedLayout->RvaToOffset(addr);
+ }
+ LogMethod(pMethod, addr, methodRegionInfo.coldSize, optimizationTier);
}
}
diff --git a/src/vm/perfmap.h b/src/vm/perfmap.h
index 22d8452347..5788dcc60a 100644
--- a/src/vm/perfmap.h
+++ b/src/vm/perfmap.h
@@ -81,8 +81,13 @@ public:
class NativeImagePerfMap : PerfMap
{
private:
+ const WCHAR *strOFFSET = W("OFFSET");
+
+ // Specify the address format since it's now possible for 'perf script' to output file offsets or RVAs.
+ bool m_EmitRVAs;
+
// Log a pre-compiled method to the map.
- void LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode, PEImageLayout * pLoadedLayout, const char *optimizationTier);
+ void LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode, PEImageLayout *pLoadedLayout, const char *optimizationTier);
public:
// Construct a new map for a native image.