コード例 #1
0
ファイル: MonoEngine.cs プロジェクト: deserthacker/MonoTools
        public int Attach(IDebugProgram2[] programs, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            var            program = programs[0];
            IDebugProcess2 process;

            program.GetProcess(out process);
            Guid processId;

            process.GetProcessId(out processId);
            if (processId != this.processId.guidProcessId)
            {
                return(VSConstants.S_FALSE);
            }

            EngineUtils.RequireOk(program.GetProgramId(out programId));

            Task.Run(() => {
                waiter.WaitOne();

                // connect to the local Mono Debugger or SSH tunnel.
                var localhost = IPAddress.Parse("127.0.0.1");
                Session.Run(new SoftDebuggerStartInfo(new SoftDebuggerConnectArgs("", localhost, MonoDebuggerPort)),
                            new DebuggerSessionOptions {
                    EvaluationOptions = EvaluationOptions.DefaultOptions, ProjectAssembliesOnly = false
                });
            });

            MonoEngineCreateEvent.Send(this);
            MonoProgramCreateEvent.Send(this);

            return(VSConstants.S_OK);
        }
コード例 #2
0
        public int Attach(IDebugProgram2[] programs, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            var            program = programs[0];
            IDebugProcess2 process;

            program.GetProcess(out process);
            Guid processId;

            process.GetProcessId(out processId);
            if (processId != this.processId.guidProcessId)
            {
                return(VSConstants.S_FALSE);
            }

            EngineUtils.RequireOk(program.GetProgramId(out programId));

            Task.Run(() =>
            {
                waiter.WaitOne();

                var ipAddress = HostUtils.ResolveHostOrIPAddress(settings.Host);
                Session.Run(new SoftDebuggerStartInfo(new SoftDebuggerConnectArgs("", ipAddress, 6438)),
                            new DebuggerSessionOptions {
                    EvaluationOptions = EvaluationOptions.DefaultOptions, ProjectAssembliesOnly = false
                });
            });

            MonoEngineCreateEvent.Send(this);
            MonoProgramCreateEvent.Send(this);

            return(VSConstants.S_OK);
        }
コード例 #3
0
        public int LaunchSuspended(string server, IDebugPort2 port, string exe, string args, string directory, string environment, string options, enum_LAUNCH_FLAGS launchFlags, uint standardInput, uint standardOutput, uint standardError, IDebugEventCallback2 callback, out IDebugProcess2 process)
        {
            processId = new AD_PROCESS_ID();
            processId.ProcessIdType = (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_GUID;
            processId.guidProcessId = Guid.NewGuid();

            EngineUtils.CheckOk(port.GetProcess(processId, out process));
            this.Callback = callback;

            Session              = new SoftDebuggerSession();
            Session.TargetReady += (sender, eventArgs) =>
            {
                var activeThread = Session.ActiveThread;
                threadManager.Add(activeThread, new MonoThread(this, activeThread));

/*
 *              Session.Stop();
 *              var location = activeThread.Location;
 *              var backtrace = activeThread.Backtrace;
 *              var locations = Session.VirtualMachine.RootDomain.GetAssemblies().Select(x => x.Location).ToArray();
 *              Session.Continue();
 */

                MonoEngineCreateEvent.Send(this);
                MonoProgramCreateEvent.Send(this);
            };
            Session.ExceptionHandler          = exception => true;
            Session.TargetExceptionThrown    += (sender, x) => Console.WriteLine(x.Type);
            Session.TargetExited             += (sender, x) => Send(new MonoProgramDestroyEvent((uint?)x.ExitCode ?? 0), MonoProgramDestroyEvent.IID, null);
            Session.TargetUnhandledException += (sender, x) => Console.WriteLine(x.Type);
            Session.LogWriter            = (stderr, text) => Console.WriteLine(text);
            Session.OutputWriter         = (stderr, text) => Console.WriteLine(text);
            Session.TargetThreadStarted += (sender, x) => threadManager.Add(x.Thread, new MonoThread(this, x.Thread));
            Session.TargetThreadStopped += (sender, x) => threadManager.Remove(x.Thread);
            Session.TargetStopped       += (sender, x) => Console.WriteLine(x.Type);
            Session.TargetStarted       += (sender, x) => Console.WriteLine();
            Session.TargetSignaled      += (sender, x) => Console.WriteLine(x.Type);
            Session.TargetInterrupted   += (sender, x) => Console.WriteLine(x.Type);
            Session.TargetHitBreakpoint += (sender, x) =>
            {
                var breakpoint        = x.BreakEvent as Breakpoint;
                var pendingBreakpoint = breakpointManager[breakpoint];
                Send(new MonoBreakpointEvent(new MonoBoundBreakpointsEnum(pendingBreakpoint.BoundBreakpoints)), MonoBreakpointEvent.IID, threadManager[x.Thread]);
            };

            return(VSConstants.S_OK);
        }