コード例 #1
0
        void OnModuleLoad(object sender, CorModuleEventArgs e)
        {
            CorMetadataImport mi = new CorMetadataImport(e.Module);

            // Required to avoid the jit to get rid of variables too early
            e.Module.JITCompilerFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION;

            string file = e.Module.Assembly.Name;

            lock (documents) {
                ISymbolReader reader = null;
                if (file.IndexOfAny(System.IO.Path.InvalidPathChars) == -1 && System.IO.File.Exists(System.IO.Path.ChangeExtension(file, ".pdb")))
                {
                    try {
                        reader = symbolBinder.GetReaderForFile(mi.RawCOMObject, file, ".");
                        foreach (ISymbolDocument doc in reader.GetDocuments())
                        {
                            if (string.IsNullOrEmpty(doc.URL))
                            {
                                continue;
                            }
                            string  docFile = System.IO.Path.GetFullPath(doc.URL);
                            DocInfo di      = new DocInfo();
                            di.Document        = doc;
                            di.Reader          = reader;
                            di.Module          = e.Module;
                            documents[docFile] = di;
                            NotifySourceFileLoaded(docFile);
                        }
                    }
                    catch (Exception ex) {
                        OnDebuggerOutput(true, string.Format("Debugger Error: {0}\n", ex.Message));
                    }
                    e.Module.SetJmcStatus(true, null);
                }
                else
                {
                    // Flag modules without debug info as not JMC. In this way
                    // the debugger won't try to step into them
                    e.Module.SetJmcStatus(false, null);
                }

                ModuleInfo moi;

                if (modules.TryGetValue(e.Module.Name, out moi))
                {
                    moi.References++;
                }
                else
                {
                    moi                    = new ModuleInfo();
                    moi.Module             = e.Module;
                    moi.Reader             = reader;
                    moi.Importer           = mi;
                    moi.References         = 1;
                    modules[e.Module.Name] = moi;
                }
            }
            e.Continue = true;
        }
コード例 #2
0
        void OnModuleUnload(object sender, CorModuleEventArgs e)
        {
            lock (documents) {
                ModuleInfo moi;
                modules.TryGetValue(e.Module.Name, out moi);
                if (moi == null || --moi.References > 0)
                {
                    return;
                }

                modules.Remove(e.Module.Name);
                List <string> toRemove = new List <string> ();
                foreach (KeyValuePair <string, DocInfo> di in documents)
                {
                    if (di.Value.Module.Name == e.Module.Name)
                    {
                        toRemove.Add(di.Key);
                    }
                }
                foreach (string file in toRemove)
                {
                    documents.Remove(file);
                    NotifySourceFileUnloaded(file);
                }
            }
        }
コード例 #3
0
ファイル: ProcessInfo.cs プロジェクト: pavel-zeman/nstack
 void CreateModuleEventHandler(object sender, CorModuleEventArgs e)
 {
     //Console.WriteLine("OnCreateModule" + e.Module.Name);
     e.Continue = true;
 }