1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-26 11:38:02 +02:00

Win32 debugging fixes, more work on custom compile commands

Fixed working dir for 'launch'
Fixed attaching to process - stack trace wasn't updating properly
Fixed more custom compile stuff, and BeefySysLib bin destination
Fixed linking issues related to Bfp* and Bp* exports in both BeefRT and BeefySysLib
Fixed a crash with conditional breakpoints
Fixed release mode IDE issues (related to hot swap breakpoints)
Fixed hotswapping type data with LLVM builds
Fixed 'Pause' state processing Running_ToTempBreakpoint for ScriptManager
Fixed Win32 step out when there's an ESP adjustment at the return site
Made step-out skip over "unimportant" instructions at return site
This commit is contained in:
Brian Fiete 2019-08-29 14:19:07 -07:00
parent 09016c8dc0
commit a367b8165f
60 changed files with 1131 additions and 1065 deletions

View file

@ -132,17 +132,16 @@ namespace IDE
continue;
}
let targetCompleteCmd = new IDEApp.TargetCompletedCmd(project);
if (didCommands)
{
mScriptManager.QueueCommands(scope String()..AppendF("%targetComplete {}", project.mProjectName), targetName, .NoLines);
let targetCompleteCmd = new IDEApp.TargetCompletedCmd(project);
targetCompleteCmd.mIsReady = false;
gApp.mExecutionQueue.Add(targetCompleteCmd);
project.mNeedsTargetRebuild = true;
}
gApp.mExecutionQueue.Add(targetCompleteCmd);
return didCommands ? .HadCommands : .Failed;
return didCommands ? .HadCommands : .NoCommands;
}
bool QueueProjectGNULink(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg)
@ -558,6 +557,15 @@ namespace IDE
}
}
if (depProject.mGeneralOptions.mTargetType == .BeefLib)
{
let depProjectOptions = gApp.GetCurProjectOptions(depProject);
var linkFlags = scope String();
gApp.ResolveConfigString(workspaceOptions, depProject, depProjectOptions, depProjectOptions.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags);
if (!linkFlags.IsWhiteSpace)
linkLine.Append(linkFlags, " ");
}
/*String depLibTargetPath = scope String();
ResolveConfigString(depProject, depOptions, "$(TargetPath)", error, depLibTargetPath);
@ -901,12 +909,15 @@ namespace IDE
}
}
switch (QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds))
if (hotProject == null)
{
case .NoCommands:
case .HadCommands:
case .Failed:
completedCompileCmd.mFailed = true;
switch (QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds))
{
case .NoCommands:
case .HadCommands:
case .Failed:
completedCompileCmd.mFailed = true;
}
}
if (project.mGeneralOptions.mTargetType == .CustomBuild)

View file

@ -368,6 +368,10 @@ namespace IDE
class StartDebugCmd : ExecutionCmd
{
public bool mWasCompiled;
public this()
{
}
}
public class TargetCompletedCmd : ExecutionCmd
@ -3716,6 +3720,8 @@ namespace IDE
return;
if (mHotResolveState != .None)
return;
if (IsCompiling)
return;
if (mWorkspace.mProjects.IsEmpty)
{
@ -3765,6 +3771,13 @@ namespace IDE
}
}
[IDECommand]
void RunWithStep()
{
mTargetStartWithStep = true;
CompileAndRun();
}
[IDECommand]
void StepInto()
{
@ -3778,8 +3791,7 @@ namespace IDE
}
else
{
mTargetStartWithStep = true;
CompileAndRun();
RunWithStep();
}
}
@ -3802,8 +3814,7 @@ namespace IDE
mRunTimingProfileId = Profiler.StartSampling("RunTiming");
}
mTargetStartWithStep = true;
CompileAndRun();
RunWithStep();
}
}
@ -4166,7 +4177,7 @@ namespace IDE
ShowTab(panel, label, false, setFocus);
if (setFocus)
panel.FocusForKeyboard();
if (!panel.mWidgetWindow.mHasFocus)
if ((!panel.mWidgetWindow.mHasFocus) && (!mRunningTestScript))
panel.mWidgetWindow.SetForeground();
}
@ -5559,7 +5570,7 @@ namespace IDE
//sourceViewPanel.QueueFullRefresh(true);
}
if ((sourceViewPanel.mWidgetWindow != null) && (!HasModalDialogs()))
if ((sourceViewPanel.mWidgetWindow != null) && (!HasModalDialogs()) && (!mRunningTestScript))
sourceViewPanel.mWidgetWindow.SetForeground();
sourceViewPanelTab.Activate(setFocus);
sourceViewPanelTab.mTabbedView.FinishTabAnim();
@ -7171,6 +7182,13 @@ namespace IDE
}*/
}
bool buildFailed = false;
if ((mBuildContext != null) && (mBuildContext.Failed))
buildFailed = true;
let buildCompleteCmd = GetBuildCompletedCmd();
if ((buildCompleteCmd != null) && (buildCompleteCmd.mFailed))
buildFailed = true;
bool canExecuteNext = false;
int32 parallelExecutionCount = 16;
if ((mExecutionQueue.Count > 0) && (mExecutionInstances.Count < parallelExecutionCount))
@ -7202,6 +7220,7 @@ namespace IDE
#endif
if ((next is ProcessBfCompileCmd) && (mBfBuildCompiler.HasQueuedCommands() || (waitForBuildClang)))
return;
/*if (next is BuildCompletedCmd)
{
if (mBuildContext != null)
@ -7279,19 +7298,25 @@ namespace IDE
}
else if (next is TargetCompletedCmd)
{
var targetCompletedCmd = (TargetCompletedCmd)next;
targetCompletedCmd.mProject.mNeedsTargetRebuild = false;
targetCompletedCmd.mProject.mForceCustomCommands = false;
if (!buildFailed)
{
var targetCompletedCmd = (TargetCompletedCmd)next;
targetCompletedCmd.mProject.mNeedsTargetRebuild = false;
targetCompletedCmd.mProject.mForceCustomCommands = false;
}
}
else if (next is StartDebugCmd)
{
var startDebugCmd = (StartDebugCmd)next;
if (DebugProject(startDebugCmd.mWasCompiled))
{
OutputLine("Debugger started");
}
else
OutputLine("Failed to start debugger");
if (!buildFailed)
{
var startDebugCmd = (StartDebugCmd)next;
if (DebugProject(startDebugCmd.mWasCompiled))
{
OutputLine("Debugger started");
}
else
OutputLine("Failed to start debugger");
}
}
else if (next is ExecutionQueueCmd)
{
@ -7319,12 +7344,9 @@ namespace IDE
if (!completedCompileCmd.mFailed)
mDepClang.mDoDependencyCheck = false;
#endif
if (mBuildContext != null)
{
if (mBuildContext.Failed)
buildCompletedCmd.mFailed = true;
}
if (buildFailed)
buildCompletedCmd.mFailed = true;
CompileResult(buildCompletedCmd.mHotProjectName, !buildCompletedCmd.mFailed);
if (buildCompletedCmd.mFailed)
@ -8045,6 +8067,22 @@ namespace IDE
newString = options.mDebugOptions.mCommandArguments;
case "WorkingDir":
newString = options.mDebugOptions.mWorkingDirectory;
case "TargetDir":
{
if (project.IsDebugSession)
{
let targetPath = scope:ReplaceBlock String();
DoResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, targetPath);
newString = scope:ReplaceBlock String();
Path.GetDirectoryPath(targetPath, newString);
break;
}
String targetDir = scope String();
DoResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mTargetDirectory, error, targetDir);
newString = scope:ReplaceBlock String();
Path.GetAbsolutePath(targetDir, project.mProjectDir, newString);
}
case "TargetPath":
{
if (project.IsDebugSession)
@ -8087,24 +8125,30 @@ namespace IDE
//Debug.WriteLine("BuildDir: {0}", newString);
case "LinkFlags":
newString = scope:ReplaceBlock String();
#if BF_PLATFORM_WINDOWS
String rtName = scope String();
String dbgName = scope String();
BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
if ((project.mGeneralOptions.mTargetType == .BeefConsoleApplication) ||
(project.mGeneralOptions.mTargetType == .BeefWindowsApplication) ||
(project.mGeneralOptions.mTargetType == .BeefDynLib))
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
default:
}
#if BF_PLATFORM_WINDOWS
String rtName = scope String();
String dbgName = scope String();
BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
default:
}
#else
newString.Append("./libBeefRT_d.so -Wl,-rpath -Wl,.");
#endif
}
case "VSToolPath":
if (workspaceOptions.mMachineType.PtrSize == 4)
newString = gApp.mSettings.mVSSettings.mBin32Path;
@ -8895,6 +8939,8 @@ namespace IDE
{
if (AreTestsRunning())
return false;
if (IsCompiling)
return false;
if (!mExecutionQueue.IsEmpty)
{
@ -8957,6 +9003,8 @@ namespace IDE
protected bool Compile(CompileKind compileKind = .Normal, Project hotProject = null)
{
Debug.Assert(mBuildContext == null);
if (mDbgCompileDump)
{
mDbgCompileIdx++;
@ -9588,13 +9636,15 @@ namespace IDE
//
{
BFWindow.Flags flags = .Border | .ThickFrame | .Resizable | .SysMenu |
.Caption | .Minimize | .Maximize | .QuitOnClose | .Menu;
if (mRunningTestScript)
flags |= .NoActivate;
scope AutoBeefPerf("IDEApp.Init:CreateMainWindow");
mMainWindow = new WidgetWindow(null, "Beef IDE", (int32)mRequestedWindowRect.mX,
(int32)mRequestedWindowRect.mY, (int32)mRequestedWindowRect.mWidth, (int32)mRequestedWindowRect.mHeight,
BFWindow.Flags.Border | BFWindow.Flags.ThickFrame | BFWindow.Flags.Resizable | BFWindow.Flags.SysMenu |
BFWindow.Flags.Caption | BFWindow.Flags.Minimize | BFWindow.Flags.Maximize | BFWindow.Flags.QuitOnClose |
BFWindow.Flags.Menu,
mMainFrame);
flags, mMainFrame);
}
UpdateTitle();
mMainWindow.SetMinimumSize(GS!(480), GS!(360));
@ -10670,7 +10720,7 @@ namespace IDE
}
}
if (!HasModalDialogs())
if ((!HasModalDialogs()) && (!mRunningTestScript))
mMainWindow.SetForeground();
if (mRunTimingProfileId != 0)

View file

@ -25,7 +25,7 @@ namespace IDE
#if SMALLTEST
Debug.WriteLine("Hey!\n");
#else
IDEApp mApp = new IDEApp();
IDEApp mApp = new IDEApp();
mApp.ParseCommandLine(args);
mApp.Init();

View file

@ -186,6 +186,7 @@ namespace IDE
{
DeleteAndClearItems!(mCmdList);
mFailed = false;
mCurCmd = null;
}
public void QueueCommands(StreamReader streamReader, StringView filePath, CmdFlags flags)
@ -466,6 +467,9 @@ namespace IDE
methodName = cmd;
}
if (mFailed)
return;
Target curTarget = mRoot;
for (var cmdPart in methodName.Split('.'))
{
@ -574,6 +578,16 @@ namespace IDE
return gApp.mPlatformName;
else if (token == "config")
return gApp.mConfigName;
else if (token == "optlevel")
{
var workspaceOptions = gApp.GetCurWorkspaceOptions();
if (workspaceOptions != null)
{
String str = new:tempAlloc .();
workspaceOptions.mBfOptimizationLevel.ToString(str);
return str;
}
}
return null;
}
@ -665,7 +679,7 @@ namespace IDE
if (doExec)
{
Exec(mCurCmd.mCmd);
mCurCmd.mExecIdx++;
mCurCmd?.mExecIdx++;
}
if (mCmdList.IsEmpty)
@ -888,7 +902,7 @@ namespace IDE
return false;
}
if (gApp.mBfResolveCompiler.IsPerformingBackgroundOperation())
if ((gApp.mBfResolveCompiler != null) && (gApp.mBfResolveCompiler.IsPerformingBackgroundOperation()))
return false;
if (gApp.[Friend]mDeferredOpen != .None)
return false;
@ -910,6 +924,9 @@ namespace IDE
if (!gApp.[Friend]mExecutionInstances.IsEmpty)
return false;
if (gApp.mDebugger == null)
return true;
if ((!gApp.AreTestsRunning()) && (!gApp.mDebugger.HasPendingDebugLoads()) &&
((gApp.mExecutionPaused) || (!gApp.mDebugger.mIsRunning)))
{
@ -929,6 +946,9 @@ namespace IDE
return false;
}
if (runState == .Running_ToTempBreakpoint)
return false;
Debug.Assert((runState == .NotStarted) || (runState == .Paused) || (runState == .Running_ToTempBreakpoint) ||
(runState == .Exception) || (runState == .Breakpoint) || (runState == .Terminated));
/*if (runState == .Paused)
@ -1133,6 +1153,62 @@ namespace IDE
}
}
public Project GetProject()
{
if (mScriptManager.mProjectName == null)
{
mScriptManager.Fail("Only usable in the context of a project");
return null;
}
let project = gApp.mWorkspace.FindProject(mScriptManager.mProjectName);
if (project == null)
{
mScriptManager.Fail("Unable to find project '{}'", mScriptManager.mProjectName);
return null;
}
return project;
}
[IDECommand]
public void CopyToDependents(String srcPath)
{
let depProject = GetProject();
if (depProject == null)
return;
for (let checkProject in gApp.mWorkspace.mProjects)
{
if (checkProject.HasDependency(depProject.mProjectName))
{
String fileName = scope .();
Path.GetFileName(srcPath, fileName);
List<String> targetPaths = scope .();
defer ClearAndDeleteItems(targetPaths);
let workspaceOptions = gApp.GetCurWorkspaceOptions();
let options = gApp.GetCurProjectOptions(checkProject);
gApp.[Friend]GetTargetPaths(checkProject, workspaceOptions, options, targetPaths);
if (!targetPaths.IsEmpty)
{
String targetDirPath = scope .();
Path.GetDirectoryPath(targetPaths[0], targetDirPath);
String destPath = scope .();
Path.GetAbsolutePath(fileName, targetDirPath, destPath);
if (File.CopyIfNewer(srcPath, destPath) case .Err)
{
mScriptManager.Fail("Failed to copy file '{}' to '{}'", srcPath, destPath);
return;
}
}
}
}
}
[IDECommand]
public void ExecuteRaw(String cmd)
{
@ -1353,6 +1429,49 @@ namespace IDE
ScriptManager.sActiveManager.Fail("Failed to find stack frame containing string '{}'", str);
}
public bool AssertRunning()
{
if (!gApp.mDebugger.mIsRunning)
{
mScriptManager.Fail("Expected target to be running");
return false;
}
return true;
}
public bool AssertDebuggerPaused()
{
if (!gApp.mDebugger.mIsRunning)
{
mScriptManager.Fail("Expected target to be running");
return false;
}
if (!gApp.mDebugger.IsPaused())
{
mScriptManager.Fail("Expected target to be paused");
return false;
}
return true;
}
[IDECommand]
public void StepInto()
{
if (!AssertDebuggerPaused())
return;
gApp.[Friend]StepInto();
}
[IDECommand]
public void StepOver()
{
if (!AssertDebuggerPaused())
return;
gApp.[Friend]StepOver();
}
[IDECommand]
public void SelectThread(String threadName)
{
@ -1948,7 +2067,7 @@ namespace IDE
[IDECommand]
public void Stop()
{
ScriptManager.sActiveManager.Clear();
mScriptManager.Clear();
}
[IDECommand]

View file

@ -351,13 +351,21 @@ namespace IDE.ui
IDEUtils.FixFilePath(targetPath);
String workingDir = scope String();
//
workingDir.Append(mWorkingDirCombo.Label);
if (Path.IsPathRooted(workingDir))
{
String relWorkingDir = scope String();
relWorkingDir.Append(mWorkingDirCombo.Label);
if (!workingDir.IsWhiteSpace)
defer targetPath.Remove(0, targetPath.Length);
Path.GetAbsolutePath(targetPath, workingDir, targetPath);
}
else
{
String targetDir = scope .();
Path.GetDirectoryPath(targetPath, targetDir);
if (!targetDir.IsWhiteSpace)
{
Path.GetAbsolutePath(targetPath, relWorkingDir, workingDir);
defer workingDir.Remove(0, workingDir.Length);
Path.GetAbsolutePath(workingDir, targetDir, workingDir);
}
}

View file

@ -2324,8 +2324,12 @@ namespace IDE.ui
}
public void FocusEdit()
{
GetActivePanel().mEditWidget.SetFocus();
{
let activePanel = GetActivePanel();
activePanel.mEditWidget.SetFocus();
if (!mWidgetWindow.mHasFocus)
EditGotFocus();
}
public override void SetFocus()