Skip to content

Commit

Permalink
PR feedback + unnecessary code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktork committed Nov 10, 2021
1 parent 3567a66 commit ef32601
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/InstrumentationEngine.Lib/InstrumentationEngineFeatures.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#pragma once

namespace MicrosoftInstrumentationEngine
Expand Down
1 change: 0 additions & 1 deletion src/InstrumentationEngine/ExceptionSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ MicrosoftInstrumentationEngine::CExceptionSection::~CExceptionSection()

HRESULT MicrosoftInstrumentationEngine::CExceptionSection::Initialize(
_In_ const IMAGE_COR_ILMETHOD* pMethodHeader,
_In_ ULONG cbMethodSize,
_In_ CInstructionGraph* pInstructionGraph
)
{
Expand Down
1 change: 0 additions & 1 deletion src/InstrumentationEngine/ExceptionSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace MicrosoftInstrumentationEngine
// body and not directly from the method info.
HRESULT Initialize(
_In_ const IMAGE_COR_ILMETHOD* pMethodHeader,
_In_ ULONG cbMethodSize,
_In_ CInstructionGraph* pInstructionGraph
);

Expand Down
15 changes: 2 additions & 13 deletions src/InstrumentationEngine/MethodInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::InitializeInstructionsAndEx
// because during the diagnostic dumping logic, the graph will be from the rendered function
// body and not directly from the method info.
m_pExceptionSection.Attach(new CExceptionSection(this));
IfFailRet(m_pExceptionSection->Initialize(pMethodHeader, cbMethodSize, m_pInstructionGraph));
IfFailRet(m_pExceptionSection->Initialize(pMethodHeader, m_pInstructionGraph));

// Convert branches to the larger form, this also calculates the current offsets for instructions
// NOTE: this must be done after the exception sections are initialized as they depend on the original
Expand Down Expand Up @@ -1924,7 +1924,6 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::GetInstrumentationResults(
IfFailRet(GetFinalInstrumentation(&cbMethodBody, &pbMethodBody));

IMAGE_COR_ILMETHOD* pMethodHeader = (IMAGE_COR_ILMETHOD*)(pbMethodBody);
ULONG cbMethodSize = cbMethodBody;

LPCBYTE pMethodBody;
ULONG codeSize = 0;
Expand All @@ -1934,21 +1933,11 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::GetInstrumentationResults(
pMethodBody = (LPCBYTE) pMethodHeader + sizeof (IMAGE_COR_ILMETHOD_TINY);
codeSize = ((COR_ILMETHOD_TINY*)pMethodHeader)->GetCodeSize();

//If a custom buffer was used by the raw profiler, we will not have the size of the
//final instrumentation memory. Attempt to compute it.
if (cbMethodSize == 0)
{
cbMethodSize = codeSize + sizeof(IMAGE_COR_ILMETHOD_TINY);
}
}
else
{
pMethodBody = (LPCBYTE)pMethodHeader + sizeof(IMAGE_COR_ILMETHOD_FAT);
codeSize = ((COR_ILMETHOD_FAT*)pMethodHeader)->GetCodeSize();
if (cbMethodSize == 0)
{
cbMethodSize = codeSize + sizeof(COR_ILMETHOD_FAT);
}
}

LPCBYTE pMethodEnd = pMethodBody + codeSize;
Expand All @@ -1965,7 +1954,7 @@ HRESULT MicrosoftInstrumentationEngine::CMethodInfo::GetInstrumentationResults(
// body and not directly from the method info.
CComPtr<CExceptionSection> pExceptionSection;
pExceptionSection.Attach(new CExceptionSection(this));
IfFailRet(pExceptionSection->Initialize(pMethodHeader, cbMethodSize, pInstructionGraph));
IfFailRet(pExceptionSection->Initialize(pMethodHeader, pInstructionGraph));

*ppInstructionGraph = pInstructionGraph.Detach();
*ppExceptionSection = pExceptionSection.Detach();
Expand Down

0 comments on commit ef32601

Please sign in to comment.