Skip to content

Commit

Permalink
Merge pull request dotnet#6974 from swaroop-sridhar/gc86
Browse files Browse the repository at this point in the history
Implement GcInfo v2 for X86
  • Loading branch information
swaroop-sridhar authored Sep 14, 2016
2 parents fb4574c + 4871121 commit f4b86dd
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 435 deletions.
8 changes: 5 additions & 3 deletions src/debug/daccess/nidump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,7 @@ void NativeImageDumper::DumpCompleteMethod(PTR_Module module, MethodIterator& mi
#ifdef _TARGET_X86_
InfoHdr hdr;
stringOutFn( "method info Block:\n" );
curGCInfoPtr += gcDump.DumpInfoHdr(PTR_CBYTE(gcInfoToken.Info), &hdr, &methodSize, 0);
curGCInfoPtr += gcDump.DumpInfoHdr(curGCInfoPtr, &hdr, &methodSize, 0);
stringOutFn( "\n" );
#endif

Expand Down Expand Up @@ -9439,10 +9439,12 @@ void NativeImageDumper::DumpReadyToRunMethod(PCODE pEntryPoint, PTR_RUNTIME_FUNC
g_holdStringOutData.Clear();
GCDump gcDump(GCINFO_VERSION);
gcDump.gcPrintf = stringOutFn;
#if !defined(_TARGET_X86_) && defined(USE_GC_INFO_DECODER)
UINT32 r2rversion = m_pReadyToRunHeader->MajorVersion;
UINT32 gcInfoVersion = GCInfoToken::ReadyToRunVersionToGcInfoVersion(r2rversion);
GcInfoDecoder gcInfoDecoder({ curGCInfoPtr, gcInfoVersion }, DECODE_CODE_LENGTH);
GCInfoToken gcInfoToken = { curGCInfoPtr, gcInfoVersion };

#if !defined(_TARGET_X86_) && defined(USE_GC_INFO_DECODER)
GcInfoDecoder gcInfoDecoder(gcInfoToken, DECODE_CODE_LENGTH);
methodSize = gcInfoDecoder.GetCodeLength();
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gcdump/gcdumpnonx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ size_t GCDump::DumpGCTable(PTR_CBYTE gcInfoBlock,

/*****************************************************************************/

void GCDump::DumpPtrsInFrame(PTR_CBYTE infoBlock,
void GCDump::DumpPtrsInFrame(PTR_CBYTE gcInfoBlock,
PTR_CBYTE codeBlock,
unsigned offs,
bool verifyGCTables)
Expand Down
24 changes: 19 additions & 5 deletions src/gcdump/i386/gcdumpx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ const char * CalleeSavedRegName(unsigned reg)

/*****************************************************************************/

unsigned GCDump::DumpInfoHdr (PTR_CBYTE table,
unsigned GCDump::DumpInfoHdr (PTR_CBYTE gcInfoBlock,
InfoHdr* header,
unsigned * methodSize,
bool verifyGCTables)
{
unsigned count;
PTR_CBYTE table = gcInfoBlock;
PTR_CBYTE tableStart = table;
PTR_CBYTE bp = table;

Expand All @@ -76,7 +77,7 @@ unsigned GCDump::DumpInfoHdr (PTR_CBYTE table,

table += decodeUnsigned(table, methodSize);

table = decodeHeader(table, header);
table = decodeHeader(table, gcInfoVersion, header);

BOOL hasArgTabOffset = FALSE;
if (header->untrackedCnt == HAS_UNTRACKED)
Expand Down Expand Up @@ -107,6 +108,12 @@ unsigned GCDump::DumpInfoHdr (PTR_CBYTE table,
header->syncEndOffset = count;
}

if (header->revPInvokeOffset == HAS_REV_PINVOKE_FRAME_OFFSET)
{
table += decodeUnsigned(table, &count);
header->revPInvokeOffset = count;
}

//
// First print out all the basic information
//
Expand Down Expand Up @@ -931,12 +938,12 @@ size_t GCDump::DumpGCTable(PTR_CBYTE table,

/*****************************************************************************/

void GCDump::DumpPtrsInFrame(PTR_CBYTE infoBlock,
void GCDump::DumpPtrsInFrame(PTR_CBYTE gcInfoBlock,
PTR_CBYTE codeBlock,
unsigned offs,
bool verifyGCTables)
{
PTR_CBYTE table = infoBlock;
PTR_CBYTE table = gcInfoBlock;

size_t methodSize;
size_t stackSize;
Expand All @@ -963,7 +970,7 @@ void GCDump::DumpPtrsInFrame(PTR_CBYTE infoBlock,
// Typically only uses one-byte to store everything.
//
InfoHdr header;
table = decodeHeader(table, &header);
table = decodeHeader(table, gcInfoVersion, &header);

if (header.untrackedCnt == HAS_UNTRACKED)
{
Expand Down Expand Up @@ -994,6 +1001,13 @@ void GCDump::DumpPtrsInFrame(PTR_CBYTE infoBlock,
header.syncEndOffset = offset;
_ASSERTE(offset != INVALID_SYNC_OFFSET);
}
if (header.revPInvokeOffset == HAS_REV_PINVOKE_FRAME_OFFSET)
{
unsigned offset;
table += decodeUnsigned(table, &offset);
header.revPInvokeOffset = offset;
_ASSERTE(offset != INVALID_REV_PINVOKE_OFFSET);
}

prologSize = header.prologSize;
epilogSize = header.epilogSize;
Expand Down
54 changes: 33 additions & 21 deletions src/inc/eetwain.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,16 @@ virtual void * GetGSCookieAddr(PREGDISPLAY pContext,
Returns true if the given IP is in the given method's prolog or an epilog.
*/
virtual bool IsInPrologOrEpilog(DWORD relPCOffset,
PTR_VOID methodInfoPtr,
GCInfoToken gcInfoToken,
size_t* prologSize) = 0;

/*
Returns true if the given IP is in the synchronized region of the method (valid for synchronized methods only)
*/
virtual bool IsInSynchronizedRegion(
DWORD relOffset,
PTR_VOID methodInfoPtr,
unsigned flags) = 0;
DWORD relOffset,
GCInfoToken gcInfoToken,
unsigned flags) = 0;

/*
Returns the size of a given function as reported in the GC info (does
Expand All @@ -296,27 +296,33 @@ virtual bool IsInSynchronizedRegion(
*/
virtual size_t GetFunctionSize(GCInfoToken gcInfoToken) = 0;

/*
Returns the ReturnKind of a given function as reported in the GC info.
*/

virtual ReturnKind GetReturnKind(GCInfoToken gcInfotoken) = 0;

/*
Returns the size of the frame (barring localloc)
*/
virtual unsigned int GetFrameSize(PTR_VOID methodInfoPtr) = 0;
virtual unsigned int GetFrameSize(GCInfoToken gcInfoToken) = 0;

#ifndef DACCESS_COMPILE

/* Debugger API */

virtual const BYTE* GetFinallyReturnAddr(PREGDISPLAY pReg)=0;

virtual BOOL IsInFilter(void *methodInfoPtr,
virtual BOOL IsInFilter(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx,
DWORD curNestLevel) = 0;

virtual BOOL LeaveFinally(void *methodInfoPtr,
virtual BOOL LeaveFinally(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx) = 0;

virtual void LeaveCatch(void *methodInfoPtr,
virtual void LeaveCatch(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx)=0;

Expand Down Expand Up @@ -535,43 +541,47 @@ void * GetGSCookieAddr(PREGDISPLAY pContext,
*/
virtual
bool IsInPrologOrEpilog(
DWORD relOffset,
PTR_VOID methodInfoPtr,
size_t* prologSize);
DWORD relOffset,
GCInfoToken gcInfoToken,
size_t* prologSize);

/*
Returns true if the given IP is in the synchronized region of the method (valid for synchronized functions only)
*/
virtual
bool IsInSynchronizedRegion(
DWORD relOffset,
PTR_VOID methodInfoPtr,
unsigned flags);
DWORD relOffset,
GCInfoToken gcInfoToken,
unsigned flags);

/*
Returns the size of a given function.
*/
virtual
size_t GetFunctionSize(GCInfoToken gcInfoToken);

/*
Returns the ReturnKind of a given function.
*/
virtual ReturnKind GetReturnKind(GCInfoToken gcInfotoken);

/*
Returns the size of the frame (barring localloc)
*/
virtual
unsigned int GetFrameSize(
PTR_VOID methodInfoPtr);
unsigned int GetFrameSize(GCInfoToken gcInfoToken);

#ifndef DACCESS_COMPILE

virtual const BYTE* GetFinallyReturnAddr(PREGDISPLAY pReg);
virtual BOOL LeaveFinally(void *methodInfoPtr,
virtual BOOL LeaveFinally(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx);
virtual BOOL IsInFilter(void *methodInfoPtr,
virtual BOOL IsInFilter(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx,
DWORD curNestLevel);
virtual void LeaveCatch(void *methodInfoPtr,
virtual void LeaveCatch(GCInfoToken gcInfoToken,
unsigned offset,
PCONTEXT pCtx);

Expand Down Expand Up @@ -646,8 +656,9 @@ struct hdrInfo
{
unsigned int methodSize; // native code bytes
unsigned int argSize; // in bytes
unsigned int stackSize; /* including callee saved registers */
unsigned int rawStkSize; /* excluding callee saved registers */
unsigned int stackSize; // including callee saved registers
unsigned int rawStkSize; // excluding callee saved registers
ReturnKind returnKind; // The ReturnKind for this method.

unsigned int prologSize;

Expand Down Expand Up @@ -689,6 +700,7 @@ struct hdrInfo
unsigned int syncStartOffset; // start/end code offset of the protected region in synchronized methods.
unsigned int syncEndOffset; // INVALID_SYNC_OFFSET if there not synchronized method
unsigned int syncEpilogStart; // The start of the epilog. Synchronized methods are guaranteed to have no more than one epilog.
unsigned int revPInvokeOffset; // INVALID_REV_PINVOKE_OFFSET if there is no Reverse PInvoke frame

enum { NOT_IN_PROLOG = -1, NOT_IN_EPILOG = -1 };

Expand Down
Loading

0 comments on commit f4b86dd

Please sign in to comment.