Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Remove VersionBlock struct for profiler attach (#20889)
Browse files Browse the repository at this point in the history
* Remove VersionBlock struct for profiler attach

* Change pipe/event names to not match the Desktop version pipe/event names
  • Loading branch information
sywhang committed Nov 10, 2018
1 parent dd6d2f8 commit 845fc29
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 210 deletions.
55 changes: 2 additions & 53 deletions src/vm/profattach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,6 @@ ProfilingAPIAttachDetach::AttachThreadingMode ProfilingAPIAttachDetach::s_attach
ProfilingAPIAttachDetach::kUninitialized;
BOOL ProfilingAPIAttachDetach::s_fInitializeCalled = FALSE;

// Both the trigger (via code:ProfilingAPIAttachClient) and the target profilee (via
// code:ProfilingAPIAttachServer) use this constant to identify their own version.
const VersionBlock ProfilingAPIAttachDetach::kCurrentProcessVersion(
CLR_MAJOR_VERSION,
CLR_MINOR_VERSION,
CLR_BUILD_VERSION,
CLR_BUILD_VERSION_QFE);

// Note that the following two VersionBlocks are initialized with static numerals rather
// than using the VER_* preproc defines, as we don't want these VersionBlocks to change
// on us from version to version unless we explicitly make a choice to begin breaking
// compatibility between triggers and profilees (and hopefully we won't need to do this
// ever!).

// A profilee compiled into this mscorwks.dll states that it can only interoperate with
// triggers (i.e., AttachProfiler() implementations (pipe clients)) whose runtime version
// is >= this constant.
//
// This value should not change as new runtimes are released unless
// code:ProfilingAPIAttachServer is modified to accept newer requests or send newer
// response messages in a way incompatible with older code:ProfilingAPIAttachClient
// objects implementing AttachProfiler(). And that is generally discouraged anyway.
const VersionBlock ProfilingAPIAttachDetach::kMinimumAllowableTriggerVersion(
4,
0,
0,
0);

// An AttachProfiler() implementation compiled into this mscorwks.dll, and called within
// a trigger process, can only interoperate with target profilee apps (pipe servers)
// whose runtime version is >= this constant.
//
// This value should not change as new runtimes are released unless
// code:ProfilingAPIAttachClient is modified to send newer request or interpret newer
// response messages in a way incompatible with older code:ProfilingAPIAttachServer
// objects implementing the pipe server. And that is generally discouraged anyway.
const VersionBlock ProfilingAPIAttachDetach::kMinimumAllowableProfileeVersion(
4,
0,
0,
0);


// ----------------------------------------------------------------------------
// ProfilingAPIAttachDetach::OverlappedResultHolder implementation. See
Expand Down Expand Up @@ -731,7 +689,6 @@ HRESULT ProfilingAPIAttachDetach::Initialize()
// Description:
// Debug-only function that asserts if there appear to be changes to structures that
// are not allowed to change (for backward-compatibility reasons). In particular:
// * VersionBlock must not change
// * BaseRequestMessage must not change
//

Expand All @@ -740,14 +697,6 @@ void ProfilingAPIAttachDetach::VerifyMessageStructureLayout()
{
LIMITED_METHOD_CONTRACT;

// If any of these asserts fire, then VersionBlock is changing its binary
// layout in an incompatible way. Bad!
_ASSERTE(sizeof(VersionBlock) == 16);
_ASSERTE(offsetof(VersionBlock, m_dwMajor) == 0);
_ASSERTE(offsetof(VersionBlock, m_dwMinor) == 4);
_ASSERTE(offsetof(VersionBlock, m_dwBuild) == 8);
_ASSERTE(offsetof(VersionBlock, m_dwQFE) == 12);

// If any of these asserts fire, then GetVersionRequestMessage is changing its binary
// layout in an incompatible way. Bad!
_ASSERTE(sizeof(GetVersionRequestMessage) == 8);
Expand All @@ -756,10 +705,10 @@ void ProfilingAPIAttachDetach::VerifyMessageStructureLayout()

// If any of these asserts fire, then GetVersionResponseMessage is changing its binary
// layout in an incompatible way. Bad!
_ASSERTE(sizeof(GetVersionResponseMessage) == 36);
_ASSERTE(sizeof(GetVersionResponseMessage) == 12);
_ASSERTE(offsetof(GetVersionResponseMessage, m_hr) == 0);
_ASSERTE(offsetof(GetVersionResponseMessage, m_profileeVersion) == 4);
_ASSERTE(offsetof(GetVersionResponseMessage, m_minimumAllowableTriggerVersion) == 20);
_ASSERTE(offsetof(GetVersionResponseMessage, m_minimumAllowableTriggerVersion) == 8);
}

#endif //_DEBUG
Expand Down
45 changes: 10 additions & 35 deletions src/vm/profattach.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,6 @@
#include "internalunknownimpl.h"
#include "corprof.h"

//---------------------------------------------------------------------------------------
// Structure representing the runtime's version. Used to negotiate versions between the
// trigger and profilee.
//
// **** COMPATIBILITY WARNING ***
//
// You are not allowed to change the binary layout of this structure, or else the
// trigger & profilee will be unable to negotiate version information. Asserts in
// code:ProfilingAPIAttachDetach::VerifyMessageStructureLayout attempt to enforce this.
//
// **** COMPATIBILITY WARNING ***
//
struct VersionBlock
{
public:
DWORD m_dwMajor;
DWORD m_dwMinor;
DWORD m_dwBuild;
DWORD m_dwQFE;

VersionBlock(DWORD dwMajor, DWORD dwMinor, DWORD dwBuild, DWORD dwQFE);
VersionBlock();
BOOL operator <(const VersionBlock & otherVersionBlock) const;
};


//---------------------------------------------------------------------------------------
// Types of request messages that may be sent from trigger across the pipe
Expand Down Expand Up @@ -120,7 +95,7 @@ struct AttachRequestMessage : public BaseRequestMessage
public:
// Trigger sends its version info here. This allows the target profilee to
// customize its response for the format expected by the trigger.
VersionBlock m_triggerVersion;
UINT m_triggerVersion;

// The GUID of the profiler's COM object to load
CLSID m_clsidProfiler;
Expand All @@ -144,7 +119,7 @@ struct AttachRequestMessage : public BaseRequestMessage

AttachRequestMessage(
DWORD cbMessage,
const VersionBlock & triggerVersion,
const UINT & triggerVersion,
const CLSID * pClsidProfiler,
LPCWSTR wszProfilerPath,
DWORD dwClientDataStartOffset,
Expand All @@ -170,7 +145,7 @@ public :
public :
AttachRequestMessageV2(
DWORD cbMessage,
const VersionBlock & triggerVersion,
const UINT & triggerVersion,
const CLSID * pClsidProfiler,
LPCWSTR wszProfilerPath,
DWORD dwClientDataStartOffset,
Expand Down Expand Up @@ -232,17 +207,17 @@ struct GetVersionResponseMessage : public BaseResponseMessage

// Target profilee provides its version info here. If trigger determines that
// this number is too small, then trigger refuses the profilee as being too old.
VersionBlock m_profileeVersion;
UINT m_profileeVersion;

// Target profilee provides here the oldest version of a trigger process that it
// can communicate with. If trigger determines that this number is too big,
// then trigger refuses the profilee as being too new.
VersionBlock m_minimumAllowableTriggerVersion;
UINT m_minimumAllowableTriggerVersion;

GetVersionResponseMessage(
HRESULT hr,
const VersionBlock & profileeVersion,
const VersionBlock & minimumAllowableTriggerVersion);
const UINT & profileeVersion,
const UINT & minimumAllowableTriggerVersion);

GetVersionResponseMessage();
};
Expand Down Expand Up @@ -313,9 +288,9 @@ class ProfilingAPIAttachDetach
DWORD * pcbReceived);
};

static const VersionBlock kCurrentProcessVersion;
static const VersionBlock kMinimumAllowableTriggerVersion;
static const VersionBlock kMinimumAllowableProfileeVersion;
static const UINT kCurrentProcessVersion = 1;
static const UINT kMinimumAllowableTriggerVersion = 1;
static const UINT kMinimumAllowableProfileeVersion = 1;

static DWORD WINAPI ProfilingAPIAttachThreadStart(LPVOID lpParameter);
static void ProcessSignaledAttachEvent();
Expand Down
Loading

0 comments on commit 845fc29

Please sign in to comment.