void RemoveMarker(ILCodeBreakpoint ilbp) { IGlyphTextMethodMarker marker; if (toMethodMarkers.TryGetValue(ilbp, out marker)) { glyphTextMarkerService.Remove(marker); toMethodMarkers.Remove(ilbp); } }
BreakpointMarkerInfo GetBreakpointMarkerInfo(ILCodeBreakpoint ilbp) { ImageReference imgRef; string markerTypeName, selectedMarkerTypeName; IClassificationType classificationType; int zIndex; if (ilbp.IsEnabled) { imgRef = DsImages.BreakpointEnabled; markerTypeName = ThemeClassificationTypeNameKeys.BreakpointStatementMarker; selectedMarkerTypeName = ThemeClassificationTypeNameKeys.SelectedBreakpointStatementMarker; classificationType = classificationTypeEnabledBreakpoint; zIndex = GlyphTextMarkerServiceZIndexes.EnabledBreakpoint; } else { imgRef = DsImages.BreakpointDisabled; markerTypeName = ThemeClassificationTypeNameKeys.DisabledBreakpointStatementMarker; selectedMarkerTypeName = null; classificationType = null; zIndex = GlyphTextMarkerServiceZIndexes.DisabledBreakpoint; } return(new BreakpointMarkerInfo(imgRef, markerTypeName, selectedMarkerTypeName, classificationType, zIndex)); }
void BreakpointAdded(ILCodeBreakpoint ilbp) { Debug.Assert(!toMethodMarkers.ContainsKey(ilbp)); if (toMethodMarkers.ContainsKey(ilbp)) return; ilbp.PropertyChanged += ILCodeBreakpoint_PropertyChanged; UpdateMarker(ilbp); }
string GetToolTipContent(ILCodeBreakpoint ilbp, ITextView textView) { var documentViewer = textView.TextBuffer.TryGetDocumentViewer(); Debug.Assert(documentViewer != null); var statement = documentViewer?.GetMethodDebugService().FindByCodeOffset(ilbp.MethodToken, ilbp.ILOffset); Debug.Assert((documentViewer != null) == (statement != null)); ITextSnapshotLine snapshotLine = null; if (statement != null && statement.Value.Statement.TextSpan.End <= textView.TextSnapshot.Length) snapshotLine = textView.TextSnapshot.GetLineFromPosition(statement.Value.Statement.TextSpan.Start); var sb = new StringBuilder(); sb.Append(dnSpy_Debugger_Resources.GlyphToolTip_Location); sb.Append(": "); if (snapshotLine != null) { sb.Append(string.Format(dnSpy_Debugger_Resources.GlyphToolTip_line_0_character_1, (snapshotLine.LineNumber + 1).ToString(CultureInfo.CurrentUICulture), (statement.Value.Statement.TextSpan.Start - snapshotLine.Start + 1).ToString(CultureInfo.CurrentUICulture))); sb.Append(" "); } sb.Append(string.Format(dnSpy_Debugger_Resources.GlyphToolTip_IL_offset_0, ilbp.ILOffset.ToString("X4"))); if (statement != null) { sb.Append(" ('"); var decompiler = (documentViewer?.DocumentTab.Content as IDecompilerTabContent)?.Decompiler ?? decompilerService.Decompiler; decompiler.Write(new StringBuilderTextColorOutput(sb), statement.Value.Method, SimplePrinterFlags.Default); sb.Append("')"); } return sb.ToString(); }
public void LoadInternal() { ILSpySettings settings = ILSpySettings.Load(); var bpsx = settings["Breakpoints"]; BreakpointManager.Instance.Clear(); foreach (var bpx in bpsx.Elements("Breakpoint")) { uint? token = (uint?)bpx.Attribute("Token"); string assemblyFullPath = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullPath")); string moduleFullPath = SessionSettings.Unescape((string)bpx.Attribute("ModuleFullPath")); bool isDynamic = (bool?)bpx.Attribute("IsDynamic") ?? false; bool isInMemory = (bool?)bpx.Attribute("IsInMemory") ?? false; uint? ilOffset = (uint?)bpx.Attribute("ILOffset") ?? (uint?)bpx.Attribute("From");//TODO: Remove "From" some time after this commit bool? isEnabled = (bool?)bpx.Attribute("IsEnabled"); if (token == null) continue; if (string.IsNullOrEmpty(moduleFullPath)) continue; if (ilOffset == null) continue; if (isEnabled == null) continue; var snModule = new SerializedDnModule(moduleFullPath, isDynamic, isInMemory); var key = MethodKey.Create(token.Value, snModule); var bp = new ILCodeBreakpoint(assemblyFullPath, key, ilOffset.Value, isEnabled.Value); BreakpointManager.Instance.Add(bp); } }
void UpdateMarker(ILCodeBreakpoint ilbp) { RemoveMarker(ilbp); var info = GetBreakpointMarkerInfo(ilbp); var marker = glyphTextMarkerService.AddMarker(ilbp.MethodToken, ilbp.ILOffset, info.ImageReference, info.MarkerTypeName, info.SelectedMarkerTypeName, info.ClassificationType, info.ZIndex, GlyphTextMarkerHelper.GetTag(ilbp), ilCodeBreakpointGlyphTextMarkerHandler, textViewFilter); toMethodMarkers.Add(ilbp, marker); }
void LoadInternal() { DNSpySettings settings = DNSpySettings.Load(); var bpsx = settings[SETTINGS_NAME]; BreakpointManager.Instance.Clear(); foreach (var bpx in bpsx.Elements("Breakpoint")) { uint? token = (uint?)bpx.Attribute("Token"); string asmFullName = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullName")); string moduleName = SessionSettings.Unescape((string)bpx.Attribute("ModuleName")); bool? isDynamic = (bool?)bpx.Attribute("IsDynamic"); bool? isInMemory = (bool?)bpx.Attribute("IsInMemory"); uint? ilOffset = (uint?)bpx.Attribute("ILOffset"); bool? isEnabled = (bool?)bpx.Attribute("IsEnabled"); if (token == null) { continue; } if (isDynamic == null || isInMemory == null) { continue; } if (string.IsNullOrEmpty(asmFullName)) { continue; } if (string.IsNullOrEmpty(moduleName)) { continue; } if (ilOffset == null) { continue; } if (isEnabled == null) { continue; } var snModule = SerializedDnSpyModule.Create(asmFullName, moduleName, isDynamic.Value, isInMemory.Value); var key = new SerializedDnSpyToken(snModule, token.Value); if (!isInMemory.Value && !isDynamic.Value) { var s = SessionSettings.Unescape((string)bpx.Attribute("Method")); if (s == null || s != GetMethodAsString(key)) { continue; } } var bp = new ILCodeBreakpoint(key, ilOffset.Value, isEnabled.Value); BreakpointManager.Instance.Add(bp); } }
void LoadInternal() { var section = settingsService.GetOrCreateSection(SETTINGS_GUID); breakpointService.Clear(); foreach (var bpx in section.SectionsWithName("Breakpoint")) { uint? token = bpx.Attribute <uint?>("Token"); string asmFullName = bpx.Attribute <string>("AssemblyFullName"); string moduleName = bpx.Attribute <string>("ModuleName"); bool? isDynamic = bpx.Attribute <bool?>("IsDynamic"); bool? isInMemory = bpx.Attribute <bool?>("IsInMemory"); bool moduleNameOnly = bpx.Attribute <bool?>("ModuleNameOnly") ?? false; uint? ilOffset = bpx.Attribute <uint?>("ILOffset"); bool? isEnabled = bpx.Attribute <bool?>("IsEnabled"); if (token == null) { continue; } if (isDynamic == null || isInMemory == null) { continue; } if (string.IsNullOrEmpty(asmFullName) && !moduleNameOnly) { continue; } if (string.IsNullOrEmpty(moduleName)) { continue; } if (ilOffset == null) { continue; } if (isEnabled == null) { continue; } var moduleId = ModuleId.Create(asmFullName, moduleName, isDynamic.Value, isInMemory.Value, moduleNameOnly); var key = new ModuleTokenId(moduleId, token.Value); if (!isInMemory.Value && !isDynamic.Value) { var s = bpx.Attribute <string>("Method"); if (s == null || s != GetMethodAsString(key)) { continue; } } var bp = new ILCodeBreakpoint(key, ilOffset.Value, isEnabled.Value); breakpointService.Add(bp); } }
void BreakpointRemoved(ILCodeBreakpoint ilbp) { Debug.Assert(toMethodMarkers.ContainsKey(ilbp)); if (!toMethodMarkers.ContainsKey(ilbp)) { return; } RemoveMarker(ilbp); ilbp.PropertyChanged -= ILCodeBreakpoint_PropertyChanged; }
void BreakpointAdded(ILCodeBreakpoint ilbp) { Debug.Assert(!toMethodMarkers.ContainsKey(ilbp)); if (toMethodMarkers.ContainsKey(ilbp)) { return; } ilbp.PropertyChanged += ILCodeBreakpoint_PropertyChanged; UpdateMarker(ilbp); }
void RemoveMarker(ILCodeBreakpoint ilbp) { IGlyphTextMethodMarker marker; if (toMethodMarkers.TryGetValue(ilbp, out marker)) { glyphTextMarkerService.Remove(marker); toMethodMarkers.Remove(ilbp); } }
static AssemblyDef GetAssembly(ILCodeBreakpoint bp) { var asmName = bp.Assembly; if (string.IsNullOrEmpty(asmName)) return null; var loadedAsm = MainWindow.Instance.CurrentAssemblyList.FindAssemblyByFileName(asmName); if (loadedAsm != null) return loadedAsm.AssemblyDefinition; if (!File.Exists(asmName)) return null; loadedAsm = MainWindow.Instance.LoadAssembly(asmName); return loadedAsm == null ? null : loadedAsm.AssemblyDefinition; }
void LoadInternal() { DNSpySettings settings = DNSpySettings.Load(); var bpsx = settings[SETTINGS_NAME]; BreakpointManager.Instance.Clear(); foreach (var bpx in bpsx.Elements("Breakpoint")) { uint? token = (uint?)bpx.Attribute("Token"); string assemblyFullPath = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullPath")); string moduleFullPath = SessionSettings.Unescape((string)bpx.Attribute("ModuleFullPath")); bool isDynamic = (bool?)bpx.Attribute("IsDynamic") ?? false; bool isInMemory = (bool?)bpx.Attribute("IsInMemory") ?? false; uint? ilOffset = (uint?)bpx.Attribute("ILOffset") ?? (uint?)bpx.Attribute("From"); //TODO: Remove "From" some time after this commit bool? isEnabled = (bool?)bpx.Attribute("IsEnabled"); if (token == null) { continue; } if (string.IsNullOrEmpty(moduleFullPath)) { continue; } if (ilOffset == null) { continue; } if (isEnabled == null) { continue; } var snModule = new SerializedDnModule(moduleFullPath, isDynamic, isInMemory); var key = MethodKey.Create(token.Value, snModule); if (!isInMemory) { var s = SessionSettings.Unescape((string)bpx.Attribute("Method")); if (s == null || s != GetMethodAsString(assemblyFullPath, key)) { continue; } } var bp = new ILCodeBreakpoint(assemblyFullPath, key, ilOffset.Value, isEnabled.Value); BreakpointManager.Instance.Add(bp); } }
static AssemblyDef GetAssembly(ILCodeBreakpoint bp) { var asmName = bp.Assembly; if (string.IsNullOrEmpty(asmName)) { return(null); } var loadedAsm = MainWindow.Instance.CurrentAssemblyList.FindAssemblyByFileName(asmName); if (loadedAsm != null) { return(loadedAsm.AssemblyDefinition); } if (!File.Exists(asmName)) { return(null); } loadedAsm = MainWindow.Instance.LoadAssembly(asmName); return(loadedAsm == null ? null : loadedAsm.AssemblyDefinition); }
public void Add(MethodDef method) { if (method.Body == null) { return; } var methodToken = CreateTokenId(method); var existingBreakpoints = GetILCodeBreakpoints(methodToken, 0).ToArray(); if (existingBreakpoints.Length != 0) { foreach (var ilbp in existingBreakpoints) { ilbp.IsEnabled = true; } } else { var ilbp = new ILCodeBreakpoint(methodToken, 0); Add(ilbp); } }
string GetToolTipContent(ILCodeBreakpoint ilbp, ITextView textView) { var documentViewer = textView.TextBuffer.TryGetDocumentViewer(); Debug.Assert(documentViewer != null); var statement = documentViewer?.GetMethodDebugService().FindByCodeOffset(ilbp.MethodToken, ilbp.ILOffset); Debug.Assert((documentViewer != null) == (statement != null)); ITextSnapshotLine snapshotLine = null; if (statement != null && statement.Value.Statement.TextSpan.End <= textView.TextSnapshot.Length) { snapshotLine = textView.TextSnapshot.GetLineFromPosition(statement.Value.Statement.TextSpan.Start); } var sb = new StringBuilder(); sb.Append(dnSpy_Debugger_Resources.GlyphToolTip_Location); sb.Append(": "); if (snapshotLine != null) { sb.Append(string.Format(dnSpy_Debugger_Resources.GlyphToolTip_line_0_character_1, (snapshotLine.LineNumber + 1).ToString(CultureInfo.CurrentUICulture), (statement.Value.Statement.TextSpan.Start - snapshotLine.Start + 1).ToString(CultureInfo.CurrentUICulture))); sb.Append(" "); } sb.Append(string.Format(dnSpy_Debugger_Resources.GlyphToolTip_IL_offset_0, ilbp.ILOffset.ToString("X4"))); if (statement != null) { sb.Append(" ('"); var decompiler = (documentViewer?.DocumentTab.Content as IDecompilerTabContent)?.Decompiler ?? decompilerService.Decompiler; decompiler.Write(new StringBuilderTextColorOutput(sb), statement.Value.Method, SimplePrinterFlags.Default); sb.Append("')"); } return(sb.ToString()); }
public MyMarkedTextLine(ILCodeBreakpoint ilbp, MethodKey methodKey, uint ilOffset) : base(methodKey, ilOffset, ilbp) { this.ilbp = ilbp; }
void LoadInternal() { DNSpySettings settings = DNSpySettings.Load(); var bpsx = settings[SETTINGS_NAME]; BreakpointManager.Instance.Clear(); foreach (var bpx in bpsx.Elements("Breakpoint")) { uint? token = (uint?)bpx.Attribute("Token"); string asmFullName = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullName")); string moduleName = SessionSettings.Unescape((string)bpx.Attribute("ModuleName")); bool? isDynamic = (bool?)bpx.Attribute("IsDynamic"); bool? isInMemory = (bool?)bpx.Attribute("IsInMemory"); uint? ilOffset = (uint?)bpx.Attribute("ILOffset"); bool? isEnabled = (bool?)bpx.Attribute("IsEnabled"); if (token == null) continue; if (isDynamic == null || isInMemory == null) continue; if (string.IsNullOrEmpty(asmFullName)) continue; if (string.IsNullOrEmpty(moduleName)) continue; if (ilOffset == null) continue; if (isEnabled == null) continue; var snModule = SerializedDnSpyModule.Create(asmFullName, moduleName, isDynamic.Value, isInMemory.Value); var key = new SerializedDnSpyToken(snModule, token.Value); if (!isInMemory.Value && !isDynamic.Value) { var s = SessionSettings.Unescape((string)bpx.Attribute("Method")); if (s == null || s != GetMethodAsString(key)) continue; } var bp = new ILCodeBreakpoint(key, ilOffset.Value, isEnabled.Value); BreakpointManager.Instance.Add(bp); } }
static ModuleDef GetModule(ILCodeBreakpoint bp) { var loadedAsm = MainWindow.Instance.LoadAssembly(bp.Assembly, bp.MethodKey.Module); return(loadedAsm == null ? null : loadedAsm.ModuleDefinition); }
void LoadInternal() { var section = settingsManager.GetOrCreateSection(SETTINGS_GUID); breakpointManager.Clear(); foreach (var bpx in section.SectionsWithName("Breakpoint")) { uint? token = bpx.Attribute<uint?>("Token"); string asmFullName = bpx.Attribute<string>("AssemblyFullName"); string moduleName = bpx.Attribute<string>("ModuleName"); bool? isDynamic = bpx.Attribute<bool?>("IsDynamic"); bool? isInMemory = bpx.Attribute<bool?>("IsInMemory"); uint? ilOffset = bpx.Attribute<uint?>("ILOffset"); bool? isEnabled = bpx.Attribute<bool?>("IsEnabled"); if (token == null) continue; if (isDynamic == null || isInMemory == null) continue; if (string.IsNullOrEmpty(asmFullName)) continue; if (string.IsNullOrEmpty(moduleName)) continue; if (ilOffset == null) continue; if (isEnabled == null) continue; var snModule = SerializedDnModule.Create(asmFullName, moduleName, isDynamic.Value, isInMemory.Value); var key = new SerializedDnToken(snModule, token.Value); if (!isInMemory.Value && !isDynamic.Value) { var s = bpx.Attribute<string>("Method"); if (s == null || s != GetMethodAsString(key)) continue; } var bp = new ILCodeBreakpoint(key, ilOffset.Value, isEnabled.Value); breakpointManager.Add(bp); } }
public MyMarkedTextLine(ILCodeBreakpoint ilbp, MethodKey methodKey, uint ilOffset) : base(methodKey, ilOffset, ilbp) { this.ilbp = ilbp; }
public MyMarkedTextLine(ILCodeBreakpoint ilbp, SerializedDnToken methodKey, uint ilOffset) : base(methodKey, ilOffset, ilbp) { this.ilbp = ilbp; }
public MyMarkedTextLine(ILCodeBreakpoint ilbp, SerializedDnSpyToken methodKey, uint ilOffset) : base(methodKey, ilOffset, ilbp) { this.ilbp = ilbp; }
public void Add(MethodDef method) { if (method.Body == null) return; var methodToken = CreateTokenId(method); var existingBreakpoints = GetILCodeBreakpoints(methodToken, 0).ToArray(); if (existingBreakpoints.Length != 0) { foreach (var ilbp in existingBreakpoints) ilbp.IsEnabled = true; } else { var ilbp = new ILCodeBreakpoint(methodToken, 0); Add(ilbp); } }
BreakpointMarkerInfo GetBreakpointMarkerInfo(ILCodeBreakpoint ilbp) { ImageReference imgRef; string markerTypeName, selectedMarkerTypeName; IClassificationType classificationType; int zIndex; if (ilbp.IsEnabled) { imgRef = DsImages.BreakpointEnabled; markerTypeName = ThemeClassificationTypeNameKeys.BreakpointStatementMarker; selectedMarkerTypeName = ThemeClassificationTypeNameKeys.SelectedBreakpointStatementMarker; classificationType = classificationTypeEnabledBreakpoint; zIndex = GlyphTextMarkerServiceZIndexes.EnabledBreakpoint; } else { imgRef = DsImages.BreakpointDisabled; markerTypeName = ThemeClassificationTypeNameKeys.DisabledBreakpointStatementMarker; selectedMarkerTypeName = null; classificationType = null; zIndex = GlyphTextMarkerServiceZIndexes.DisabledBreakpoint; } return new BreakpointMarkerInfo(imgRef, markerTypeName, selectedMarkerTypeName, classificationType, zIndex); }
void UpdateMarker(ILCodeBreakpoint ilbp) { RemoveMarker(ilbp); var info = GetBreakpointMarkerInfo(ilbp); var marker = glyphTextMarkerService.AddMarker(ilbp.MethodToken, ilbp.ILOffset, info.ImageReference, info.MarkerTypeName, info.SelectedMarkerTypeName, info.ClassificationType, info.ZIndex, GlyphTextMarkerHelper.GetTag(ilbp), ilCodeBreakpointGlyphTextMarkerHandler, textViewFilter); toMethodMarkers.Add(ilbp, marker); }
static ModuleDef GetModule(ILCodeBreakpoint bp) { var loadedAsm = MainWindow.Instance.LoadAssembly(bp.Assembly, bp.MethodKey.Module); return loadedAsm == null ? null : loadedAsm.ModuleDefinition; }
void BreakpointRemoved(ILCodeBreakpoint ilbp) { Debug.Assert(toMethodMarkers.ContainsKey(ilbp)); if (!toMethodMarkers.ContainsKey(ilbp)) return; RemoveMarker(ilbp); ilbp.PropertyChanged -= ILCodeBreakpoint_PropertyChanged; }