public AutoWatchWindow(MainForm mainForm) : base(mainForm) { InitializeComponent(); // Hook handler for lazily expanding treeView1.BeforeExpand += treeView1_BeforeSelect; }
public QuickViewWindow(MainForm mainForm) : base(mainForm) { InitializeComponent(); // Hook handler for lazily expanding treeView1.BeforeExpand += treeView1_BeforeExpand; }
private SourceViewerForm(MainForm parent, string path, ArrayList lines) { m_lines = lines; BeginInit(parent); InitLines("{0,4}:", lines, null); EndInit(path); }
// Public build function. // Fails to build (and returns null) if it can't load the file. public static SourceViewerForm Build(MainForm parent, string path) { ArrayList lines = LoadLinesFromFile(path); if (lines == null) { return null; } return new SourceViewerForm(parent, path, lines); }
public static void Gui(string args) { // just do the check that gui is not already loaded, // strange things are happening else: var ap = new ArgParser(args); if (ap.Exists(0)) { if (ap.AsString(0) == "close") { if (m_mainForm != null) { m_mainForm.CloseGui(); Application.Exit(); // this line will cause the message pump on other thread to quit. return; } else throw new MDbgShellException("GUI not started."); } else throw new MDbgShellException("invalid argument"); } if (Shell.IO == m_mainForm) { WriteOutput("GUI already started. Cannot start second instance."); return; } WriteOutput("starting gui"); m_mainForm = new MainForm(Shell); var t = new Thread(RunMessageLoop); // Only MTA Threads can access CorDebug interfaces because mscordbi doesn't provide marshalling to make them accessable from STA Threads // However, UI thread must be STA. So we'll make cross-thread calls to a worker thread for all ICorDebug access. t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Start(); m_mainForm.InitComplete.WaitOne(); // wait till form is fully displayed. WriteOutput(MainForm.MetaInfoOutputConstant, "GUI: Simple Extension for Managed debugger (MDbg) started"); WriteOutput(MainForm.MetaInfoOutputConstant, "for information on how to use the extension select in menu bar help|about"); WriteOutput(MainForm.MetaInfoOutputConstant, "!!This is just a sample. It is not intended for Production purposes!!\n"); }
// Initialization function. called by derived ctor. // parent - main containing window that this source window lives inside of. // path - unique string identifier for source window (full pathname) // lines - content protected void BeginInit(MainForm parent) { if (m_glyphs == null) { m_glyphs = new Glyphs(); } // // Required for Windows Form Designer support // InitializeComponent(); // Set window properties MdiParent = parent; Debug.Assert(parent == MainForm); // Still not visisible. We return from here, and then caller will initialize content // and then call EndInit(). }
// There's one SourceViewerForm instance for each source-file // Get the instance for the new source file. // Called on UI thread. public static SourceViewerBaseForm GetSourceFile(MainForm parent, MDbgFunction function) { var source = (SourceViewerBaseForm) m_sourceList[function]; if (source == null) { source = new VirtualSourceViewerForm(parent, function); AddSourceViewer(source); } m_ActiveSourceFile = source; return source; }
// Track the "active" source file. The UI can use this as the default // target for input (eg, who processes the stepping commands). // There's one SourceViewerForm instance for each source-file // Get the instance for the new source file. // Called on UI thread. public static SourceViewerForm GetSourceFile(MainForm parent, string path) { path = CommandBase.Shell.FileLocator.GetFileLocation(path); var source = (SourceViewerForm) m_sourceList[path]; if (source == null) { source = SourceViewerForm.Build(parent, path); if (source != null) { AddSourceViewer(source); } } m_ActiveSourceFile = source; return source; }
public ModuleWindow(MainForm mainForm) : base(mainForm) { InitializeComponent(); }
public Callstack(MainForm mainForm) : base(mainForm) { InitializeComponent(); }
public SyncWriter(MainForm form, string outputType, string txt, int highlightStart, int highlightLen) { Debug.Assert(txt != null && form != null); if (highlightLen == Int32.MaxValue) { highlightLen = txt.Length; } m_txt = txt; m_form = form; m_type = outputType; m_highlightStart = highlightStart; m_highlightLen = highlightLen; }
public HelperWindowMenuItem(MainForm mainForm, string name, Type tForm) { Debug.Assert(tForm.IsSubclassOf(typeof (DebuggerToolWindow))); m_mainForm = mainForm; m_typeHelperForm = tForm; EventHandler handler = OnClick; var item = new MenuItem(name, handler); m_mainForm.AddToViewMenu(item); }
public SequencePointIterator(RawWriter w, MainForm parent, int[] seqIlOffsets, string[] seqPaths, int[] seqStartLines, int[] seqStartColumns, int[] seqEndLines, int[] seqEndColumns) { m_writer = w; m_parent = parent; m_seqIlOffsets = seqIlOffsets; m_seqPaths = seqPaths; m_seqStartLines = seqStartLines; m_seqStartColumns = seqStartColumns; m_seqEndLines = seqEndLines; m_seqEndColumns = seqEndColumns; Debug.Assert(m_seqCount == 0); if (m_seqIlOffsets != null) { m_seqCount = m_seqIlOffsets.Length; // All arrays should be same length. Debug.Assert(seqIlOffsets.Length == m_seqCount); Debug.Assert(seqPaths.Length == m_seqCount); Debug.Assert(seqStartLines.Length == m_seqCount); Debug.Assert(seqStartColumns.Length == m_seqCount); Debug.Assert(seqEndLines.Length == m_seqCount); Debug.Assert(seqEndColumns.Length == m_seqCount); } }
internal VirtualSourceViewerForm(MainForm parent, MDbgFunction function) { m_function = function; Debug.Assert(function != null); // Now actually right in text. do this first so that we can get the current font. BeginInit(parent); // Get fonts FontCache cache; { Font fontCurrent = richText.Font; var emphasis = new Font( fontCurrent.FontFamily, fontCurrent.Size, FontStyle.Bold ); cache = new FontCache(emphasis); } // Underlying writer to the window. var rawWriter = new RawWriter(cache); // Il2Native mapping can be used to find out what IL offsets we can actually stop on. Il2NativeIterator il2nativeIterator = null; // Actual IL disassembly in string form. ILDasmIterator ilDasm = null; // Iterator through sequence points and source files. SequencePointIterator seqIterator = null; string fullName = "?"; int token = 0; ulong nativeStartAddress = 0; CorDebugJITCompilerFlags codeFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DEFAULT; // Make cross-thread call to worker thread to collect raw information. // This needs to access MDbg and so can't be done on our UI thread. parent.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess proc) { Debug.Assert(proc != null); Debug.Assert(!proc.IsRunning); Debug.Assert(function.Module.Process == proc); // Get some properties about this function to display. token = function.CorFunction.Token; nativeStartAddress = function.CorFunction.NativeCode.Address; codeFlags = function.CorFunction.NativeCode.CompilerFlags; CorCode ilCode = function.CorFunction.ILCode; Debug.Assert(ilCode.IsIL); byte[] code = ilCode.GetCode(); fullName = function.FullName; // This does the real disassembly work. string[] lines = null; // strings of IL. ILDisassembler.Disassemble(code, function.Module.Importer, out lines, out m_il2RowMapping); ilDasm = new ILDasmIterator(rawWriter, m_il2RowMapping, lines); IL2NativeMap[] il2nativeMapping = function.CorFunction.NativeCode. GetILToNativeMapping(); il2nativeIterator = new Il2NativeIterator(rawWriter, il2nativeMapping, code); // Get sequence points ISymbolMethod symMethod = function.SymMethod; // Sequence point information int[] seqIlOffsets = null; string[] seqPaths = null; int[] seqStartLines = null, seqEndLines = null, seqStartColumns = null, seqEndColumns = null; int seqCount = 0; if (symMethod != null) { seqCount = symMethod.SequencePointCount; seqIlOffsets = new int[seqCount]; var seqDocuments = new ISymbolDocument[seqCount]; seqPaths = new string[seqCount]; seqStartLines = new int[seqCount]; seqEndLines = new int[seqCount]; seqStartColumns = new int[seqCount]; seqEndColumns = new int[seqCount]; symMethod.GetSequencePoints(seqIlOffsets, seqDocuments, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); for (int i = 0; i < seqCount; i++) { seqPaths[i] = seqDocuments[i].URL; } } seqIterator = new SequencePointIterator(rawWriter, parent, seqIlOffsets, seqPaths, seqStartLines, seqStartColumns, seqEndLines, seqEndColumns); } ); // end worker call // We assume sequence points are sorted by IL offset. We assert that in the iterators below. // Now we need to go through and stitch the IL + Source together. // This also works even if we have no source (since that's just the degenerate case of 0 sequence points) // Print out header information Debug.Assert(token != 0); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Function name:{0} (token={1:x})", fullName, token)); rawWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "> Native Code Address =0x{0:x}, flags={1}", nativeStartAddress, codeFlags)); // Walk through the IL in order and write out interleaved IL and Sequence Points. while (!seqIterator.IsDone) { // Add IL snippets that occur before this sequence point. WriteIlAndNative(ilDasm, il2nativeIterator, seqIterator.IlOffset); seqIterator.WriteSource(); seqIterator.Next(); } // Write the IL that's after the last sequence point WriteIlAndNative(ilDasm, il2nativeIterator, ilDasm.IlLength); // Set the text. InitLines(null, rawWriter.Lines, rawWriter.FormatList); EndInit(fullName); }