示例#1
0
        public DDebugSession()
        {
            logGdb = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONODEVELOP_GDB_LOG"));
            Engine = new DBGEngine();

            Engine.Output += delegate(OutputFlags type, string msg)
            {
                /*if (!GlobalProperties.Instance.VerboseDebugOutput && (type == OutputFlags.Verbose || type == OutputFlags.Normal)) return;
                 *
                 *      var ErrType=ErrorType.Message;
                 *      if (type == OutputFlags.Warning)
                 *              return;
                 *      if (type == OutputFlags.Error)
                 *              ErrType = ErrorType.Error;
                 *      Log(msg.Replace("\n",string.Empty),ErrType);*/
            };

            Engine.OnLoadModule += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint Timestamp)
            {
                if (EngineStarting)
                {
                    return(DebugStatus.Break);
                }
                return(DebugStatus.NoChange);
            };

            Engine.OnCreateProcess += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint TimeStamp)
            {
                //debugeeProcessId =  Process.GetProcessesByName(ModuleName)[0].Id;
                debugeeOffSet = BaseOffset;

                return(DebugStatus.NoChange);
            };

            Engine.OnBreakPoint += delegate(uint Id, string cmd, ulong off, string exp)
            {
                FireBreakPoint(off);
                StopWaitingForEvents = true;
                return(DebugStatus.Break);
            };

            Engine.OnException += delegate(CodeException ex)
            {
                StopWaitingForEvents = true;

                return(DebugStatus.Break);
            };

            Engine.OnExitProcess += delegate(uint code)
            {
                /*Log("Debugger Process exited with code " + code.ToString(),
                 *      code<1?ErrorType.Information:ErrorType.Error);
                 * StopExecution();*/
                return(DebugStatus.NoChange);
            };


            Engine.Execute("n 10");             // Set decimal numbers
            Engine.Execute(".lines -e");        // Enable source code locating
        }
示例#2
0
        public DDebugSession()
        {
            Engine = new DBGEngine();

            Engine.Output += delegate(OutputFlags type, string msg)
            {
                /*if (!GlobalProperties.Instance.VerboseDebugOutput && (type == OutputFlags.Verbose || type == OutputFlags.Normal)) return;
                 *
                 *      var ErrType=ErrorType.Message;
                 *      if (type == OutputFlags.Warning)
                 *              return;
                 *      if (type == OutputFlags.Error)
                 *              ErrType = ErrorType.Error;
                 *      Log(msg.Replace("\n",string.Empty),ErrType);*/
            };

            Engine.OnLoadModule += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint Timestamp)
            {
                if (EngineStarting)
                {
                    return(DebugStatus.Break);
                }
                return(DebugStatus.NoChange);
            };

            Engine.OnCreateProcess += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint TimeStamp)
            {
                targetProcessId = Engine.GetTargetProcessId();
                debugeeOffSet   = BaseOffset;

                return(DebugStatus.NoChange);
            };

            Engine.OnBreakPoint += delegate(uint Id, string cmd, ulong off, string exp)
            {
                FireBreakPoint(off);
                StopWaitingForEvents = true;
                return(DebugStatus.Break);
            };

            Engine.OnException += delegate(CodeException ex)
            {
                StopWaitingForEvents = true;

                return(DebugStatus.Break);
            };

            Engine.OnExitProcess += delegate(uint code)
            {
                Exit();
                return(DebugStatus.NoChange);
            };


            Engine.Execute("n 10");             // Set decimal numbers
            Engine.Execute(".lines -e");        // Enable source code locating
        }
示例#3
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;
        }
示例#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;
        }
示例#5
0
        public DDebugSession()
        {
            logGdb = !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MONODEVELOP_GDB_LOG"));
            Engine = new DBGEngine();

                Engine.Output += delegate(OutputFlags type, string msg)
                {
                /*if (!GlobalProperties.Instance.VerboseDebugOutput && (type == OutputFlags.Verbose || type == OutputFlags.Normal)) return;

                    var ErrType=ErrorType.Message;
                    if (type == OutputFlags.Warning)
                        return;
                    if (type == OutputFlags.Error)
                        ErrType = ErrorType.Error;
                    Log(msg.Replace("\n",string.Empty),ErrType);*/
                };

                Engine.OnLoadModule += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint Timestamp)
                {
                    if (EngineStarting)
                        return DebugStatus.Break;
                    return DebugStatus.NoChange;
                };

                Engine.OnCreateProcess += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint TimeStamp)
                {
                    //debugeeProcessId =  Process.GetProcessesByName(ModuleName)[0].Id;
                    debugeeOffSet = BaseOffset;

                    return DebugStatus.NoChange;
                };

                Engine.OnBreakPoint += delegate(uint Id, string cmd, ulong off, string exp)
                {
                    FireBreakPoint(off);
                    StopWaitingForEvents = true;
                    return DebugStatus.Break;

                };

                Engine.OnException += delegate(CodeException ex)
                {
                    StopWaitingForEvents = true;

                    return DebugStatus.Break;
                };

                Engine.OnExitProcess += delegate(uint code)
                {
                    /*Log("Debugger Process exited with code " + code.ToString(),
                        code<1?ErrorType.Information:ErrorType.Error);
                    StopExecution();*/
                    return DebugStatus.NoChange;
                };

            Engine.Execute("n 10"); // Set decimal numbers
            Engine.Execute(".lines -e"); // Enable source code locating
        }
		public DDebugSession()
		{
			Engine = new DBGEngine();

			Engine.Output += delegate(OutputFlags type, string msg)
			{
				/*if (!GlobalProperties.Instance.VerboseDebugOutput && (type == OutputFlags.Verbose || type == OutputFlags.Normal)) return;

					var ErrType=ErrorType.Message;
					if (type == OutputFlags.Warning)
						return;
					if (type == OutputFlags.Error)
						ErrType = ErrorType.Error;
					Log(msg.Replace("\n",string.Empty),ErrType);*/
			};

			Engine.OnLoadModule += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint Timestamp)
			{
				if (EngineStarting)
					return DebugStatus.Break;
				return DebugStatus.NoChange;
			};

			Engine.OnCreateProcess += delegate(ulong BaseOffset, uint ModuleSize, string ModuleName, uint Checksum, uint TimeStamp)
			{
				targetProcessId = Engine.GetTargetProcessId();
				debugeeOffSet = BaseOffset;

				return DebugStatus.NoChange;
			};

			Engine.OnBreakPoint += delegate(uint Id, string cmd, ulong off, string exp)
			{
				FireBreakPoint(off);
				StopWaitingForEvents = true;
				return DebugStatus.Break;

			};

			Engine.OnException += delegate(CodeException ex)
			{
				StopWaitingForEvents = true;

				return DebugStatus.Break;
			};

			Engine.OnExitProcess += delegate(uint code)
			{
				Exit();
				return DebugStatus.NoChange;
			};


			Engine.Execute("n 10"); // Set decimal numbers
			Engine.Execute(".lines -e"); // Enable source code locating            
		}