Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PAL_IsDebuggerPresent for SunOS #37273

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/coreclr/src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6351,7 +6351,7 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
emit->emitIns_AR_R(ins_Store(TYP_I_IMPL), EA_PTRSIZE, zeroReg, frameReg, untrLclLo + i);
}
#if defined(TARGET_AMD64)
assert((i == blkSize) || (i + sizeof(int) == blkSize));
assert((i == blkSize) || (i + (int)sizeof(int) == blkSize));
if (i != blkSize)
{
emit->emitIns_AR_R(ins_Store(TYP_INT), EA_4BYTE, zeroReg, frameReg, untrLclLo + i);
Expand Down Expand Up @@ -6412,7 +6412,7 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
{
emit->emitIns_AR_R(ins_Store(TYP_I_IMPL), EA_PTRSIZE, zeroReg, frameReg, untrLclLo + i);
}
assert((i == alignmentLoBlkSize) || (i + sizeof(int) == alignmentLoBlkSize));
assert((i == alignmentLoBlkSize) || (i + (int)sizeof(int) == alignmentLoBlkSize));
if (i != alignmentLoBlkSize)
{
emit->emitIns_AR_R(ins_Store(TYP_INT), EA_4BYTE, zeroReg, frameReg, untrLclLo + i);
Expand Down Expand Up @@ -6530,7 +6530,7 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
emit->emitIns_AR_R(ins_Store(TYP_I_IMPL), EA_PTRSIZE, zeroReg, frameReg, alignedLclHi + i);
}
#if defined(TARGET_AMD64)
assert((i == alignmentHiBlkSize) || (i + sizeof(int) == alignmentHiBlkSize));
assert((i == alignmentHiBlkSize) || (i + (int)sizeof(int) == alignmentHiBlkSize));
if (i != alignmentHiBlkSize)
{
emit->emitIns_AR_R(ins_Store(TYP_INT), EA_4BYTE, zeroReg, frameReg, alignedLclHi + i);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*****************************************************************************/

const unsigned short GenTree::gtOperKindTable[] = {
#define GTNODE(en, st, cm, ok) ok + GTK_COMMUTE *cm,
#define GTNODE(en, st, cm, ok) (ok) + GTK_COMMUTE *cm,
#include "gtlist.h"
};

Expand Down Expand Up @@ -10483,7 +10483,7 @@ void Compiler::gtDispLclVar(unsigned lclNum, bool padForBiggestDisp)

printf("%s", buf);

if (padForBiggestDisp && (charsPrinted < LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH))
if (padForBiggestDisp && (charsPrinted < (int)LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH))
{
printf("%*c", LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH - charsPrinted, ' ');
}
Expand Down
24 changes: 12 additions & 12 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Compiler::impPushOnStack(GenTree* tree, typeInfo ti)
// attempts to do that have proved too difficult. Instead, we'll assume that in checks like this,
// when there's a mismatch, it's because of this reason -- the typeInfo::AreEquivalentModuloNativeInt
// method used in the last disjunct allows exactly this mismatch.
assert(ti.IsDead() || (ti.IsByRef() && (tree->TypeGet() == TYP_I_IMPL) || tree->TypeGet() == TYP_BYREF) ||
assert(ti.IsDead() || (ti.IsByRef() && ((tree->TypeGet() == TYP_I_IMPL) || (tree->TypeGet() == TYP_BYREF))) ||
(ti.IsUnboxedGenericTypeVar() && tree->TypeGet() == TYP_REF) ||
(ti.IsObjRef() && tree->TypeGet() == TYP_REF) || (ti.IsMethod() && tree->TypeGet() == TYP_I_IMPL) ||
(ti.IsType(TI_STRUCT) && tree->TypeGet() != TYP_REF) ||
Expand Down Expand Up @@ -5430,7 +5430,7 @@ void Compiler::verVerifyCall(OPCODE opcode,

if ((actualMethodAttribs & CORINFO_FLG_VIRTUAL) && ((actualMethodAttribs & CORINFO_FLG_FINAL) == 0))
{
VerifyOrReturn(tiActualObj.IsThisPtr() && lvaIsOriginalThisReadOnly() ||
VerifyOrReturn((tiActualObj.IsThisPtr() && lvaIsOriginalThisReadOnly()) ||
verIsBoxedValueType(tiActualObj),
"The 'this' parameter to the call must be either the calling method's "
"'this' parameter or "
Expand Down Expand Up @@ -5586,7 +5586,7 @@ void Compiler::verVerifyCall(OPCODE opcode,

if (opcode == CEE_CALL && (mflags & CORINFO_FLG_VIRTUAL) && ((mflags & CORINFO_FLG_FINAL) == 0))
{
VerifyOrReturn(tiThis.IsThisPtr() && lvaIsOriginalThisReadOnly() || verIsBoxedValueType(tiThis),
VerifyOrReturn((tiThis.IsThisPtr() && lvaIsOriginalThisReadOnly()) || verIsBoxedValueType(tiThis),
"The 'this' parameter to the call must be either the calling method's 'this' parameter or "
"a boxed value type.");
}
Expand Down Expand Up @@ -10356,7 +10356,7 @@ var_types Compiler::impGetByRefResultType(genTreeOps oper, bool fUnsigned, GenTr
assert(genActualType(op1->TypeGet()) != TYP_BYREF && genActualType(op2->TypeGet()) != TYP_BYREF);

assert(genActualType(op1->TypeGet()) == genActualType(op2->TypeGet()) ||
varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType));
(varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType)));

type = genActualType(op1->gtType);

Expand Down Expand Up @@ -11326,7 +11326,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
// We had better assign it a value of the correct type
assertImp(
genActualType(lclTyp) == genActualType(op1->gtType) ||
genActualType(lclTyp) == TYP_I_IMPL && (op1->IsLocalAddrExpr() != nullptr) ||
(genActualType(lclTyp) == TYP_I_IMPL && op1->IsLocalAddrExpr() != nullptr) ||
(genActualType(lclTyp) == TYP_I_IMPL && (op1->gtType == TYP_BYREF || op1->gtType == TYP_REF)) ||
(genActualType(op1->gtType) == TYP_I_IMPL && lclTyp == TYP_BYREF) ||
(varTypeIsFloating(lclTyp) && varTypeIsFloating(op1->TypeGet())) ||
Expand Down Expand Up @@ -12637,8 +12637,8 @@ void Compiler::impImportBlockCode(BasicBlock* block)
#endif // TARGET_64BIT

assertImp(genActualType(op1->TypeGet()) == genActualType(op2->TypeGet()) ||
varTypeIsI(op1->TypeGet()) && varTypeIsI(op2->TypeGet()) ||
varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType));
(varTypeIsI(op1->TypeGet()) && varTypeIsI(op2->TypeGet())) ||
(varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType)));

/* Create the comparison node */

Expand Down Expand Up @@ -12737,8 +12737,8 @@ void Compiler::impImportBlockCode(BasicBlock* block)
#endif // TARGET_64BIT

assertImp(genActualType(op1->TypeGet()) == genActualType(op2->TypeGet()) ||
varTypeIsI(op1->TypeGet()) && varTypeIsI(op2->TypeGet()) ||
varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType));
(varTypeIsI(op1->TypeGet()) && varTypeIsI(op2->TypeGet())) ||
(varTypeIsFloating(op1->gtType) && varTypeIsFloating(op2->gtType)));

if (opts.OptimizationEnabled() && (block->bbJumpDest == block->bbNext))
{
Expand Down Expand Up @@ -15469,9 +15469,9 @@ void Compiler::impImportBlockCode(BasicBlock* block)
}
}

assert(helper == CORINFO_HELP_UNBOX && op1->gtType == TYP_BYREF || // Unbox helper returns a byref.
helper == CORINFO_HELP_UNBOX_NULLABLE &&
varTypeIsStruct(op1) // UnboxNullable helper returns a struct.
assert((helper == CORINFO_HELP_UNBOX && op1->gtType == TYP_BYREF) || // Unbox helper returns a byref.
(helper == CORINFO_HELP_UNBOX_NULLABLE &&
varTypeIsStruct(op1)) // UnboxNullable helper returns a struct.
);

/*
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ void InlineStrategy::DumpXml(FILE* file, unsigned indent)
strncpy(buf, methodName, sizeof(buf));
buf[sizeof(buf) - 1] = 0;

for (int i = 0; i < _countof(buf); i++)
for (size_t i = 0; i < _countof(buf); i++)
{
switch (buf[i])
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4085,7 +4085,7 @@ void Compiler::lvaMarkLocalVars()
else if (lvaReportParamTypeArg())
{
// We should have a context arg.
assert(info.compTypeCtxtArg != BAD_VAR_NUM);
assert(info.compTypeCtxtArg != (int)BAD_VAR_NUM);
lvaGetDesc(info.compTypeCtxtArg)->lvImplicitlyReferenced = reportParamTypeArg;
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ void Lowering::LowerSIMD(GenTreeSIMD* simdNode)
GenTree* arg = list->Current();

assert(arg->TypeGet() == simdNode->gtSIMDBaseType);
assert(argCount < _countof(constArgValues));
assert(argCount < (int)_countof(constArgValues));

if (arg->IsCnsFltOrDbl())
{
Expand Down
14 changes: 7 additions & 7 deletions src/coreclr/src/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6162,7 +6162,7 @@ void LinearScan::allocateRegisters()
if (getLsraExtendLifeTimes())
{
// If we have extended lifetimes, we need to make sure all the registers are freed.
for (int regNumIndex = 0; regNumIndex <= REG_FP_LAST; regNumIndex++)
for (size_t regNumIndex = 0; regNumIndex <= REG_FP_LAST; regNumIndex++)
{
RegRecord& regRecord = physRegs[regNumIndex];
Interval* interval = regRecord.assignedInterval;
Expand Down Expand Up @@ -6624,9 +6624,9 @@ void LinearScan::writeRegisters(RefPosition* currentRefPosition, GenTree* tree)
// | GT_ADD (3) |
// +---------+----------+
// |
// / \
// / \
// / \
// / '\'
// / '\'
// / '\'
// +-------------------+ +----------------------+
// | x (1) | "tree" | y (2) |
// +-------------------+ +----------------------+
Expand All @@ -6637,9 +6637,9 @@ void LinearScan::writeRegisters(RefPosition* currentRefPosition, GenTree* tree)
// | GT_ADD (4) |
// +---------+----------+
// |
// / \
// / \
// / \
// / '\'
// / '\'
// / '\'
// +-------------------+ +----------------------+
// | GT_RELOAD (3) | | y (2) |
// +-------------------+ +----------------------+
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Phase::PrePhase()
static Phases s_whitelist[] = {PHASE_BUILD_SSA, PHASE_RATIONALIZE, PHASE_LOWERING, PHASE_STACK_LEVEL_SETTER};
bool doPrePhase = false;

for (int i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
for (size_t i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
{
if (m_phase == s_whitelist[i])
{
Expand Down Expand Up @@ -175,7 +175,7 @@ void Phase::PostPhase(PhaseStatus status)

if (madeChanges)
{
for (int i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
for (size_t i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
{
if (m_phase == s_whitelist[i])
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/pal/inc/pal_mstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T;
#endif

#ifndef SSIZE_T_MIN
#define SSIZE_T_MIN I64(0x8000000000000000)
#define SSIZE_T_MIN (ssize_t)I64(0x8000000000000000)
#endif

#ifndef PAL_STDCPP_COMPAT
Expand Down
28 changes: 28 additions & 0 deletions src/coreclr/src/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ int CacheLineSize;
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
#elif defined(__sun)
#ifndef _KERNEL
#define _KERNEL
#define UNDEF_KERNEL
#endif
#include <sys/procfs.h>
#ifdef UNDEF_KERNEL
#undef _KERNEL
#endif
#endif

#include <algorithm>
Expand Down Expand Up @@ -888,6 +897,25 @@ PAL_IsDebuggerPresent()
return TRUE;
else
return FALSE;
#elif defined(__sun)
int readResult;
char statusFilename[64];
snprintf(statusFilename, sizeof(statusFilename), "/proc/%d/status", getpid());
int fd = open(statusFilename, O_RDONLY);
if (fd == -1)
{
return FALSE;
}

pstatus_t status;
do
{
readResult = read(fd, &status, sizeof(status));
}
while ((readResult == -1) && (errno == EINTR));

close(fd);
return status.pr_flttrace.word[0] != 0;
#else
return FALSE;
#endif
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so d
#include <semaphore.h>
#include <stdint.h>
#include <dlfcn.h>
#include <limits.h>

#ifdef __linux__
#include <sys/syscall.h> // __NR_membarrier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int __cdecl main(int argc, char *argv[])
}


memset(szwReturnedPath, 0, _MAX_DIR+1);
memset(szwReturnedPath, 0, sizeof(szwReturnedPath));
dwRc = GetFullPathNameW(szwFileName,
_MAX_DIR,
szwReturnedPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ int __cdecl main(int argc, char *argv[])

/* Initialize the receiving char buffers.
*/
memset(szwReturnedPath, 0, _MAX_DIR+1);
memset(szwFullFileName, 0, _MAX_DIR+1);
memset(szwReturnedPath, 0, sizeof(szwReturnedPath));
memset(szwFullFileName, 0, sizeof(szwFullFileName));

/* Create Full filename to pass, will include '..\'
* as a pre-fix. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ int __cdecl main(int argc, char *argv[])

/* Initialize the receiving char buffers.
*/
memset(szReturnedPath, 0, _MAX_DIR+1);
memset(szFullFileName, 0, _MAX_DIR+1);
memset(szReturnedPath, 0, sizeof(szReturnedPath));
memset(szFullFileName, 0, sizeof(szFullFileName));

/* Create Full filename to pass, will include '..\'
* in the middle of the path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ int __cdecl main(int argc, char *argv[])

/* Initialize the receiving char buffers.
*/
memset(szReturnedPath, 0, _MAX_DIR+1);
memset(szFullFileName, 0, _MAX_DIR+1);
memset(szReturnedPath, 0, sizeof(szFullFileName));
memset(szFullFileName, 0, sizeof(szFullFileName));

/* Create Full filename to pass, will include '..\'
* in the middle of the path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ bool LockAndCloseWithoutThreadExitTests()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Test harness

bool (*const (TestList[]))() =
bool (*const TestList[])() =
{
NameTests,
HeaderMismatchTests,
Expand Down