mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-20 21:29:10 +00:00
Improve handling of hidden LV tables
If a local variable table gets buried, it won't appear in the code list, so most things ignore it. Unfortunately, the code that adds new entries and edits tables was finding them, which was causing variable definitions to appear to fall into a black hole. This is addressed in two ways. First, we now add a message to the log when a hidden table is noticed. Second, the code that finds the nearest prior table now keeps track of hidden vs. not hidden. If a non-hidden table is available, that is returned. If the only option is a hidden table, we will return that, because the callers have already assumed that a table exists by virtue of its presence in the LvTable list.
This commit is contained in:
parent
73f04ef2d2
commit
14ecad0849
@ -1191,6 +1191,14 @@ namespace SourceGen {
|
|||||||
Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (LvTables.TryGetValue(offset, out LocalVariableTable unused)) {
|
||||||
|
// table was ignored
|
||||||
|
Messages.Add(new MessageList.MessageEntry(
|
||||||
|
MessageList.MessageEntry.SeverityLevel.Warning,
|
||||||
|
offset,
|
||||||
|
MessageList.MessageEntry.MessageType.HiddenLocalVariableTable,
|
||||||
|
string.Empty,
|
||||||
|
MessageList.MessageEntry.ProblemResolution.LocalVariableTableIgnored));
|
||||||
}
|
}
|
||||||
|
|
||||||
Anattrib attr = mAnattribs[offset];
|
Anattrib attr = mAnattribs[offset];
|
||||||
|
@ -256,13 +256,16 @@ namespace SourceGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the closest table that is defined at or before the specified offset.
|
/// Finds the closest table that is defined at or before the specified offset. Will
|
||||||
|
/// attempt to only return un-hidden tables, but will return a hidden table if no
|
||||||
|
/// others are available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset">Target offset.</param>
|
/// <param name="offset">Target offset.</param>
|
||||||
/// <returns>The table's definition offset, or -1 if no tables were defined before this
|
/// <returns>The table's definition offset, or -1 if no tables were defined before this
|
||||||
/// point.</returns>
|
/// point.</returns>
|
||||||
public int GetNearestTableOffset(int offset) {
|
public int GetNearestTableOffset(int offset) {
|
||||||
int nearest = -1;
|
int nearest = -1;
|
||||||
|
int nearestUnhidden = -1;
|
||||||
|
|
||||||
// Could do a smarter search, but I'm expecting the set to be small.
|
// Could do a smarter search, but I'm expecting the set to be small.
|
||||||
foreach (KeyValuePair<int, LocalVariableTable> kvp in mLvTables) {
|
foreach (KeyValuePair<int, LocalVariableTable> kvp in mLvTables) {
|
||||||
@ -270,8 +273,15 @@ namespace SourceGen {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nearest = kvp.Key;
|
nearest = kvp.Key;
|
||||||
|
if (mProject.GetAnattrib(nearest).IsStart) {
|
||||||
|
nearestUnhidden = nearest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nearestUnhidden >= 0) {
|
||||||
|
return nearestUnhidden;
|
||||||
|
} else {
|
||||||
|
return nearest;
|
||||||
}
|
}
|
||||||
return nearest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -380,5 +390,9 @@ namespace SourceGen {
|
|||||||
} while (mSymbolTable.TryGetNonVariableValue(testLabel, out Symbol unused));
|
} while (mSymbolTable.TryGetNonVariableValue(testLabel, out Symbol unused));
|
||||||
return testLabel;
|
return testLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsTableHidden(int offset, DisasmProject project) {
|
||||||
|
return !project.GetAnattrib(offset).IsStart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1778,14 +1778,10 @@ namespace SourceGen {
|
|||||||
public void EditLocalVariableTable() {
|
public void EditLocalVariableTable() {
|
||||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||||
int offset = CodeLineList[selIndex].FileOffset;
|
int offset = CodeLineList[selIndex].FileOffset;
|
||||||
// Find the offset of the nearest table that's earlier in the file.
|
|
||||||
int bestOffset = -1;
|
LocalVariableLookup lvLookup = new LocalVariableLookup(mProject.LvTables,
|
||||||
foreach (KeyValuePair<int,LocalVariableTable> kvp in mProject.LvTables) {
|
mProject, false);
|
||||||
if (kvp.Key > offset) {
|
int bestOffset = lvLookup.GetNearestTableOffset(offset);
|
||||||
break; // too far
|
|
||||||
}
|
|
||||||
bestOffset = kvp.Key;
|
|
||||||
}
|
|
||||||
Debug.Assert(bestOffset >= 0);
|
Debug.Assert(bestOffset >= 0);
|
||||||
CreateOrEditLocalVariableTable(bestOffset);
|
CreateOrEditLocalVariableTable(bestOffset);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ namespace SourceGen {
|
|||||||
public enum MessageType {
|
public enum MessageType {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
HiddenLabel,
|
HiddenLabel,
|
||||||
|
HiddenLocalVariableTable,
|
||||||
UnresolvedWeakRef,
|
UnresolvedWeakRef,
|
||||||
InvalidOffsetOrLength,
|
InvalidOffsetOrLength,
|
||||||
InvalidDescriptor,
|
InvalidDescriptor,
|
||||||
@ -61,6 +62,7 @@ namespace SourceGen {
|
|||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
None,
|
None,
|
||||||
LabelIgnored,
|
LabelIgnored,
|
||||||
|
LocalVariableTableIgnored,
|
||||||
FormatDescriptorIgnored,
|
FormatDescriptorIgnored,
|
||||||
}
|
}
|
||||||
public ProblemResolution Resolution { get; private set; }
|
public ProblemResolution Resolution { get; private set; }
|
||||||
@ -149,6 +151,9 @@ namespace SourceGen {
|
|||||||
case MessageEntry.MessageType.HiddenLabel:
|
case MessageEntry.MessageType.HiddenLabel:
|
||||||
problem = Res.Strings.MSG_HIDDEN_LABEL;
|
problem = Res.Strings.MSG_HIDDEN_LABEL;
|
||||||
break;
|
break;
|
||||||
|
case MessageEntry.MessageType.HiddenLocalVariableTable:
|
||||||
|
problem = Res.Strings.MSG_HIDDEN_LOCAL_VARIABLE_TABLE;
|
||||||
|
break;
|
||||||
case MessageEntry.MessageType.UnresolvedWeakRef:
|
case MessageEntry.MessageType.UnresolvedWeakRef:
|
||||||
problem = Res.Strings.MSG_UNRESOLVED_WEAK_REF;
|
problem = Res.Strings.MSG_UNRESOLVED_WEAK_REF;
|
||||||
break;
|
break;
|
||||||
@ -173,6 +178,9 @@ namespace SourceGen {
|
|||||||
case MessageEntry.ProblemResolution.LabelIgnored:
|
case MessageEntry.ProblemResolution.LabelIgnored:
|
||||||
resolution = Res.Strings.MSG_LABEL_IGNORED;
|
resolution = Res.Strings.MSG_LABEL_IGNORED;
|
||||||
break;
|
break;
|
||||||
|
case MessageEntry.ProblemResolution.LocalVariableTableIgnored:
|
||||||
|
resolution = Res.Strings.MSG_LOCAL_VARIABLE_TABLE_IGNORED;
|
||||||
|
break;
|
||||||
case MessageEntry.ProblemResolution.FormatDescriptorIgnored:
|
case MessageEntry.ProblemResolution.FormatDescriptorIgnored:
|
||||||
resolution = Res.Strings.MSG_FORMAT_DESCRIPTOR_IGNORED;
|
resolution = Res.Strings.MSG_FORMAT_DESCRIPTOR_IGNORED;
|
||||||
break;
|
break;
|
||||||
|
@ -109,9 +109,11 @@ limitations under the License.
|
|||||||
<system:String x:Key="str_LocalVariableTableEmpty">• Empty variable table</system:String>
|
<system:String x:Key="str_LocalVariableTableEmpty">• Empty variable table</system:String>
|
||||||
<system:String x:Key="str_MsgFormatDescriptorIgnored">Format ignored</system:String>
|
<system:String x:Key="str_MsgFormatDescriptorIgnored">Format ignored</system:String>
|
||||||
<system:String x:Key="str_MsgHiddenLabel">Hidden label</system:String>
|
<system:String x:Key="str_MsgHiddenLabel">Hidden label</system:String>
|
||||||
|
<system:String x:Key="str_MsgHiddenLocalVariableTable">Hidden variable table</system:String>
|
||||||
<system:String x:Key="str_MsgInvalidDescriptor">Invalid format desc</system:String>
|
<system:String x:Key="str_MsgInvalidDescriptor">Invalid format desc</system:String>
|
||||||
<system:String x:Key="str_MsgInvalidOffsetOrLength">Invalid offset or len</system:String>
|
<system:String x:Key="str_MsgInvalidOffsetOrLength">Invalid offset or len</system:String>
|
||||||
<system:String x:Key="str_MsgLabelIgnored">Label ignored</system:String>
|
<system:String x:Key="str_MsgLabelIgnored">Label ignored</system:String>
|
||||||
|
<system:String x:Key="str_MsgLocalVariableTableIgnored">LV table skipped over</system:String>
|
||||||
<system:String x:Key="str_MsgUnresolvedWeakRef">Ref'd symbol not found</system:String>
|
<system:String x:Key="str_MsgUnresolvedWeakRef">Ref'd symbol not found</system:String>
|
||||||
<system:String x:Key="str_NoFilesAvailable">no files available</system:String>
|
<system:String x:Key="str_NoFilesAvailable">no files available</system:String>
|
||||||
<system:String x:Key="str_NoExportedSymbolsFound">No exported symbols found.</system:String>
|
<system:String x:Key="str_NoExportedSymbolsFound">No exported symbols found.</system:String>
|
||||||
|
@ -199,12 +199,16 @@ namespace SourceGen.Res {
|
|||||||
(string)Application.Current.FindResource("str_MsgFormatDescriptorIgnored");
|
(string)Application.Current.FindResource("str_MsgFormatDescriptorIgnored");
|
||||||
public static string MSG_HIDDEN_LABEL =
|
public static string MSG_HIDDEN_LABEL =
|
||||||
(string)Application.Current.FindResource("str_MsgHiddenLabel");
|
(string)Application.Current.FindResource("str_MsgHiddenLabel");
|
||||||
|
public static string MSG_HIDDEN_LOCAL_VARIABLE_TABLE =
|
||||||
|
(string)Application.Current.FindResource("str_MsgHiddenLocalVariableTable");
|
||||||
public static string MSG_INVALID_DESCRIPTOR =
|
public static string MSG_INVALID_DESCRIPTOR =
|
||||||
(string)Application.Current.FindResource("str_MsgInvalidDescriptor");
|
(string)Application.Current.FindResource("str_MsgInvalidDescriptor");
|
||||||
public static string MSG_INVALID_OFFSET_OR_LENGTH =
|
public static string MSG_INVALID_OFFSET_OR_LENGTH =
|
||||||
(string)Application.Current.FindResource("str_MsgInvalidOffsetOrLength");
|
(string)Application.Current.FindResource("str_MsgInvalidOffsetOrLength");
|
||||||
public static string MSG_LABEL_IGNORED =
|
public static string MSG_LABEL_IGNORED =
|
||||||
(string)Application.Current.FindResource("str_MsgLabelIgnored");
|
(string)Application.Current.FindResource("str_MsgLabelIgnored");
|
||||||
|
public static string MSG_LOCAL_VARIABLE_TABLE_IGNORED =
|
||||||
|
(string)Application.Current.FindResource("str_MsgLocalVariableTableIgnored");
|
||||||
public static string MSG_UNRESOLVED_WEAK_REF =
|
public static string MSG_UNRESOLVED_WEAK_REF =
|
||||||
(string)Application.Current.FindResource("str_MsgUnresolvedWeakRef");
|
(string)Application.Current.FindResource("str_MsgUnresolvedWeakRef");
|
||||||
public static string NO_FILES_AVAILABLE =
|
public static string NO_FILES_AVAILABLE =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user