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; }
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; }