예제 #1
0
        public static MdbAdaptor CreateAdaptor(string mdbVersion)
        {
            ProcessStartInfo pinfo = new ProcessStartInfo();

            pinfo.FileName = "gmcs";

            if (mdbVersion != null)
            {
                MdbAdaptor mdb = TryCreateAdaptor(pinfo, mdbVersion);
                if (mdb == null)
                {
                    throw new InvalidOperationException("Unsupported MDB version");
                }
                return(mdb);
            }

            foreach (string v in supportedVersions)
            {
                MdbAdaptor mdb = TryCreateAdaptor(pinfo, v);
                if (mdb != null)
                {
                    return(mdb);
                }
            }
            throw new InvalidOperationException("Unsupported MDB version");
        }
예제 #2
0
 public string InitializeMdb(string mdbVersion, int mdPid)
 {
     mdbAdaptor = MdbAdaptorFactory.CreateAdaptor(mdbVersion);
     WatchParentProcess(mdPid);
     return(mdbAdaptor.MdbVersion);
 }
예제 #3
0
        static MdbAdaptor TryCreateAdaptor(ProcessStartInfo pinfo, string versions)
        {
            string[] versionsArray = versions.Split('|');
            string   version       = versionsArray [0];

            string tmpPath = Path.GetTempPath();

            tmpPath = Path.Combine(tmpPath, "monodevelop-debugger-mdb");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }

            string   outFile  = Path.Combine(tmpPath, "adaptor-" + ApiVersion + "--" + version + ".dll");
            DateTime thisTime = File.GetLastWriteTime(typeof(MdbAdaptorFactory).Assembly.Location);

            if (!File.Exists(outFile) || File.GetLastWriteTime(outFile) < thisTime)
            {
                string args = "/t:library ";
                args += "\"/out:" + outFile + "\" ";
                args += "\"/r:" + typeof(MdbAdaptorFactory).Assembly.Location + "\" ";
                args += "\"/r:" + typeof(Mono.Debugger.Debugger).Assembly.Location + "\" ";
                args += "\"/r:" + typeof(Mono.Debugging.Client.DebuggerSession).Assembly.Location + "\" ";
                args += "\"/r:" + typeof(Mono.Debugging.Backend.Mdb.IDebuggerServer).Assembly.Location + "\" ";

                // Write the source code for all required classes
                foreach (string ver in versionsArray)
                {
                    string resName = "MdbAdaptor-" + ver + ".cs";
                    Stream s       = typeof(MdbAdaptorFactory).Assembly.GetManifestResourceStream(resName);
                    if (s == null)
                    {
                        throw new InvalidOperationException("Resource not found: " + resName);
                    }
                    StreamReader sr  = new StreamReader(s);
                    string       txt = sr.ReadToEnd();
                    sr.Close();
                    s.Close();

                    string csfile = Path.Combine(tmpPath, "adaptor-" + ver + ".cs");
                    File.WriteAllText(csfile, txt);
                    args += "\"" + csfile + "\" ";
                }

                pinfo.Arguments              = args;
                pinfo.RedirectStandardError  = true;
                pinfo.RedirectStandardOutput = true;
                pinfo.UseShellExecute        = false;
                Process proc = Process.Start(pinfo);
                proc.WaitForExit();
                if (proc.ExitCode != 0)
                {
                    return(null);
                }
                Console.WriteLine("Generated: " + outFile);
            }

            Assembly asm = Assembly.LoadFrom(outFile);
            Type     at  = asm.GetType("DebuggerServer.MdbAdaptor_" + version.Replace('-', '_'));

            if (at != null)
            {
                MdbAdaptor a = (MdbAdaptor)Activator.CreateInstance(at);
                a.MdbVersion = version;
                return(a);
            }
            return(null);
        }
		public string InitializeMdb (string mdbVersion, int mdPid)
		{
			mdbAdaptor = MdbAdaptorFactory.CreateAdaptor (mdbVersion);
			WatchParentProcess (mdPid);
			return mdbAdaptor.MdbVersion;
		}