From 3acf83ead3e283cedb81c549a2e53123bfe78380 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 25 Dec 2019 11:12:59 -0800 Subject: [PATCH] Check for hidden visualizations As always, we try to prevent this from happening, but a determined user can accomplish anything. --- SourceGen/DisasmProject.cs | 27 +++++++++++++++++++++++++++ SourceGen/MessageList.cs | 10 ++++++++++ SourceGen/Res/Strings.xaml | 2 ++ SourceGen/Res/Strings.xaml.cs | 4 ++++ 4 files changed, 43 insertions(+) diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index d54dd61..240d99e 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -689,6 +689,9 @@ namespace SourceGen { } } + /// + /// Checks to see if any part of the address map runs across a bank boundary. + /// private void ValidateAddressMap() { foreach (AddressMap.AddressMapEntry entry in AddrMap) { if ((entry.Addr & 0xff0000) != ((entry.Addr + entry.Length - 1) & 0xff0000)) { @@ -705,6 +708,27 @@ namespace SourceGen { } } + /// + /// Checks for hidden visualization sets. + /// + private void ValidateVisualizationSets() { + foreach (KeyValuePair kvp in VisualizationSets) { + Anattrib attr = GetAnattrib(kvp.Key); + if (!attr.IsStart) { + string tag = string.Empty; + if (kvp.Value.Count > 0) { + tag = kvp.Value[0].Tag; + } + Messages.Add(new MessageList.MessageEntry( + MessageList.MessageEntry.SeverityLevel.Warning, + kvp.Key, + MessageList.MessageEntry.MessageType.HiddenVisualization, + tag, + MessageList.MessageEntry.ProblemResolution.VisualizationIgnored)); + } + } + } + #region Analysis /// @@ -850,7 +874,10 @@ namespace SourceGen { Validate(); reanalysisTimer.EndTask("Validate"); #endif + reanalysisTimer.StartTask("ErrorCheck"); ValidateAddressMap(); + ValidateVisualizationSets(); + reanalysisTimer.EndTask("ErrorCheck"); reanalysisTimer.EndTask("DisasmProject.Analyze()"); //reanalysisTimer.DumpTimes("DisasmProject timers:", debugLog); diff --git a/SourceGen/MessageList.cs b/SourceGen/MessageList.cs index 4df60ed..824309e 100644 --- a/SourceGen/MessageList.cs +++ b/SourceGen/MessageList.cs @@ -49,6 +49,7 @@ namespace SourceGen { Unknown = 0, HiddenLabel, HiddenLocalVariableTable, + HiddenVisualization, UnresolvedWeakRef, InvalidOffsetOrLength, InvalidDescriptor, @@ -64,6 +65,7 @@ namespace SourceGen { None, LabelIgnored, LocalVariableTableIgnored, + VisualizationIgnored, FormatDescriptorIgnored, } public ProblemResolution Resolution { get; private set; } @@ -71,6 +73,8 @@ namespace SourceGen { public MessageEntry(SeverityLevel severity, int offset, MessageType mtype, object context, ProblemResolution resolution) { + Debug.Assert(context != null); + Severity = severity; Offset = offset; MsgType = mtype; @@ -155,6 +159,9 @@ namespace SourceGen { case MessageEntry.MessageType.HiddenLocalVariableTable: problem = Res.Strings.MSG_HIDDEN_LOCAL_VARIABLE_TABLE; break; + case MessageEntry.MessageType.HiddenVisualization: + problem = Res.Strings.MSG_HIDDEN_VISUALIZATION; + break; case MessageEntry.MessageType.UnresolvedWeakRef: problem = Res.Strings.MSG_UNRESOLVED_WEAK_REF; break; @@ -188,6 +195,9 @@ namespace SourceGen { case MessageEntry.ProblemResolution.FormatDescriptorIgnored: resolution = Res.Strings.MSG_FORMAT_DESCRIPTOR_IGNORED; break; + case MessageEntry.ProblemResolution.VisualizationIgnored: + resolution = Res.Strings.MSG_VISUALIZATION_IGNORED; + break; default: resolution = "???"; break; diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml index df8de73..a4c2d5d 100644 --- a/SourceGen/Res/Strings.xaml +++ b/SourceGen/Res/Strings.xaml @@ -117,11 +117,13 @@ limitations under the License. Format ignored Hidden label Hidden variable table + Hidden visualization Invalid format desc Invalid offset or len Label ignored LV table skipped over Ref'd symbol not found + Visualization ignored no files available No exported symbols found. The file doesn't exist. diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs index 38dd8a4..aa71c32 100644 --- a/SourceGen/Res/Strings.xaml.cs +++ b/SourceGen/Res/Strings.xaml.cs @@ -215,6 +215,8 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_MsgHiddenLabel"); public static string MSG_HIDDEN_LOCAL_VARIABLE_TABLE = (string)Application.Current.FindResource("str_MsgHiddenLocalVariableTable"); + public static string MSG_HIDDEN_VISUALIZATION = + (string)Application.Current.FindResource("str_MsgHiddenVisualization"); public static string MSG_INVALID_DESCRIPTOR = (string)Application.Current.FindResource("str_MsgInvalidDescriptor"); public static string MSG_INVALID_OFFSET_OR_LENGTH = @@ -225,6 +227,8 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_MsgLocalVariableTableIgnored"); public static string MSG_UNRESOLVED_WEAK_REF = (string)Application.Current.FindResource("str_MsgUnresolvedWeakRef"); + public static string MSG_VISUALIZATION_IGNORED = + (string)Application.Current.FindResource("str_MsgVisualizationIgnored"); public static string NO_FILES_AVAILABLE = (string)Application.Current.FindResource("str_NoFilesAvailable"); public static string NO_EXPORTED_SYMBOLS_FOUND =