From d995abf704e92034296a9553994c36219a3e095e Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Mon, 9 Oct 2023 09:41:38 -0700 Subject: [PATCH 1/3] Make a copy of assembly path. --- src/coreclr/vm/perfinfo.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/perfinfo.cpp b/src/coreclr/vm/perfinfo.cpp index 0be2e519936fbe..2ab369990fe870 100644 --- a/src/coreclr/vm/perfinfo.cpp +++ b/src/coreclr/vm/perfinfo.cpp @@ -32,8 +32,8 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid) PRECONDITION(guid != nullptr); } CONTRACTL_END; - SString value; - const SString& path = pPEAssembly->GetPath(); + // Nothing to log if the assembly path isn't present. + SString path = pPEAssembly->GetPath(); if (path.IsEmpty()) { return; @@ -49,12 +49,10 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid) } } + SString value; value.Printf("%s%c%s%c%p", path.GetUTF8(), sDelimiter, guid, sDelimiter, baseAddr); - SString command; - command.Printf("%s", "ImageLoad"); - WriteLine(command, value); - + WriteLine(SL("ImageLoad"), 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 From a38c3d8069adf96a74873606d9e010c441fb2f8c Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Mon, 9 Oct 2023 10:02:23 -0700 Subject: [PATCH 2/3] Use correct C++. --- src/coreclr/vm/perfinfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/perfinfo.cpp b/src/coreclr/vm/perfinfo.cpp index 2ab369990fe870..2cfcfba02ed211 100644 --- a/src/coreclr/vm/perfinfo.cpp +++ b/src/coreclr/vm/perfinfo.cpp @@ -52,7 +52,8 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid) SString value; value.Printf("%s%c%s%c%p", path.GetUTF8(), sDelimiter, guid, sDelimiter, baseAddr); - WriteLine(SL("ImageLoad"), value); + SString command{ SString::Literal, "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 From 2f84988ae4c75f3156e25262348d44d822867b10 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Mon, 9 Oct 2023 10:15:54 -0700 Subject: [PATCH 3/3] Use copy ctor explicitly --- src/coreclr/vm/perfinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/perfinfo.cpp b/src/coreclr/vm/perfinfo.cpp index 2cfcfba02ed211..98fc667661a504 100644 --- a/src/coreclr/vm/perfinfo.cpp +++ b/src/coreclr/vm/perfinfo.cpp @@ -33,7 +33,7 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid) } CONTRACTL_END; // Nothing to log if the assembly path isn't present. - SString path = pPEAssembly->GetPath(); + SString path{ pPEAssembly->GetPath() }; if (path.IsEmpty()) { return;