summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/inc/clrconfigvalues.h1
-rw-r--r--src/vm/perfinfo.cpp4
-rw-r--r--src/vm/perfmap.cpp25
-rw-r--r--src/vm/perfmap.h7
4 files changed, 32 insertions, 5 deletions
diff --git a/src/inc/clrconfigvalues.h b/src/inc/clrconfigvalues.h
index a97e53d4f8..c034f4f689 100644
--- a/src/inc/clrconfigvalues.h
+++ b/src/inc/clrconfigvalues.h
@@ -565,6 +565,7 @@ RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ProfAPI_ValidateNGENInstrumentation, W("Pro
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapEnabled, W("PerfMapEnabled"), 0, "This flag is used on Linux to enable writing /tmp/perf-$pid.map. It is disabled by default", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapIgnoreSignal, W("PerfMapIgnoreSignal"), 0, "When perf map is enabled, this option will configure the specified signal to be accepted and ignored as a marker in the perf logs. It is disabled by default", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_PerfMapShowOptimizationTiers, W("PerfMapShowOptimizationTiers"), 1, "Shows optimization tiers in the perf map for methods, as part of the symbol name. Useful for seeing separate stack frames for different optimization tiers of each method.")
+RETAIL_CONFIG_STRING_INFO(EXTERNAL_NativeImagePerfMapFormat, W("NativeImagePerfMapFormat"), "Specifies the format of native image perfmap files generated by crossgen. Valid options are RVA or OFFSET.")
#endif
RETAIL_CONFIG_STRING_INFO(EXTERNAL_StartupDelayMS, W("StartupDelayMS"), "")
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.