private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) { if (listWatch.SelectedItems.Count == 0) { return; } if (listWatch.SelectedIndices[0] == 0) { return; } int index = listWatch.SelectedIndices[0]; WatchEntry entry = (WatchEntry)listWatch.SelectedItems[0].Tag; var item = listWatch.Items[index]; listWatch.Items.RemoveAt(index); listWatch.Items.Insert(index - 1, item); // also exchange in project settings! if (m_WatchEntries.Count != listWatch.Items.Count) { Debug.Log("Watch Entry count mismatch!!"); } var oldItem = m_WatchEntries[index]; m_WatchEntries[index] = m_WatchEntries[index - 1]; m_WatchEntries[index - 1] = oldItem; /* * m_WatchEntries.RemoveAt( index ); * m_WatchEntries.Insert( index - 1, oldItem ); */ }
private void moveDownToolStripMenuItem_Click( object sender, EventArgs e ) { if ( listWatch.SelectedItems.Count == 0 ) { return; } if ( listWatch.SelectedIndices[0] + 1 == listWatch.Items.Count ) { return; } int index = listWatch.SelectedIndices[0]; WatchEntry entry = (WatchEntry)listWatch.SelectedItems[0].Tag; var item = listWatch.Items[index]; listWatch.Items.RemoveAt( index ); listWatch.Items.Insert( index + 1, item ); // also exchange in project settings! var oldItem = m_WatchEntries[index]; m_WatchEntries.RemoveAt( index ); m_WatchEntries.Insert( index + 1, oldItem ); }
private void contextDebugItem_Opening( object sender, CancelEventArgs e ) { if ( listWatch.SelectedItems.Count == 0 ) { e.Cancel = true; return; } WatchEntry entry = (WatchEntry)listWatch.SelectedItems[0].Tag; watchReadFromMemoryToolStripMenuItem.Checked = entry.DisplayMemory; displayBoundsToolStripMenuItem.Visible = entry.DisplayMemory; toggleEndiannessToolStripMenuItem.Checked = !entry.BigEndian; moveDownToolStripMenuItem.Enabled = ( listWatch.SelectedIndices[0] + 1 < listWatch.Items.Count ); moveUpToolStripMenuItem.Enabled = ( listWatch.SelectedIndices[0] > 0 ); if ( displayBoundsToolStripMenuItem.Visible ) { bytes1ToolStripMenuItem.Checked = ( entry.SizeInBytes == 1 ); bytes2ToolStripMenuItem.Checked = ( entry.SizeInBytes == 2 ); bytes4ToolStripMenuItem.Checked = ( entry.SizeInBytes == 4 ); bytes8ToolStripMenuItem.Checked = ( entry.SizeInBytes == 8 ); bytes16ToolStripMenuItem.Checked = ( entry.SizeInBytes == 16 ); bytes32ToolStripMenuItem.Checked = ( entry.SizeInBytes == 32 ); } }
private string TypeToString( WatchEntry Entry ) { string result = Entry.Type.ToString(); if ( !Entry.BigEndian ) { result += ", LE"; } return result; }
private void binaryToolStripMenuItem_Click( object sender, EventArgs e ) { foreach ( ListViewItem item in listWatch.SelectedItems ) { WatchEntry entry = (WatchEntry)item.Tag; entry.Type = WatchEntry.DisplayType.BINARY; item.SubItems[1].Text = TypeToString( entry ); UpdateValue( entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue ); } }
private void toggleEndiannessToolStripMenuItem_Click( object sender, EventArgs e ) { toggleEndiannessToolStripMenuItem.Checked = !toggleEndiannessToolStripMenuItem.Checked; foreach ( ListViewItem item in listWatch.SelectedItems ) { WatchEntry entry = (WatchEntry)item.Tag; entry.BigEndian = !toggleEndiannessToolStripMenuItem.Checked; item.SubItems[1].Text = TypeToString( entry ); UpdateValue( entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue ); } }
private void copySelectedValuesToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { var sb = new StringBuilder(); foreach (ListViewItem item in listWatch.SelectedItems) { WatchEntry entry = (WatchEntry)item.Tag; sb.AppendLine(item.SubItems[2].Text); } Clipboard.SetText(sb.ToString()); }
private void bytes4ToolStripMenuItem_Click( object sender, EventArgs e ) { foreach ( ListViewItem item in listWatch.SelectedItems ) { WatchEntry entry = (WatchEntry)item.Tag; entry.SizeInBytes = 4; UpdateValue( entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue ); if ( Core.MainForm.AppState == Types.StudioState.DEBUGGING_BROKEN ) { Core.Debugging.Debugger.RefreshRegistersAndWatches(); } } }
private void watchReadFromMemoryToolStripMenuItem_Click( object sender, EventArgs e ) { watchReadFromMemoryToolStripMenuItem.Checked = !watchReadFromMemoryToolStripMenuItem.Checked; displayBoundsToolStripMenuItem.Visible = watchReadFromMemoryToolStripMenuItem.Checked; foreach ( ListViewItem item in listWatch.SelectedItems ) { WatchEntry entry = (WatchEntry)item.Tag; entry.DisplayMemory = watchReadFromMemoryToolStripMenuItem.Checked; UpdateValue( entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue ); } if ( watchReadFromMemoryToolStripMenuItem.Checked ) { Core.Debugging.Debugger.RefreshRegistersAndWatches(); } }
public void AddWatchEntry(WatchEntry Watch) { ListViewItem item = new ListViewItem(); item.Text = Watch.Name; if (Watch.IndexedX) { item.Text += ",x"; } if (Watch.IndexedY) { item.Text += ",y"; } item.SubItems.Add(TypeToString(Watch)); if (Watch.DisplayMemory) { item.SubItems.Add("(unread)"); m_WatchEntries.Add(Watch); } else if (!Watch.DisplayMemory) { if (Watch.SizeInBytes == 1) { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x02")); Watch.CurrentValue = data; item.SubItems.Add(data.ToString()); } else if (Watch.SizeInBytes == 2) { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x04")); Watch.CurrentValue = data; item.SubItems.Add(data.ToString()); } else { item.SubItems.Add("(unread)"); } } else { item.SubItems.Add("(unread)"); m_WatchEntries.Add(Watch); } item.Tag = Watch; listWatch.Items.Add(item); }
public void RemoveWatchEntry( WatchEntry Watch ) { m_WatchEntries.Remove( Watch ); foreach ( ListViewItem item in listWatch.Items ) { WatchEntry watchEntry = (WatchEntry)item.Tag; if ( watchEntry == Watch ) { listWatch.Items.Remove( item ); if ( DebuggedProject != null ) { DebuggedProject.SetModified(); } return; } } }
public bool Load(byte[] ProjectData) { string currentConfig = "Default"; string activeElement = ""; Node = new System.Windows.Forms.TreeNode(); Node.Tag = this; GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(ProjectData); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); ushort origDebugStartAddress = 2049; while (chunk.ReadFromStream(memIn)) { GR.IO.MemoryReader memChunk = chunk.MemoryReader(); switch (chunk.Type) { case Types.FileChunk.PROJECT: // Project Info // Version memChunk.ReadUInt32(); Settings.Name = memChunk.ReadString(); Settings.Filename = memChunk.ReadString(); Settings.DebugPort = memChunk.ReadUInt16(); origDebugStartAddress = memChunk.ReadUInt16(); Settings.BuildTool = memChunk.ReadString(); Settings.RunTool = memChunk.ReadString(); Settings.MainDocument = memChunk.ReadString(); currentConfig = memChunk.ReadString(); activeElement = memChunk.ReadString(); Node.Text = Settings.Name; break; case Types.FileChunk.PROJECT_ELEMENT: // Element Info { // Version int version = (int)memChunk.ReadUInt32(); ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32(); //System.Windows.Forms.TreeNode nodeParent = NodeFromHierarchy( ProjectElement element = CreateElement(type, Node); element.Name = memChunk.ReadString(); //element.Filename = System.IO.Path.GetFileName( memChunk.ReadString() ); element.Filename = memChunk.ReadString(); if (element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER) { element.Node.Text = element.Name; } else { element.Node.Text = System.IO.Path.GetFileName(element.Filename); } GR.IO.FileChunk subChunk = new GR.IO.FileChunk(); if (!subChunk.ReadFromStream(memChunk)) { return(false); } if (subChunk.Type != Types.FileChunk.PROJECT_ELEMENT_DATA) { return(false); } // Element Data element.DocumentInfo.DocumentFilename = element.Filename; if (element.Document != null) { if (!element.Document.ReadFromReader(subChunk.MemoryReader())) { Elements.Remove(element); element.Document.Dispose(); element = null; } else { element.Document.SetDocumentFilename(element.Filename); } } element.TargetFilename = memChunk.ReadString(); element.TargetType = (Types.CompileTargetType)memChunk.ReadUInt32(); int dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { string dependency = memChunk.ReadString(); element.ForcedDependency.DependentOnFile.Add(new FileDependency.DependencyInfo(dependency, true, false)); } // 3 free strings memChunk.ReadString(); memChunk.ReadString(); memChunk.ReadString(); int perConfigSettingCount = memChunk.ReadInt32(); for (int i = 0; i < perConfigSettingCount; ++i) { GR.IO.FileChunk chunkElementPerConfigSetting = new GR.IO.FileChunk(); chunkElementPerConfigSetting.ReadFromStream(memChunk); if (chunkElementPerConfigSetting.Type == Types.FileChunk.PROJECT_ELEMENT_PER_CONFIG_SETTING) { ProjectElement.PerConfigSettings perConfigSetting = new ProjectElement.PerConfigSettings(); GR.IO.MemoryReader memSubChunk = chunkElementPerConfigSetting.MemoryReader(); string config = memSubChunk.ReadString(); perConfigSetting.PreBuild = memSubChunk.ReadString(); perConfigSetting.CustomBuild = memSubChunk.ReadString(); perConfigSetting.PostBuild = memSubChunk.ReadString(); perConfigSetting.DebugFile = memSubChunk.ReadString(); perConfigSetting.DebugFileType = (C64Studio.Types.CompileTargetType)memSubChunk.ReadInt32(); perConfigSetting.PreBuildChain.Active = (memSubChunk.ReadInt32() == 1); int numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PreBuildChain.Entries.Add(entry); } perConfigSetting.PostBuildChain.Active = (memSubChunk.ReadInt32() == 1); numEntries = memSubChunk.ReadInt32(); for (int j = 0; j < numEntries; ++j) { var entry = new BuildChainEntry(); entry.ProjectName = memSubChunk.ReadString(); entry.Config = memSubChunk.ReadString(); entry.DocumentFilename = memSubChunk.ReadString(); entry.PreDefines = memSubChunk.ReadString(); perConfigSetting.PostBuildChain.Entries.Add(entry); } element.Settings[config] = perConfigSetting; } } element.IsShown = (memChunk.ReadInt32() != 0); element.AssemblerType = (C64Studio.Types.AssemblerType)memChunk.ReadUInt32(); int hierarchyPartCount = memChunk.ReadInt32(); for (int i = 0; i < hierarchyPartCount; ++i) { string part = memChunk.ReadString(); element.ProjectHierarchy.Add(part); } if (element.ProjectHierarchy.Count > 0) { // node is sub-node, move accordingly System.Windows.Forms.TreeNode parentNode = NodeFromHierarchy(element.ProjectHierarchy); if ((parentNode != null) && (parentNode != element.Node.Parent)) { element.Node.Remove(); parentNode.Nodes.Add(element.Node); } } // dependency - include symbols dependencyCount = memChunk.ReadInt32(); for (int i = 0; i < dependencyCount; ++i) { element.ForcedDependency.DependentOnFile[i].IncludeSymbols = (memChunk.ReadInt32() != 0); } // code folding entries int numFoldingEntries = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks = new GR.Collections.Set <int>(); for (int i = 0; i < numFoldingEntries; ++i) { int collapsedBlockLine = memChunk.ReadInt32(); element.DocumentInfo.CollapsedFoldingBlocks.Add(collapsedBlockLine); //Debug.Log( "Get collapsed blocked for " + element.DocumentInfo.FullPath + ", line " + collapsedBlockLine ); } // TODO - load other stuff if ((element != null) && (element.IsShown)) { ShowDocument(element); if (element.Document != null) { element.Document.ShowHint = DockState.Document; //element.Document.Show( MainForm.panelMain ); } } } break; case Types.FileChunk.PROJECT_ELEMENT_DISPLAY_DATA: { string elementFilename = memChunk.ReadString(); ProjectElement element = GetElementByFilename(elementFilename); if (element != null) { UInt32 numBytes = memChunk.ReadUInt32(); GR.Memory.ByteBuffer displayData = new GR.Memory.ByteBuffer(); memChunk.ReadBlock(displayData, numBytes); if (element.Document != null) { element.Document.ApplyDisplayDetails(displayData); } } } break; case Types.FileChunk.PROJECT_CONFIG: { ProjectConfig config = new ProjectConfig(); config.Load(memChunk); if (string.IsNullOrEmpty(config.DebugStartAddressLabel)) { config.DebugStartAddressLabel = origDebugStartAddress.ToString(); } Settings.Configs.Add(config.Name, config); } break; case Types.FileChunk.PROJECT_WATCH_ENTRY: { WatchEntry watch = new WatchEntry(); watch.Load(memChunk); Core.MainForm.AddWatchEntry(watch); //Debug.Log( "loaded watch entry for " + watch.Name ); } break; } } if (Settings.Configs.Count == 0) { // there must be one config ProjectConfig config = new ProjectConfig(); config.Name = "Default"; Settings.Configs.Add(config.Name, config); Settings.CurrentConfig = config; } else { if (Settings.Configs.ContainsKey(currentConfig)) { Settings.CurrentConfig = Settings.Configs[currentConfig]; } else { foreach (ProjectConfig config in Settings.Configs.Values) { Settings.CurrentConfig = config; break; } } } foreach (ProjectElement element in Elements) { if (element.Settings.Count == 0) { foreach (ProjectConfig config in Settings.Configs.Values) { // needs a default setting! element.Settings[config.Name] = new ProjectElement.PerConfigSettings(); } } if ((!string.IsNullOrEmpty(element.Filename)) && (GR.Path.IsPathEqual(element.Filename, Settings.MainDocument))) { Core.MainForm.m_SolutionExplorer.HighlightNode(element.Node); } Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.DOCUMENT_INFO_CREATED, element.DocumentInfo)); Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.ELEMENT_CREATED, element)); } if (!String.IsNullOrEmpty(activeElement)) { ProjectElement element = GetElementByFilename(activeElement); if ((element != null) && (element.Document != null)) { element.Document.Show(); } } m_Modified = false; return(true); }
public void UpdateValues() { if ( InvokeRequired ) { Invoke( new MainForm.ParameterLessCallback( UpdateValues ) ); return; } foreach ( var watchEntry in m_WatchEntries ) { ListViewItem itemToModify = null; foreach ( ListViewItem item in listWatch.Items ) { WatchEntry oldWatchEntry = (WatchEntry)item.Tag; if ( oldWatchEntry == watchEntry ) { itemToModify = item; break; } } if ( itemToModify == null ) { itemToModify = new ListViewItem(); itemToModify.Text = watchEntry.Name; if ( watchEntry.IndexedX ) { itemToModify.Text += ",x"; } if ( watchEntry.IndexedY ) { itemToModify.Text += ",y"; } itemToModify.SubItems.Add( TypeToString( watchEntry ) ); if ( watchEntry.DisplayMemory ) { itemToModify.SubItems.Add( "(unread)" ); } else if ( !watchEntry.DisplayMemory ) { if ( watchEntry.SizeInBytes == 1 ) { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( watchEntry.Address.ToString( "x02" ) ); watchEntry.CurrentValue = data; itemToModify.SubItems.Add( data.ToString() ); } else if ( watchEntry.SizeInBytes == 2 ) { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( watchEntry.Address.ToString( "x04" ) ); watchEntry.CurrentValue = data; itemToModify.SubItems.Add( data.ToString() ); } } else { itemToModify.SubItems.Add( "(unread)" ); } itemToModify.Tag = watchEntry; listWatch.Items.Add( itemToModify ); } if ( !watchEntry.DisplayMemory ) { switch ( watchEntry.Type ) { case WatchEntry.DisplayType.HEX: itemToModify.SubItems[2].Text = "$" + watchEntry.Address.ToString( "x4" ); break; case WatchEntry.DisplayType.DEZ: itemToModify.SubItems[2].Text = watchEntry.Address.ToString(); break; case WatchEntry.DisplayType.BINARY: itemToModify.SubItems[2].Text = "%" + Convert.ToString( watchEntry.Address, 2 ); break; default: itemToModify.SubItems[2].Text = watchEntry.Address.ToString( "x4" ); break; } } } }
public void UpdateValue( string WatchVar, bool IndexedX, bool IndexedY, GR.Memory.ByteBuffer Data ) { foreach ( ListViewItem item in listWatch.Items ) { WatchEntry watchEntry = (WatchEntry)item.Tag; if ( ( watchEntry.Name == WatchVar ) && ( watchEntry.IndexedX == IndexedX ) && ( watchEntry.IndexedY == IndexedY ) ) { watchEntry.CurrentValue = Data; if ( watchEntry.SizeInBytes != watchEntry.CurrentValue.Length ) { Debug.Log( "Watch entry received different size than expected!" ); } if ( watchEntry.CurrentValue.Length == 0 ) { item.SubItems[2].Text = "(unread)"; continue; } switch ( watchEntry.Type ) { case WatchEntry.DisplayType.HEX: if ( watchEntry.DisplayMemory ) { StringBuilder sb = new StringBuilder(); sb.Append( "$" ); if ( watchEntry.BigEndian ) { for ( int i = 0; i < Data.Length; ++i ) { sb.Append( Data.ByteAt( i ).ToString( "x2" ) ); if ( i + 1 < Data.Length ) { sb.Append( " " ); } } } else { for ( int i = 0; i < Data.Length; ++i ) { sb.Append( Data.ByteAt( (int)Data.Length - 1 - i ).ToString( "x2" ) ); if ( i + 1 < Data.Length ) { sb.Append( " " ); } } } item.SubItems[2].Text = sb.ToString(); } else { item.SubItems[2].Text = "$" + watchEntry.Address.ToString( "x4" ); } break; case WatchEntry.DisplayType.DEZ: if ( !watchEntry.DisplayMemory ) { item.SubItems[2].Text = watchEntry.Address.ToString(); } else if ( watchEntry.SizeInBytes == 1 ) { item.SubItems[2].Text = Data.ByteAt( 0 ).ToString(); } else if ( watchEntry.BigEndian ) { string totalText = ""; for ( uint i = 0; i < Data.Length; ++i ) { totalText += Data.ByteAt( (int)i ).ToString( "d" ) + " "; } item.SubItems[2].Text = totalText; } else { string totalText = ""; for ( uint i = 0; i < Data.Length; ++i ) { totalText += Data.ByteAt( (int)Data.Length - 1 - (int)i ).ToString( "d" ) + " "; } item.SubItems[2].Text = totalText; } break; case WatchEntry.DisplayType.BINARY: if ( !watchEntry.DisplayMemory ) { item.SubItems[2].Text = "%" + Convert.ToString( watchEntry.Address, 2 ); } else if ( watchEntry.SizeInBytes == 1 ) { item.SubItems[2].Text = "%" + Convert.ToString( Data.ByteAt( 0 ), 2 ); } else if ( watchEntry.SizeInBytes == 2 ) { item.SubItems[2].Text = "%" + Convert.ToString( Data.UInt16At( 0 ), 2 ); } else { item.SubItems[2].Text = Data.ToString(); } break; default: if ( watchEntry.DisplayMemory ) { item.SubItems[2].Text = Data.ByteAt( 0 ).ToString(); } else { item.SubItems[2].Text = watchEntry.Address.ToString( "x4" ); } break; } } } }
public void RemoveWatchEntry(WatchEntry Watch) { m_WatchEntries.Remove(Watch); }
public void AddWatchEntry(WatchEntry Watch) { m_WatchEntries.AddLast(Watch); }