Beispiel #1
0
        void StartDebuggerSession(DebuggerStartInfo startInfo, long attachToProcessId)
        {
            IsDebugging    = true;
            EngineStarting = true;

            bool showConsole = false;

            DebugCreateProcessOptions opt = new DebugCreateProcessOptions();

            if (attachToProcessId == 0)
            {
                opt.CreateFlags    = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
                opt.EngCreateFlags = EngCreateFlags.Default;
            }

            if (attachToProcessId != 0)
            {
                Engine.CreateProcessAndAttach(0, null, opt, null, null, (uint)attachToProcessId, AttachFlags.InvasiveNoInitialBreak);
            }
            else
            {
                Engine.CreateProcessAndAttach(0, startInfo.Command + (string.IsNullOrWhiteSpace(startInfo.Arguments) ? "" : (" " + startInfo.Arguments)), opt, Path.GetDirectoryName(startInfo.Command), "", 0, 0);
                Engine.Symbols.SourcePath = (string.IsNullOrWhiteSpace(startInfo.WorkingDirectory)) ? Path.GetDirectoryName(startInfo.Command) : startInfo.WorkingDirectory;
                Engine.Symbols.SymbolPath = startInfo.WorkingDirectory;
            }

            Engine.IsSourceCodeOrientedStepping = true;

            Engine.WaitForEvent();
            Engine.Execute("bc");             // Clear breakpoint list
            Engine.Execute("ld *");           // Extraordinarily important: Load symbols for all modules! - Only then, the stuff from the .pdb seems to get loaded into the debug environment
            Engine.WaitForEvent();

            foreach (Breakpoint bp in Breakpoints)
            {
                ulong off = 0;
                if (!Engine.Symbols.GetOffsetByLine(bp.FileName, (uint)bp.Line, out off))
                {
                    continue;
                }

                Engine.AddBreakPoint(BreakPointOptions.Enabled).Offset = off;

                //bp.Breakpoint = DebugManagement.Engine.AddBreakPoint(BreakPointOptions.Enabled);
                //bp.Breakpoint.Offset = off;
            }

            EngineStarting = false;
        }
Beispiel #2
0
        void StartDebuggerSession(DebuggerStartInfo startInfo, long attachToProcessId)
        {
            IsDebugging    = true;
            EngineStarting = true;

            bool showConsole = false;

            DebugCreateProcessOptions opt = new DebugCreateProcessOptions();

            opt.CreateFlags    = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
            opt.EngCreateFlags = EngCreateFlags.Default;

            if (attachToProcessId != 0)
            {
                Engine.CreateProcessAndAttach(0, "", opt, Path.GetDirectoryName(startInfo.Command), "", (uint)attachToProcessId, 0);
            }
            else
            {
                Engine.CreateProcessAndAttach(0, startInfo.Command + (string.IsNullOrWhiteSpace(startInfo.Arguments) ? "" : (" " + startInfo.Arguments)), opt, Path.GetDirectoryName(startInfo.Command), "", 0, 0);
            }

            Engine.Symbols.SourcePath           = (string.IsNullOrWhiteSpace(startInfo.WorkingDirectory)) ? @"C:\Users\michaelc\Desktop\Temp\mono-d-tests\console1" : Path.GetDirectoryName(startInfo.Command);
            Engine.IsSourceCodeOrientedStepping = true;

            Engine.WaitForEvent();
            Engine.Execute("bc");             // Clear breakpoint list
            Engine.WaitForEvent();


            foreach (Breakpoint bp in Breakpoints)
            {
                ulong off = 0;
                if (!Engine.Symbols.GetOffsetByLine(bp.FileName, (uint)bp.Line, out off))
                {
                    continue;
                }

                Engine.AddBreakPoint(BreakPointOptions.Enabled).Offset = off;

                //bp.Breakpoint = DebugManagement.Engine.AddBreakPoint(BreakPointOptions.Enabled);
                //bp.Breakpoint.Offset = off;
            }

            EngineStarting = false;
        }
            /// <summary>
            /// Launch the debugger asynchronously
            /// </summary>
            public static void LaunchWithDebugger(string exe, string args,string sourcePath,bool showConsole)
            {
                StopExecution();

                // Make all documents read-only
                WorkbenchLogic.Instance.AllDocumentsReadOnly = true;

                // If there's an external debugger specified and if it's wanted to launch it, start that one
                if (GlobalProperties.Instance.UseExternalDebugger)
                {
                    IDEManager.Instance.MainWindow.LeftStatusText = "Launch external debugger";
                    CurrentProcess = FileExecution.ExecuteAsync(GlobalProperties.Instance.ExternalDebugger_Bin,
                        AbstractBuildSupport.BuildArgumentString(GlobalProperties.Instance.ExternalDebugger_Arguments, new Dictionary<string, string>{
                            {"$sourcePath",sourcePath},
                            {"$targetDir",Path.GetDirectoryName(exe)},
                            {"$target",exe},
                            {"$exe",Path.ChangeExtension(exe,".exe")},
                            {"$dll",Path.ChangeExtension(exe,".dll")},
                            {"$args",args}
                        }), // %WINDBG_ARGS% Program.exe Arg1 Arg2
                        Path.GetDirectoryName(exe), CurrentProcess_Exited);

                    Instance.UpdateGUI();

                    return;
                }

                IDEManager.Instance.MainWindow.LeftStatusText = "Start debugging "+Path.GetFileName(exe);

                if (!dbgEngineInited)
                    InitDebugger();

                IsDebugging = true;
                Instance.UpdateGUI();
                EngineStarting = true;
                StopWaitingForEvents = false;

                DebugCreateProcessOptions opt = new DebugCreateProcessOptions();
                opt.CreateFlags = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
                opt.EngCreateFlags = EngCreateFlags.Default;

                Engine.CreateProcessAndAttach(0, exe + (string.IsNullOrWhiteSpace(args) ? "" : (" " + args)), opt, Path.GetDirectoryName(exe), "", 0, 0);

                Engine.Symbols.SourcePath = string.IsNullOrWhiteSpace(sourcePath) ? sourcePath : Path.GetDirectoryName(exe);
                Engine.IsSourceCodeOrientedStepping = true;

                Engine.WaitForEvent();
                Engine.Execute("bc"); // Clear breakpoint list
                Engine.WaitForEvent();

                BreakpointManagement.SetupBreakpoints();

                EngineStarting = false;

                WaitForDebugEvent(); // Wait for the first breakpoint/exception/program exit to occur
            }
Beispiel #4
0
        void StartDebuggerSession(DebuggerStartInfo startInfo, long attachToProcessId)
        {
            IsDebugging = true;
            EngineStarting = true;

            bool showConsole = false;

            DebugCreateProcessOptions opt = new DebugCreateProcessOptions();
            opt.CreateFlags = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
            opt.EngCreateFlags = EngCreateFlags.Default;

            if (attachToProcessId != 0)
                Engine.CreateProcessAndAttach(0, "", opt, Path.GetDirectoryName(startInfo.Command), "", (uint)attachToProcessId, 0);
            else
                Engine.CreateProcessAndAttach(0, startInfo.Command + (string.IsNullOrWhiteSpace(startInfo.Arguments) ? "" : (" " + startInfo.Arguments)), opt, Path.GetDirectoryName(startInfo.Command), "", 0, 0);

            Engine.Symbols.SourcePath = (string.IsNullOrWhiteSpace(startInfo.WorkingDirectory)) ? @"C:\Users\michaelc\Desktop\Temp\mono-d-tests\console1" : Path.GetDirectoryName(startInfo.Command);
            Engine.IsSourceCodeOrientedStepping = true;

            Engine.WaitForEvent();
            Engine.Execute("bc"); // Clear breakpoint list
            Engine.WaitForEvent();

            foreach (Breakpoint bp in Breakpoints)
            {
                ulong off = 0;
                if (!Engine.Symbols.GetOffsetByLine(bp.FileName, (uint)bp.Line, out off))
                    continue;

                Engine.AddBreakPoint(BreakPointOptions.Enabled).Offset = off;

                //bp.Breakpoint = DebugManagement.Engine.AddBreakPoint(BreakPointOptions.Enabled);
                //bp.Breakpoint.Offset = off;
            }

            EngineStarting = false;
        }
Beispiel #5
0
            /// <summary>
            /// Launch the debugger asynchronously
            /// </summary>
            public static void LaunchWithDebugger(string exe, string args, string sourcePath, bool showConsole)
            {
                StopExecution();

                // Make all documents read-only
                WorkbenchLogic.Instance.AllDocumentsReadOnly = true;

                // If there's an external debugger specified and if it's wanted to launch it, start that one
                if (GlobalProperties.Instance.UseExternalDebugger)
                {
                    IDEManager.Instance.MainWindow.LeftStatusText = "Launch external debugger";
                    CurrentProcess = FileExecution.ExecuteAsync(GlobalProperties.Instance.ExternalDebugger_Bin,
                                                                AbstractBuildSupport.BuildArgumentString(GlobalProperties.Instance.ExternalDebugger_Arguments, new Dictionary <string, string> {
                        { "$sourcePath", sourcePath },
                        { "$targetDir", Path.GetDirectoryName(exe) },
                        { "$target", exe },
                        { "$exe", Path.ChangeExtension(exe, ".exe") },
                        { "$dll", Path.ChangeExtension(exe, ".dll") },
                        { "$args", args }
                    }),                             // %WINDBG_ARGS% Program.exe Arg1 Arg2
                                                                Path.GetDirectoryName(exe), CurrentProcess_Exited);

                    Instance.UpdateGUI();

                    return;
                }

                IDEManager.Instance.MainWindow.LeftStatusText = "Start debugging " + Path.GetFileName(exe);

                if (!dbgEngineInited)
                {
                    InitDebugger();
                }

                IsDebugging = true;
                Instance.UpdateGUI();
                EngineStarting       = true;
                StopWaitingForEvents = false;

                DebugCreateProcessOptions opt = new DebugCreateProcessOptions();

                opt.CreateFlags    = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
                opt.EngCreateFlags = EngCreateFlags.Default;

                Engine.CreateProcessAndAttach(0, exe + (string.IsNullOrWhiteSpace(args) ? "" : (" " + args)), opt, Path.GetDirectoryName(exe), "", 0, 0);


                Engine.Symbols.SourcePath           = string.IsNullOrWhiteSpace(sourcePath) ? sourcePath : Path.GetDirectoryName(exe);
                Engine.IsSourceCodeOrientedStepping = true;

                Engine.WaitForEvent();
                Engine.Execute("bc");                 // Clear breakpoint list
                Engine.WaitForEvent();

                CoreManager.DebugManagement.CurrentDebugSupport.PostlaunchInit(Engine);
                BreakpointManagement.SetupBreakpoints();

                EngineStarting = false;

                WaitForDebugEvent();                 // Wait for the first breakpoint/exception/program exit to occur
            }
		void StartDebuggerSession(DebuggerStartInfo startInfo, long attachToProcessId)
		{
			IsDebugging = true;
			EngineStarting = true;

			bool showConsole = false;

			DebugCreateProcessOptions opt = new DebugCreateProcessOptions();
			if (attachToProcessId == 0)
			{
				opt.CreateFlags = CreateFlags.DebugOnlyThisProcess | (showConsole ? CreateFlags.CreateNewConsole : 0);
				opt.EngCreateFlags = EngCreateFlags.Default;
			}

			if (attachToProcessId != 0)
			{
				Engine.CreateProcessAndAttach(0, null, opt, null, null, (uint)attachToProcessId, AttachFlags.InvasiveNoInitialBreak);
			}
			else
			{
				Engine.CreateProcessAndAttach(0, startInfo.Command + (string.IsNullOrWhiteSpace(startInfo.Arguments) ? "" : (" " + startInfo.Arguments)), opt, Path.GetDirectoryName(startInfo.Command), "", 0, 0);
				Engine.Symbols.SourcePath = (string.IsNullOrWhiteSpace(startInfo.WorkingDirectory)) ? Path.GetDirectoryName(startInfo.Command) : startInfo.WorkingDirectory;
				Engine.Symbols.SymbolPath = startInfo.WorkingDirectory;
			}

			Engine.IsSourceCodeOrientedStepping = true;

			Engine.WaitForEvent();
			Engine.Execute("bc"); // Clear breakpoint list
			Engine.Execute("ld *"); // Extraordinarily important: Load symbols for all modules! - Only then, the stuff from the .pdb seems to get loaded into the debug environment
			Engine.WaitForEvent();			

			foreach (Breakpoint bp in Breakpoints)
			{
				ulong off = 0;
				if (!Engine.Symbols.GetOffsetByLine(bp.FileName, (uint)bp.Line, out off))
					continue;

				Engine.AddBreakPoint(BreakPointOptions.Enabled).Offset = off;

				//bp.Breakpoint = DebugManagement.Engine.AddBreakPoint(BreakPointOptions.Enabled);
				//bp.Breakpoint.Offset = off;								
			}

			EngineStarting = false;
		}