mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Debug Break,SafeBreak,IsDebuggerPresent. [NoDebug]
This commit is contained in:
parent
42a361a8c0
commit
06f6c41679
6 changed files with 43 additions and 1 deletions
|
@ -27,6 +27,11 @@ EmitObjectAccessCheck = false
|
|||
Filter = "[System.UseLLVM]"
|
||||
BfOptimizationLevel = "O0"
|
||||
|
||||
[[Configs.Debug.Win64.DistinctOptions]]
|
||||
Filter = "[System.NoDebug]"
|
||||
BfOptimizationLevel = "O0"
|
||||
EmitDebugInfo = "No"
|
||||
|
||||
[[Configs.Debug.Win32.DistinctOptions]]
|
||||
Filter = "[System.Optimize]"
|
||||
BfOptimizationLevel = "O2"
|
||||
|
|
|
@ -163,6 +163,12 @@ namespace System
|
|||
|
||||
}
|
||||
|
||||
[AttributeUsage(.Method | .Class | .Struct | .Enum)]
|
||||
public struct NoDebugAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(.Method | .Class | .Struct | .Enum)]
|
||||
public struct UseLLVMAttribute : Attribute
|
||||
{
|
||||
|
|
|
@ -76,5 +76,28 @@ namespace System.Diagnostics
|
|||
paramStr.Append('\n');
|
||||
Write(paramStr.Ptr, paramStr.Length);
|
||||
}
|
||||
|
||||
static bool gIsDebuggerPresent = IsDebuggerPresent;
|
||||
[LinkName("IsDebuggerPresent"), CallingConvention(.Stdcall)]
|
||||
static extern int32 Internal_IsDebuggerPresent();
|
||||
|
||||
public static bool IsDebuggerPresent
|
||||
{
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
get => gIsDebuggerPresent = Internal_IsDebuggerPresent() != 0;
|
||||
#else
|
||||
get => false;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Intrinsic("debugtrap")]
|
||||
public static extern void Break();
|
||||
|
||||
[NoDebug]
|
||||
public static void SafeBreak()
|
||||
{
|
||||
if (gIsDebuggerPresent)
|
||||
Break();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17337,6 +17337,11 @@ void BeMCContext::Generate(BeFunction* function)
|
|||
vregInfo->mIsExpr = true;
|
||||
}
|
||||
break;
|
||||
case BfIRIntrinsic_DebugTrap:
|
||||
{
|
||||
AllocInst(BeMCInstKind_DbgBreak);
|
||||
}
|
||||
break;
|
||||
case BfIRIntrinsic_MemSet:
|
||||
{
|
||||
if (auto constVal = BeValueDynCast<BeConstant>(castedInst->mArgs[1].mValue))
|
||||
|
|
|
@ -413,6 +413,7 @@ enum BfIRIntrinsic : uint8
|
|||
BfIRIntrinsic_BSwap,
|
||||
BfIRIntrinsic_Cast,
|
||||
BfIRIntrinsic_Cos,
|
||||
BfIRIntrinsic_DebugTrap,
|
||||
BfIRIntrinsic_Div,
|
||||
BfIRIntrinsic_Eq,
|
||||
BfIRIntrinsic_Floor,
|
||||
|
|
|
@ -157,6 +157,7 @@ static const BuiltinEntry gIntrinEntries[] =
|
|||
{"bswap"},
|
||||
{"cast"},
|
||||
{"cos"},
|
||||
{"debugtrap"},
|
||||
{"div"},
|
||||
{"eq"},
|
||||
{"floor"},
|
||||
|
@ -2422,6 +2423,7 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
{ llvm::Intrinsic::bswap, -1},
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // cast,
|
||||
{ llvm::Intrinsic::cos, 0, -1},
|
||||
{ llvm::Intrinsic::debugtrap, -1}, // debugtrap,
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // div
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // eq
|
||||
{ llvm::Intrinsic::floor, 0, -1},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue