mirror of
https://github.com/trudnai/Steve2.git
synced 2024-06-10 05:29:33 +00:00
BugFix: Disassembly Scrolling & Highlighting
This commit is contained in:
parent
428b1b68c2
commit
55fd25d01a
|
@ -490,6 +490,14 @@
|
||||||
<ContextState
|
<ContextState
|
||||||
contextName = "_addr_zp_X_dbg:mmio.c">
|
contextName = "_addr_zp_X_dbg:mmio.c">
|
||||||
</ContextState>
|
</ContextState>
|
||||||
|
<ContextState
|
||||||
|
contextName = "specialized closure #1 in DebuggerViewController.DisplayDisassembly(scrollY:):DebuggerViewController.swift">
|
||||||
|
<PersistentStrings>
|
||||||
|
<PersistentString
|
||||||
|
value = "highlighted_line_number">
|
||||||
|
</PersistentString>
|
||||||
|
</PersistentStrings>
|
||||||
|
</ContextState>
|
||||||
<ContextState
|
<ContextState
|
||||||
contextName = "read_woz:6502.c">
|
contextName = "read_woz:6502.c">
|
||||||
<PersistentStrings>
|
<PersistentStrings>
|
||||||
|
@ -994,13 +1002,16 @@
|
||||||
contextName = "DebuggerViewController.DisplayDisassembly(scrollY:):DebuggerViewController.swift">
|
contextName = "DebuggerViewController.DisplayDisassembly(scrollY:):DebuggerViewController.swift">
|
||||||
<PersistentStrings>
|
<PersistentStrings>
|
||||||
<PersistentString
|
<PersistentString
|
||||||
value = "scroll_line_number">
|
value = "disassLineRange">
|
||||||
</PersistentString>
|
</PersistentString>
|
||||||
<PersistentString
|
<PersistentString
|
||||||
value = "disass_addr">
|
value = "disass_addr">
|
||||||
</PersistentString>
|
</PersistentString>
|
||||||
<PersistentString
|
<PersistentString
|
||||||
value = "highlighted_line_number">
|
value = "m6502.PC">
|
||||||
|
</PersistentString>
|
||||||
|
<PersistentString
|
||||||
|
value = "line_number">
|
||||||
</PersistentString>
|
</PersistentString>
|
||||||
<PersistentString
|
<PersistentString
|
||||||
value = "Disass_Display.string.utf8CString">
|
value = "Disass_Display.string.utf8CString">
|
||||||
|
@ -1008,6 +1019,12 @@
|
||||||
<PersistentString
|
<PersistentString
|
||||||
value = "Disass_Display">
|
value = "Disass_Display">
|
||||||
</PersistentString>
|
</PersistentString>
|
||||||
|
<PersistentString
|
||||||
|
value = "scroll_line_number">
|
||||||
|
</PersistentString>
|
||||||
|
<PersistentString
|
||||||
|
value = "highlighted_line_number">
|
||||||
|
</PersistentString>
|
||||||
</PersistentStrings>
|
</PersistentStrings>
|
||||||
</ContextState>
|
</ContextState>
|
||||||
<ContextState
|
<ContextState
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
enableASanStackUseAfterReturn = "YES"
|
enableASanStackUseAfterReturn = "YES"
|
||||||
enableUBSanitizer = "YES"
|
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
@ -91,13 +90,6 @@
|
||||||
ReferencedContainer = "container:A2Mac.xcodeproj">
|
ReferencedContainer = "container:A2Mac.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</MacroExpansion>
|
</MacroExpansion>
|
||||||
<AdditionalOptions>
|
|
||||||
<AdditionalOption
|
|
||||||
key = "NSZombieEnabled"
|
|
||||||
value = "YES"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</AdditionalOption>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
|
|
|
@ -391,15 +391,16 @@ N V - B D I Z C
|
||||||
func remove_highlight(view: NSTextView) {
|
func remove_highlight(view: NSTextView) {
|
||||||
if highlighted_line_number > 0 {
|
if highlighted_line_number > 0 {
|
||||||
if let lineRange = getLineRange(disassLineRange, forLine: highlighted_line_number) {
|
if let lineRange = getLineRange(disassLineRange, forLine: highlighted_line_number) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
|
|
||||||
if let layoutManager = view.layoutManager {
|
if let layoutManager = view.layoutManager {
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.03, execute: {
|
||||||
layoutManager.removeTemporaryAttribute(NSAttributedString.Key.backgroundColor, forCharacterRange: lineRange)
|
layoutManager.removeTemporaryAttribute(NSAttributedString.Key.backgroundColor, forCharacterRange: lineRange)
|
||||||
layoutManager.removeTemporaryAttribute(NSAttributedString.Key.foregroundColor, forCharacterRange: lineRange)
|
layoutManager.removeTemporaryAttribute(NSAttributedString.Key.foregroundColor, forCharacterRange: lineRange)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
highlighted_line_number = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func highlight(view: NSTextView, line: Int, attr: [NSAttributedString.Key : Any]) {
|
func highlight(view: NSTextView, line: Int, attr: [NSAttributedString.Key : Any]) {
|
||||||
|
@ -518,11 +519,21 @@ N V - B D I Z C
|
||||||
|
|
||||||
var disassLineRange = [LineRange_t]()
|
var disassLineRange = [LineRange_t]()
|
||||||
|
|
||||||
|
|
||||||
|
func TrunDisassAddressPC(_ on: NSControl.StateValue = .on) {
|
||||||
|
if let disassAddressPC = DisassAddressPC {
|
||||||
|
disassAddressPC.state = on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func DisplayDisassembly( scrollY : CGFloat = -1 ) {
|
func DisplayDisassembly( scrollY : CGFloat = -1 ) {
|
||||||
var disass = "" // String(repeating: "\n", count: 0x1800)
|
var disass = "" // String(repeating: "\n", count: 0x1800)
|
||||||
var loc = 0
|
var loc = 0
|
||||||
|
|
||||||
|
if cpuState == cpuState_running {
|
||||||
remove_highlight(view: Disass_Display)
|
remove_highlight(view: Disass_Display)
|
||||||
|
}
|
||||||
|
|
||||||
line_number = 0
|
line_number = 0
|
||||||
|
|
||||||
|
@ -575,6 +586,14 @@ N V - B D I Z C
|
||||||
addr_line.updateValue(line_number, forKey: m6502.PC)
|
addr_line.updateValue(line_number, forKey: m6502.PC)
|
||||||
|
|
||||||
let isCurrentLine = m6502.PC == m6502_saved.PC
|
let isCurrentLine = m6502.PC == m6502_saved.PC
|
||||||
|
if isCurrentLine {
|
||||||
|
// line = invertLine(line: line)
|
||||||
|
highlighted_line_number = line_number
|
||||||
|
}
|
||||||
|
|
||||||
|
if m6502.PC == disass_addr_pc {
|
||||||
|
scroll_line_number = line_number
|
||||||
|
}
|
||||||
|
|
||||||
m6502_Disass_1_Instr()
|
m6502_Disass_1_Instr()
|
||||||
|
|
||||||
|
@ -585,14 +604,6 @@ N V - B D I Z C
|
||||||
disassLineRange.append(lineRange)
|
disassLineRange.append(lineRange)
|
||||||
loc += len
|
loc += len
|
||||||
|
|
||||||
if isCurrentLine {
|
|
||||||
// line = invertLine(line: line)
|
|
||||||
highlighted_line_number = line_number
|
|
||||||
}
|
|
||||||
if m6502.PC == disass_addr_pc {
|
|
||||||
scroll_line_number = line_number
|
|
||||||
}
|
|
||||||
|
|
||||||
disass += line + "\n"
|
disass += line + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,6 +615,7 @@ N V - B D I Z C
|
||||||
// let isEmpty = self.Disass_Display.string.isEmpty
|
// let isEmpty = self.Disass_Display.string.isEmpty
|
||||||
if need_disass {
|
if need_disass {
|
||||||
self.Disass_Display.string = disass // + String(repeating: "\n", count: 0x8000)
|
self.Disass_Display.string = disass // + String(repeating: "\n", count: 0x8000)
|
||||||
|
self.Disass_Display.scroll(CGPoint.zero)
|
||||||
// self.testTextField(str: "")
|
// self.testTextField(str: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,10 +647,12 @@ N V - B D I Z C
|
||||||
|
|
||||||
|
|
||||||
func UpdateImmediately() {
|
func UpdateImmediately() {
|
||||||
DisplayRegisters()
|
DispatchQueue.main.async {
|
||||||
DisplayStack()
|
self.DisplayRegisters()
|
||||||
DisplayMemory()
|
self.DisplayStack()
|
||||||
DisplayDisassembly()
|
self.DisplayMemory()
|
||||||
|
self.DisplayDisassembly()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -646,10 +660,8 @@ N V - B D I Z C
|
||||||
func Update() {
|
func Update() {
|
||||||
if self.UpdateSemaphore.wait(timeout: .now()) == .success {
|
if self.UpdateSemaphore.wait(timeout: .now()) == .success {
|
||||||
if Disass_Display != nil {
|
if Disass_Display != nil {
|
||||||
DispatchQueue.global().async {
|
|
||||||
self.UpdateImmediately()
|
self.UpdateImmediately()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.UpdateSemaphore.signal()
|
self.UpdateSemaphore.signal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,6 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func Continue() {
|
func Continue() {
|
||||||
PauseButtonUpdate()
|
PauseButtonUpdate()
|
||||||
|
|
||||||
|
@ -190,8 +188,9 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
||||||
m6502_Step_dbg()
|
m6502_Step_dbg()
|
||||||
|
|
||||||
// TODO: This should be in Debugger!
|
// TODO: This should be in Debugger!
|
||||||
if let debugger = DebuggerViewController.shared {
|
if let debuggerViewController = DebuggerViewController.shared {
|
||||||
debugger.Update()
|
debuggerViewController.remove_highlight(view: debuggerViewController.Disass_Display, line: debuggerViewController.highlighted_line_number)
|
||||||
|
debuggerViewController.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Update Screen and speaker etc
|
// TODO: Update Screen and speaker etc
|
||||||
|
|
|
@ -339,7 +339,34 @@ class ViewController: NSViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func debuggerShowWindow() {
|
||||||
|
if let debuggerWindowController = DebuggerWindowController.shared {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
debuggerWindowController.showWindow(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func debuggerRemoveHighlight() {
|
||||||
|
if let debuggerViewController = DebuggerViewController.shared {
|
||||||
|
debuggerViewController.remove_highlight(view: debuggerViewController.Disass_Display, line: debuggerViewController.highlighted_line_number)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func debuggerPauseUpdate() {
|
||||||
|
if let debuggerViewController = DebuggerViewController.shared {
|
||||||
|
debuggerViewController.TrunDisassAddressPC(.on)
|
||||||
|
debuggerViewController.remove_highlight(view: debuggerViewController.Disass_Display, line: debuggerViewController.highlighted_line_number)
|
||||||
|
debuggerViewController.Update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func Resume() {
|
func Resume() {
|
||||||
|
debuggerRemoveHighlight()
|
||||||
|
|
||||||
#if SCHEDULER_CVDISPLAYLINK
|
#if SCHEDULER_CVDISPLAYLINK
|
||||||
CVDisplayLinkStart(displayLink!)
|
CVDisplayLinkStart(displayLink!)
|
||||||
#else
|
#else
|
||||||
|
@ -370,6 +397,8 @@ class ViewController: NSViewController {
|
||||||
if let debugger = DebuggerWindowController.shared {
|
if let debugger = DebuggerWindowController.shared {
|
||||||
debugger.PauseButtonUpdate()
|
debugger.PauseButtonUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debuggerPauseUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1265,20 +1294,12 @@ class ViewController: NSViewController {
|
||||||
|
|
||||||
func debugBreak() {
|
func debugBreak() {
|
||||||
Pause()
|
Pause()
|
||||||
|
|
||||||
// TODO: This should be in Debugger!
|
|
||||||
if let debugger = DebuggerViewController.shared {
|
|
||||||
debugger.Update()
|
|
||||||
}
|
|
||||||
if let debugger = DebuggerWindowController.shared {
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
debugger.showWindow(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spkr_play_disk_motor_time = 0
|
spkr_play_disk_motor_time = 0
|
||||||
spkr_stopAll()
|
spkr_stopAll()
|
||||||
|
|
||||||
|
// TODO: This should be in Debugger!
|
||||||
|
debuggerPauseUpdate()
|
||||||
|
debuggerShowWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user