forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotnet#4068 from Lucrecious/master
Generate map files for symbol resolution for Linux native images on PerfView
- Loading branch information
Showing
7 changed files
with
200 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// =========================================================================== | ||
// File: perfinfo.cpp | ||
// | ||
|
||
#include "common.h" | ||
|
||
#if defined(FEATURE_PERFMAP) && !defined(DACCESS_COMPILE) | ||
#include "perfinfo.h" | ||
#include "pal.h" | ||
|
||
PerfInfo::PerfInfo(int pid) | ||
{ | ||
LIMITED_METHOD_CONTRACT; | ||
|
||
SString tempPath; | ||
if (!WszGetTempPath(tempPath)) | ||
{ | ||
return; | ||
} | ||
|
||
SString path; | ||
path.Printf("%Sperfinfo-%d.map", tempPath.GetUnicode(), pid); | ||
OpenFile(path); | ||
} | ||
|
||
// Logs image loads into the process' perfinfo-%d.map file | ||
void PerfInfo::LogImage(PEFile* pFile, WCHAR* guid) | ||
{ | ||
CONTRACTL | ||
{ | ||
THROWS; | ||
GC_NOTRIGGER; | ||
MODE_PREEMPTIVE; | ||
PRECONDITION(pFile != NULL); | ||
PRECONDITION(guid != NULL); | ||
} CONTRACTL_END; | ||
|
||
SString value; | ||
const SString& path = pFile->GetPath(); | ||
value.Printf("%S%c%S", path.GetUnicode(), sDelimiter, guid); | ||
|
||
SString command; | ||
command.Printf("%s", "ImageLoad"); | ||
WriteLine(command, value); | ||
|
||
} | ||
|
||
// Writes a command line, with "type" being the type of command, with "value" as the command's corresponding instructions/values. This is to be used to log specific information, e.g. LogImage | ||
void PerfInfo::WriteLine(SString& type, SString& value) | ||
{ | ||
|
||
CONTRACTL | ||
{ | ||
THROWS; | ||
GC_NOTRIGGER; | ||
MODE_PREEMPTIVE; | ||
} CONTRACTL_END; | ||
|
||
if (m_Stream == NULL) | ||
{ | ||
return; | ||
} | ||
|
||
SString line; | ||
line.Printf("%S%c%S%c\n", | ||
type.GetUnicode(), sDelimiter, value.GetUnicode(), sDelimiter); | ||
|
||
EX_TRY | ||
{ | ||
StackScratchBuffer scratch; | ||
const char* strLine = line.GetANSI(scratch); | ||
ULONG inCount = line.GetCount(); | ||
ULONG outCount; | ||
|
||
m_Stream->Write(strLine, inCount, &outCount); | ||
|
||
if (inCount != outCount) | ||
{ | ||
// error encountered | ||
} | ||
} | ||
EX_CATCH{} EX_END_CATCH(SwallowAllExceptions); | ||
} | ||
|
||
// Opens a file ready to be written in. | ||
void PerfInfo::OpenFile(SString& path) | ||
{ | ||
STANDARD_VM_CONTRACT; | ||
|
||
m_Stream = new (nothrow) CFileStream(); | ||
|
||
if (m_Stream != NULL) | ||
{ | ||
HRESULT hr = m_Stream->OpenForWrite(path.GetUnicode()); | ||
if (FAILED(hr)) | ||
{ | ||
delete m_Stream; | ||
m_Stream = NULL; | ||
} | ||
} | ||
} | ||
|
||
PerfInfo::~PerfInfo() | ||
{ | ||
LIMITED_METHOD_CONTRACT; | ||
|
||
delete m_Stream; | ||
m_Stream = NULL; | ||
} | ||
|
||
|
||
#endif | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
// =========================================================================== | ||
// File: perfinfo.h | ||
// | ||
|
||
#ifndef PERFINFO_H | ||
#define PERFINFO_H | ||
|
||
|
||
#include "sstring.h" | ||
#include "fstream.h" | ||
|
||
/* | ||
A perfinfo-%d.map is created for every process that is created with manage code, the %d | ||
being repaced with the process ID. | ||
Every line in the perfinfo-%d.map is a type and value, separated by sDelimiter character: type;value | ||
type represents what the user might want to do with its given value. value has a format chosen by | ||
the user for parsing later on. | ||
*/ | ||
class PerfInfo { | ||
public: | ||
PerfInfo(int pid); | ||
~PerfInfo(); | ||
void LogImage(PEFile* pFile, WCHAR* guid); | ||
|
||
private: | ||
CFileStream* m_Stream; | ||
|
||
const char sDelimiter = ';'; | ||
|
||
void OpenFile(SString& path); | ||
|
||
void WriteLine(SString& type, SString& value); | ||
|
||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters