//============================================================================ // MainForm_FormClosing //============================================================================ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { AllocLogStream.stopProcessing(); if (mTCPClient != null) { mTCPClient.stopListener(); mTCPClient = null; } }
//============================================================================ // onClientConnected //============================================================================ public void onClientConnected(string title, string pdbFile) { AllocLogStream.pauseProcessing(); ThreadSafeCallbackList.MessagePacket pak = new ThreadSafeCallbackList.MessagePacket(); pak.mCallback = this.handleClientConnected; pak.mDataObject = pdbFile; pak.mMessageID = title; mMessageCallbackList.enqueueMessage(pak); }
//============================================================================ // toolStripButton4_Click //============================================================================ private void toolStripButton4_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Alloc Log File (*.bin)|*.bin"; if (sfd.ShowDialog() == DialogResult.OK) { AllocLogStream.saveStreamAs(sfd.FileName); } }
//============================================================================ // stopProcessButton_Click //============================================================================ private void stopProcessButton_Click(object sender, EventArgs e) { AllocLogStream.stopProcessing(); if (mTCPClient != null) { mTCPClient.stopListener(); mTCPClient = null; } onStopPressed(null, null); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GlobalSettings.load(); MainForm frm = new MainForm(); AllocLogStream.addListener(frm); Application.Run(frm); }
//============================================================================ // fileLoadThread //============================================================================ private void fileLoadThread(object obj) { threadStartParms parms = (threadStartParms)obj; string filename = parms.filename; string pdbfilename = parms.pdbfilename; //open the file, and inact the log stream FileStream fs = new FileStream(filename, FileMode.Open); BinaryReader br = new BinaryReader(fs); AllocLogStream.processBinaryStream(br, pdbfilename, parms.throttleTime); fs.Close(); ThreadSafeCallbackList.MessagePacket pak = new ThreadSafeCallbackList.MessagePacket(); pak.mCallback = this.onStopPressed; pak.mDataObject = null; pak.mMessageID = "stopped"; mMessageCallbackList.enqueueMessage(pak); }
//============================================================================ // HandleClientComm //============================================================================ private void HandleClientComm(object client) { TcpClient tcpClient = (TcpClient)client; if (tcpClient == null) { stopListener(); return; } NetworkStream clientStream = tcpClient.GetStream(); IPEndPoint ipend = (IPEndPoint)(tcpClient.Client.RemoteEndPoint); AllocLogStream.processNetworkStream(ipend.Address.ToString(), clientStream, mPDBFilename, tcpClient); stopListener(); tcpClient.Close(); }
//============================================================================ // onMessageRecieved //============================================================================ public void onMessageRecieved(PacketWrapper packet) { ThreadSafeCallbackList.MessagePacket pak = new ThreadSafeCallbackList.MessagePacket(); pak.mCallback = this.handleMessageRecieved; pak.mDataObject = packet; pak.mMessageID = "packet"; if (GlobalSettings.PlaybackSpeed != GlobalSettings.ePlaybackSpeeds.eASAP) { //spinloop here while we're waiting for commands to be processed.. while (mMessageCallbackList.Count() > 1024) { if (!AllocLogStream.isProcessing()) { break; } // Thread.Sleep(1000); } } mMessageCallbackList.enqueueMessage(pak); }
//============================================================================ // onClientConnected //============================================================================ public void onClientConnected(string name, string pdbFilename) { AllocStats.clearHeaps(); LoadSymbolsParams lsp = new LoadSymbolsParams(); lsp.mProcHandle = 0x00ABBEEF; // Process.GetCurrentProcess().Id; lsp.mSymbolFileName = pdbFilename; //string sName = @"C:\depot\phoenix\xbox\code\xgame\xbox\debug\xgameD.exe"; //since this takes so long, spend display a 'wait' bar to the user.. { mSymbolProcEvent.Reset(); BackgroundWorker mWorkerThread = new BackgroundWorker(); mWorkerThread.WorkerReportsProgress = false; //mWorkerThread.ProgressChanged += bw_ProgressChanged; mWorkerThread.WorkerSupportsCancellation = false; //mWorkerThread.RunWorkerCompleted += bw_RunWorkerCompleted; mWorkerThread.DoWork += bw_DoWork; mWorkerThread.RunWorkerAsync(lsp); HaloWarsMem.loadSymbolInfo((uint)lsp.mProcHandle, lsp.mSymbolFileName); mSymbolProcEvent.Set(); } AllocLogStream.unpauseProcessing(); heapLines.onConnect(); heapKey.onConnect(); heapFileView.onConnect(); topAllocs.onConnect(); mFileTimelines.onConnect(); mFileGroupings.onConnect(); }