@@ -32,6 +32,9 @@ if CLIENT or TESTING then
32
32
CPULib .Debugger .Labels = {}
33
33
CPULib .Debugger .PositionByPointer = {}
34
34
CPULib .Debugger .PointersByLine = {}
35
+ CPULib .Debugger .PreferredTracker = " IP"
36
+ CPULib .Debugger .PreferredTrackerFriendlyName = " IP"
37
+ CPULib .Debugger .FollowTracker = true
35
38
36
39
CPULib .Debugger .Breakpoint = {}
37
40
@@ -82,7 +85,7 @@ if CLIENT or TESTING then
82
85
83
86
---- --------------------------------------------------------------------------
84
87
-- Make sure the file is opened in the tab
85
- function CPULib .SelectTab (editor ,fileName )
88
+ function CPULib .SelectTab (editor ,fileName , dontForceChange )
86
89
if not editor then return end
87
90
local editorType = string.lower (editor .EditorType )
88
91
local fullFileName = editorType .. " chip\\ " .. fileName
@@ -91,6 +94,7 @@ if CLIENT or TESTING then
91
94
fullFileName = fileName
92
95
end
93
96
97
+ local currentTab = editor :GetActiveTabIndex ()
94
98
local sourceTab
95
99
for tab = 1 ,editor :GetNumTabs () do
96
100
if editor :GetEditor (tab ).chosenfile == fullFileName then
@@ -101,8 +105,13 @@ if CLIENT or TESTING then
101
105
if not sourceTab then
102
106
editor :LoadFile (fullFileName ,true )
103
107
sourceTab = editor :GetActiveTabIndex ()
108
+ if dontForceChange then
109
+ editor :SetActiveTab (currentTab )
110
+ end
104
111
else
105
- editor :SetActiveTab (sourceTab )
112
+ if not dontForceChange then
113
+ editor :SetActiveTab (sourceTab )
114
+ end
106
115
end
107
116
108
117
return editor :GetEditor (sourceTab ),sourceTab
@@ -290,7 +299,17 @@ if CLIENT or TESTING then
290
299
else
291
300
table.insert (result ," IP = " .. (CPULib .Debugger .Variables .IP or " #####" ))
292
301
end
293
-
302
+ if CPULib .Debugger .Variables .IP == INVALID_BREAKPOINT_IP then
303
+ table.insert (result ," CS:IP = #####" )
304
+ else
305
+ table.insert (result ," CS:IP = " .. ((CPULib .Debugger .Variables .CSIP ) or " #####" ))
306
+ end
307
+ if CPULib .Debugger .Variables .IP == INVALID_BREAKPOINT_IP then
308
+ table.insert (result ," PHYS IP = #####" )
309
+ else
310
+ table.insert (result ," PHYS IP = " .. (CPULib .Debugger .Variables .PHYSIP or " #####" ))
311
+ end
312
+ table.insert (result ," Following " .. CPULib .Debugger .PreferredTrackerFriendlyName )
294
313
if CPULib .InterruptText then
295
314
table.insert (result ," " )
296
315
table.insert (result ,CPULib .InterruptText )
@@ -308,7 +327,7 @@ if CLIENT or TESTING then
308
327
CPULib .Debugger .Breakpoint = {}
309
328
CPULib .Debugger .Variables = {}
310
329
CPULib .Debugger .FirstFile = nil
311
- CPULib .DebugUpdateHighlights ()
330
+ CPULib .DebugUpdateHighlights (not CPULib . Debugger . FollowTracker )
312
331
end
313
332
314
333
net .Receive (" CPULib.InvalidateDebugger" , function (netlen )
@@ -352,15 +371,15 @@ if CLIENT or TESTING then
352
371
function CPULib .DebugUpdateHighlights (dontForcePosition )
353
372
if ZCPU_Editor then
354
373
-- Highlight current position
355
- local currentPosition = CPULib .Debugger .PositionByPointer [CPULib .Debugger .Variables . IP ]
374
+ local currentPosition = CPULib .Debugger .PositionByPointer [CPULib .Debugger .Variables [ CPULib . Debugger . PreferredTracker or " IP " ] ]
356
375
357
376
if currentPosition then
358
377
-- Clear all highlighted lines
359
378
for tab = 1 ,ZCPU_Editor :GetNumTabs () do
360
379
ZCPU_Editor :GetEditor (tab ):ClearHighlightedLines ()
361
380
end
362
-
363
- local textEditor = CPULib .SelectTab (ZCPU_Editor ,currentPosition .File )
381
+
382
+ local textEditor = CPULib .SelectTab (ZCPU_Editor ,currentPosition .File , not CPULib . Debugger . FollowTracker )
364
383
if textEditor then
365
384
textEditor :HighlightLine (currentPosition .Line ,130 ,0 ,0 ,255 )
366
385
if not dontForcePosition then
@@ -397,21 +416,24 @@ if CLIENT or TESTING then
397
416
---- --------------------------------------------------------------------------
398
417
-- Debug data arrived from server
399
418
function CPULib .OnDebugData_Registers (um )
400
- CPULib .Debugger .Variables .IP = um :ReadFloat ()
401
- CPULib .Debugger .Variables .EAX = um :ReadFloat ()
402
- CPULib .Debugger .Variables .EBX = um :ReadFloat ()
403
- CPULib .Debugger .Variables .ECX = um :ReadFloat ()
404
- CPULib .Debugger .Variables .EDX = um :ReadFloat ()
405
- CPULib .Debugger .Variables .ESI = um :ReadFloat ()
406
- CPULib .Debugger .Variables .EDI = um :ReadFloat ()
407
- CPULib .Debugger .Variables .EBP = um :ReadFloat ()
408
- CPULib .Debugger .Variables .ESP = um :ReadFloat ()
409
-
419
+ CPULib .Debugger .Variables .CS = um :ReadFloat ()
420
+ CPULib .Debugger .Variables .IP = um :ReadFloat ()
421
+ CPULib .Debugger .Variables .PHYSPAGE = um :ReadFloat ()
422
+ CPULib .Debugger .Variables .EAX = um :ReadFloat ()
423
+ CPULib .Debugger .Variables .EBX = um :ReadFloat ()
424
+ CPULib .Debugger .Variables .ECX = um :ReadFloat ()
425
+ CPULib .Debugger .Variables .EDX = um :ReadFloat ()
426
+ CPULib .Debugger .Variables .ESI = um :ReadFloat ()
427
+ CPULib .Debugger .Variables .EDI = um :ReadFloat ()
428
+ CPULib .Debugger .Variables .EBP = um :ReadFloat ()
429
+ CPULib .Debugger .Variables .ESP = um :ReadFloat ()
430
+ CPULib .Debugger .Variables .CSIP = CPULib .Debugger .Variables .CS + CPULib .Debugger .Variables .IP
431
+ CPULib .Debugger .Variables .PHYSIP = CPULib .Debugger .Variables .PHYSPAGE * 128 + CPULib .Debugger .Variables .CSIP % 128
410
432
for reg = 0 ,31 do
411
433
CPULib .Debugger .Variables [" R" .. reg ] = um :ReadFloat ()
412
434
end
413
435
414
- CPULib .DebugUpdateHighlights ()
436
+ CPULib .DebugUpdateHighlights (not CPULib . Debugger . FollowTracker )
415
437
end
416
438
usermessage .Hook (" cpulib_debugdata_registers" , CPULib .OnDebugData_Registers )
417
439
@@ -617,7 +639,13 @@ if SERVER then
617
639
618
640
if not onlyMemPointers then
619
641
umsg .Start (" cpulib_debugdata_registers" , umsgrp )
642
+ umsg .Float (VM .CS )
620
643
umsg .Float (VM .IP )
644
+ if (VM .CurrentPage .Remapped == 1 ) then
645
+ umsg .Float (VM .CurrentPage .MappedIndex )
646
+ else
647
+ umsg .Float (math.floor ((VM .CS + VM .IP )/ 128 ))
648
+ end
621
649
umsg .Float (VM .EAX )
622
650
umsg .Float (VM .EBX )
623
651
umsg .Float (VM .ECX )
0 commit comments