1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Add Apply Platform Symbols experimental feature

This turns platform symbols into address labels.  Useful for things
like system ROM images that have an established set of entry points.
This commit is contained in:
Andy McFadden 2019-11-19 13:31:04 -08:00
parent 97a5623599
commit ff68409398
4 changed files with 71 additions and 9 deletions

View File

@ -3952,6 +3952,49 @@ namespace SourceGen {
showTextDlg.ShowDialog();
}
public void Debug_ApplyPlatformSymbols() {
ChangeSet cs = new ChangeSet(1);
foreach (Symbol sym in mProject.SymbolTable) {
if (sym.SymbolSource != Symbol.Source.Platform) {
continue;
}
DefSymbol defSym = (DefSymbol)sym;
if (defSym.MultiMask != null) {
// These would require additional work... probably.
continue;
}
int offset = mProject.AddrMap.AddressToOffset(0, sym.Value);
if (offset < 0) {
continue;
}
// Make sure this is the start of an instruction or data item. (If you
// haven't finished hinting code, it's best to disable the string/fill finder.)
Anattrib attr = mProject.GetAnattrib(offset);
if (!attr.IsStart) {
Debug.WriteLine("Found match at non-start +" + offset.ToString("x6") +
": " + defSym);
continue;
}
// Check for user label. Okay to overwrite auto label.
if (mProject.UserLabels.ContainsKey(offset)) {
Debug.WriteLine("User label already exists at +" + offset.ToString("x6"));
continue;
}
// Create a new user label symbol.
Symbol newSym = new Symbol(sym.Label, sym.Value, Symbol.Source.User,
Symbol.Type.GlobalAddr, Symbol.LabelAnnotation.None);
UndoableChange uc = UndoableChange.CreateLabelChange(offset, null, newSym);
cs.Add(uc);
}
ApplyUndoableChanges(cs);
}
#endregion Debug features
}
}

View File

@ -306,10 +306,10 @@ not help you debug 6502 projects.</p>
<ul>
<li>Re-analyze (F5). Causes a full re-analysis. Useful if you think
the display is out of sync.</li>
<li>Show Problem List Viewer. Opens a floating window that shows some
of the problems encountered during the last analysis pass.</li>
<li>Show Undo/Redo History. Opens a floating window that lets you
watch the contents of the undo buffer while you work.</li>
<li>Source Generation Tests. Opens the regression test harness. See
<code>README.md</code> in the SGTestData directory for more information.
If the regression tests weren't included in the SourceGen distribution,
this will have nothing to do.</li>
<li>Show Analyzer Output. Opens a floating window with a text log from
the most recent analysis pass. The exact contents will vary depending
on how the verbosity level is configured internally. Debug messages
@ -318,9 +318,11 @@ not help you debug 6502 projects.</p>
timer results from the most recent analysis pass. Times for individual
stages are noted, as are times for groups of functions. This
provides a crude sense of where time is being spent.</li>
<li>Show Undo/Redo History. Opens a floating window that lets you
watch the contents of the undo buffer while you work.</li>
<li>Extension Script Info. Shows a bit about the currently-loaded
extension scripts.</li>
<li>Toggle Comment Rulers. Adds a string of digits above every
<li>Show Comment Rulers. Adds a string of digits above every
multi-line comment (long comment, note). Useful for confirming that
the width limitation is being obeyed. These are added exactly
as shown, without comment delimiters, into generated assembly output,
@ -329,10 +331,18 @@ not help you debug 6502 projects.</p>
script sandbox every 60 seconds. This seems to be required to avoid
an infrequently-encountered Windows bug. (See code for notes and
stackoverflow.com links.)</li>
<li>Source Generation Tests. Opens the regression test harness. See
the README.md in the SGTestData directory for more information. If
the regression tests weren't included in the SourceGen distribution,
this will have nothing to do.</li>
<li>Applesoft to HTML. An experimental feature that formats an
Applesoft program as HTML.</li>
<li>Apply Platform Symbols. An experimental feature for turning platform
symbols into address labels. This will run through the list of all
symbols loaded from .sym65 files and find addresses that fall within
the bounds of the file. If it finds an address that is the start
of a code/data line and doesn't already have a user-supplied label,
the platform symbol's label will be applied. Useful for
disassembling ROM images or other code with an established set of
public entry points.
(Tip: disable "analyze uncategorized data" from the project
properties editor first.)</li>
</ul>

View File

@ -176,6 +176,7 @@ limitations under the License.
</RoutedUICommand>
<RoutedUICommand x:Key="Debug_ApplesoftToHtmlCmd" Text="Applesoft to HTML..."/>
<RoutedUICommand x:Key="Debug_ApplyPlatformSymbolsCmd" Text="Apply Platform Symbols"/>
<RoutedUICommand x:Key="Debug_ExtensionScriptInfoCmd" Text="Extension Script Info..."/>
<RoutedUICommand x:Key="Debug_ShowAnalysisTimersCmd" Text="Show Analysis Timers"/>
<RoutedUICommand x:Key="Debug_ShowAnalyzerOutputCmd" Text="Show Analyzer Output"/>
@ -296,6 +297,8 @@ limitations under the License.
CanExecute="IsProjectOpen" Executed="Debug_RefreshCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ApplesoftToHtmlCmd}"
Executed="Debug_ApplesoftToHtmlCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ApplyPlatformSymbolsCmd}"
CanExecute="IsProjectOpen" Executed="Debug_ApplyPlatformSymbolsCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ExtensionScriptInfoCmd}"
CanExecute="IsProjectOpen" Executed="Debug_ExtensionScriptInfoCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ShowAnalysisTimersCmd}"
@ -408,6 +411,7 @@ limitations under the License.
Command="{StaticResource Debug_ToggleKeepAliveHackCmd}" IsCheckable="True"/>
<Separator/>
<MenuItem Command="{StaticResource Debug_ApplesoftToHtmlCmd}"/>
<MenuItem Command="{StaticResource Debug_ApplyPlatformSymbolsCmd}"/>
</MenuItem>
</Menu>

View File

@ -1333,6 +1333,11 @@ namespace SourceGen.WpfGui {
mMainCtrl.Debug_ApplesoftToHtml();
}
private void Debug_ApplyPlatformSymbolsCmd_Executed(object sender,
ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_ApplyPlatformSymbols();
}
private void Debug_ExtensionScriptInfoCmd_Executed(object sender,
ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_ExtensionScriptInfo();