1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-07 19:18:19 +02:00

Comptime debugging

This commit is contained in:
Brian Fiete 2022-03-08 06:27:06 -08:00
parent bbb97d1490
commit ff2e40e3bf
40 changed files with 6213 additions and 443 deletions

View file

@ -1080,6 +1080,26 @@ public:
return NULL;
return &this->mVals[this->mSize - addSize];
}
template <typename TAlt>
int BinarySearchAlt(const TAlt& val, const std::function<int(const T& lhs, const TAlt& rhs)>& func)
{
int lo = 0;
int hi = this->mSize - 1;
while (lo <= hi)
{
int i = (lo + hi) / 2;
const T& midVal = this->mVals[i];
int c = func(midVal, val);
if (c == 0) return i;
if (c < 0)
lo = i + 1;
else
hi = i - 1;
}
return ~lo;
}
};
template <typename T, typename TAlloc = AllocatorCLib<T> >

View file

@ -225,6 +225,7 @@ namespace IDE
Add("Comment Toggle", new => gApp.[Friend]CommentToggle, .Editor);
Add("Compile File", new => gApp.Cmd_CompileFile);
Add("Debug All Tests", new () => { gApp.[Friend]RunTests(true, true); });
Add("Debug Comptime", new => gApp.DebugComptime);
Add("Debug Normal Tests", new () => { gApp.[Friend]RunTests(false, true); });
Add("Delete All Right", new => gApp.[Friend]DeleteAllRight);
Add("Duplicate Line", new () => { gApp.[Friend]DuplicateLine(); });

View file

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using System.Diagnostics;
using Beefy.utils;
using IDE.util;
using IDE.Compiler;
namespace IDE.Debugger
{
@ -80,7 +81,8 @@ namespace IDE.Debugger
Optimized = 1,
HasPendingDebugInfo = 2,
CanLoadOldVersion = 4,
WasHotReplaced = 8
WasHotReplaced = 8,
HadError = 0x10
}
//[Flags]
@ -142,6 +144,9 @@ namespace IDE.Debugger
[CallingConvention(.Stdcall),CLink]
static extern bool Debugger_OpenFile(char8* launchPath, char8* targetPath, char8* args, char8* workingDir, void* envBlockPtr, int32 envBlockLen, bool hotSwapEnabled);
[CallingConvention(.Stdcall),CLink]
static extern bool Debugger_ComptimeAttach(void* bfCompiler);
[CallingConvention(.Stdcall),CLink]
static extern bool Debugger_Attach(int32 processId, AttachFlags attachFlags);
@ -371,6 +376,7 @@ namespace IDE.Debugger
public bool mIsRunning;
public bool mIsRunningCompiled;
public bool mIsRunningWithHotSwap;
public bool mIsComptimeDebug;
//public RunState mLastUpdatedRunState;
public bool mCallStackDirty;
public int32 mActiveCallStackIdx;
@ -427,11 +433,21 @@ namespace IDE.Debugger
DeleteAndNullify!(mRunningPath);
mRunningPath = new String(launchPath);
mIsComptimeDebug = false;
mIsRunningCompiled = isCompiled;
mIsRunningWithHotSwap = hotSwapEnabled;
return Debugger_OpenFile(launchPath, targetPath, args, workingDir, envBlock.Ptr, (int32)envBlock.Length, hotSwapEnabled);
}
public bool ComptimeAttach(BfCompiler compiler)
{
mIsComptimeDebug = true;
mIsRunningCompiled = false;
mIsRunningWithHotSwap = false;
mIsRunning = true;
return Debugger_ComptimeAttach(compiler.mNativeBfCompiler);
}
public void SetSymSrvOptions(String symCacheDir, String symSrvStr, SymSrvFlags symSrvFlags)
{
Debugger_SetSymSrvOptions(symCacheDir, symSrvStr, (int32)symSrvFlags);
@ -439,7 +455,9 @@ namespace IDE.Debugger
public bool OpenMiniDump(String file)
{
mIsComptimeDebug = false;
mIsRunningCompiled = false;
mIsRunningWithHotSwap = false;
return Debugger_OpenMiniDump(file);
}
@ -482,6 +500,9 @@ namespace IDE.Debugger
if (breakpoint.mThreadId != -1)
breakpoint.mThreadId = 0;
}
mIsComptimeDebug = false;
mIsRunning = false;
}
public RunState GetRunState()
@ -1083,6 +1104,9 @@ namespace IDE.Debugger
public bool Attach(Process process, AttachFlags attachFlags)
{
mIsRunningCompiled = false;
mIsComptimeDebug = false;
mIsRunningWithHotSwap = false;
return Debugger_Attach(process.Id, attachFlags);
}

View file

@ -862,7 +862,8 @@ namespace IDE
let sourceViewPanel = GetActiveSourceViewPanel();
if (sourceViewPanel != null)
{
Path.GetDirectoryPath(sourceViewPanel.mFilePath, fullDir);
if (sourceViewPanel.mFilePath != null)
Path.GetDirectoryPath(sourceViewPanel.mFilePath, fullDir);
}
else if ((gApp.mDebugger.mRunningPath != null) && (!mWorkspace.IsInitialized))
{
@ -4342,7 +4343,10 @@ namespace IDE
if (mExecutionQueue.Count == 0)
{
mOutputPanel.Clear();
OutputLine("Compiling...");
if (mDebugger?.mIsComptimeDebug == true)
OutputLine("Compiling with comptime debugging...");
else
OutputLine("Compiling...");
Compile(.Normal, null);
}
}
@ -4447,6 +4451,24 @@ namespace IDE
}
}
[IDECommand]
public void DebugComptime()
{
if (mDebugger.mIsRunning)
return;
if (IsCompiling)
return;
CheckDebugVisualizers();
mTargetDidInitBreak = true;
mTargetStartWithStep = false;
mDebugger.ComptimeAttach(mBfBuildCompiler);
mDebugger.RehupBreakpoints(true);
mBfBuildCompiler.ForceRebuild();
Compile();
}
[IDECommand]
void RunWithoutCompiling()
{
@ -5622,6 +5644,7 @@ namespace IDE
subMenu = root.AddMenuItem("&Build");
AddMenuItem(subMenu, "&Build Workspace", "Build Workspace", new => UpdateMenuItem_HasWorkspace);
AddMenuItem(subMenu, "&Debug Comptime", "Debug Comptime", new => UpdateMenuItem_HasWorkspace);
AddMenuItem(subMenu, "&Clean", "Clean", new => UpdateMenuItem_DebugStopped_HasWorkspace);
AddMenuItem(subMenu, "Clean Beef", "Clean Beef", new => UpdateMenuItem_DebugStopped_HasWorkspace);
//subMenu.AddMenuItem("Compile Current File", null, new (menu) => { CompileCurrentFile(); });
@ -7211,7 +7234,7 @@ namespace IDE
// No 'wrong hash' warnings
}
else if (((hash != .None) && (sourceViewPanel.mEditData != null) && (!sourceViewPanel.mEditData.CheckHash(hash))) ||
(sourceViewPanel.mHasChangedSinceLastCompile))
(sourceViewPanel.mHasChangedSinceLastCompile) && (mDebugger?.mIsComptimeDebug != true))
{
sourceViewPanel.ShowWrongHash();
}
@ -7695,6 +7718,11 @@ namespace IDE
void SysKeyDown(KeyDownEvent evt)
{
if (evt.mKeyCode != .Alt)
{
NOP!();
}
if (evt.mHandled)
return;
@ -8723,6 +8751,9 @@ namespace IDE
if ((mVerbosity >= .Detailed) && (buildCompletedCmd.mStopwatch != null))
OutputLine("Total build time: {0:0.00}s", buildCompletedCmd.mStopwatch.ElapsedMilliseconds / 1000.0f);
if (mDebugger?.mIsComptimeDebug == true)
DebuggerComptimeStop();
CompileDone(!buildCompletedCmd.mFailed);
if (mTestManager != null)
@ -9427,6 +9458,9 @@ namespace IDE
bool needsComptime = bfCompiler.GetLastHadComptimeRebuilds();
if (mDebugger?.mIsComptimeDebug == true)
needsComptime = true;
if ((!workspaceOptions.mIncrementalBuild) && (!lastCompileHadMessages))
{
tryQueueFiles = false;
@ -10376,6 +10410,9 @@ namespace IDE
{
Beep(MessageBeepType.Error);
}
if (mDebugger?.mIsComptimeDebug == true)
DebuggerComptimeStop();
}
void DbgCopyChangedFiles(DateTime cmpTime, StringView srcDir, StringView destDir)
@ -10767,6 +10804,9 @@ namespace IDE
if (mDebugger.mIsRunning)
{
if (mDebugger.mIsComptimeDebug)
CancelBuild();
mDebugger.StopDebugging();
}
}
@ -12104,6 +12144,12 @@ namespace IDE
return .Normal;
}
void DebuggerComptimeStop()
{
mDebugger.DisposeNativeBreakpoints();
mDebugger.Detach();
}
void DebuggerPaused()
{
mDebugger.mActiveCallStackIdx = 0;
@ -14027,6 +14073,7 @@ namespace IDE
[Import("user32.lib"), CLink, CallingConvention(.Stdcall)]
public static extern bool MessageBeep(MessageBeepType type);
#endif
}
static

View file

@ -787,6 +787,7 @@ namespace IDE
Add("Comment Block", "Ctrl+K, Ctrl+C");
Add("Comment Lines", "Ctrl+K, Ctrl+/");
Add("Comment Toggle", "Ctrl+K, Ctrl+T");
Add("Debug Comptime", "Alt+F7");
Add("Duplicate Line", "Ctrl+D");
Add("Find Class", "Alt+Shift+L");
Add("Find in Document", "Ctrl+F");

View file

@ -539,6 +539,7 @@ namespace IDE.ui
String sourceLineText = scope .(1024);
int32 maxLine = 0;
int addrOffset = 0;
for (var lineStrView in codeData.Split('\n'))
{
@ -557,6 +558,9 @@ namespace IDE.ui
switch (line[0])
{
case 'A':
addrOffset = (int)int64.Parse(StringView(line, 2), System.Globalization.NumberStyles.HexNumber);
continue;
case 'O':
isOptimized = true;
addLineData = false;
@ -612,7 +616,7 @@ namespace IDE.ui
//int ptrSize = 8;
var addrString = scope String(disasmLine, 0, parenPos);
addrString.Replace("'", "");
lineData.mAddr = (int)int64.Parse(addrString, System.Globalization.NumberStyles.HexNumber);
lineData.mAddr = (int)int64.Parse(addrString, System.Globalization.NumberStyles.HexNumber) + addrOffset;
lineData.mAddrEnd = lineData.mAddr + 1;
if (prevDisasmLineData != -1)
@ -709,7 +713,7 @@ namespace IDE.ui
addLineData = false;
JumpEntry jumpEntry = new JumpEntry();
int64 addrFrom = (int64)mLineDatas[mLineDatas.Count - 1].mAddr;
int64 addrTo = int64.Parse(scope String(line, 2), System.Globalization.NumberStyles.HexNumber);
int64 addrTo = int64.Parse(scope String(line, 2), System.Globalization.NumberStyles.HexNumber) + addrOffset;
jumpEntry.mAddrMin = (int)Math.Min(addrFrom, addrTo);
jumpEntry.mAddrMax = (int)Math.Max(addrFrom, addrTo);
jumpEntry.mIsReverse = jumpEntry.mAddrMin == (int)addrTo;
@ -1193,6 +1197,7 @@ namespace IDE.ui
int leftIdx = -1;
int rightIdx = -1;
int commaIdx = -1;
String debugExpr = null;
if ((cursorPos < content.mData.mTextLength) && (!((char8)content.mData.mText[cursorPos].mChar).IsWhiteSpace))
@ -1208,59 +1213,94 @@ namespace IDE.ui
content.ExtractString(lineStart, lineEnd - lineStart, lineStr);
int strIdx = 0;
int colonPos = -1;
int instrStartIdx = -1;
int instrEndIdx = -1;
int firstParamIdx = -1;
int commaIdx = -1;
bool isComptime = false;
for (int i in 0..<lineStr.Length-1)
{
if ((lineStr[i] == '[') && (lineStr[i+1] == 'F'))
isComptime = true;
}
for (; strIdx < lineStr.Length; strIdx++)
{
char8 c = lineStr[strIdx];
if (colonPos == -1)
{
if (c == ':')
colonPos = strIdx;
}
else if (instrStartIdx == -1)
{
if (c.IsLower)
instrStartIdx = strIdx;
}
else if (instrEndIdx == -1)
{
if (c.IsWhiteSpace)
instrEndIdx = strIdx;
}
else if (firstParamIdx == -1)
{
if (!c.IsWhiteSpace)
firstParamIdx = strIdx;
}
else if (commaIdx == -1)
{
if (c == ',')
commaIdx = strIdx;
}
}
if (isComptime)
{
int cursorStrIdx = cursorPos - lineStart;
if ((cursorStrIdx >= 0) && (cursorStrIdx < lineStr.Length))
{
leftIdx = cursorStrIdx;
rightIdx = cursorStrIdx;
int cursorStrIdx = cursorPos - lineStart;
if (cursorStrIdx > commaIdx)
{
if (commaIdx != -1)
leftIdx = lineStart + commaIdx + 1;
else
leftIdx = lineStart + firstParamIdx;
rightIdx = lineEnd - 1;
}
else if (cursorStrIdx >= firstParamIdx)
{
leftIdx = lineStart + firstParamIdx;
if (commaIdx != -1)
rightIdx = lineStart + commaIdx - 1;
else
rightIdx = lineEnd - 1;
}
while (leftIdx > 0)
{
if (lineStr[leftIdx - 1].IsWhiteSpace)
break;
leftIdx--;
}
while (rightIdx < lineStr.Length - 1)
{
if (lineStr[rightIdx + 1].IsWhiteSpace)
break;
rightIdx++;
}
leftIdx += lineStart;
rightIdx += lineStart;
}
}
else
{
int colonPos = -1;
int instrStartIdx = -1;
int instrEndIdx = -1;
int firstParamIdx = -1;
for (; strIdx < lineStr.Length; strIdx++)
{
char8 c = lineStr[strIdx];
if (colonPos == -1)
{
if (c == ':')
colonPos = strIdx;
}
else if (instrStartIdx == -1)
{
if (c.IsLower)
instrStartIdx = strIdx;
}
else if (instrEndIdx == -1)
{
if (c.IsWhiteSpace)
instrEndIdx = strIdx;
}
else if (firstParamIdx == -1)
{
if (!c.IsWhiteSpace)
firstParamIdx = strIdx;
}
else if (commaIdx == -1)
{
if (c == ',')
commaIdx = strIdx;
}
}
int cursorStrIdx = cursorPos - lineStart;
if (cursorStrIdx > commaIdx)
{
if (commaIdx != -1)
leftIdx = lineStart + commaIdx + 1;
else
leftIdx = lineStart + firstParamIdx;
rightIdx = lineEnd - 1;
}
else if (cursorStrIdx >= firstParamIdx)
{
leftIdx = lineStart + firstParamIdx;
if (commaIdx != -1)
rightIdx = lineStart + commaIdx - 1;
else
rightIdx = lineEnd - 1;
}
}
if (leftIdx != -1)
{
@ -1273,6 +1313,11 @@ namespace IDE.ui
int32 semiPos = (int32)debugExpr.IndexOf(';');
if (semiPos != -1)
debugExpr.RemoveToEnd(semiPos);
debugExpr.Trim();
int atPos = debugExpr.IndexOf('@');
if (atPos != -1)
debugExpr.RemoveToEnd(atPos);
debugExpr.Replace('[', '(');
debugExpr.Replace(']', ')');
@ -1282,6 +1327,13 @@ namespace IDE.ui
debugExpr.Replace("word ptr", "(int16*)");
debugExpr.Replace("byte ptr", "(int8*)");
if ((debugExpr.Contains('(')) && (debugExpr[0].IsLetter))
{
int parenPos = debugExpr.IndexOf('(');
debugExpr.Insert(parenPos, "*)");
debugExpr.Insert(0, "*(");
}
if (line < mLineDatas.Count - 1)
{
if (mLineDatas[line].mAddrEnd != (int)0)

View file

@ -321,6 +321,11 @@ namespace IDE.ui
float statusLabelPos = (int)GS!(-1.3f);
if ((gApp.mDebugger?.mIsComptimeDebug == true) && (gApp.mDebugger.IsPaused()))
{
completionPct = null;
}
//completionPct = 0.4f;
if (completionPct.HasValue)
{
@ -331,6 +336,10 @@ namespace IDE.ui
using (g.PushColor(0xFF00FF00))
g.FillRect(completionRect.mX, completionRect.mY, completionRect.mWidth * completionPct.Value, completionRect.mHeight);
}
else if ((gApp.mDebugger?.mIsComptimeDebug == true) && (gApp.mDebugger.IsPaused()))
{
g.DrawString("Debugging Comptime", GS!(200), statusLabelPos, FontAlign.Centered, GS!(120));
}
else if ((gApp.mDebugger.mIsRunning) && (gApp.HaveSourcesChanged()))
{
Rect completionRect = Rect(GS!(200), GS!(1), GS!(120), GS!(17));

View file

@ -475,9 +475,9 @@ void BeCOFFObject::DbgMakeFuncType(BeDbgFunction* dbgFunc)
if (hasThis)
{
if ((dbgFunc->mVariables.size() > 0) && (dbgFunc->mVariables[0] == NULL))
outT.Write(DbgGetTypeId(dbgFunc->GetParamType(1))); // 0 is sret, 1 = this
outT.Write(DbgGetTypeId(BeValueDynCast<BeDbgType>(dbgFunc->GetParamType(1)))); // 0 is sret, 1 = this
else
outT.Write(DbgGetTypeId(dbgFunc->GetParamType(0))); // 0 = this
outT.Write(DbgGetTypeId(BeValueDynCast<BeDbgType>(dbgFunc->GetParamType(0)))); // 0 = this
}
else
outT.Write((int32)T_VOID);
@ -941,7 +941,7 @@ int BeCOFFObject::DbgGetTypeId(BeDbgType* dbgType, bool doDefine)
{
CV_modifier_t attr = { 0 };
attr.MOD_const = 1;
int32 elementId = DbgGetTypeId(constType->mElement);
int32 elementId = DbgGetTypeId(BeValueDynCast<BeDbgType>(constType->mElement));
DbgTStartTag();
outT.Write((int16)LF_MODIFIER);
@ -985,10 +985,10 @@ void BeCOFFObject::DbgGenerateTypeInfo()
auto& outT = mDebugTSect.mData;
outT.Write((int)CV_SIGNATURE_C13);
for (auto dbgType : mBeModule->mDbgModule->mTypes)
for (auto mdNode : mBeModule->mDbgModule->mTypes)
{
bool defineType = true;
if (auto dbgStructType = BeValueDynCast<BeDbgStructType>(dbgType))
if (auto dbgStructType = BeValueDynCast<BeDbgStructType>(mdNode))
{
if (!dbgStructType->mIsFullyDefined)
defineType = false;
@ -996,7 +996,8 @@ void BeCOFFObject::DbgGenerateTypeInfo()
if (defineType)
{
DbgGetTypeId(dbgType, true);
if (auto dbgType = BeValueDynCast<BeDbgType>(mdNode))
DbgGetTypeId(dbgType, true);
}
}
@ -1032,6 +1033,8 @@ void BeCOFFObject::DbgStartVarDefRange(BeDbgFunction* dbgFunc, BeDbgVariable* db
auto funcSym = GetSymbol(dbgFunc->mValue);
auto varType = BeValueDynCast<BeDbgType>(dbgVar->mType);
auto& outS = mDebugSSect.mData;
if (varLoc.mKind == BeDbgVariableLoc::Kind_SymbolAddr)
{
@ -1042,14 +1045,14 @@ void BeCOFFObject::DbgStartVarDefRange(BeDbgFunction* dbgFunc, BeDbgVariable* db
if (varLoc.mOfs == 0)
{
outS.Write((int16)S_DEFRANGE_REGISTER);
outS.Write((int16)GetCVRegNum(varLoc.mReg, dbgVar->mType->mSize * 8));
outS.Write((int16)GetCVRegNum(varLoc.mReg, varType->mSize * 8));
CV_RANGEATTR rangeAttr = { 0 };
outS.Write(*(int16*)&rangeAttr); // offset to register
}
else
{
outS.Write((int16)S_DEFRANGE_REGISTER_REL);
outS.Write((int16)GetCVRegNum(varLoc.mReg, dbgVar->mType->mSize * 8));
outS.Write((int16)GetCVRegNum(varLoc.mReg, varType->mSize * 8));
outS.Write((int16)0);
outS.Write((int32)varLoc.mOfs);
// CV_RANGEATTR rangeAttr = { 0 };
@ -1135,6 +1138,8 @@ void BeCOFFObject::DbgSEndTag()
void BeCOFFObject::DbgOutputLocalVar(BeDbgFunction* dbgFunc, BeDbgVariable* dbgVar)
{
auto varType = BeValueDynCast<BeDbgType>(dbgVar->mType);
// CodeView only allows 16-bit lengths, so we need to split ranges for very long spans
if (dbgVar->mDeclEnd - dbgVar->mDeclStart > 0xFFFF)
{
@ -1215,7 +1220,7 @@ void BeCOFFObject::DbgOutputLocalVar(BeDbgFunction* dbgFunc, BeDbgVariable* dbgV
DbgSStartTag();
outS.Write((int16)S_LOCAL);
outS.Write(DbgGetTypeId(dbgVar->mType));
outS.Write(DbgGetTypeId(varType));
CV_LVARFLAGS flags = { 0 };
if (dbgVar->mParamNum != -1)
@ -1732,7 +1737,7 @@ void BeCOFFObject::DbgGenerateModuleInfo()
else
outS.Write(dbgGlobalVar->mIsLocalToUnit ? (int16)S_LDATA32 : (int16)S_GDATA32);
outS.Write(DbgGetTypeId(dbgGlobalVar->mType));
outS.Write(DbgGetTypeId(BeValueDynCast<BeDbgType>(dbgGlobalVar->mType)));
BF_ASSERT(dbgGlobalVar->mValue != NULL);
@ -1896,7 +1901,7 @@ void BeCOFFObject::WriteConst(BeCOFFSection& sect, BeConstant* constVal)
{
WriteConst(sect, constCast->mTarget);
}
else if (auto constGep = BeValueDynCast<BeGEPConstant>(constVal))
else if (auto constGep = BeValueDynCast<BeGEP2Constant>(constVal))
{
if (auto globalVar = BeValueDynCast<BeGlobalVariable>(constGep->mTarget))
{

View file

@ -5,6 +5,9 @@
#include "BeefySysLib/util/AllocDebug.h"
#include "BeefySysLib/util/Hash.h"
#include "BeModule.h"
#include "BeContext.h"
#include "..\Compiler\CeMachine.h"
#ifdef _DEBUG
#define BE_EXTRA_CHECKS
@ -228,7 +231,7 @@ BeIRCodeGen::BeIRCodeGen()
mBeContext = NULL;
mBeModule = NULL;
mHasDebugLoc = false;
mDebugging = false;
mDebugging = false;
mCmdCount = 0;
}
@ -736,6 +739,20 @@ void BeIRCodeGen::Read(BeValue*& beValue)
BE_MEM_END("ParamType_Const_BitCast");
return;
}
else if (constType == BfConstType_GEP32_1)
{
CMD_PARAM(BeConstant*, target);
CMD_PARAM(int, idx0);
BF_ASSERT(target->GetType()->IsPointer());
auto gepConstant = mBeModule->mAlloc.Alloc<BeGEP1Constant>();
gepConstant->mTarget = target;
gepConstant->mIdx0 = idx0;
beValue = gepConstant;
BE_MEM_END("ParamType_Const_GEP32_1");
return;
}
else if (constType == BfConstType_GEP32_2)
{
CMD_PARAM(BeConstant*, target);
@ -743,7 +760,7 @@ void BeIRCodeGen::Read(BeValue*& beValue)
CMD_PARAM(int, idx1);
BF_ASSERT(target->GetType()->IsPointer());
auto gepConstant = mBeModule->mAlloc.Alloc<BeGEPConstant>();
auto gepConstant = mBeModule->mAlloc.Alloc<BeGEP2Constant>();
gepConstant->mTarget = target;
gepConstant->mIdx0 = idx0;
gepConstant->mIdx1 = idx1;
@ -2852,7 +2869,15 @@ void BeIRCodeGen::HandleNextCmd()
case BfIRCmd_DbgGetType:
{
CMD_PARAM(int, typeId);
SetResult(curId, GetTypeEntry(typeId).mDIType);
if (mBeModule->mCeMachine != NULL)
{
auto dbgType = mBeModule->mDbgModule->mTypes.Alloc<BeDbgTypeId>();
dbgType->mTypeId = typeId;
SetResult(curId, dbgType);
}
else
SetResult(curId, GetTypeEntry(typeId).mDIType);
}
break;
case BfIRCmd_DbgGetTypeInst:
@ -2974,7 +2999,21 @@ void BeIRCodeGen::HandleNextCmd()
{
CMD_PARAM(BeMDNode*, elementTypeNode);
BeDbgType* elementType = (BeDbgType*)elementTypeNode;
BeDbgType* elementType = BeValueDynCast<BeDbgType>(elementTypeNode);
if (elementType == NULL)
{
if (auto dbgTypeId = BeValueDynCast<BeDbgTypeId>(elementTypeNode))
{
auto bfElementType = mBeModule->mCeMachine->mCeModule->mContext->mTypes[dbgTypeId->mTypeId];
auto bfPtrType = mBeModule->mCeMachine->mCeModule->CreatePointerType(bfElementType);
auto dbgType = mBeModule->mDbgModule->mTypes.Alloc<BeDbgTypeId>();
dbgType->mTypeId = bfPtrType->mTypeId;
SetResult(curId, dbgType);
break;
}
}
BeDbgType* useType = elementType->FindDerivedType(BeDbgPointerType::TypeId);
if (useType == NULL)
{
@ -2992,7 +3031,23 @@ void BeIRCodeGen::HandleNextCmd()
case BfIRCmd_DbgCreateReferenceType:
{
CMD_PARAM(BeMDNode*, elementTypeNode);
auto useType = mBeModule->mDbgModule->CreateReferenceType((BeDbgType*)elementTypeNode);
BeDbgType* elementType = BeValueDynCast<BeDbgType>(elementTypeNode);
if (elementType == NULL)
{
if (auto dbgTypeId = BeValueDynCast<BeDbgTypeId>(elementTypeNode))
{
auto bfElementType = mBeModule->mCeMachine->mCeModule->mContext->mTypes[dbgTypeId->mTypeId];
auto bfPtrType = mBeModule->mCeMachine->mCeModule->CreateRefType(bfElementType);
auto dbgType = mBeModule->mDbgModule->mTypes.Alloc<BeDbgTypeId>();
dbgType->mTypeId = bfPtrType->mTypeId;
SetResult(curId, dbgType);
break;
}
}
auto useType = mBeModule->mDbgModule->CreateReferenceType(elementType);
SetResult(curId, useType);
}
break;
@ -3000,7 +3055,15 @@ void BeIRCodeGen::HandleNextCmd()
{
CMD_PARAM(BeMDNode*, elementTypeNode);
BeDbgType* elementType = (BeDbgType*)elementTypeNode;
BeDbgType* elementType = BeValueDynCast<BeDbgType>(elementTypeNode);
if (elementType == NULL)
{
auto dbgType = mBeModule->mDbgModule->mTypes.Alloc<BeDbgConstType>();
dbgType->mElement = elementTypeNode;
SetResult(curId, dbgType);
break;
}
BeDbgType* useType = elementType->FindDerivedType(BeDbgConstType::TypeId);
if (useType == NULL)
{
@ -3363,7 +3426,7 @@ void BeIRCodeGen::HandleNextCmd()
auto dbgVar = mBeModule->mOwnedValues.Alloc<BeDbgVariable>();
dbgVar->mName = name;
dbgVar->mType = (BeDbgType*)type;
dbgVar->mType = type;
dbgVar->mParamNum = argNo - 1;
int argIdx = argNo - 1;
@ -3411,7 +3474,7 @@ void BeIRCodeGen::HandleNextCmd()
auto dbgVar = mBeModule->mOwnedValues.Alloc<BeDbgVariable>();
dbgVar->mName = name;
dbgVar->mType = (BeDbgType*)type;
dbgVar->mType = type;
dbgVar->mScope = scope;
dbgVar->mInitType = (BfIRInitType)initType;
mActiveFunction->mDbgFunction->mVariables.push_back(dbgVar);
@ -3490,7 +3553,7 @@ void BeIRCodeGen::HandleNextCmd()
dbgGlobalVariable->mLinkageName = linkageName;
dbgGlobalVariable->mFile = (BeDbgFile*)file;
dbgGlobalVariable->mLineNum = lineNum;
dbgGlobalVariable->mType = (BeDbgType*)type;
dbgGlobalVariable->mType = type;
dbgGlobalVariable->mIsLocalToUnit = isLocalToUnit;
dbgGlobalVariable->mValue = val;
dbgGlobalVariable->mDecl = decl;

View file

@ -82,7 +82,7 @@ public:
BeContext* mBeContext;
BeModule* mBeModule;
Array<BeDbgLoc*> mSavedDebugLocs;
bool mHasDebugLoc;
bool mHasDebugLoc;
int mCmdCount;
Dictionary<int, BeIRCodeGenEntry> mResults;

View file

@ -2279,9 +2279,34 @@ BeMCOperand BeMCContext::GetOperand(BeValue* value, bool allowMetaResult, bool a
return mcOperand;
}
case BeGEPConstant::TypeId:
case BeGEP1Constant::TypeId:
{
auto gepConstant = (BeGEPConstant*)value;
auto gepConstant = (BeGEP1Constant*)value;
auto mcVal = GetOperand(gepConstant->mTarget);
BePointerType* ptrType = (BePointerType*)GetType(mcVal);
BEMC_ASSERT(ptrType->mTypeCode == BeTypeCode_Pointer);
auto result = mcVal;
// We assume we never do both an idx0 and idx1 at once. Fix if we change that.
int byteOffset = 0;
BeType* elementType = ptrType->mElementType;
byteOffset += gepConstant->mIdx0 * ptrType->mElementType->GetStride();
result = AllocRelativeVirtualReg(ptrType, result, GetImmediate(byteOffset), 1);
// The def is primary to create a single 'master location' for the GEP vreg to become legalized before use
auto vregInfo = GetVRegInfo(result);
vregInfo->mDefOnFirstUse = true;
result.mKind = BeMCOperandKind_VReg;
return result;
}
break;
case BeGEP2Constant::TypeId:
{
auto gepConstant = (BeGEP2Constant*)value;
auto mcVal = GetOperand(gepConstant->mTarget);
@ -2887,10 +2912,14 @@ static bool NeedsDecompose(BeConstant* constant)
if (auto targetConstant = BeValueDynCast<BeConstant>(castConst->mValue))
return NeedsDecompose(targetConstant);
}
else if (auto castConst = BeValueDynCast<BeGEPConstant>(constant))
else if (auto castConst = BeValueDynCast<BeGEP1Constant>(constant))
{
return NeedsDecompose(castConst->mTarget);
}
else if (auto castConst = BeValueDynCast<BeGEP2Constant>(constant))
{
return NeedsDecompose(castConst->mTarget);
}
return false;
}
@ -8681,7 +8710,7 @@ void BeMCContext::DoActualization()
else
{
inst->mArg0.mKind = BeMCOperandKind_VRegAddr;
vregInfo->mDbgVariable->mType = mModule->mDbgModule->CreateReferenceType(vregInfo->mDbgVariable->mType);
vregInfo->mDbgVariable->mType = mModule->mDbgModule->CreateReferenceType(BeValueDynCast<BeDbgType>(vregInfo->mDbgVariable->mType));
}
}
vregInfo->mWantsExprActualize = false;

View file

@ -497,7 +497,13 @@ void BeStructConstant::GetData(BeConstData& data)
val->GetData(data);
}
BeType* BeGEPConstant::GetType()
BeType* BeGEP1Constant::GetType()
{
BePointerType* ptrType = (BePointerType*)mTarget->GetType();
return ptrType;
}
BeType* BeGEP2Constant::GetType()
{
BePointerType* ptrType = (BePointerType*)mTarget->GetType();
BF_ASSERT(ptrType->mTypeCode == BeTypeCode_Pointer);
@ -1040,6 +1046,12 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
return;
}
if (auto dbgType = BeValueDynCast<BeDbgTypeId>(mdNode))
{
str += StrFormat("DbgTypeId: %d", dbgType->mTypeId);
return;
}
if (auto dbgVar = BeValueDynCast<BeDbgVariable>(mdNode))
{
ToString(str, dbgVar->mType);
@ -1281,9 +1293,17 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
return;
}
if (auto constantGEP = BeValueDynCast<BeGEPConstant>(value))
if (auto constantGEP = BeValueDynCast<BeGEP1Constant>(value))
{
str += "ConstGEP1 ";
ToString(str, constantGEP->mTarget);
str += StrFormat(" %d %d", constantGEP->mIdx0);
return;
}
if (auto constantGEP = BeValueDynCast<BeGEP2Constant>(value))
{
str += "ConstGep ";
str += "ConstGEP2 ";
ToString(str, constantGEP->mTarget);
str += StrFormat(" %d %d", constantGEP->mIdx0, constantGEP->mIdx1);
return;
@ -1373,7 +1393,16 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
return;
}
if (auto constant = BeValueDynCast<BeGEPConstant>(value))
if (auto constant = BeValueDynCast<BeGEP1Constant>(value))
{
ToString(str, constant->GetType());
str += " gep (";
ToString(str, constant->mTarget);
str += StrFormat(", %d)", constant->mIdx0);
return;
}
if (auto constant = BeValueDynCast<BeGEP2Constant>(value))
{
ToString(str, constant->GetType());
str += " gep (";
@ -1762,6 +1791,7 @@ BeModule::BeModule(const StringImpl& moduleName, BeContext* context)
mLastDbgLoc = NULL;
mActiveFunction = NULL;
mDbgModule = NULL;
mCeMachine = NULL;
mPrevDbgLocInline = NULL;
mCurDbgLocIdx = 0;
mCurLexBlockId = 0;

View file

@ -55,6 +55,7 @@ class BePhiInst;
class BeSwitchInst;
class BeRetInst;
class BeCallInst;
class CeMachine;
class BeDbgVariable;
class BeDbgDeclareInst;
@ -357,10 +358,26 @@ public:
}
};
class BeGEPConstant : public BeConstant
class BeGEP1Constant : public BeConstant
{
public:
BE_VALUE_TYPE(BeGEPConstant, BeConstant);
BE_VALUE_TYPE(BeGEP1Constant, BeConstant);
int mIdx0;
virtual BeType* GetType();
virtual void HashContent(BeHashContext& hashCtx) override
{
hashCtx.Mixin(TypeId);
mTarget->HashReference(hashCtx);
hashCtx.Mixin(mIdx0);
}
};
class BeGEP2Constant : public BeConstant
{
public:
BE_VALUE_TYPE(BeGEP2Constant, BeConstant);
int mIdx0;
int mIdx1;
@ -1646,6 +1663,26 @@ public:
}
};
class BeDbgTypeId : public BeMDNode
{
public:
BE_VALUE_TYPE(BeDbgTypeId, BeMDNode);
public:
int mTypeId;
BeDbgTypeId()
{
mTypeId = -1;
}
virtual void HashContent(BeHashContext& hashCtx) override
{
hashCtx.Mixin(TypeId);
hashCtx.Mixin(mTypeId);
}
};
class BeDbgType : public BeMDNode
{
public:
@ -1743,7 +1780,7 @@ public:
BE_VALUE_TYPE(BeDbgConstType, BeDbgType);
public:
BeDbgType* mElement;
BeMDNode* mElement;
virtual void HashContent(BeHashContext& hashCtx) override
{
@ -1920,7 +1957,7 @@ public:
public:
String mName;
BeDbgType* mType;
BeMDNode* mType;
BeValue* mValue;
int mParamNum;
BfIRInitType mInitType;
@ -2044,7 +2081,7 @@ public:
mCvArgListId = -1;
}
BeDbgType* GetParamType(int paramIdx)
BeMDNode* GetParamType(int paramIdx)
{
/*if (!mParams.empty())
return mParams[paramIdx]->mType;*/
@ -2209,7 +2246,7 @@ public:
String mLinkageName;
BeDbgFile* mFile;
int mLineNum;
BeDbgType* mType;
BeMDNode* mType;
bool mIsLocalToUnit;
BeConstant* mValue;
BeMDNode* mDecl;
@ -2246,7 +2283,7 @@ public:
OwnedVector<BeDbgNamespace> mNamespaces;
OwnedVector<BeDbgGlobalVariable> mGlobalVariables;
OwnedVector<BeDbgType> mTypes;
OwnedVector<BeMDNode> mTypes;
Array<BeDbgFunction*> mFuncs; // Does not include methods in structs
virtual void HashContent(BeHashContext& hashCtx) override;
@ -2284,6 +2321,7 @@ public:
int mCurLexBlockId;
BeDbgModule* mDbgModule;
CeMachine* mCeMachine;
public:
void AddInst(BeInst* inst);

View file

@ -750,6 +750,11 @@ public:
return (mKind == BfTypedValueKind_UntypedValue);
}
bool IsNoValueType() const
{
return (mKind == BfTypedValueKind_NoValue);
}
bool IsParams()
{
return (mKind == BfTypedValueKind_ParamsSplat) || (mKind == BfTypedValueKind_Params);

View file

@ -7658,6 +7658,12 @@ void BfCompiler::Cancel()
mCanceling = true;
mFastFinish = true;
mHadCancel = true;
if (mCEMachine != NULL)
{
AutoCrit autoCrit(mCEMachine->mCritSect);
mCEMachine->mSpecialCheck = true;
mFastFinish = true;
}
BfLogSysM("BfCompiler::Cancel\n");
BpEvent("BfCompiler::Cancel", "");
}
@ -7665,6 +7671,8 @@ void BfCompiler::Cancel()
void BfCompiler::RequestFastFinish()
{
mFastFinish = true;
if (mCEMachine != NULL)
mCEMachine->mSpecialCheck = true;
BfLogSysM("BfCompiler::RequestFastFinish\n");
BpEvent("BfCompiler::RequestFastFinish", "");
}

View file

@ -21,6 +21,8 @@
#include "BfFixits.h"
#include "CeMachine.h"
#include "BfDefBuilder.h"
#include "CeMachine.h"
#include "CeDebugger.h"
#pragma warning(pop)
#pragma warning(disable:4996)
@ -4018,6 +4020,35 @@ BfTypedValue BfExprEvaluator::LoadLocal(BfLocalVariable* varDecl, bool allowRef)
BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringImpl& findName, bool ignoreInitialError, bool* hadError)
{
if ((mModule->mCompiler->mCEMachine != NULL) && (mModule->mCompiler->mCEMachine->mDebugger != NULL) && (mModule->mCompiler->mCEMachine->mDebugger->mCurDbgState != NULL))
{
auto ceDebugger = mModule->mCompiler->mCEMachine->mDebugger;
auto ceContext = ceDebugger->mCurDbgState->mCeContext;
auto activeFrame = ceDebugger->mCurDbgState->mActiveFrame;
if (activeFrame->mFunction->mDbgInfo != NULL)
{
int instIdx = activeFrame->GetInstIdx();
for (auto& dbgVar : activeFrame->mFunction->mDbgInfo->mVariables)
{
if (dbgVar.mName == findName)
{
if (dbgVar.mValue.mKind == CeOperandKind_AllocaAddr)
{
return BfTypedValue(mModule->mBfIRBuilder->CreateConstAggCE(mModule->mBfIRBuilder->MapType(dbgVar.mType), activeFrame->mFrameAddr + dbgVar.mValue.mFrameOfs), dbgVar.mType, true);
}
}
}
}
if (findName == "FR")
{
auto ptrType = mModule->CreatePointerType(mModule->GetPrimitiveType(BfTypeCode_UInt8));
auto intVal = mModule->mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, activeFrame->mFrameAddr);
auto ptrVal = mModule->mBfIRBuilder->CreateIntToPtr(intVal, mModule->mBfIRBuilder->MapType(ptrType));
return BfTypedValue(ptrVal, ptrType);
}
}
auto identifierNode = BfNodeDynCast<BfIdentifierNode>(refNode);
if (mModule->mCurMethodState != NULL)
{
@ -4649,7 +4680,8 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
if (isFailurePass)
{
mModule->Fail(StrFormat("'%s.%s' is inaccessible due to its protection level", mModule->TypeToString(typeInstance).c_str(), fieldDef->mName.c_str()), targetSrc);
if (mModule->GetCeDbgState() == NULL)
mModule->Fail(StrFormat("'%s.%s' is inaccessible due to its protection level", mModule->TypeToString(typeInstance).c_str(), fieldDef->mName.c_str()), targetSrc);
}
auto resolvePassData = mModule->mCompiler->mResolvePassData;
@ -6039,23 +6071,46 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
CeEvalFlags evalFlags = CeEvalFlags_None;
if ((mBfEvalExprFlags & BfEvalExprFlags_NoCeRebuildFlags) != 0)
evalFlags = (CeEvalFlags)(evalFlags | CeEvalFlags_NoRebuild);
auto constRet = mModule->mCompiler->mCEMachine->Call(targetSrc, mModule, methodInstance, irArgs, evalFlags, mExpectingType);
if (constRet)
if ((mModule->mIsComptimeModule) && (mModule->mCompiler->mCEMachine->mDebugger != NULL) && (mModule->mCompiler->mCEMachine->mDebugger->mCurDbgState != NULL))
{
auto constant = mModule->mBfIRBuilder->GetConstant(constRet.mValue);
BF_ASSERT(!constRet.mType->IsVar());
return constRet;
}
auto ceDbgState = mModule->mCompiler->mCEMachine->mDebugger->mCurDbgState;
if ((ceDbgState->mDbgExpressionFlags & DwEvalExpressionFlag_AllowCalls) != 0)
{
ceDbgState->mHadSideEffects = true;
if (mModule->mCompiler->mFastFinish)
{
if ((mModule->mCurMethodInstance == NULL) || (!mModule->mCurMethodInstance->mIsAutocompleteMethod))
{
// We didn't properly resolve this so queue for a rebuild later
mModule->DeferRebuildType(mModule->mCurTypeInstance);
SetAndRestoreValue<CeDebugger*> prevDebugger(mModule->mCompiler->mCEMachine->mDebugger, NULL);
evalFlags = (CeEvalFlags)(evalFlags | CeEvalFlags_DbgCall);
auto result = ceDbgState->mCeContext->Call(targetSrc, mModule, methodInstance, irArgs, evalFlags, mExpectingType);
if (result)
return result;
}
else
{
ceDbgState->mBlockedSideEffects = true;
}
}
else
{
auto constRet = mModule->mCompiler->mCEMachine->Call(targetSrc, mModule, methodInstance, irArgs, evalFlags, mExpectingType);
if (constRet)
{
auto constant = mModule->mBfIRBuilder->GetConstant(constRet.mValue);
BF_ASSERT(!constRet.mType->IsVar());
return constRet;
}
if (mModule->mCompiler->mFastFinish)
{
if ((mModule->mCurMethodInstance == NULL) || (!mModule->mCurMethodInstance->mIsAutocompleteMethod))
{
// We didn't properly resolve this so queue for a rebuild later
mModule->DeferRebuildType(mModule->mCurTypeInstance);
}
}
doConstReturn = true;
}
doConstReturn = true;
}
}
else if (mModule->mIsComptimeModule)
@ -17499,6 +17554,51 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
}
return;
}
if (auto ceDbgState = mModule->GetCeDbgState())
{
if (targetFunctionName.StartsWith("__"))
{
auto ceDebugger = mModule->mCompiler->mCEMachine->mDebugger;
auto _ResolveArg = [&](int argIdx, BfType* type = NULL)
{
if (argIdx >= args.mSize)
return BfTypedValue();
return mModule->CreateValueFromExpression(args[argIdx], type);
};
if (targetFunctionName == "__getHighBits")
{
auto typedVal = _ResolveArg(0);
if ((typedVal) && (typedVal.mType->IsPrimitiveType()))
{
auto primType = (BfPrimitiveType*)typedVal.mType;
int64 val = ceDebugger->ValueToInt(typedVal);
int64 bitCount = ceDebugger->ValueToInt(_ResolveArg(1));
int64 resultVal = val >> (typedVal.mType->mSize * 8 - bitCount);
mResult = BfTypedValue(mModule->mBfIRBuilder->CreateConst(primType->mTypeDef->mTypeCode, (uint64)resultVal), typedVal.mType);
return;
}
}
else if (targetFunctionName == "__clearHighBits")
{
auto typedVal = _ResolveArg(0);
if ((typedVal) && (typedVal.mType->IsPrimitiveType()))
{
auto primType = (BfPrimitiveType*)typedVal.mType;
int64 val = ceDebugger->ValueToInt(typedVal);
int64 bitCount = ceDebugger->ValueToInt(_ResolveArg(1));
int64 andBits = (0x8000000000000000LL) >> ((typedVal.mType->mSize - 8) * 8 + bitCount - 1);
int64 resultVal = val & ~andBits;
mResult = BfTypedValue(mModule->mBfIRBuilder->CreateConst(primType->mTypeDef->mTypeCode, (uint64)resultVal), typedVal.mType);
return;
}
}
}
}
}
else if (auto expr = BfNodeDynCast<BfExpression>(target))
{
@ -18968,7 +19068,7 @@ BfTypedValue BfExprEvaluator::PerformAssignment_CheckOp(BfAssignmentExpression*
}
void BfExprEvaluator::PerformAssignment(BfAssignmentExpression* assignExpr, bool evaluatedLeft, BfTypedValue rightValue, BfTypedValue* outCascadeValue)
{
{
auto binaryOp = BfAssignOpToBinaryOp(assignExpr->mOp);
BfExpression* targetNode = assignExpr->mLeft;
@ -19375,10 +19475,54 @@ void BfExprEvaluator::PerformAssignment(BfAssignmentExpression* assignExpr, bool
}
else if (!alreadyWritten)
{
//ptr = mModule->LoadValue(ptr);
BF_ASSERT(ptr.IsAddr());
convVal = mModule->LoadValue(convVal);
auto storeInst = mModule->mBfIRBuilder->CreateAlignedStore(convVal.mValue, ptr.mValue, ptr.mType->mAlign, mIsVolatileReference);
if ((mModule->mIsComptimeModule) && (mModule->mCompiler->mCEMachine->mDebugger != NULL) && (mModule->mCompiler->mCEMachine->mDebugger->mCurDbgState != NULL))
{
auto ceDbgState = mModule->mCompiler->mCEMachine->mDebugger->mCurDbgState;
bool success = false;
if ((convVal.mValue.IsConst()) && (ptr.mValue.IsConst()))
{
auto constant = mModule->mBfIRBuilder->GetConstant(ptr.mValue);
auto valConstant = mModule->mBfIRBuilder->GetConstant(convVal.mValue);
auto ceTypedVal = mModule->mCompiler->mCEMachine->mDebugger->GetAddr(constant);
if (!ceTypedVal)
{
mModule->Fail("Invalid assignment address", assignExpr);
return;
}
auto ceContext = mModule->mCompiler->mCEMachine->mCurContext;
if (ceContext->CheckMemory(ceTypedVal.mAddr, convVal.mType->mSize))
{
if ((ceDbgState->mDbgExpressionFlags & DwEvalExpressionFlag_AllowSideEffects) != 0)
{
ceDbgState->mHadSideEffects = true;
if (ceContext->WriteConstant(mModule, ceTypedVal.mAddr, valConstant, convVal.mType))
success = true;
}
else
{
ceDbgState->mBlockedSideEffects = true;
success = true;
}
}
}
if (!success)
{
mModule->Fail("Assignment failed", assignExpr);
return;
}
}
if (!alreadyWritten)
{
//ptr = mModule->LoadValue(ptr);
BF_ASSERT(ptr.IsAddr());
convVal = mModule->LoadValue(convVal);
auto storeInst = mModule->mBfIRBuilder->CreateAlignedStore(convVal.mValue, ptr.mValue, ptr.mType->mAlign, mIsVolatileReference);
}
}
}
}
@ -21570,7 +21714,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
leftValue.mType = leftValue.mType->GetUnderlyingType();
if ((binaryOp == BfBinaryOp_ConditionalAnd) || (binaryOp == BfBinaryOp_ConditionalOr))
{
{
if (mModule->mCurMethodState->mDeferredLocalAssignData != NULL)
mModule->mCurMethodState->mDeferredLocalAssignData->BreakExtendChain();
if (mModule->mCurMethodState->mCurScope->mScopeKind == BfScopeKind_StatementTarget)

View file

@ -1684,6 +1684,12 @@ String BfIRBuilder::ToString(BfIRValue irValue)
BfIRValue targetConst(BfIRValueFlags_Const, box->mTarget);
return ToString(targetConst) + " box to " + ToString(box->mToType);
}
else if (constant->mConstType == BfConstType_GEP32_1)
{
auto gepConst = (BfConstantGEP32_1*)constant;
BfIRValue targetConst(BfIRValueFlags_Const, gepConst->mTarget);
return ToString(targetConst) + StrFormat(" Gep32 %d", gepConst->mIdx0);
}
else if (constant->mConstType == BfConstType_GEP32_2)
{
auto gepConst = (BfConstantGEP32_2*)constant;
@ -4616,8 +4622,30 @@ BfIRValue BfIRBuilder::CreateIntToPtr(BfIRValue val, BfIRType type)
return retVal;
}
BfIRValue BfIRBuilder::CreateIntToPtr(uint64 val, BfIRType type)
{
return CreateIntToPtr(CreateConst(BfTypeCode_IntPtr, val), type);
}
BfIRValue BfIRBuilder::CreateInBoundsGEP(BfIRValue val, int idx0)
{
if (val.IsConst())
{
auto constGEP = mTempAlloc.Alloc<BfConstantGEP32_1>();
constGEP->mConstType = BfConstType_GEP32_1;
constGEP->mTarget = val.mId;
constGEP->mIdx0 = idx0;
BfIRValue retVal;
retVal.mFlags = BfIRValueFlags_Const;
retVal.mId = mTempAlloc.GetChunkedId(constGEP);
#ifdef CHECK_CONSTHOLDER
retVal.mHolder = this;
#endif
return retVal;
}
BfIRValue retVal = WriteCmd(BfIRCmd_InboundsGEP1_32, val, idx0);
NEW_CMD_INSERTED_IRVALUE;
return retVal;
@ -4650,6 +4678,39 @@ BfIRValue BfIRBuilder::CreateInBoundsGEP(BfIRValue val, int idx0, int idx1)
BfIRValue BfIRBuilder::CreateInBoundsGEP(BfIRValue val, BfIRValue idx0)
{
auto constant = GetConstant(val);
if (constant != NULL)
{
if (constant->mConstType == BfConstType_IntToPtr)
{
auto fromPtrToInt = (BfConstantIntToPtr*)constant;
auto fromTarget = GetConstantById(fromPtrToInt->mTarget);
if (IsInt(fromTarget->mTypeCode))
{
if (fromPtrToInt->mToType.mKind == BfIRTypeData::TypeKind_TypeId)
{
auto type = mModule->mContext->mTypes[fromPtrToInt->mToType.mId];
if (type->IsPointer())
{
auto elementType = type->GetUnderlyingType();
auto addConstant = GetConstant(idx0);
if ((addConstant != NULL) && (IsInt(addConstant->mTypeCode)))
{
return CreateIntToPtr(CreateConst(fromTarget->mTypeCode, (uint64)(fromTarget->mInt64 + addConstant->mInt64 * elementType->GetStride())),
fromPtrToInt->mToType);
}
}
}
}
}
if (auto idxConstant = GetConstant(idx0))
{
if (IsInt(idxConstant->mTypeCode))
return CreateInBoundsGEP(val, idxConstant->mInt32);
}
}
BfIRValue retVal = WriteCmd(BfIRCmd_InBoundsGEP1, val, idx0);
NEW_CMD_INSERTED_IRVALUE;
return retVal;

View file

@ -126,6 +126,7 @@ enum BfConstType
BfConstType_GlobalVar = BfTypeCode_Length,
BfConstType_BitCast,
BfConstType_BitCastNull,
BfConstType_GEP32_1,
BfConstType_GEP32_2,
BfConstType_ExtractValue,
BfConstType_PtrToInt,
@ -878,6 +879,13 @@ struct BfConstantIntToPtr
BfIRType mToType;
};
struct BfConstantGEP32_1
{
BfConstType mConstType;
int mTarget;
int mIdx0;
};
struct BfConstantGEP32_2
{
BfConstType mConstType;
@ -1223,6 +1231,7 @@ public:
BfIRValue CreateBitCast(BfIRValue val, BfIRType type);
BfIRValue CreatePtrToInt(BfIRValue val, BfTypeCode typeCode);
BfIRValue CreateIntToPtr(BfIRValue val, BfIRType type);
BfIRValue CreateIntToPtr(uint64 val, BfIRType type);
BfIRValue CreateInBoundsGEP(BfIRValue val, int idx0);
BfIRValue CreateInBoundsGEP(BfIRValue val, int idx0, int idx1);
BfIRValue CreateInBoundsGEP(BfIRValue val, BfIRValue idx0);

View file

@ -25,6 +25,7 @@
#include "BfDefBuilder.h"
#include "BfDeferEvalChecker.h"
#include "CeMachine.h"
#include "CeDebugger.h"
#include <fcntl.h>
#include <time.h>
@ -1045,7 +1046,7 @@ void BfModule::FinishInit()
mHasFullDebugInfo = moduleOptions.mEmitDebugInfo == 1;
if (mIsComptimeModule)
mHasFullDebugInfo = false;
mHasFullDebugInfo = true;
if (((!mCompiler->mIsResolveOnly) && (!mIsScratchModule) && (moduleOptions.mEmitDebugInfo != 0) && (mIsReified)) ||
(mIsComptimeModule))
@ -1732,6 +1733,15 @@ String* BfModule::GetStringPoolString(BfIRValue constantStr, BfIRConstHolder * c
return NULL;
}
CeDbgState* BfModule::GetCeDbgState()
{
if (!mIsComptimeModule)
return NULL;
if ((mCompiler->mCEMachine != NULL) && (mCompiler->mCEMachine->mDebugger != NULL))
return mCompiler->mCEMachine->mDebugger->mCurDbgState;
return NULL;
}
BfIRValue BfModule::GetStringCharPtr(int stringId, bool force)
{
if ((mBfIRBuilder->mIgnoreWrites) && (!force))
@ -3066,8 +3076,10 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
//BF_ASSERT(refNode != NULL);
if (mIsComptimeModule)
if ((mIsComptimeModule) && (!mCompiler->mCEMachine->mDbgPaused))
{
mHadBuildError = true;
if ((mCompiler->mCEMachine->mCurContext != NULL) && (mCompiler->mCEMachine->mCurContext->mCurTargetSrc != NULL))
{
BfError* bfError = mCompiler->mPassInstance->Fail("Comptime method generation had errors", mCompiler->mCEMachine->mCurContext->mCurTargetSrc);
@ -3075,8 +3087,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
mCompiler->mPassInstance->MoreInfo(error, refNode);
return bfError;
}
mHadBuildError = true;
return NULL;
}
@ -4139,7 +4150,7 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance*
}
}
else if (mBfIRBuilder != NULL)
{
{
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
SetAndRestoreValue<bool> prevIgnoreWrite(mBfIRBuilder->mIgnoreWrites, true);
@ -12452,6 +12463,39 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
return GetDefaultTypedValue(typedValue.mType);
}
}
if ((mIsComptimeModule) && (mCompiler->mCEMachine->mDebugger != NULL) && (mCompiler->mCEMachine->mDebugger->mCurDbgState != NULL))
{
auto ceDebugger = mCompiler->mCEMachine->mDebugger;
auto ceContext = ceDebugger->mCurDbgState->mCeContext;
auto activeFrame = ceDebugger->mCurDbgState->mActiveFrame;
auto ceTypedValue = ceDebugger->GetAddr(constantValue);
if (ceTypedValue)
{
if ((typedValue.mType->IsObjectOrInterface()) || (typedValue.mType->IsPointer()))
{
void* data = ceContext->GetMemoryPtr(ceTypedValue.mAddr, sizeof(addr_ce));
if (data == NULL)
{
Fail("Invalid address", refNode);
return GetDefaultTypedValue(typedValue.mType);
}
addr_ce dataAddr = *(addr_ce*)data;
return BfTypedValue(mBfIRBuilder->CreateIntToPtr(
mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, (uint64)dataAddr), mBfIRBuilder->MapType(typedValue.mType)), typedValue.mType);
}
auto constVal = ceContext->CreateConstant(this, ceContext->mMemory.mVals + ceTypedValue.mAddr, typedValue.mType);
if (!constVal)
{
Fail("Failed to create const", refNode);
return GetDefaultTypedValue(typedValue.mType);
}
return BfTypedValue(constVal, typedValue.mType);
}
}
}
}
@ -14605,6 +14649,11 @@ void BfModule::MarkUsingThis()
BfTypedValue BfModule::GetThis(bool markUsing)
{
if ((mIsComptimeModule) && (mCompiler->mCEMachine->mDebugger != NULL) && (mCompiler->mCEMachine->mDebugger->mCurDbgState != NULL))
{
return mCompiler->mCEMachine->mDebugger->mCurDbgState->mExplicitThis;
}
auto useMethodState = mCurMethodState;
while ((useMethodState != NULL) && (useMethodState->mClosureState != NULL) && (useMethodState->mClosureState->mCapturing))
{
@ -14628,7 +14677,7 @@ BfTypedValue BfModule::GetThis(bool markUsing)
}
}
else
{
{
//TODO: Do we allow useMethodState to be NULL anymore?
return BfTypedValue();
}
@ -16616,6 +16665,7 @@ void BfModule::EmitDtorBody()
}
else
{
PopulateType(fieldInst->mResolvedType);
if (fieldInst->mResolvedType->IsValuelessType())
{
value = mBfIRBuilder->GetFakeVal();

View file

@ -33,6 +33,7 @@ class BfType;
class BfResolvedType;
class BfExprEvaluator;
class CeEmitContext;
class CeDbgState;
enum BfPopulateType
{
@ -1543,6 +1544,7 @@ public:
void VerifyOnDemandMethods();
bool IsSkippingExtraResolveChecks();
bool AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing, bool isWarning);
CeDbgState* GetCeDbgState();
BfError* Fail(const StringImpl& error, BfAstNode* refNode = NULL, bool isPersistent = false, bool deferError = false);
BfError* FailInternal(const StringImpl& error, BfAstNode* refNode = NULL);
BfError* FailAfter(const StringImpl& error, BfAstNode* refNode);

View file

@ -12086,7 +12086,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
if ((typedVal.mType->IsPointer()) && (toType->IsIntPtr()))
{
if ((!typedVal.mType->GetUnderlyingType()->IsVoid()) && ((castFlags & BfCastFlags_FromCompiler) == 0))
{
{
if (!ignoreErrors)
Fail(StrFormat("Unable to cast directly from '%s' to '%s', consider casting to void* first", TypeToString(typedVal.mType).c_str(), TypeToString(toType).c_str()), srcNode);
else if (!silentFail)

View file

@ -720,7 +720,7 @@ BfBlock* BfParser::ParseInlineBlock(int spaceIdx, int endIdx)
while (true)
{
NextToken(endIdx + 1);
NextToken(endIdx + 1, false, true);
if (mSyntaxToken == BfSyntaxToken_HIT_END_IDX)
{
mSrcIdx = usedEndIdx;
@ -1384,7 +1384,7 @@ double BfParser::ParseLiteralDouble()
return strtod(buf, NULL);
}
void BfParser::NextToken(int endIdx, bool outerIsInterpolate)
void BfParser::NextToken(int endIdx, bool outerIsInterpolate, bool disablePreprocessor)
{
auto prevToken = mToken;
@ -2337,7 +2337,13 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate)
}
break;
case '#':
HandlePreprocessor();
if (disablePreprocessor)
{
TokenFail("Unexpected character");
continue;
}
else
HandlePreprocessor();
if (mSyntaxToken == BfSyntaxToken_EOF)
return;
break;

View file

@ -227,7 +227,7 @@ public:
void MoveSource(const char* data, int length); // Takes ownership of data ptr
void RefSource(const char* data, int length);
void MakeNegative(uint64& val, bool& hadOverflow);
void NextToken(int endIdx = -1, bool outerIsInterpolate = false);
void NextToken(int endIdx = -1, bool outerIsInterpolate = false, bool disablePreprocessor = false);
BfAstNode* CreateNode();
void Parse(BfPassInstance* passInstance);

View file

@ -3503,6 +3503,10 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
BF_ASSERT(sizeExpr != NULL);
if (sizeExpr != NULL)
{
BfMethodState methodState;
SetAndRestoreValue<BfMethodState*> prevMethodState(ctx->mModule->mCurMethodState, &methodState);
methodState.mTempKind = BfMethodState::TempKind_Static;
BfConstResolver constResolver(ctx->mModule);
BfType* intType = ctx->mModule->GetPrimitiveType(BfTypeCode_IntPtr);
constResolver.mAllowGenericConstValue = true;

View file

@ -3523,7 +3523,7 @@ void BfModule::VisitCodeBlock(BfBlock* block)
mCurMethodState->mMixinState->mResultExpr = expr;
break;
}
else if ((mCurMethodInstance->IsMixin()) && (mCurMethodState->mCurScope == &mCurMethodState->mHeadScope))
else if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsMixin()) && (mCurMethodState->mCurScope == &mCurMethodState->mHeadScope))
{
// Only in mixin definition - result ignored
CreateValueFromExpression(expr);

View file

@ -27,6 +27,14 @@ String Beefy::EncodeDataPtr(uint32 addr, bool doPrefix)
return StrFormat("%08X", addr);
}
String Beefy::EncodeDataPtr(int addr, bool doPrefix)
{
if (doPrefix)
return StrFormat("0x%08X", addr);
else
return StrFormat("%08X", addr);
}
String Beefy::EncodeDataPtr(uint64 addr, bool doPrefix)
{
if (doPrefix)

View file

@ -269,6 +269,7 @@ void* DecodeLocalDataPtr(const char*& strRef);
String EncodeDataPtr(void* addr, bool doPrefix);
String EncodeDataPtr(uint32 addr, bool doPrefix);
String EncodeDataPtr(uint64 addr, bool doPrefix);
String EncodeDataPtr(int addr, bool doPrefix);
void* ZeroedAlloc(int size);
/*template <typename T>
T* ZeroedAlloc()

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,357 @@
#pragma once
#include "BfSystem.h"
#include "BfModule.h"
#include "BeefySysLib/util/Heap.h"
#include "BeefySysLib/util/AllocDebug.h"
#include "../Debugger.h"
NS_BF_BEGIN
class BfCompiler;
class CeFrame;
class CeExprEvaluator;
class CeContext;
class CeMachine;
class CeFunction;
class BfReducer;
class CeDebugger;
class DebugVisualizerEntry;
class CeBreakpoint : public Breakpoint
{
public:
uintptr mCurBindAddr;
bool mHasBound;
int mIdx;
public:
CeBreakpoint()
{
mCurBindAddr = 1;
mHasBound = false;
mIdx = -1;
}
virtual uintptr GetAddr() { return mCurBindAddr; }
virtual bool IsMemoryBreakpointBound() { return false; }
};
struct CeFormatInfo
{
int mCallStackIdx;
bool mHidePointers;
bool mIgnoreDerivedClassInfo;
bool mNoVisualizers;
bool mNoMembers;
bool mRawString;
bool mNoEdit;
DbgTypeKindFlags mTypeKindFlags;
intptr mArrayLength;
intptr mOverrideCount;
intptr mMaxCount;
DwDisplayType mDisplayType;
int mTotalSummaryLength;
String mReferenceId;
String mSubjectExpr;
String mExpectedType;
String mNamespaceSearch;
int mExpandItemDepth;
BfTypedValue mExplicitThis;
CeFormatInfo()
{
mCallStackIdx = -1;
mHidePointers = false;
mIgnoreDerivedClassInfo = false;
mRawString = false;
mNoVisualizers = false;
mNoMembers = false;
mNoEdit = false;
mTypeKindFlags = DbgTypeKindFlag_None;
mArrayLength = -1;
mOverrideCount = -1;
mMaxCount = -1;
mTotalSummaryLength = 0;
mDisplayType = DwDisplayType_NotSpecified;
mExpandItemDepth = 0;
}
};
class CeEvaluationContext
{
public:
CeDebugger* mDebugger;
BfParser* mParser;
BfReducer* mReducer;
BfPassInstance* mPassInstance;
BfExprEvaluator* mExprEvaluator;
BfExpression* mExprNode;
BfTypedValue mResultOverride;
String mExprString;
BfTypedValue mExplicitThis;
int mCallStackIdx;
public:
CeEvaluationContext(CeDebugger* winDebugger, const StringImpl& expr, CeFormatInfo* formatInfo = NULL, BfTypedValue contextValue = BfTypedValue());
void Init(CeDebugger* winDebugger, const StringImpl& expr, CeFormatInfo* formatInfo = NULL, BfTypedValue contextValue = BfTypedValue());
bool HasExpression();
~CeEvaluationContext();
BfTypedValue EvaluateInContext(BfTypedValue contextTypedValue);
String GetErrorStr();
bool HadError();
};
class CeDbgState
{
public:
CeFrame* mActiveFrame;
CeContext* mCeContext;
BfTypedValue mExplicitThis;
DwEvalExpressionFlags mDbgExpressionFlags;
bool mHadSideEffects;
bool mBlockedSideEffects;
public:
CeDbgState()
{
mActiveFrame = NULL;
mCeContext = NULL;
mDbgExpressionFlags = DwEvalExpressionFlag_None;
mHadSideEffects = false;
mBlockedSideEffects = false;
}
};
class CePendingExpr
{
public:
int mThreadId;
BfParser* mParser;
BfType* mExplitType;
CeFormatInfo mFormatInfo;
DwEvalExpressionFlags mExpressionFlags;
int mCursorPos;
BfAstNode* mExprNode;
String mReferenceId;
int mCallStackIdx;
String mResult;
int mIdleTicks;
String mException;
CePendingExpr();
~CePendingExpr();
};
class CeFileInfo
{
public:
Array<CeBreakpoint*> mOrderedBreakpoints;
};
class CeDbgFieldEntry
{
public:
BfType* mType;
int mDataOffset;
public:
CeDbgFieldEntry()
{
mType = NULL;
mDataOffset = 0;
}
};
class CeDbgTypeInfo
{
public:
struct ConstIntEntry
{
public:
int mFieldIdx;
int64 mVal;
};
public:
BfType* mType;
Array<CeDbgFieldEntry> mFieldOffsets;
Array<ConstIntEntry> mConstIntEntries;
};
struct CeTypedValue
{
addr_ce mAddr;
BfIRType mType;
CeTypedValue()
{
mAddr = 0;
mType = BfIRType();
}
CeTypedValue(addr_ce addr, BfIRType type)
{
mAddr = addr;
mType = type;
}
operator bool() const
{
return mType.mKind != BfIRTypeData::TypeKind_None;
}
};
class CeDebugger : public Debugger
{
public:
BfCompiler* mCompiler;
CeMachine* mCeMachine;
DebugManager* mDebugManager;
CePendingExpr* mDebugPendingExpr;
CeDbgState* mCurDbgState;
Array<CeBreakpoint*> mBreakpoints;
Dictionary<String, CeFileInfo*> mFileInfo;
Dictionary<int, CeDbgTypeInfo> mDbgTypeInfoMap;
CeEvaluationContext* mCurEvaluationContext;
CeBreakpoint* mActiveBreakpoint;
int mBreakpointVersion;
bool mBreakpointCacheDirty;
bool mBreakpointFramesDirty;
int mCurDisasmFuncId;
public:
bool SetupStep(int frameIdx = 0);
CeFrame* GetFrame(int callStackIdx);
String EvaluateContinue(CePendingExpr* pendingExpr, BfPassInstance& bfPassInstance);
String Evaluate(const StringImpl& expr, CeFormatInfo formatInfo, int callStackIdx, int cursorPos, int language, DwEvalExpressionFlags expressionFlags);
DwDisplayInfo* GetDisplayInfo(const StringImpl& referenceId);
String GetMemberList(BfType* type, addr_ce addr, addr_ce addrInst, bool isStatic);
DebugVisualizerEntry* FindVisualizerForType(BfType* dbgType, Array<String>* wildcardCaptures);
bool ParseFormatInfo(const StringImpl& formatInfoStr, CeFormatInfo* formatInfo, BfPassInstance* bfPassInstance, int* assignExprOffset, String* assignExprString, String* errorString, BfTypedValue contextTypedValue = BfTypedValue());
String MaybeQuoteFormatInfoParam(const StringImpl& str);
BfTypedValue EvaluateInContext(const BfTypedValue& contextTypedValue, const StringImpl& subExpr, CeFormatInfo* formatInfo = NULL, String* outReferenceId = NULL, String* outErrors = NULL);
void DbgVisFailed(DebugVisualizerEntry* debugVis, const StringImpl& evalString, const StringImpl& errors);
String GetArrayItems(DebugVisualizerEntry* debugVis, BfType* valueType, BfTypedValue& curNode, int& count, String* outContinuationData);
String GetLinkedListItems(DebugVisualizerEntry* debugVis, addr_ce endNodePtr, BfType* valueType, BfTypedValue& curNode, int& count, String* outContinuationData);
String GetDictionaryItems(DebugVisualizerEntry* debugVis, BfTypedValue dictValue, int bucketIdx, int nodeIdx, int& count, String* outContinuationData);
String GetTreeItems(DebugVisualizerEntry* debugVis, Array<addr_ce>& parentList, BfType*& valueType, BfTypedValue& curNode, int count, String* outContinuationData);
bool EvalCondition(DebugVisualizerEntry* debugVis, BfTypedValue typedVal, CeFormatInfo& formatInfo, const StringImpl& condition, const Array<String>& dbgVisWildcardCaptures, String& errorStr);
CeTypedValue GetAddr(BfConstant* constant);
CeTypedValue GetAddr(const BfTypedValue typeVal);
String ReadString(BfTypeCode charType, intptr addr, intptr maxLength, CeFormatInfo& formatInfo);
void ProcessEvalString(BfTypedValue useTypedValue, String& evalStr, String& displayString, CeFormatInfo& formatInfo, DebugVisualizerEntry* debugVis, bool limitLength);
String TypedValueToString(const BfTypedValue& typedValue, const StringImpl& expr, CeFormatInfo& formatFlags, bool fullPrecision = false);
void HandleCustomExpandedItems(String& retVal, DebugVisualizerEntry* debugVis, BfTypedValue typedValue, addr_ce addr, addr_ce addrInst, Array<String>& dbgVisWildcardCaptures, CeFormatInfo& formatInfo);
void ClearBreakpointCache();
void UpdateBreakpointCache();
void UpdateBreakpointFrames();
void UpdateBreakpointAddrs();
void UpdateBreakpoints(CeFunction* ceFunction);
void Continue();
CeDbgTypeInfo* GetDbgTypeInfo(int typeId);
CeDbgTypeInfo* GetDbgTypeInfo(BfIRType irType);
int64 ValueToInt(const BfTypedValue& typedVal);
BfType* FindType(const StringImpl& name);
public:
CeDebugger(DebugManager* debugManager, BfCompiler* bfCompiler);
~CeDebugger();
virtual void OutputMessage(const StringImpl& msg) override;
virtual void OutputRawMessage(const StringImpl& msg) override;
virtual int GetAddrSize() override;
virtual bool CanOpen(const StringImpl& fileName, DebuggerResult* outResult) override;
virtual void OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array<uint8>& envBlock, bool hotSwapEnabled) override;
virtual bool Attach(int processId, BfDbgAttachFlags attachFlags) override;
virtual void Run() override;
virtual void HotLoad(const Array<String>& objectFiles, int hotIdx) override;
virtual void InitiateHotResolve(DbgHotResolveFlags flags) override;
virtual intptr GetDbgAllocHeapSize() override;
virtual String GetDbgAllocInfo() override;
virtual void Update() override;
virtual void ContinueDebugEvent() override;
virtual void ForegroundTarget() override;
virtual Breakpoint* CreateBreakpoint(const StringImpl& fileName, int lineNum, int wantColumn, int instrOffset) override;
virtual Breakpoint* CreateMemoryBreakpoint(intptr addr, int byteCount) override;
virtual Breakpoint* CreateSymbolBreakpoint(const StringImpl& symbolName) override;
virtual Breakpoint* CreateAddressBreakpoint(intptr address) override;
virtual uintptr GetBreakpointAddr(Breakpoint* breakpoint) override;
virtual void CheckBreakpoint(Breakpoint* breakpoint) override;
virtual void HotBindBreakpoint(Breakpoint* wdBreakpoint, int lineNum, int hotIdx) override;
virtual void DeleteBreakpoint(Breakpoint* wdBreakpoint) override;
virtual void DetachBreakpoint(Breakpoint* wdBreakpoint) override;
virtual void MoveBreakpoint(Breakpoint* wdBreakpoint, int lineNum, int wantColumn, bool rebindNow) override;
virtual void MoveMemoryBreakpoint(Breakpoint* wdBreakpoint, intptr addr, int byteCount) override;
virtual void DisableBreakpoint(Breakpoint* wdBreakpoint) override;
virtual void SetBreakpointCondition(Breakpoint* wdBreakpoint, const StringImpl& condition) override;
virtual void SetBreakpointLogging(Breakpoint* wdBreakpoint, const StringImpl& logging, bool breakAfterLogging) override;
virtual Breakpoint* FindBreakpointAt(intptr address) override;
virtual Breakpoint* GetActiveBreakpoint() override;
virtual void BreakAll() override;
virtual bool TryRunContinue() override;
virtual void StepInto(bool inAssembly) override;
virtual void StepIntoSpecific(intptr addr) override;
virtual void StepOver(bool inAssembly) override;
virtual void StepOut(bool inAssembly) override;
virtual void SetNextStatement(bool inAssembly, const StringImpl& fileName, int64 lineNumOrAsmAddr, int wantColumn) override;
//virtual DbgTypedValue GetRegister(const StringImpl& regName, CPURegisters* registers, Array<RegForm>* regForms = NULL) override;
virtual String Evaluate(const StringImpl& expr, int callStackIdx, int cursorPos, int language, DwEvalExpressionFlags expressionFlags) override;
virtual String EvaluateContinue() override;
virtual void EvaluateContinueKeep() override;
virtual String EvaluateToAddress(const StringImpl& expr, int callStackIdx, int cursorPos) override;
virtual String EvaluateAtAddress(const StringImpl& expr, intptr atAddr, int cursorPos) override;
virtual String GetCollectionContinuation(const StringImpl& continuationData, int callStackIdx, int count) override;
virtual String GetAutoExpressions(int callStackIdx, uint64 memoryRangeStart, uint64 memoryRangeLen) override;
virtual String GetAutoLocals(int callStackIdx, bool showRegs) override;
virtual String CompactChildExpression(const StringImpl& expr, const StringImpl& parentExpr, int callStackIdx) override;
virtual String GetProcessInfo() override;
virtual String GetThreadInfo() override;
virtual void SetActiveThread(int threadId) override;
virtual int GetActiveThread() override;
virtual void FreezeThread(int threadId) override;
virtual void ThawThread(int threadId) override;
virtual bool IsActiveThreadWaiting() override;
virtual void ClearCallStack() override;
virtual void UpdateCallStack(bool slowEarlyOut = true) override;
virtual int GetCallStackCount() override;
virtual int GetRequestedStackFrameIdx() override;
virtual int GetBreakStackFrameIdx() override;
virtual bool ReadMemory(intptr address, uint64 length, void* dest, bool local = false) override;
virtual bool WriteMemory(intptr address, void* src, uint64 length) override;
virtual DbgMemoryFlags GetMemoryFlags(intptr address) override;
virtual void UpdateRegisterUsage(int stackFrameIdx) override;
virtual void UpdateCallStackMethod(int stackFrameIdx) override;
virtual void GetCodeAddrInfo(intptr addr, String* outFile, int* outHotIdx, int* outDefLineStart, int* outDefLineEnd, int* outLine, int* outColumn) override;
virtual void GetStackAllocInfo(intptr addr, int* outThreadId, int* outStackIdx) override;
virtual String GetStackFrameInfo(int stackFrameIdx, intptr* addr, String* outFile, int32* outHotIdx, int32* outDefLineStart, int32* outDefLineEnd, int32* outLine, int32* outColumn, int32* outLanguage, int32* outStackSize, int8* outFlags) override;
virtual String Callstack_GetStackFrameOldFileInfo(int stackFrameIdx) override;
virtual int GetJmpState(int stackFrameIdx) override;
virtual intptr GetStackFrameCalleeAddr(int stackFrameIdx) override;
virtual String GetStackMethodOwner(int stackFrameIdx, int& language) override;
virtual String FindCodeAddresses(const StringImpl& fileName, int line, int column, bool allowAutoResolve) override;
virtual String GetAddressSourceLocation(intptr address) override;
virtual String GetAddressSymbolName(intptr address, bool demangle) override;
virtual String DisassembleAtRaw(intptr address) override;
virtual String DisassembleAt(intptr address) override;
virtual String FindLineCallAddresses(intptr address) override;
virtual String GetCurrentException() override;
virtual String GetModulesInfo() override;
virtual void SetAliasPath(const StringImpl& origPath, const StringImpl& localPath) override;
virtual void CancelSymSrv() override;
virtual bool HasPendingDebugLoads() override;
virtual int LoadImageForModule(const StringImpl& moduleName, const StringImpl& debugFileName) override;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName) override;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName) override;
virtual void StopDebugging() override;
virtual void Terminate() override;
virtual void Detach() override;
virtual Profiler* StartProfiling() override;
virtual Profiler* PopProfiler() override; // Profiler requested by target program
virtual void ReportMemory(MemReporter* memReporter) override;
virtual bool IsOnDemandDebugger() override;
};
NS_BF_END

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,8 @@ class BeSwitchInst;
class BeGlobalVariable;
class CeMachine;
class CeFunction;
class CeDebugger;
class CeBreakpoint;
#define CEOP_SIZED(OPNAME) \
CeOp_##OPNAME##_8, \
@ -69,6 +71,7 @@ enum CeErrorKind
enum CeOp : int16
{
CeOp_InvalidOp,
CeOp_DbgBreak,
CeOp_Ret,
CeOp_SetRetType,
CeOp_Jmp,
@ -204,10 +207,55 @@ enum CeOp : int16
CeOp_COUNT
};
enum CeOperandKind
{
CeOperandKind_None,
CeOperandKind_FrameOfs,
CeOperandKind_AllocaAddr,
CeOperandKind_Block,
CeOperandKind_Immediate,
CeOperandKind_ConstStructTableIdx,
CeOperandKind_CallTableIdx
};
class CeOperand
{
public:
CeOperandKind mKind;
union
{
int mFrameOfs;
int mBlockIdx;
int mImmediate;
int mCallTableIdx;
int mStructTableIdx;
BeConstant* mConstant;
};
BeType* mType;
public:
CeOperand()
{
mKind = CeOperandKind_None;
mFrameOfs = 0;
mType = NULL;
}
operator bool() const
{
return mKind != CeOperandKind_None;
}
bool IsImmediate()
{
return mKind == CeOperandKind_Immediate;
}
};
struct CeEmitEntry
{
int mCodePos;
int mFile;
int mScope;
int mLine;
int mColumn;
};
@ -490,6 +538,40 @@ public:
}
};
class CeDbgVariable
{
public:
String mName;
CeOperand mValue;
BfType* mType;
};
class CeDbgFunctionInfo
{
public:
Array<CeDbgVariable> mVariables;
};
class CeBreakpointBind
{
public:
CeOp mPrevOpCode;
CeBreakpoint* mBreakpoint;
};
struct CeDbgScope
{
public:
String mFilePath;
int mInlinedAt;
public:
CeDbgScope()
{
mInlinedAt = -1;
}
};
class CeFunction
{
public:
@ -511,7 +593,7 @@ public:
bool mFailed;
bool mIsVarReturn;
Array<uint8> mCode;
Array<String> mFiles;
Array<CeDbgScope> mDbgScopes;
Array<CeEmitEntry> mEmitTable;
Array<CeCallEntry> mCallTable;
Array<CeStringEntry> mStringTable;
@ -519,10 +601,13 @@ public:
Array<CeStaticFieldEntry> mStaticFieldTable;
Array<BfType*> mTypeTable;
Array<CeFunction*> mInnerFunctions;
Dictionary<int, CeBreakpointBind> mBreakpoints;
String mGenError;
int mFrameSize;
int mMaxReturnSize;
int mId;
int mId;
int mBreakpointVersion;
CeDbgFunctionInfo* mDbgInfo;
public:
CeFunction()
@ -537,11 +622,15 @@ public:
mIsVarReturn = false;
mFrameSize = 0;
mMaxReturnSize = 0;
mBreakpointVersion = 0;
mId = -1;
mDbgInfo = NULL;
}
~CeFunction();
void Print();
void UnbindBreakpoints();
CeEmitEntry* FindEmitEntry(int loc, int* entryIdx = NULL);
};
enum CeEvalFlags
@ -551,52 +640,8 @@ enum CeEvalFlags
CeEvalFlags_PersistantError = 2,
CeEvalFlags_DeferIfNotOnlyError = 4,
CeEvalFlags_NoRebuild = 8,
CeEvalFlags_ForceReturnThis = 0x10
};
enum CeOperandKind
{
CeOperandKind_None,
CeOperandKind_FrameOfs,
CeOperandKind_AllocaAddr,
CeOperandKind_Block,
CeOperandKind_Immediate,
CeOperandKind_ConstStructTableIdx,
CeOperandKind_CallTableIdx
};
class CeOperand
{
public:
CeOperandKind mKind;
union
{
int mFrameOfs;
int mBlockIdx;
int mImmediate;
int mCallTableIdx;
int mStructTableIdx;
BeConstant* mConstant;
};
BeType* mType;
public:
CeOperand()
{
mKind = CeOperandKind_None;
mFrameOfs = 0;
mType = NULL;
}
operator bool() const
{
return mKind != CeOperandKind_None;
}
bool IsImmediate()
{
return mKind == CeOperandKind_Immediate;
}
CeEvalFlags_ForceReturnThis = 0x10,
CeEvalFlags_DbgCall = 0x20
};
#define BF_CE_DEFAULT_STACK_SIZE 4*1024*1024
@ -609,7 +654,21 @@ public:
enum CeOperandInfoKind
{
CEOI_None,
CEOI_None8 = CEOI_None,
CEOI_None16 = CEOI_None,
CEOI_None32 = CEOI_None,
CEOI_None64 = CEOI_None,
CEOI_NoneF32 = CEOI_None,
CEOI_NoneF64 = CEOI_None,
CEOI_FrameRef,
CEOI_FrameRef8,
CEOI_FrameRef16,
CEOI_FrameRef32,
CEOI_FrameRef64,
CEOI_FrameRefF32,
CEOI_FrameRefF64,
CEOI_IMM8,
CEOI_IMM16,
CEOI_IMM32,
@ -631,18 +690,24 @@ enum CeSizeClass
class CeDumpContext
{
public:
Dictionary<int, CeDbgVariable*> mVarMap;
CeFunction* mCeFunction;
String mStr;
uint8* mStart;
uint8* mPtr;
uint8* mEnd;
int mJmp;
public:
CeDumpContext()
{
mJmp = -1;
}
void DumpOperandInfo(CeOperandInfoKind operandInfoKind);
void Next();
void Dump();
};
@ -760,6 +825,11 @@ public:
mInstPtr = NULL;
mReturnType = NULL;
}
int GetInstIdx()
{
return (int)(mInstPtr - &mFunction->mCode[0] - 2);
}
};
class CeStaticFieldInfo
@ -909,6 +979,7 @@ public:
BfType* GetBfType(BfIRType irType);
void PrepareConstStructEntry(CeConstStructData& constStructData);
bool CheckMemory(addr_ce addr, int32 size);
uint8* GetMemoryPtr(addr_ce addr, int32 size);
bool GetStringFromAddr(addr_ce strInstAddr, StringImpl& str);
bool GetStringFromStringView(addr_ce addr, StringImpl& str);
bool GetCustomAttribute(BfModule* module, BfIRConstHolder* constHolder, BfCustomAttributes* customAttributes, int attributeIdx, addr_ce resultAddr);
@ -928,12 +999,40 @@ struct CeTypeInfo
int mRevision;
};
class CeStepState
{
public:
enum Kind
{
Kind_None,
Kind_StepOver,
Kind_StepOver_Asm,
Kind_StepInfo,
Kind_StepInfo_Asm,
Kind_StepOut,
Kind_StepOut_Asm,
Kind_Jmp
};
Kind mKind;
int mNextInstIdx;
int mStartDepth;
public:
CeStepState()
{
mKind = Kind_None;
mNextInstIdx = -1;
mStartDepth = 0;
}
};
class CeMachine
{
public:
Dictionary<BfMethodInstance*, CeFunctionInfo*> mFunctions;
Dictionary<String, CeFunctionInfo*> mNamedFunctionMap;
Dictionary<int, CeFunction*> mFunctionIdMap; // Only used for 32-bit
Dictionary<int, CeFunction*> mFunctionIdMap; // Only used for 32-bit and debugging
Dictionary<BfType*, CeTypeInfo> mTypeInfoMap;
HashSet<BfMethodInstance*> mMethodInstanceSet;
HashSet<BfFieldInstance*> mFieldInstanceSet;
@ -959,6 +1058,14 @@ public:
BfReducer* mTempReducer;
BfPassInstance* mTempPassInstance;
CritSect mCritSect;
SyncEvent mDebugEvent;
CeStepState mStepState;
CeDebugger* mDebugger;
bool mDbgPaused;
bool mSpecialCheck;
bool mDbgWantBreak;
public:
CeMachine(BfCompiler* compiler);
~CeMachine();
@ -967,6 +1074,7 @@ public:
BeContext* GetBeContext();
BeModule* GetBeModule();
int GetInstSize(CeFunction* ceFunction, int instIdx);
void DerefMethodInfo(CeFunctionInfo* ceFunctionInfo);
void RemoveFunc(CeFunction* ceFunction);
void RemoveMethod(BfMethodInstance* methodInstance);

View file

@ -7676,7 +7676,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue
if (bitCount <= 0)
return argValues[0];
int64 andBits = (0x8000000000000000LL) >> ((argValues[0].mType->GetByteCount() - 8) * 8 + bitCount - 1);
int64 andBits = (0x8000000000000000LL) >> ((argValues[0].mType->GetByteCount() - 8) * 8 + bitCount - 1);
DbgTypedValue result;
result.mType = argValues[0].mType;
result.mInt64 = val & ~andBits;

View file

@ -184,6 +184,49 @@ public:
}
};
struct DwFormatInfo
{
int mCallStackIdx;
bool mHidePointers;
bool mIgnoreDerivedClassInfo;
bool mNoVisualizers;
bool mNoMembers;
bool mRawString;
bool mNoEdit;
DbgTypeKindFlags mTypeKindFlags;
intptr mArrayLength;
intptr mOverrideCount;
intptr mMaxCount;
DwDisplayType mDisplayType;
DbgTypedValue mExplicitThis;
int mTotalSummaryLength;
String mReferenceId;
String mSubjectExpr;
String mExpectedType;
String mNamespaceSearch;
int mExpandItemDepth;
DbgLanguage mLanguage;
DwFormatInfo()
{
mCallStackIdx = -1;
mHidePointers = false;
mIgnoreDerivedClassInfo = false;
mRawString = false;
mNoVisualizers = false;
mNoMembers = false;
mNoEdit = false;
mTypeKindFlags = DbgTypeKindFlag_None;
mArrayLength = -1;
mOverrideCount = -1;
mMaxCount = -1;
mTotalSummaryLength = 0;
mDisplayType = DwDisplayType_NotSpecified;
mExpandItemDepth = 0;
mLanguage = DbgLanguage_Unknown;
}
};
struct DbgMethodArgument
{
DbgTypedValue mTypedValue;

View file

@ -11,6 +11,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "BeefySysLib/util/BeefPerf.h"
#include "NetManager.h"
#include "Compiler/CeDebugger.h"
#ifdef BF_PLATFORM_WINDOWS
#include "DbgMiniDump.h"
@ -79,7 +80,7 @@ DebugManager::DebugManager()
mStepOverExternalFiles = false;
mDebugger32 = NULL;
mDebugger64 = NULL;
mDebugger64 = NULL;
mNetManager = new NetManager();
mNetManager->mDebugManager = this;
@ -97,14 +98,20 @@ DebugManager::DebugManager()
DebugManager::~DebugManager()
{
if ((gDebugger != NULL) && (gDebugger->IsOnDemandDebugger()))
{
delete gDebugger;
gDebugger = NULL;
}
delete mNetManager;
delete mDebugger64;
delete mDebugger32;
delete mDebugger32;
/*for (auto stepFilter : mStepFilters)
{
}*/
delete mDebugVisualizers;
delete mDebugVisualizers;
}
void DebugManager::OutputMessage(const StringImpl& msg)
@ -779,6 +786,12 @@ BF_EXPORT bool BF_CALLTYPE Debugger_OpenFile(const char* launchPath, const char*
return true;
}
BF_EXPORT bool BF_CALLTYPE Debugger_ComptimeAttach(void* bfCompiler)
{
gDebugger = new CeDebugger(gDebugManager, (BfCompiler*)bfCompiler);
return true;
}
BF_EXPORT void BF_CALLTYPE Debugger_SetSymSrvOptions(const char* symCacheDir, const char* symSrvStr, int flags)
{
Array<String> symServers;
@ -1021,7 +1034,7 @@ BF_EXPORT uintptr BF_CALLTYPE Breakpoint_GetAddress(Breakpoint* wdBreakpoint, Br
{
if (outLinkedSibling != NULL)
*outLinkedSibling = wdBreakpoint->mLinkedSibling;
return wdBreakpoint->GetAddr();
return gDebugger->GetBreakpointAddr(wdBreakpoint);
}
BF_EXPORT bool BF_CALLTYPE Breakpoint_IsMemoryBreakpointBound(Breakpoint* wdBreakpoint)

View file

@ -65,7 +65,7 @@ class DebugManager
{
public:
Debugger* mDebugger32;
Debugger* mDebugger64;
Debugger* mDebugger64;
CritSect mCritSect;
Dictionary<String, StepFilter> mStepFilters;

View file

@ -62,6 +62,13 @@ public:
virtual bool IsMemoryBreakpointBound() = 0;
};
enum DbgTypeKindFlags
{
DbgTypeKindFlag_None = 0,
DbgTypeKindFlag_Int = 1
};
enum DwDisplayType : int8
{
DwDisplayType_NotSpecified,
@ -282,6 +289,7 @@ public:
virtual void SetBreakpointLogging(Breakpoint* wdBreakpoint, const StringImpl& logging, bool breakAfterLogging) = 0;
virtual Breakpoint* FindBreakpointAt(intptr address) = 0;
virtual Breakpoint* GetActiveBreakpoint() = 0;
virtual uintptr GetBreakpointAddr(Breakpoint* breakpoint) { return breakpoint->GetAddr(); }
virtual void BreakAll() = 0;
virtual bool TryRunContinue() = 0;
virtual void StepInto(bool inAssembly) = 0;
@ -343,7 +351,7 @@ public:
virtual Profiler* StartProfiling() = 0;
virtual Profiler* PopProfiler() = 0; // Profiler requested by target program
virtual void ReportMemory(MemReporter* memReporter) = 0;
virtual bool IsOnDemandDebugger() = 0;
virtual bool IsOnDemandDebugger() = 0;
};
class Profiler

View file

@ -331,6 +331,7 @@
<ClCompile Include="Compiler\BfTargetTriple.cpp" />
<ClCompile Include="Compiler\BfUtil.cpp" />
<ClCompile Include="Compiler\BfVarDeclChecker.cpp" />
<ClCompile Include="Compiler\CeDebugger.cpp" />
<ClCompile Include="Compiler\CeMachine.cpp" />
<ClCompile Include="Compiler\MemReporter.cpp" />
<ClCompile Include="DbgMiniDump.cpp" />
@ -399,6 +400,7 @@
<ClInclude Include="Compiler\BfCompiler.h" />
<ClInclude Include="Compiler\BfUtil.h" />
<ClInclude Include="Compiler\BfVarDeclChecker.h" />
<ClInclude Include="Compiler\CeDebugger.h" />
<ClInclude Include="Compiler\CeMachine.h" />
<ClInclude Include="third_party\FtsFuzzyMatch.h" />
<ClInclude Include="Compiler\MemReporter.h" />

View file

@ -214,6 +214,9 @@
<ClCompile Include="Compiler\CeMachine.cpp">
<Filter>Compiler</Filter>
</ClCompile>
<ClCompile Include="Compiler\CeDebugger.cpp">
<Filter>Compiler</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Compiler\BfAst.h">
@ -405,5 +408,8 @@
<ClInclude Include="third_party\FtsFuzzyMatch.h">
<Filter>third_party</Filter>
</ClInclude>
<ClInclude Include="Compiler\CeDebugger.h">
<Filter>Compiler</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -5825,7 +5825,7 @@ bool WinDebugger::EvalCondition(DebugVisualizerEntry* debugVis, DbgCompileUnit*
return false;
}
return evalResult.mBool;
return evalResult.mBool;
}
String WinDebugger::GetArrayItems(DbgCompileUnit* dbgCompileUnit, DebugVisualizerEntry* debugVis, DbgType* valueType, DbgTypedValue& curNode, int& count, String* outContinuationData)
@ -8156,7 +8156,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
displayString += "{ " + firstRet + " }";
else
displayString += bigRet;
}
}
DbgType* memberListType = actualType;
bool memberListForceCast = false;
@ -8231,7 +8231,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
return "";
}
retVal += "\n" + displayType->ToString(DbgLanguage_Unknown, true);
retVal += "\n" + displayType->ToString(DbgLanguage_Unknown, true);
memberListType = innerType;
}
@ -11026,6 +11026,7 @@ String WinDebugger::GetStackFrameInfo(int stackFrameIdx, intptr* addr, String* o
FrameFlags_HasPendingDebugInfo = 2,
FrameFlags_CanGetOldSource = 4,
FrameFlags_WasHotReplaced = 8,
FrameFlags_HadError = 0x10
};
AutoCrit autoCrit(mDebugManager->mCritSect);

View file

@ -272,55 +272,6 @@ public:
}
};
enum DbgTypeKindFlags
{
DbgTypeKindFlag_None = 0,
DbgTypeKindFlag_Int = 1
};
struct DwFormatInfo
{
int mCallStackIdx;
bool mHidePointers;
bool mIgnoreDerivedClassInfo;
bool mNoVisualizers;
bool mNoMembers;
bool mRawString;
bool mNoEdit;
DbgTypeKindFlags mTypeKindFlags;
intptr mArrayLength;
intptr mOverrideCount;
intptr mMaxCount;
DwDisplayType mDisplayType;
DbgTypedValue mExplicitThis;
int mTotalSummaryLength;
String mReferenceId;
String mSubjectExpr;
String mExpectedType;
String mNamespaceSearch;
int mExpandItemDepth;
DbgLanguage mLanguage;
DwFormatInfo()
{
mCallStackIdx = -1;
mHidePointers = false;
mIgnoreDerivedClassInfo = false;
mRawString = false;
mNoVisualizers = false;
mNoMembers = false;
mNoEdit = false;
mTypeKindFlags = DbgTypeKindFlag_None;
mArrayLength = -1;
mOverrideCount = -1;
mMaxCount = -1;
mTotalSummaryLength = 0;
mDisplayType = DwDisplayType_NotSpecified;
mExpandItemDepth = 0;
mLanguage = DbgLanguage_Unknown;
}
};
class DbgPendingExpr
{
public:
@ -411,6 +362,8 @@ public:
}
};
struct DwFormatInfo;
class WinDebugger : public Debugger
{
public:
@ -542,7 +495,7 @@ public:
bool SetHotJump(DbgSubprogram* oldSubprogram, addr_target newTarget, int newTargetSize);
DbgSubprogram* TryFollowHotJump(DbgSubprogram* subprogram, addr_target addr);
bool ParseFormatInfo(DbgModule* dbgModule, const StringImpl& formatInfoStr, DwFormatInfo* formatInfo, BfPassInstance* bfPassInstance, int* assignExprOffset, String* assignExpr = NULL, String* errorString = NULL, DbgTypedValue contextTypedValue = DbgTypedValue());
bool ParseFormatInfo(DbgModule* dbgModule, const StringImpl& formatInfoStr, DwFormatInfo* formatInfo, BfPassInstance* bfPassInstance, int* assignExprOffset, String* assignExpr = NULL, String* errorString = NULL, DbgTypedValue contextTypedValue = DbgTypedValue());
String MaybeQuoteFormatInfoParam(const StringImpl& str);
void DbgVisFailed(DebugVisualizerEntry* debugVis, const StringImpl& evalString, const StringImpl& errors);
DbgTypedValue EvaluateInContext(DbgCompileUnit* dbgCompileUnit, const DbgTypedValue& contextTypedValue, const StringImpl& subExpr, DwFormatInfo* formatInfo = NULL, String* outReferenceId = NULL, String* outErrors = NULL);