public bool OnInitialBreakpointReached(int Address, int BreakpointIndex) { if (BreakpointsToAddAfterStartup.Count == 0) { return(false); } // now add all later breakpoints foreach (Types.Breakpoint bp in BreakpointsToAddAfterStartup) { if ((bp.TriggerOnLoad) || (bp.TriggerOnStore)) { if (bp.TriggerOnExec) { // this was already added, remove Debugger.DeleteBreakpoint(bp.RemoteIndex, bp); bp.RemoteIndex = -1; } /* * VICERemoteDebugger.RequestData delData = new VICERemoteDebugger.RequestData( VICERemoteDebugger.Request.ADD_BREAKPOINT, bp.Address ); * delData.Breakpoint = bp; * Debugger.QueueRequest( delData ); */ Debugger.AddBreakpoint(bp); } } // only auto-go on if the initial break point was not the fake first breakpoint if (Address != LateBreakpointOverrideDebugStart) { // need to add new intermediate break point Types.Breakpoint bpTemp = new C64Studio.Types.Breakpoint(); bpTemp.Address = LateBreakpointOverrideDebugStart; bpTemp.TriggerOnExec = true; bpTemp.Temporary = true; Debugger.AddBreakpoint(bpTemp); /* * RemoteDebugger.RequestData addNewBP = new RemoteDebugger.RequestData( RemoteDebugger.Request.ADD_BREAKPOINT, m_LateBreakpointOverrideDebugStart ); * addNewBP.Breakpoint = bpTemp; * Debugger.QueueRequest( addNewBP );*/ } // and auto-go on with debugging Debugger.Run(); if (MarkedDocument != null) { MarkLine(MarkedDocument.DocumentInfo.Project, MarkedDocument.DocumentInfo.FullPath, -1); MarkedDocument = null; } Core.Executing.BringToForeground(); FirstActionAfterBreak = false; Core.MainForm.SetGUIForDebugging(true); return(true); }
public void UnmarkLine() { if (MarkedDocument != null) { MarkedDocument.SetLineMarked(MarkedDocumentLine, false); MarkedDocument = null; } }
public void OpenDocumentAndGotoLine(Project MarkProject, DocumentInfo Document, int Line) { if (Core.MainForm.InvokeRequired) { Core.MainForm.Invoke(new OpenDocumentAndGotoLineCallback(OpenDocumentAndGotoLine), new object[] { MarkProject, Document, Line }); return; } if (Document != null) { var baseDoc = Core.Navigating.FindDocumentByPath(Document.FullPath); if (baseDoc != null) { baseDoc.Show(); baseDoc.SetCursorToLine(Line, true); return; } } if (MarkProject != null) { string inPath = Document.FullPath.Replace("\\", "/"); foreach (ProjectElement element in MarkProject.Elements) { if (GR.Path.IsPathEqual(GR.Path.Append(MarkProject.Settings.BasePath, element.Filename), inPath)) { BaseDocument doc = MarkProject.ShowDocument(element); if (doc != null) { doc.SetCursorToLine(Line, true); } return; } } } if (Document.FullPath.Length > 0) { // file is not part of project BaseDocument newDoc = Core.MainForm.OpenFile(Document.FullPath); if (newDoc != null) { bool setFromMainDoc = false; if ((!setFromMainDoc) && (Core.Compiling.ParserASM.ASMFileInfo.ContainsFile(newDoc.DocumentInfo.FullPath))) { if (!Core.Compiling.IsCurrentlyBuilding()) { newDoc.DocumentInfo.SetASMFileInfo(Core.Compiling.ParserASM.ASMFileInfo, Core.Compiling.ParserASM.KnownTokens(), Core.Compiling.ParserASM.KnownTokenInfo()); } } //Debug.Log( "m_Outline.RefreshFromDocument after showdoc" ); //Core.MainForm.m_Outline.RefreshFromDocument( newDoc.DocumentInfo.BaseDoc ); newDoc.SetCursorToLine(Line, true); } } }
public int CompareTo(object obj) { if (obj is BaseDocument) { BaseDocument temp = (BaseDocument)obj; return(GetHashCode().CompareTo(temp.GetHashCode())); } throw new ArgumentException("object is not a BaseDocument"); }
internal void PreparseDocument(BaseDocument Document) { if (Document.DocumentInfo.Project != null) { Core.MainForm.AddTask(new C64Studio.Tasks.TaskParseFile(Document.DocumentInfo, Document.DocumentInfo.Project.Settings.CurrentConfig)); } else { Core.MainForm.AddTask(new C64Studio.Tasks.TaskParseFile(Document.DocumentInfo, null)); } }
public void MarkLine(Project MarkProject, DocumentInfo Document, int Line) { if (MarkedDocument != null) { if (MarkedDocument.InvokeRequired) { MarkedDocument.Invoke(new Navigating.OpenDocumentAndGotoLineCallback(MarkLine), new object[] { MarkProject, Document, Line }); return; } } UnmarkLine(); string inPath = Document.FullPath.Replace("\\", "/"); if (MarkProject != null) { foreach (ProjectElement element in MarkProject.Elements) { string myPath = GR.Path.Append(MarkProject.Settings.BasePath, element.Filename).Replace("\\", "/"); if (String.Compare(myPath, inPath, true) == 0) { BaseDocument doc = MarkProject.ShowDocument(element); MarkedDocument = doc; MarkedDocumentLine = Line; if (doc != null) { doc.SetLineMarked(Line, Line != -1); } return; } } } foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.DocumentFilename == null) { continue; } string myPath = baseDoc.DocumentFilename.Replace("\\", "/"); if (String.Compare(myPath, inPath, true) == 0) { MarkedDocument = baseDoc; MarkedDocumentLine = Line; baseDoc.Select(); baseDoc.SetLineMarked(Line, Line != -1); return; } } }
public BaseDocument CreateDocument(ProjectElement.ElementType Type) { BaseDocument document = null; switch (Type) { case ProjectElement.ElementType.ASM_SOURCE: document = new SourceASM(MainForm); break; } return(document); }
public void OpenDocumentAndGotoLine(Project MarkProject, string DocumentFilename, int Line) { if (Core.MainForm.InvokeRequired) { Core.MainForm.Invoke(new OpenDocumentAndGotoLineCallback(OpenDocumentAndGotoLine), new object[] { MarkProject, DocumentFilename, Line }); return; } string inPath = DocumentFilename.Replace("\\", "/"); foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.DocumentInfo.FullPath == null) { continue; } string myPath = baseDoc.DocumentInfo.FullPath.Replace("\\", "/"); if (String.Compare(myPath, inPath, true) == 0) { baseDoc.Show(); baseDoc.SetCursorToLine(Line, true); return; } } if (MarkProject != null) { foreach (ProjectElement element in MarkProject.Elements) { if (GR.Path.IsPathEqual(GR.Path.Append(MarkProject.Settings.BasePath, element.Filename), inPath)) { BaseDocument doc = MarkProject.ShowDocument(element); if (doc != null) { doc.SetCursorToLine(Line, true); } return; } } } if (DocumentFilename.Length > 0) { // file is not part of project BaseDocument newDoc = Core.MainForm.OpenFile(DocumentFilename); if (newDoc != null) { newDoc.SetCursorToLine(Line, true); } } }
private void listPETSCII_MouseDoubleClick(object sender, MouseEventArgs e) { if (listPETSCII.SelectedIndex == -1) { return; } Types.C64Character character = (Types.C64Character)listPETSCII.Items[listPETSCII.SelectedIndex].Value; BaseDocument doc = Core.MainForm.ActiveDocument; if (doc != null) { doc.InsertText("" + character.CharValue); } }
private void listChars_ItemActivate(object sender, EventArgs e) { if (listChars.SelectedItems.Count == 0) { return; } Types.C64Character character = (Types.C64Character)listChars.SelectedItems[0].Tag; BaseDocument doc = Core.MainForm.ActiveDocument; if (doc != null) { doc.InsertText("" + character.CharValue); } }
public bool OnInitialBreakpointReached(int Address) { if ((BreakpointsToAddAfterStartup.Count == 0) && (Core.Debugging.OverrideDebugStart == -1)) { return(false); } // now add all later breakpoints foreach (Types.Breakpoint bp in BreakpointsToAddAfterStartup) { Debugger.AddBreakpoint(bp); } // only auto-go on if the initial break point was not the fake first breakpoint if (Address != LateBreakpointOverrideDebugStart) { // need to add new intermediate break point Types.Breakpoint bpTemp = new C64Studio.Types.Breakpoint(); bpTemp.Address = LateBreakpointOverrideDebugStart; bpTemp.TriggerOnExec = true; bpTemp.Temporary = true; Debugger.AddBreakpoint(bpTemp); } if (MarkedDocument != null) { MarkLine(MarkedDocument.DocumentInfo.Project, MarkedDocument.DocumentInfo, -1); MarkedDocument = null; } // keep running for non cart if (!Parser.ASMFileParser.IsCartridge(DebugType)) { Debugger.Run(); } Core.Executing.BringToForeground(); FirstActionAfterBreak = false; Core.MainForm.SetGUIForDebugging(true); // force a reset for cartridges, so the debugger starts at the init // can't reset on a normal file, just hope our break point is not hit too early if (Parser.ASMFileParser.IsCartridge(DebugType)) { Debugger.Reset(); } return(true); }
public void ShowDocument(BaseDocument Doc) { if (Doc.InvokeRequired) { Doc.Invoke(new MainForm.DocCallback(ShowDocument), new object[] { Doc }); return; } if (!Doc.Visible) { //Doc.Show(); Doc.Activate(); } if (Doc.Pane != null) { if (Doc.Pane.ActiveContent != Doc) { Doc.Pane.ActiveContent = Doc; } } }
public BaseDocument FindDocumentByPath(string FullPath) { string inPath = FullPath.Replace("\\", "/"); foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.DocumentInfo.FullPath == null) { continue; } string myPath = baseDoc.DocumentInfo.FullPath.Replace("\\", "/"); if (String.Compare(myPath, inPath, true) == 0) { return(baseDoc); } } return(null); }
public bool NeedsRebuild(DocumentInfo DocInfo, string ConfigSetting) { if (DocInfo == null) { return(false); } // actual parsing and deducing dependencies if a rebuild is necessary! foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.Modified) { Core.AddToOutput("Component '" + baseDoc.DocumentInfo.DocumentFilename + "' needs rebuilding." + System.Environment.NewLine); return(true); } } if (DocInfo.Element != null) { foreach (var dependency in DocInfo.Element.ForcedDependency.DependentOnFile) { var project = Core.Navigating.Solution.GetProjectByName(dependency.Project); if (project == null) { Core.AddToOutput("Could not find dependency project " + dependency.Project + " for " + dependency + System.Environment.NewLine); return(true); } ProjectElement elementDependency = project.GetElementByFilename(dependency.Filename); if (elementDependency == null) { Core.AddToOutput("Could not find dependency " + dependency.Filename + " in project " + dependency.Project + " for " + dependency + System.Environment.NewLine); return(true); } if (NeedsRebuild(elementDependency.DocumentInfo, ConfigSetting)) { Core.AddToOutput("Dependency '" + elementDependency.DocumentInfo.DocumentFilename + "' needs rebuilding." + System.Environment.NewLine); return(true); } foreach (var rebuildFile in m_RebuiltFiles) { if (GR.Path.IsPathEqual(elementDependency.DocumentInfo.DocumentFilename, rebuildFile)) { Core.AddToOutput("Dependency " + elementDependency.DocumentInfo.DocumentFilename + " was rebuilt in this cycle, need to rebuild dependent element " + DocInfo.DocumentFilename + System.Environment.NewLine); return(true); } } } if (DocInfo.DeducedDependency[ConfigSetting] != null) { // custom build overrides output file -> always rebuild if ((DocInfo.Element.Settings.ContainsKey(ConfigSetting)) && (!string.IsNullOrEmpty(DocInfo.Element.Settings[ConfigSetting].CustomBuild)) && (!string.IsNullOrEmpty(DocInfo.Element.TargetFilename))) { Core.AddToOutput("Custom build always requires a rebuild" + System.Environment.NewLine); return(true); } foreach (var dependency in DocInfo.Element.ExternalDependencies.DependentOnFile) { string fullPath = BuildFullPath(DocInfo.Project.Settings.BasePath, dependency.Filename); var fileTime = FileLastWriteTime(fullPath); if (fileTime != DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]) { Core.AddToOutput("External Dependency " + fullPath + " was modified, need to rebuild dependent element " + DocInfo.DocumentFilename + System.Environment.NewLine); return(true); } } } else { // no build time stored yet, needs rebuild DocInfo.DeducedDependency[ConfigSetting] = new DependencyBuildState(); Core.AddToOutput("No last build time found for configuration '" + ConfigSetting + "', need rebuilding." + System.Environment.NewLine); return(true); } // check indirect dependencies from pre build chains if (!DocInfo.Element.Settings.ContainsKey(ConfigSetting)) { DocInfo.Element.Settings.Add(ConfigSetting, new ProjectElement.PerConfigSettings()); } var configSettingInner = DocInfo.Element.Settings[ConfigSetting]; if (configSettingInner.PreBuildChain.Active) { foreach (var chainEntry in configSettingInner.PreBuildChain.Entries) { var chainProject = Core.Navigating.Solution.GetProjectByName(chainEntry.ProjectName); if (chainProject != null) { string fullPath = BuildFullPath(chainProject.Settings.BasePath, chainEntry.DocumentFilename); var fileTime = FileLastWriteTime(fullPath); if (fileTime != DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]) { if (DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath] == default(DateTime)) { Core.AddToOutput($"PreBuild chain entry {fullPath} was modified {fileTime} , need to rebuild dependent element {DocInfo.DocumentFilename}" + System.Environment.NewLine); } else { Core.AddToOutput($"PreBuild chain entry {fullPath} was modified {fileTime} != {DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]}, need to rebuild dependent element {DocInfo.DocumentFilename}" + System.Environment.NewLine); } return(true); } } } } if (configSettingInner.PostBuildChain.Active) { foreach (var chainEntry in configSettingInner.PostBuildChain.Entries) { var chainProject = Core.Navigating.Solution.GetProjectByName(chainEntry.ProjectName); if (chainProject != null) { string fullPath = BuildFullPath(chainProject.Settings.BasePath, chainEntry.DocumentFilename); var fileTime = FileLastWriteTime(fullPath); if (fileTime != DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]) { if (DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath] == default(DateTime)) { Core.AddToOutput($"PostBuild chain entry {fullPath} was modified {fileTime} , need to rebuild dependent element {DocInfo.DocumentFilename}" + System.Environment.NewLine); } else { Core.AddToOutput($"PostBuild chain entry {fullPath} was modified {fileTime} != {DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]}, need to rebuild dependent element {DocInfo.DocumentFilename}" + System.Environment.NewLine); } return(true); } } } } } if (DocInfo.Compilable) { if (!DocInfo.HasBeenSuccessfullyBuilt) { Core.AddToOutput("Element '" + DocInfo.DocumentFilename + "' was not built successfully last time." + System.Environment.NewLine); return(true); } } if (DocInfo.Project == null) { Core.AddToOutput("Element '" + DocInfo.DocumentFilename + "' has no project, therefor needs rebuilding." + System.Environment.NewLine); return(true); } if (DocInfo.DeducedDependency[ConfigSetting] == null) { // no build time stored yet, needs rebuild DocInfo.DeducedDependency[ConfigSetting] = new DependencyBuildState(); Core.AddToOutput("No build time stored for '" + ConfigSetting + "' yet, therefor needs rebuilding." + System.Environment.NewLine); return(true); } foreach (KeyValuePair <string, DateTime> dependency in DocInfo.DeducedDependency[ConfigSetting].BuildState) { var fileTime = FileLastWriteTime(dependency.Key); if (fileTime != dependency.Value) { //Debug.Log( "File time differs for " + dependency.Key ); Core.AddToOutput("File '" + dependency.Key + "' was modified, therefor needs rebuilding." + System.Environment.NewLine); return(true); } } return(false); }
public bool NeedsRebuild(DocumentInfo DocInfo, string ConfigSetting) { if (DocInfo == null) { return(false); } // actual parsing and deducing dependencies if a rebuild is necessary! foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.Modified) { return(true); } } if (DocInfo.Element != null) { foreach (var dependency in DocInfo.Element.ForcedDependency.DependentOnFile) { ProjectElement elementDependency = DocInfo.Project.GetElementByFilename(dependency.Filename); if (elementDependency == null) { Core.AddToOutput("Could not find dependency for " + dependency + System.Environment.NewLine); return(true); } if (NeedsRebuild(elementDependency.DocumentInfo, ConfigSetting)) { return(true); } foreach (var rebuildFile in m_RebuiltFiles) { if (GR.Path.IsPathEqual(elementDependency.DocumentInfo.DocumentFilename, rebuildFile)) { Core.AddToOutput("Dependency " + elementDependency.DocumentInfo.DocumentFilename + " was rebuilt in this cycle, need to rebuild dependent element " + DocInfo.DocumentFilename + System.Environment.NewLine); return(true); } } } if (DocInfo.DeducedDependency[ConfigSetting] != null) { // custom build overrides output file -> always rebuild if ((!string.IsNullOrEmpty(DocInfo.Element.Settings[ConfigSetting].CustomBuild)) && (!string.IsNullOrEmpty(DocInfo.Element.TargetFilename))) { Core.AddToOutput("Custom build always requires a rebuild" + System.Environment.NewLine); return(true); } foreach (var dependency in DocInfo.Element.ExternalDependencies.DependentOnFile) { string fullPath = BuildFullPath(DocInfo.Project.Settings.BasePath, dependency.Filename); DateTime fileTime = new DateTime(); try { if (System.IO.File.Exists(fullPath)) { fileTime = System.IO.File.GetLastWriteTime(fullPath); } } catch { } if (fileTime != DocInfo.DeducedDependency[ConfigSetting].BuildState[fullPath]) { Core.AddToOutput("External Dependency " + fullPath + " was modified, need to rebuild dependent element " + DocInfo.DocumentFilename + System.Environment.NewLine); DocInfo.DeducedDependency[ConfigSetting].BuildState.Add(fullPath, fileTime); return(true); } } } else { // no build time stored yet, needs rebuild DocInfo.DeducedDependency[ConfigSetting] = new DependencyBuildState(); return(true); } } if (DocInfo.Compilable) { if (!DocInfo.HasBeenSuccessfullyBuilt) { return(true); } } if (DocInfo.Project == null) { return(true); } if (DocInfo.DeducedDependency[ConfigSetting] == null) { // no build time stored yet, needs rebuild DocInfo.DeducedDependency[ConfigSetting] = new DependencyBuildState(); return(true); } foreach (KeyValuePair <string, DateTime> dependency in DocInfo.DeducedDependency[ConfigSetting].BuildState) { DateTime fileTime = new DateTime(); try { fileTime = System.IO.File.GetLastWriteTime(dependency.Key); } catch { } if (fileTime != dependency.Value) { //Debug.Log( "File time differs for " + dependency.Key ); return(true); } } return(false); }
public bool NeedsRebuild(DocumentInfo DocInfo, string ConfigSetting) { if (DocInfo == null) { return(false); } // actual parsing and deducing dependencies if a rebuild is necessary! foreach (IDockContent dockContent in Core.MainForm.panelMain.Documents) { BaseDocument baseDoc = (BaseDocument)dockContent; if (baseDoc.Modified) { return(true); } } if (DocInfo.Element != null) { foreach (var dependency in DocInfo.Element.ForcedDependency.DependentOnFile) { ProjectElement elementDependency = DocInfo.Project.GetElementByFilename(dependency.Filename); if (elementDependency == null) { Core.AddToOutput("Could not find dependency for " + dependency + System.Environment.NewLine); return(true); } if (NeedsRebuild(elementDependency.DocumentInfo, ConfigSetting)) { return(true); } foreach (var rebuildFile in m_RebuiltFiles) { if (GR.Path.IsPathEqual(elementDependency.DocumentInfo.DocumentFilename, rebuildFile)) { Core.AddToOutput("Dependency " + elementDependency.DocumentInfo.DocumentFilename + " was rebuilt in this cycle, need to rebuild dependent element " + DocInfo.DocumentFilename + System.Environment.NewLine); return(true); } } } } if (DocInfo.Compilable) { if (!DocInfo.HasBeenSuccessfullyBuilt) { return(true); } } if (DocInfo.Project == null) { return(true); } if (DocInfo.DeducedDependency[ConfigSetting] == null) { // no build time stored yet, needs rebuild DocInfo.DeducedDependency[ConfigSetting] = new DependencyBuildState(); return(true); } foreach (KeyValuePair <string, DateTime> dependency in DocInfo.DeducedDependency[ConfigSetting].BuildState) { DateTime fileTime = new DateTime(); try { fileTime = System.IO.File.GetLastWriteTime(dependency.Key); } catch { } if (fileTime != dependency.Value) { //Debug.Log( "File time differs for " + dependency.Key ); return(true); } } return(false); }
public bool DebugCompiledFile(DocumentInfo DocumentToDebug, DocumentInfo DocumentToRun) { if (DocumentToDebug == null) { Core.AddToOutput("Debug document not found, this is an internal error!"); return(false); } if (DocumentToDebug.Element == null) { Core.AddToOutput("Debugging " + DocumentToDebug.DocumentFilename + System.Environment.NewLine); } else { Core.AddToOutput("Debugging " + DocumentToDebug.Element.Name + System.Environment.NewLine); } ToolInfo toolRun = Core.DetermineTool(DocumentToRun, true); if (toolRun == null) { System.Windows.Forms.MessageBox.Show("No emulator tool has been configured yet!", "Missing emulator tool"); Core.AddToOutput("There is no emulator tool configured!"); return(false); } SetupDebugger(toolRun); if (!Debugger.CheckEmulatorVersion(toolRun)) { return(false); } DebuggedASMBase = DocumentToDebug; DebugBaseDocumentRun = DocumentToRun; Core.MainForm.m_DebugWatch.ReseatWatches(DocumentToDebug.ASMFileInfo); Debugger.ClearCaches(); MemoryViews.ForEach(mv => mv.MarkAllMemoryAsUnknown()); ReseatBreakpoints(DocumentToDebug.ASMFileInfo); AddVirtualBreakpoints(DocumentToDebug.ASMFileInfo); Debugger.ClearAllBreakpoints(); MarkedDocument = null; MarkedDocumentLine = -1; if (!Core.Executing.StartProcess(toolRun, DocumentToRun)) { return(false); } if (!System.IO.Directory.Exists(Core.Executing.RunProcess.StartInfo.WorkingDirectory.Trim(new char[] { '"' }))) { Core.AddToOutput("The determined working directory " + Core.Executing.RunProcess.StartInfo.WorkingDirectory + " does not exist" + System.Environment.NewLine); return(false); } // determine debug target type Types.CompileTargetType targetType = C64Studio.Types.CompileTargetType.NONE; if (DocumentToRun.Element != null) { targetType = DocumentToRun.Element.TargetType; } string fileToRun = ""; if (DocumentToRun.Element != null) { fileToRun = DocumentToRun.Element.TargetFilename; ProjectElement.PerConfigSettings configSetting = DocumentToRun.Element.Settings[DocumentToRun.Project.Settings.CurrentConfig.Name]; if (!string.IsNullOrEmpty(configSetting.DebugFile)) { targetType = configSetting.DebugFileType; } } if (targetType == C64Studio.Types.CompileTargetType.NONE) { targetType = Core.Compiling.m_LastBuildInfo.TargetType; } DebugType = targetType; string breakPointFile = PrepareAfterStartBreakPoints(); string command = toolRun.DebugArguments; if (Parser.ASMFileParser.IsCartridge(targetType)) { command = command.Replace("-initbreak 0x$(DebugStartAddressHex) ", ""); } if ((toolRun.PassLabelsToEmulator) && (DebuggedASMBase.ASMFileInfo != null)) { breakPointFile += DebuggedASMBase.ASMFileInfo.LabelsAsFile(EmulatorInfo.LabelFormat(toolRun)); } if (breakPointFile.Length > 0) { try { TempDebuggerStartupFilename = System.IO.Path.GetTempFileName(); System.IO.File.WriteAllText(TempDebuggerStartupFilename, breakPointFile); command += " -moncommands \"" + TempDebuggerStartupFilename + "\""; } catch (System.IO.IOException ioe) { System.Windows.Forms.MessageBox.Show(ioe.Message, "Error writing temporary file"); Core.AddToOutput("Error writing temporary file"); TempDebuggerStartupFilename = ""; return(false); } } //ParserASM.CompileTarget != Types.CompileTargetType.NONE ) ? ParserASM.CompileTarget : DocumentToRun.Element.TargetType; // need to adjust initial breakpoint address for late added store/load breakpoints? InitialBreakpointIsTemporary = true; //if ( BreakpointsToAddAfterStartup.Count > 0 ) { // yes LateBreakpointOverrideDebugStart = OverrideDebugStart; // special start addresses for different run types if (Parser.ASMFileParser.IsCartridge(targetType)) { OverrideDebugStart = Debugger.ConnectedMachine.InitialBreakpointAddressCartridge; } else { // directly after calling load from ram (as VICE does when autostarting a .prg file) // TODO - check with .t64, .tap, .d64 OverrideDebugStart = Debugger.ConnectedMachine.InitialBreakpointAddress; } } if ((DocumentToDebug.Project != null) && (LateBreakpointOverrideDebugStart == -1) && (!string.IsNullOrEmpty(DocumentToDebug.Project.Settings.CurrentConfig.DebugStartAddressLabel))) { int debugStartAddress = -1; if (!Core.MainForm.DetermineDebugStartAddress(DocumentToDebug, DocumentToDebug.Project.Settings.CurrentConfig.DebugStartAddressLabel, out debugStartAddress)) { Core.AddToOutput("Cannot determine value for debug start address from '" + DocumentToDebug.Project.Settings.CurrentConfig.DebugStartAddressLabel + "'" + System.Environment.NewLine); return(false); } if (debugStartAddress != 0) { InitialBreakpointIsTemporary = false; OverrideDebugStart = debugStartAddress; LateBreakpointOverrideDebugStart = debugStartAddress; } } if (Core.Settings.TrueDriveEnabled) { command = toolRun.TrueDriveOnArguments + " " + command; } else { command = toolRun.TrueDriveOffArguments + " " + command; } bool error = false; Core.Executing.RunProcess.StartInfo.Arguments = Core.MainForm.FillParameters(command, DocumentToRun, true, out error); if (error) { return(false); } if (Parser.ASMFileParser.IsCartridge(targetType)) { Core.Executing.RunProcess.StartInfo.Arguments += " " + Core.MainForm.FillParameters(toolRun.CartArguments, DocumentToRun, true, out error); } else { Core.Executing.RunProcess.StartInfo.Arguments += " " + Core.MainForm.FillParameters(toolRun.PRGArguments, DocumentToRun, true, out error); } if (error) { return(false); } Core.AddToOutput("Calling " + Core.Executing.RunProcess.StartInfo.FileName + " with " + Core.Executing.RunProcess.StartInfo.Arguments + System.Environment.NewLine); Core.Executing.RunProcess.Exited += new EventHandler(Core.MainForm.runProcess_Exited); Core.SetStatus("Running..."); Core.MainForm.SetGUIForWaitOnExternalTool(true); if (Core.Executing.RunProcess.Start()) { DateTime current = DateTime.Now; // new GTK VICE opens up with console window (yuck) which nicely interferes with WaitForInputIdle -> give it 5 seconds to open main window bool waitForInputIdleFailed = false; try { Core.Executing.RunProcess.WaitForInputIdle(5000); } catch (Exception ex) { Debug.Log("WaitForInputIdle failed: " + ex.ToString()); waitForInputIdleFailed = true; } // only connect with debugger if VICE int numConnectionAttempts = 1; if ((string.IsNullOrEmpty(Core.Executing.RunProcess.MainWindowTitle)) && (waitForInputIdleFailed)) { // assume GTK VICE numConnectionAttempts = 10; } if (EmulatorInfo.SupportsDebugging(toolRun)) { //Debug.Log( "Have " + numConnectionAttempts + " attempts" ); Core.AddToOutput("Connection attempt "); for (int i = 0; i < numConnectionAttempts; ++i) { //Debug.Log( "attempt" + i ); Core.AddToOutput((i + 1).ToString()); if (Debugger.ConnectToEmulator(Parser.ASMFileParser.IsCartridge(targetType))) { //Debug.Log( "-succeeded" ); Core.AddToOutput(" succeeded" + System.Environment.NewLine); Core.MainForm.m_CurrentActiveTool = toolRun; DebuggedProject = DocumentToRun.Project; Core.MainForm.AppState = Types.StudioState.DEBUGGING_RUN; Core.MainForm.SetGUIForDebugging(true); break; } // wait a second for (int j = 0; j < 20; ++j) { System.Threading.Thread.Sleep(50); System.Windows.Forms.Application.DoEvents(); } } if (Core.MainForm.AppState != Types.StudioState.DEBUGGING_RUN) { Core.AddToOutput("failed " + numConnectionAttempts + " times, giving up" + System.Environment.NewLine); return(false); } } else { Core.MainForm.m_CurrentActiveTool = toolRun; DebuggedProject = DocumentToRun.Project; Core.MainForm.AppState = Types.StudioState.DEBUGGING_RUN; Core.MainForm.SetGUIForDebugging(true); } } return(true); }
public BaseDocument ShowDocument(ProjectElement Element) { if (Element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER) { return(null); } if (Element.Document == null) { BaseDocument document = Core.MainForm.CreateNewDocument(Element.DocumentInfo.Type, Element.DocumentInfo.Project); if (document == null) { System.Windows.Forms.MessageBox.Show("Could not create document for " + Element.DocumentInfo.Type.ToString(), "Error creating document"); return(null); } Element.Document = document; Element.Document.ShowHint = DockState.Document; Element.Document.Icon = Core.MainForm.IconFromType(Element.DocumentInfo); document.SetProjectElement(Element); document.Core = Core; document.SetDocumentFilename(Element.Filename); if (Element.DocumentInfo.Project == null) { // icon for non project documents document.Icon = System.Drawing.SystemIcons.Asterisk; } if (document.DocumentFilename == null) { // a new file Element.Name = Element.Name; Element.Document.Show(Core.MainForm.panelMain); } else if (document.Load()) { Element.Name = document.Text; //Element.Name; Element.Document.Show(Core.MainForm.panelMain); } else if (!string.IsNullOrEmpty(Element.Filename)) { Element.Document = null; return(null); } if (Element.Document != null) { Element.Document.DocumentInfo = Element.DocumentInfo; Element.DocumentInfo.BaseDoc = Element.Document; } if ((Element.Document != null) && (Element.Document is SourceASMEx)) { Element.Document.DocumentEvent += new BaseDocument.DocumentEventHandler(Core.MainForm.Document_DocumentEvent); } // set known tokens if we have any bool setFromMainDoc = false; if (!string.IsNullOrEmpty(Settings.MainDocument)) { var element = GetElementByFilename(Settings.MainDocument); if ((element != null) && (element.DocumentInfo.Type == ProjectElement.ElementType.ASM_SOURCE) && (element.DocumentInfo.ASMFileInfo != null)) { if (element.DocumentInfo.ASMFileInfo.ContainsFile(Element.DocumentInfo.FullPath)) { if (!Core.Compiling.IsCurrentlyBuilding()) { Element.DocumentInfo.SetASMFileInfo(element.DocumentInfo.ASMFileInfo, element.DocumentInfo.KnownKeywords, element.DocumentInfo.KnownTokens); } setFromMainDoc = true; } } } if ((!setFromMainDoc) && (Core.Compiling.ParserASM.ASMFileInfo.ContainsFile(Element.DocumentInfo.FullPath))) { if (!Core.Compiling.IsCurrentlyBuilding()) { Element.DocumentInfo.SetASMFileInfo(Core.Compiling.ParserASM.ASMFileInfo, Core.Compiling.ParserASM.KnownTokens(), Core.Compiling.ParserASM.KnownTokenInfo()); } } //Debug.Log( "m_Outline.RefreshFromDocument after showdoc" ); Core.MainForm.m_Outline.RefreshFromDocument(Element.DocumentInfo.BaseDoc); } Element.Document.Select(); Element.IsShown = true; Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.DOCUMENT_OPENED, Element.DocumentInfo)); Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.ELEMENT_OPENED, Element)); return(Element.Document); }