//--// public Gateway( ManagerRemote mgrRemote, _DBG.PortDefinition pd ) { m_mgrRemote = mgrRemote; m_portDefinition = pd; m_ctrl = new _WP.Controller( _WP.Packet.MARKER_PACKET_V1, this ); m_stubs = ArrayList.Synchronized( new ArrayList() ); m_endpoints = Hashtable.Synchronized( new Hashtable() ); }
internal static Packets.ProfilerPacket Decode(_DBG.BitStream stream) { uint type = stream.ReadBits(Packets.Commands.Bits.CommandHeader); Tracing.PacketTrace("New Packet {0}", type); switch(type) { case Packets.Commands.c_Profiling_Timestamp: return new Packets.TimestampPacket(stream); case Packets.Commands.c_Profiling_Memory_Layout: return new Packets.MemoryLayoutPacket(stream); case Packets.Commands.c_Profiling_HeapDump_Start: return new Packets.HeapDumpStartPacket(stream); case Packets.Commands.c_Profiling_HeapDump_Stop: return new Packets.HeapDumpStopPacket(stream); case Packets.Commands.c_Profiling_HeapDump_Root: return new Packets.HeapDumpRootPacket(stream); case Packets.Commands.c_Profiling_HeapDump_Object: return new Packets.HeapDumpObjectPacket(stream); case Packets.Commands.c_Profiling_Calls_Call: return new Packets.CallPacket(stream); case Packets.Commands.c_Profiling_Calls_Return: return new Packets.ReturnPacket(stream); case Packets.Commands.c_Profiling_Calls_CtxSwitch: return new Packets.ContextSwitchPacket(stream); case Packets.Commands.c_Profiling_Allocs_Alloc: return new Packets.ObjectAllocationPacket(stream); case Packets.Commands.c_Profiling_Allocs_Relloc: return new Packets.ObjectRelocationPacket(stream); case Packets.Commands.c_Profiling_Allocs_Delete: return new Packets.ObjectDeletionPacket(stream); case Packets.Commands.c_Profiling_GarbageCollect_Begin: return new Packets.GarbageCollectionBeginPacket(stream); case Packets.Commands.c_Profiling_GarbageCollect_End: return new Packets.GarbageCollectionEndPacket(stream); case Packets.Commands.c_Profiling_HeapCompact_Begin: return new Packets.HeapCompactionBeginPacket(stream); case Packets.Commands.c_Profiling_HeapCompact_End: return new Packets.HeapCompactionEndPacket(stream); default: throw new ApplicationException("Unable to decode packet."); } }
public ProfilerSession(_DBG.Engine engine) { if (engine == null) { throw new ArgumentNullException(); } m_connected = true; m_engine = engine; m_engine.OnCommand += new _DBG.CommandEventHandler(OnDeviceCommand); m_incomingStream = new _DBG.BitStream(true); m_startTime = 0; m_lastKnownTime = 0; m_currentHeapDump = null; m_threadCallStacks = new Dictionary<uint, Stack<uint>>(); m_liveObjectTable = new List<uint>(); m_firstPacket = true; m_receiverThread = new Thread(WorkerThread); m_receiverThread.Start(); }
public ObjectDeletionPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Allocs_Delete) { m_address = ReadAndUnpackBits(stream); }
public GarbageCollectionEndPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_GarbageCollect_End) { m_freeBytes = ReadAndUnpackBits(stream); }
void OnMessage( _DBG.WireProtocol.IncomingMessage msg, string text ) { AppendText( text ); }
static protected uint ReadTypeDefIndex(_DBG.BitStream stream) { uint assembly = ReadAndUnpackBits(stream); uint type = ReadAndUnpackBits(stream); return assembly << ASSEMBLY_BIT_OFFSET | type; }
public TimestampPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Timestamp) { ulong l = (ulong)ReadAndUnpackBits(stream) << Packets.Commands.Bits.TimestampShift; m_time = l / TimeSpan.TicksPerMillisecond; Tracing.PacketTrace("time {0}", m_time); }
void Callback_Progress( _DBG.SRecordFile.Block bl, int offset, bool fLast ) { foreach(ListViewItem item in this.listViewFiles.CheckedItems) { if( item.Tag == bl && fLast == false ) { item.Selected = true; } else { item.Selected = false; } } progressBar1.Value = fLast ? 0 : Math.Min( (int)(offset * 100 / bl.data.Length), 100 ); }
public HeapDumpObjectPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_HeapDump_Object) { m_address = ReadAndUnpackBits(stream); m_size = ReadAndUnpackBits(stream) * ProfilerSession.HeapBlockSize; m_dt = (_DBG.RuntimeDataType)stream.ReadBits(Commands.Bits.DataType); if (m_dt == _DBG.RuntimeDataType.DATATYPE_CLASS || m_dt == _DBG.RuntimeDataType.DATATYPE_VALUETYPE) { m_typedef = ReadTypeDefIndex(stream); } else if (m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY) { m_arrayElementType = ReadTypeDefIndex(stream); m_arrayLevels = (ushort)ReadAndUnpackBits(stream); } m_refs = new List<uint>(); bool moreRefs; while (moreRefs = ReadBoolean(stream)) { m_refs.Add(ReadAndUnpackBits(stream)); } }
private void OnDeviceListChanged(_DBG.UsbDeviceDiscovery.DeviceChanged devChange) { if (OnDeviceListUpdate != null) { OnDeviceListUpdate(null, null); } }
static protected uint ReadMethodDefIndex(_DBG.BitStream stream) { uint assembly = ReadAndUnpackBits(stream); uint method = ReadAndUnpackBits(stream); return assembly << ASSEMBLY_BIT_OFFSET | method; }
public HeapDumpRootPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_HeapDump_Root) { m_address = ReadAndUnpackBits(stream); m_source = stream.ReadBits(Packets.Commands.Bits.RootTypes); switch(m_source) { case Packets.Commands.RootTypes.Root_Stack: m_method = ReadMethodDefIndex(stream); break; } Tracing.PacketTrace("root type:{0} at {1}", m_source, m_address); }
public HeapDumpStopPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_HeapDump_Stop) { m_heapBytesUsed = ReadAndUnpackBits(stream); }
public HeapDumpStartPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_HeapDump_Start) { }
public MemoryLayoutPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Memory_Layout) { m_heapAddress = ReadAndUnpackBits(stream); m_heapLength = ReadAndUnpackBits(stream); Tracing.PacketTrace("layout {0}:{1}", m_heapAddress, m_heapLength); }
public HeapCompactionEndPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_HeapCompact_End) { m_freeBytes = ReadAndUnpackBits(stream); }
internal MFDevice(_DBG.PortDefinition port, _DBG.PortDefinition tinyBooterPort) { m_port = port; m_portTinyBooter = tinyBooterPort; }
internal bool ConnectTo(int timeout_ms, bool tryToConnect, _DBG.ConnectionSource target) { int retries = m_port is _DBG.PortDefinition_Tcp ? 2 : timeout_ms / 300; if (retries == 0) retries = 1; try { if (m_eng == null) { m_eng = new _DBG.Engine(m_port); m_eng.OnNoise += new _DBG.NoiseEventHandler(OnNoiseHandler); m_eng.OnMessage += new _DBG.MessageEventHandler(OnMessage); m_eng.Start(); } if (tryToConnect) { for (int j = retries; j > 0; j--) { switch (target) { case _DBG.ConnectionSource.MicroBooter: if (CheckForMicroBooter()) return true; Thread.Sleep(timeout_ms / retries); break; default: if (m_eng.TryToConnect(0, timeout_ms / retries, true, _DBG.ConnectionSource.Unknown)) { if (m_eng.ConnectionSource == _DBG.ConnectionSource.TinyCLR) { m_eng.UnlockDevice(m_data); } else if (m_eng.ConnectionSource == _DBG.ConnectionSource.TinyBooter) { if (target == _DBG.ConnectionSource.TinyCLR) { m_eng.ExecuteMemory(0); Thread.Sleep(100); } } break; } if (EventCancel.WaitOne(0, false)) throw new MFUserExitException(); break; } if (m_eng.IsConnected && target == m_eng.ConnectionSource) { break; } } if (target != m_eng.ConnectionSource) { Disconnect(); } } } catch (ThreadAbortException) { } catch (MFUserExitException) { Disconnect(); throw; } catch { Disconnect(); } return (m_eng != null && (!tryToConnect || m_eng.IsConnected)); }
public static Process LaunchEmulator(_DBG.PortDefinition_Emulator pd, bool fWaitForDebugger, string program) { _DBG.PlatformInfo pi = new _DBG.PlatformInfo(null); _DBG.PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port); _DBG.CommandLineBuilder cb = new _DBG.CommandLineBuilder(); if (emu == null) { throw new ArgumentException(); } if (emu.legacyCommandLine) { throw new NotSupportedException("Legacy emulators not supported."); } if (!string.IsNullOrEmpty(emu.additionalOptions)) { _DBG.CommandLineBuilder cbT = new _DBG.CommandLineBuilder(emu.additionalOptions); cb.AddArguments(cbT.Arguments); } if (!string.IsNullOrEmpty(emu.config)) { cb.AddArguments("/config:" + emu.config); } if (fWaitForDebugger) { cb.AddArguments("/waitfordebugger"); } string[] files = EmulatorLauncher.GetFilesToLoad(program); foreach (string pe in files) { cb.AddArguments("/load:" + pe); } string args = ""; args = args.Trim(); if (args.Length > 0) { cb.AddArguments("/commandlinearguments:" + args); } string commandLine = cb.ToString(); commandLine = Environment.ExpandEnvironmentVariables(commandLine); Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = emu.application; p.StartInfo.Arguments = commandLine; p.StartInfo.UseShellExecute = false; p.StartInfo.WorkingDirectory = Path.GetDirectoryName(emu.application); try { p.Start(); } catch (System.ComponentModel.Win32Exception we) { MessageBox.Show(string.Format("Failed to launch emulator: {0}", we.NativeErrorCode), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } return p; }
public CallPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Calls_Call) { if (ReadBoolean(stream)) { m_assembly = ReadAndUnpackBits(stream); Debug.Assert(m_assembly != 0); } m_method = ReadAndUnpackBits(stream); }
static protected bool ReadBoolean(_DBG.BitStream stream) { return (stream.ReadBits(1) == 1); }
private void OnMessage(_DBG.WireProtocol.IncomingMessage msg, string text) { if (OnDebugText != null) { OnDebugText(this, new DebugOutputEventArgs(text)); } }
public ReturnPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Calls_Call) { m_duration = (ulong)ReadAndUnpackBits(stream) << Packets.Commands.Bits.CallTimingShift; }
private void OnProgress(_DBG.SRecordFile.Block block, int offset, bool fLast) { int percent = (int)(offset * 100 / block.data.Length); if ((percent % 10) == 0 && m_lastPercent != percent) { m_lastPercent = percent; m_form.DumpToOutput(string.Format("Percent Complete {0}%", percent)); } }
public ContextSwitchPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Calls_Call) { m_thread = ReadAndUnpackBits(stream); }
void OnProgress( _DBG.SRecordFile.Block bl, int offset, bool fLast ) { GenericCallback( m_callback_Progress, bl, offset, fLast ); }
public ObjectAllocationPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Allocs_Alloc) { m_address = ReadAndUnpackBits(stream); m_size = ReadAndUnpackBits(stream) * ProfilerSession.HeapBlockSize; m_dt = (_DBG.RuntimeDataType)stream.ReadBits(Commands.Bits.DataType); if (m_dt == _DBG.RuntimeDataType.DATATYPE_CLASS || m_dt == _DBG.RuntimeDataType.DATATYPE_VALUETYPE || m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY) { m_type = ReadTypeDefIndex(stream); if (m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY) { m_rank = (ushort)ReadAndUnpackBits(stream); } } else { m_type = (uint)m_dt; } }
public void OnDeviceChanged( _DBG.UsbDeviceDiscovery.DeviceChanged change ) { // lets make this thread safe comboBoxPort.Invoke( (MethodInvoker)delegate{ IList ports = GeneratePortList(); comboBoxPort.DataSource = ports; comboBoxPort.SelectedItem = HandleDisplayDevice( ports ); }); }
public ObjectRelocationPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Allocs_Relloc) { uint count = ReadAndUnpackBits(stream); reloc = new ObjectRelocation.RelocationRegion[count]; for (uint i = 0; i < count; i++) { reloc[i] = new ObjectRelocation.RelocationRegion(); reloc[i].m_start = ReadAndUnpackBits(stream); reloc[i].m_end = ReadAndUnpackBits(stream); reloc[i].m_offset = ReadAndUnpackBits(stream); } }