From 863e46dfddfded9b4c7477eb46e4243616616fe9 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Tue, 1 Feb 2022 23:11:36 +0600 Subject: [PATCH 01/10] Fix pal_assert.h for PAL_STDCPP_COMPAT Improves https://github.com/dotnet/runtime/issues/37310 --- src/coreclr/pal/inc/pal_assert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/pal/inc/pal_assert.h b/src/coreclr/pal/inc/pal_assert.h index 2953473343ec2b..aea57ec1e6f6a8 100644 --- a/src/coreclr/pal/inc/pal_assert.h +++ b/src/coreclr/pal/inc/pal_assert.h @@ -34,7 +34,7 @@ extern "C" { #if defined(_DEBUG) #define _ASSERTE(e) do { \ if (!(e)) { \ - fprintf (stderr, \ + PAL_fprintf (PAL_get_stderr(PAL_get_caller), \ "ASSERT FAILED\n" \ "\tExpression: %s\n" \ "\tLocation: line %d in %s\n" \ From f7272c6b0ed365efc2e1736905bed45bd1425c53 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 11:19:32 +0600 Subject: [PATCH 02/10] Remove _ASSERTE from tests This is pickup _ASSERTE from PAL which is not what it is desired. --- .../eventpipewritingprofiler.h | 2 +- .../native/rejitprofiler/ilrewriter.cpp | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h b/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h index 9de3dab1b387ab..e9f6aee1f97f2f 100644 --- a/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h +++ b/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h @@ -37,7 +37,7 @@ class EventPipeWritingProfiler : public Profiler template static void WriteToBuffer(BYTE *pBuffer, size_t bufferLength, size_t *pOffset, T value) { - _ASSERTE(bufferLength >= (*pOffset + sizeof(T))); + assert(bufferLength >= (*pOffset + sizeof(T))); *(T*)(pBuffer + *pOffset) = value; *pOffset += sizeof(T); diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index 4659c6054ed356..d01a9537b1673f 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -124,7 +124,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset >= m_CodeSize) { - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } opcode = 0x100 + pIL[offset++]; @@ -133,13 +133,13 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) if ((CEE_PREFIX7 <= opcode) && (opcode <= CEE_PREFIX2)) { // NOTE: CEE_PREFIX2-7 are currently not supported - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } if (opcode >= CEE_COUNT) { - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } @@ -148,7 +148,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) int size = (flags & OPCODEFLAGS_SizeMask); if (offset + size > m_CodeSize) { - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } @@ -189,7 +189,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset + sizeof(INT32) > m_CodeSize) { - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } @@ -203,7 +203,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset + sizeof(INT32) > m_CodeSize) { - _ASSERTE(false); + assert(false); return COR_E_INVALIDPROGRAM; } @@ -221,12 +221,12 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) break; } default: - _ASSERTE(false); + assert(false); break; } offset += size; } - _ASSERTE(offset == m_CodeSize); + assert(offset == m_CodeSize); if (fBranch) { @@ -243,7 +243,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) HRESULT ILRewriter::ImportEH(const COR_ILMETHOD_SECT_EH* pILEH, unsigned nEH) { - _ASSERTE(m_pEH == NULL); + assert(m_pEH == NULL); m_nEH = nEH; @@ -289,7 +289,7 @@ ILInstr* ILRewriter::GetInstrFromOffset(unsigned offset) if (offset <= m_CodeSize) pInstr = m_pOffsetToInstr[offset]; - _ASSERTE(pInstr != NULL); + assert(pInstr != NULL); return pInstr; } @@ -370,7 +370,7 @@ HRESULT ILRewriter::Export() m_pOutputBuffer[offset++] = (opcode & 0xFF); } - _ASSERTE(pInstr->m_opcode < dimensionof(s_OpCodeFlags)); + assert(pInstr->m_opcode < dimensionof(s_OpCodeFlags)); BYTE flags = s_OpCodeFlags[pInstr->m_opcode]; switch (flags) { @@ -399,7 +399,7 @@ HRESULT ILRewriter::Export() offset += sizeof(INT32); break; default: - _ASSERTE(false); + assert(false); break; } offset += (flags & OPCODEFLAGS_SizeMask); @@ -448,9 +448,9 @@ HRESULT ILRewriter::Export() } else { - _ASSERTE(opcode >= CEE_BR_S && opcode <= CEE_BLT_UN_S); + assert(opcode >= CEE_BR_S && opcode <= CEE_BLT_UN_S); pInstr->m_opcode = opcode - CEE_BR_S + CEE_BR; - _ASSERTE(pInstr->m_opcode >= CEE_BR && pInstr->m_opcode <= CEE_BLT_UN); + assert(pInstr->m_opcode >= CEE_BR && pInstr->m_opcode <= CEE_BLT_UN); } fTryAgain = true; continue; @@ -461,7 +461,7 @@ HRESULT ILRewriter::Export() *(UNALIGNED INT32 *)&(pIL[pInstr->m_pNext->m_offset - sizeof(INT32)]) = delta; break; default: - _ASSERTE(false); + assert(false); break; } } @@ -641,7 +641,7 @@ UINT ILRewriter::AddNewInt32Local() if (cbOrigSig > 0) { // First byte of signature must identify that it's a locals signature! - _ASSERTE(rgbOrigSig[iOrigSig] == SIG_LOCAL_SIG); + assert(rgbOrigSig[iOrigSig] == SIG_LOCAL_SIG); iOrigSig++; } @@ -721,7 +721,7 @@ UINT ILRewriter::AddNewInt32Local() // We're done building up the new signature blob. We now need to add it to // the metadata for this module, so we can get a token back for it. - _ASSERTE(iNewSig <= sizeof(rgbNewSig)); + assert(iNewSig <= sizeof(rgbNewSig)); hr = m_pMetaDataEmit->GetTokenFromSig(&rgbNewSig[0], // [IN] Signature to define. iNewSig, // [IN] Size of signature data. &m_tkLocalVarSig); // [OUT] returned signature token. @@ -759,7 +759,7 @@ WCHAR* ILRewriter::GetNameFromToken(mdToken tk) NULL, NULL); break; default: - _ASSERTE(false); + assert(false); break; } From ec77c1fc1f82637917587a877035f2171636ada7 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 13:07:41 +0600 Subject: [PATCH 03/10] Add workaround for _ASSERTE --- .../native/rejitprofiler/ilrewriter.cpp | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index d01a9537b1673f..d46173e47b6976 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. #include + +// Workaround to not link PAL to this test. +#define _ASSERTE assert #include #include "ilrewriter.h" #include "sigparse.h" @@ -124,7 +127,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset >= m_CodeSize) { - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } opcode = 0x100 + pIL[offset++]; @@ -133,13 +136,13 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) if ((CEE_PREFIX7 <= opcode) && (opcode <= CEE_PREFIX2)) { // NOTE: CEE_PREFIX2-7 are currently not supported - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } if (opcode >= CEE_COUNT) { - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } @@ -148,7 +151,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) int size = (flags & OPCODEFLAGS_SizeMask); if (offset + size > m_CodeSize) { - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } @@ -189,7 +192,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset + sizeof(INT32) > m_CodeSize) { - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } @@ -203,7 +206,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) { if (offset + sizeof(INT32) > m_CodeSize) { - assert(false); + _ASSERTE(false); return COR_E_INVALIDPROGRAM; } @@ -221,12 +224,12 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) break; } default: - assert(false); + _ASSERTE(false); break; } offset += size; } - assert(offset == m_CodeSize); + _ASSERTE(offset == m_CodeSize); if (fBranch) { @@ -243,7 +246,7 @@ HRESULT ILRewriter::ImportIL(LPCBYTE pIL) HRESULT ILRewriter::ImportEH(const COR_ILMETHOD_SECT_EH* pILEH, unsigned nEH) { - assert(m_pEH == NULL); + _ASSERTE(m_pEH == NULL); m_nEH = nEH; @@ -289,7 +292,7 @@ ILInstr* ILRewriter::GetInstrFromOffset(unsigned offset) if (offset <= m_CodeSize) pInstr = m_pOffsetToInstr[offset]; - assert(pInstr != NULL); + _ASSERTE(pInstr != NULL); return pInstr; } @@ -370,7 +373,7 @@ HRESULT ILRewriter::Export() m_pOutputBuffer[offset++] = (opcode & 0xFF); } - assert(pInstr->m_opcode < dimensionof(s_OpCodeFlags)); + _ASSERTE(pInstr->m_opcode < dimensionof(s_OpCodeFlags)); BYTE flags = s_OpCodeFlags[pInstr->m_opcode]; switch (flags) { @@ -399,7 +402,7 @@ HRESULT ILRewriter::Export() offset += sizeof(INT32); break; default: - assert(false); + _ASSERTE(false); break; } offset += (flags & OPCODEFLAGS_SizeMask); @@ -448,9 +451,9 @@ HRESULT ILRewriter::Export() } else { - assert(opcode >= CEE_BR_S && opcode <= CEE_BLT_UN_S); + _ASSERTE(opcode >= CEE_BR_S && opcode <= CEE_BLT_UN_S); pInstr->m_opcode = opcode - CEE_BR_S + CEE_BR; - assert(pInstr->m_opcode >= CEE_BR && pInstr->m_opcode <= CEE_BLT_UN); + _ASSERTE(pInstr->m_opcode >= CEE_BR && pInstr->m_opcode <= CEE_BLT_UN); } fTryAgain = true; continue; @@ -461,7 +464,7 @@ HRESULT ILRewriter::Export() *(UNALIGNED INT32 *)&(pIL[pInstr->m_pNext->m_offset - sizeof(INT32)]) = delta; break; default: - assert(false); + _ASSERTE(false); break; } } @@ -641,7 +644,7 @@ UINT ILRewriter::AddNewInt32Local() if (cbOrigSig > 0) { // First byte of signature must identify that it's a locals signature! - assert(rgbOrigSig[iOrigSig] == SIG_LOCAL_SIG); + _ASSERTE(rgbOrigSig[iOrigSig] == SIG_LOCAL_SIG); iOrigSig++; } @@ -721,7 +724,7 @@ UINT ILRewriter::AddNewInt32Local() // We're done building up the new signature blob. We now need to add it to // the metadata for this module, so we can get a token back for it. - assert(iNewSig <= sizeof(rgbNewSig)); + _ASSERTE(iNewSig <= sizeof(rgbNewSig)); hr = m_pMetaDataEmit->GetTokenFromSig(&rgbNewSig[0], // [IN] Signature to define. iNewSig, // [IN] Size of signature data. &m_tkLocalVarSig); // [OUT] returned signature token. @@ -759,7 +762,7 @@ WCHAR* ILRewriter::GetNameFromToken(mdToken tk) NULL, NULL); break; default: - assert(false); + _ASSERTE(false); break; } From 4ce80da7bfb6c21f917322519dfb8ce0b66c0cbf Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 17:00:11 +0600 Subject: [PATCH 04/10] Another try. --- src/coreclr/pal/inc/pal_assert.h | 2 ++ .../native/eventpipeprofiler/eventpipewritingprofiler.h | 2 +- src/tests/profiler/native/rejitprofiler/ilrewriter.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coreclr/pal/inc/pal_assert.h b/src/coreclr/pal/inc/pal_assert.h index aea57ec1e6f6a8..87af991d9abbc3 100644 --- a/src/coreclr/pal/inc/pal_assert.h +++ b/src/coreclr/pal/inc/pal_assert.h @@ -31,6 +31,7 @@ extern "C" { #endif // __cplusplus +#ifndef _ASSERTE #if defined(_DEBUG) #define _ASSERTE(e) do { \ if (!(e)) { \ @@ -48,6 +49,7 @@ extern "C" { #else // !DEBUG #define _ASSERTE(e) ((void)0) #endif +#endif // _ASSERTE #ifndef assert #define assert(e) _ASSERTE(e) diff --git a/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h b/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h index e9f6aee1f97f2f..9de3dab1b387ab 100644 --- a/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h +++ b/src/tests/profiler/native/eventpipeprofiler/eventpipewritingprofiler.h @@ -37,7 +37,7 @@ class EventPipeWritingProfiler : public Profiler template static void WriteToBuffer(BYTE *pBuffer, size_t bufferLength, size_t *pOffset, T value) { - assert(bufferLength >= (*pOffset + sizeof(T))); + _ASSERTE(bufferLength >= (*pOffset + sizeof(T))); *(T*)(pBuffer + *pOffset) = value; *pOffset += sizeof(T); diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index d46173e47b6976..7708315cc66ea3 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -4,7 +4,7 @@ #include // Workaround to not link PAL to this test. -#define _ASSERTE assert +#define _ASSERTE(e) static_assert(e, #e) #include #include "ilrewriter.h" #include "sigparse.h" From 021a39cc041f5616601a069aa6f19f0b6496bd27 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 17:39:13 +0600 Subject: [PATCH 05/10] One more try --- src/tests/profiler/native/rejitprofiler/ilrewriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index 7708315cc66ea3..f6f49d58935cc5 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. #include +#include // Workaround to not link PAL to this test. -#define _ASSERTE(e) static_assert(e, #e) +#define _ASSERTE assert #include #include "ilrewriter.h" #include "sigparse.h" From 38483e12a5990db915fe632b1335e35bdac9b5f2 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 20:41:18 +0600 Subject: [PATCH 06/10] Use assert from C++ lib in corhlpr.cpp --- src/coreclr/inc/corhlpr.cpp | 30 ++++++++++--------- .../native/rejitprofiler/ilrewriter.cpp | 4 --- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/coreclr/inc/corhlpr.cpp b/src/coreclr/inc/corhlpr.cpp index f9559cec6a7014..69fd566b087712 100644 --- a/src/coreclr/inc/corhlpr.cpp +++ b/src/coreclr/inc/corhlpr.cpp @@ -6,6 +6,8 @@ ** Corhlpr.h - signature helpers. ** ** ** ****************************************************************************/ +#include + #ifndef SOS_INCLUDE #ifdef _BLD_CLR @@ -48,7 +50,7 @@ void __stdcall DecoderInit(void *pThis, COR_ILMETHOD *header) #ifdef HOST_64BIT if((((size_t) header) & 3) == 0) // header is aligned #else - _ASSERTE((((size_t) header) & 3) == 0); // header is aligned + assert((((size_t) header) & 3) == 0); // header is aligned #endif { *((COR_ILMETHOD_FAT *)decoder) = header->Fat; @@ -129,18 +131,18 @@ unsigned __stdcall IlmethodEmit(unsigned size, COR_ILMETHOD_FAT* header, } else { // Fat format - _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned + assert((((size_t) outBuff) & 3) == 0); // header is dword aligned COR_ILMETHOD_FAT* fatHeader = (COR_ILMETHOD_FAT*) outBuff; outBuff += sizeof(COR_ILMETHOD_FAT); *fatHeader = *header; fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_FatFormat); - _ASSERTE((fatHeader->GetFlags() & CorILMethod_FormatMask) == CorILMethod_FatFormat); + assert((fatHeader->GetFlags() & CorILMethod_FormatMask) == CorILMethod_FatFormat); if (moreSections) fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_MoreSects); fatHeader->SetSize(sizeof(COR_ILMETHOD_FAT) / 4); } #ifndef SOS_INCLUDE - _ASSERTE(&origBuff[size] == outBuff); + assert(&origBuff[size] == outBuff); #endif // !SOS_INCLUDE return(size); } @@ -211,7 +213,7 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, if (size == 0) return(0); - _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned + assert((((size_t) outBuff) & 3) == 0); // header is dword aligned BYTE* origBuff = outBuff; if (ehCount <= 0) return 0; @@ -234,11 +236,11 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, fatClause->GetHandlerLength() > 0xFF) { break; // fall through and generate as FAT } - _ASSERTE((fatClause->GetFlags() & ~0xFFFF) == 0); - _ASSERTE((fatClause->GetTryOffset() & ~0xFFFF) == 0); - _ASSERTE((fatClause->GetTryLength() & ~0xFF) == 0); - _ASSERTE((fatClause->GetHandlerOffset() & ~0xFFFF) == 0); - _ASSERTE((fatClause->GetHandlerLength() & ~0xFF) == 0); + assert((fatClause->GetFlags() & ~0xFFFF) == 0); + assert((fatClause->GetTryOffset() & ~0xFFFF) == 0); + assert((fatClause->GetTryLength() & ~0xFF) == 0); + assert((fatClause->GetHandlerOffset() & ~0xFFFF) == 0); + assert((fatClause->GetHandlerLength() & ~0xFF) == 0); COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; smallClause->SetFlags((CorExceptionFlag) fatClause->GetFlags()); @@ -259,7 +261,7 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, EHSect->DataSize = (BYTE) EHSect->Size(ehCount); #endif // !SOS_INCLUDE EHSect->Reserved = 0; - _ASSERTE(EHSect->DataSize == EHSect->Size(ehCount)); // make sure didn't overflow + assert(EHSect->DataSize == EHSect->Size(ehCount)); // make sure didn't overflow outBuff = (BYTE*) &EHSect->Clauses[ehCount]; // Set the offsets for the exception type tokens. if (ehTypeOffsets) @@ -268,7 +270,7 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; if (smallClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { - _ASSERTE(! IsNilToken(smallClause->GetClassToken())); + assert(! IsNilToken(smallClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&smallClause->ClassToken - origBuff); } } @@ -285,7 +287,7 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, EHSect->SetDataSize(EHSect->Size(ehCount)); memcpy(EHSect->Clauses, clauses, ehCount * sizeof(COR_ILMETHOD_SECT_EH_CLAUSE_FAT)); outBuff = (BYTE*) &EHSect->Clauses[ehCount]; - _ASSERTE(&origBuff[size] == outBuff); + assert(&origBuff[size] == outBuff); // Set the offsets for the exception type tokens. if (ehTypeOffsets) { @@ -293,7 +295,7 @@ unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&EHSect->Clauses[i]; if (fatClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { - _ASSERTE(! IsNilToken(fatClause->GetClassToken())); + assert(! IsNilToken(fatClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&fatClause->ClassToken - origBuff); } } diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index f6f49d58935cc5..4659c6054ed356 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. #include -#include - -// Workaround to not link PAL to this test. -#define _ASSERTE assert #include #include "ilrewriter.h" #include "sigparse.h" From 437ca5395dd3cc756113e2a1f09415a6009e5975 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 2 Feb 2022 23:04:50 +0600 Subject: [PATCH 07/10] Replace _ASSERTE to assert in corhlpr.h --- src/coreclr/inc/corhlpr.cpp | 2 -- src/coreclr/inc/corhlpr.h | 13 +++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/coreclr/inc/corhlpr.cpp b/src/coreclr/inc/corhlpr.cpp index 69fd566b087712..1a58e987153a3c 100644 --- a/src/coreclr/inc/corhlpr.cpp +++ b/src/coreclr/inc/corhlpr.cpp @@ -6,8 +6,6 @@ ** Corhlpr.h - signature helpers. ** ** ** ****************************************************************************/ -#include - #ifndef SOS_INCLUDE #ifdef _BLD_CLR diff --git a/src/coreclr/inc/corhlpr.h b/src/coreclr/inc/corhlpr.h index a4021921dd6eb5..0e6ed3bed35cfd 100644 --- a/src/coreclr/inc/corhlpr.h +++ b/src/coreclr/inc/corhlpr.h @@ -17,6 +17,7 @@ #define CORHLPR_TURNED_FPO_ON 1 #endif +#include #include "cor.h" #include "corhdr.h" #include "corerror.h" @@ -82,10 +83,6 @@ do { hr = (EXPR); if(FAILED(hr)) { goto LABEL; } } while (0) #endif -#ifndef _ASSERTE -#define _ASSERTE(expr) -#endif - #if !BIGENDIAN #define VAL16(x) x #define VAL32(x) x @@ -259,7 +256,7 @@ typedef struct tagCOR_ILMETHOD_SECT_EH_CLAUSE_SMALL : public IMAGE_COR_ILMETHOD_ return VAL16(TryOffset); } void SetTryOffset(DWORD Offset) { - _ASSERTE((Offset & ~0xffff) == 0); + assert((Offset & ~0xffff) == 0); TryOffset = VAL16(Offset); } @@ -267,7 +264,7 @@ typedef struct tagCOR_ILMETHOD_SECT_EH_CLAUSE_SMALL : public IMAGE_COR_ILMETHOD_ return TryLength; } void SetTryLength(DWORD Length) { - _ASSERTE((Length & ~0xff) == 0); + assert((Length & ~0xff) == 0); TryLength = Length; } @@ -275,7 +272,7 @@ typedef struct tagCOR_ILMETHOD_SECT_EH_CLAUSE_SMALL : public IMAGE_COR_ILMETHOD_ return VAL16(HandlerOffset); } void SetHandlerOffset(DWORD Offset) { - _ASSERTE((Offset & ~0xffff) == 0); + assert((Offset & ~0xffff) == 0); HandlerOffset = VAL16(Offset); } @@ -283,7 +280,7 @@ typedef struct tagCOR_ILMETHOD_SECT_EH_CLAUSE_SMALL : public IMAGE_COR_ILMETHOD_ return HandlerLength; } void SetHandlerLength(DWORD Length) { - _ASSERTE((Length & ~0xff) == 0); + assert((Length & ~0xff) == 0); HandlerLength = Length; } From 12319ccb67009d855921f09949936719b4609670 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Fri, 11 Feb 2022 21:39:27 +0600 Subject: [PATCH 08/10] Temporary ask for header inclusion tree during compilation --- src/tests/profiler/native/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/profiler/native/CMakeLists.txt b/src/tests/profiler/native/CMakeLists.txt index b9a1f47e5ab803..5973f28896146e 100644 --- a/src/tests/profiler/native/CMakeLists.txt +++ b/src/tests/profiler/native/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(../../../coreclr/pal/prebuilt/inc) if(NOT WIN32) include_directories(../../../coreclr/pal/inc/rt ../../../coreclr/pal/inc ../../../coreclr/inc) add_compile_options(-DPAL_STDCPP_COMPAT) + add_compile_options(-H -MM) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-null-arithmetic) else(CMAKE_CXX_COMPILER_ID MATCHES "Clang") From ade3c472a8aa36a7e74c6cc18f5444a051a4cdc1 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 13 Apr 2022 16:51:14 +0600 Subject: [PATCH 09/10] Remove debug message --- src/tests/profiler/native/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tests/profiler/native/CMakeLists.txt b/src/tests/profiler/native/CMakeLists.txt index 5973f28896146e..b9a1f47e5ab803 100644 --- a/src/tests/profiler/native/CMakeLists.txt +++ b/src/tests/profiler/native/CMakeLists.txt @@ -31,7 +31,6 @@ include_directories(../../../coreclr/pal/prebuilt/inc) if(NOT WIN32) include_directories(../../../coreclr/pal/inc/rt ../../../coreclr/pal/inc ../../../coreclr/inc) add_compile_options(-DPAL_STDCPP_COMPAT) - add_compile_options(-H -MM) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-null-arithmetic) else(CMAKE_CXX_COMPILER_ID MATCHES "Clang") From 3fc1a083b0a3bf61f1cbf01182798b95841f547f Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 13 Apr 2022 17:57:05 +0600 Subject: [PATCH 10/10] Attempt to disable ASSERTE in the ilrewriter.cpp --- src/tests/profiler/native/rejitprofiler/ilrewriter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp index 4659c6054ed356..371bac8f125a12 100644 --- a/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp +++ b/src/tests/profiler/native/rejitprofiler/ilrewriter.cpp @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#define _ASSERTE(e) ((void)0) + #include #include #include "ilrewriter.h"