-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdebcmd.c
2991 lines (2509 loc) · 88.3 KB
/
debcmd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
*
* Copyright (c) 1997, 1998 Timpanogas Research Group, Inc. All Rights
* Reserved.
*
* AUTHOR : Jeff V. Merkey
* FILE : DEBCMD.C
* DESCRIP : Multi-Processing Debugger Command Library for MANOS v1.0
* DATE : August 6, 1998
*
*
***************************************************************************/
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "string.h"
#include "kernel.h"
#include "keyboard.h"
#include "screen.h"
#include "types.h"
#include "emit.h"
#include "os.h"
#include "dos.h"
#include "tss.h"
#include "mps.h"
#include "hal.h"
#include "xcall.h"
#include "window.h"
#include "line.h"
#include "loader.h"
#include "menu.h"
#include "rlock.h"
#include "event.h"
#include "debug.h"
#include "dparse.h"
#include "bus.h"
#include "debcmd.h"
LONG debug_deref = 0;
LONG full_deref_toggle = 0;
LONG general_toggle = TRUE;
LONG line_info_toggle = TRUE;
LONG control_toggle = 0;
LONG segment_toggle = 0;
LONG numeric_toggle = 0;
LONG reason_toggle = TRUE;
LONG enterKeyACC(SCREEN *screen, LONG key, void *stackFrame,
ACCELERATOR *accel)
{
BYTE verbBuffer[100];
register BYTE *verb, *pp, *vp;
register LONG i, count;
extern LONG repeatCommand;
extern BYTE lastCommand;
extern BYTE lastDebugCommand[];
extern BYTE debugCommand[];
if (screen) {};
if (key) {};
if (stackFrame) {};
if (accel) {};
if (!debugCommand[0])
{
count = 0;
pp = lastDebugCommand;
vp = verb = &verbBuffer[0];
while (*pp && *pp == ' ' && count++ < 80)
pp++;
while (*pp && *pp != ' ' && count++ < 80)
*vp++ = *pp++;
*vp = '\0';
while (*pp && *pp == ' ' && count++ < 80)
pp++;
if (!strcmp(strupr(verb), "P") || lastCommand == F8)
strcpy(debugCommand, "P");
else
if (!strcmp(strupr(verb), "T") || lastCommand == F7)
strcpy(debugCommand, "T");
else
if (!strcmp(strupr(verb), "W") || !strcmp(strupr(verb), "D") ||
!strcmp(strupr(verb), "DB")|| !strcmp(strupr(verb), "DW") ||
!strcmp(strupr(verb), "DD")|| !strcmp(strupr(verb), "DDS")||
!strcmp(strupr(verb), "DS")|| !strcmp(strupr(verb), "DL") ||
!strcmp(strupr(verb), "U") || !strcmp(strupr(verb), "UU"))
{
strcpy(debugCommand, verb);
repeatCommand = TRUE;
}
}
return 0;
}
LONG activateRegisterDisplayACC(SCREEN *screen, LONG key, void *stackFrame,
ACCELERATOR *accel)
{
extern LONG registerDisplayActive;
extern LONG lastCR0;
extern LONG lastCR2;
extern LONG lastCR4;
extern StackFrame lastStackFrame;
if (screen) {};
if (key) {};
if (stackFrame) {};
if (accel) {};
if (registerDisplayActive)
{
close_window(0);
registerDisplayActive = 0;
}
else
{
registerDisplayActive = TRUE;
lastCR0 = ReadCR0();
lastCR2 = ReadCR2();
lastCR4 = ReadCR4();
CopyData((LONG *)stackFrame, (LONG *)&lastStackFrame,
sizeof(StackFrame));
activate_window(0);
WindowRegisterFrame(0, stackFrame);
}
printfScreen(screen, "\r");
return TRUE;
}
LONG displayDebuggerHelpHelp(SCREEN *screen, BYTE *commandLine, DEBUGGER_PARSER *parser)
{
if (screen) {}
if (commandLine) {}
if (parser) {}
printfScreenWithAttribute(screen, LTCYAN, "displays general help for all commands, or help for a specific command\n");
printfScreenWithAttribute(screen, LTCYAN, "HELP <enter> - list all commands\n");
printfScreenWithAttribute(screen, LTCYAN, "HELP command <enter> - help for a specific command\n");
return TRUE;
}
LONG displayDebuggerHelp(SCREEN *screen, BYTE *commandLine,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
register LONG count;
BYTE verbBuffer[100];
register BYTE *verb, *pp, *vp;
if (stackFrame) {};
if (Exception) {};
commandLine = &commandLine[parser->debugCommandNameLength];
while (*commandLine && *commandLine == ' ') commandLine++;
count = 0;
pp = commandLine;
vp = verb = &verbBuffer[0];
while (*pp && *pp == ' ' && count++ < 80)
pp++;
while (*pp && *pp != ' ' && count++ < 80)
*vp++ = *pp++;
*vp = '\0';
while (*pp && *pp == ' ' && count++ < 80)
pp++;
DebuggerParserHelpRoutine(screen, verb, commandLine);
return TRUE;
}
void DisplayLoaderMap(SCREEN *debugScreen)
{
printfScreenWithAttribute(debugScreen, LTCYAN, "Loader Code Segment : %08X Loader Code Length : %d bytes\n",
LoaderCodeSegment, DosDataTable->CODE_VIRT_SIZE);
printfScreenWithAttribute(debugScreen, LTCYAN, "Loader Data Segment : %08X Loader Data Length : %d bytes\n",
LoaderDataSegment, DosDataTable->DATA_VIRT_SIZE);
printfScreenWithAttribute(debugScreen, LTCYAN, "Loader Code End (V) : %08X Loader Data End (V) : %08X\n",
LoaderCodeSegment + DosDataTable->CODE_VIRT_SIZE,
LoaderDataSegment + DosDataTable->DATA_VIRT_SIZE);
printfScreenWithAttribute(debugScreen, LTCYAN, "Reloc Table Start : %08X Debug Table Start : %08X\n",
DosDataTable->RELOC_OFFSET, DosDataTable->DEBUG_TABLE);
printfScreenWithAttribute(debugScreen, LTCYAN, "Reloc Table End : %08X Debug Table End : %08X\n",
DosDataTable->RELOC_OFFSET + DosDataTable->RELOC_SIZE,
DosDataTable->DEBUG_TABLE + DosDataTable->DEBUG_SIZE);
printfScreenWithAttribute(debugScreen, LTCYAN, "High Memory Start : %08X High Memory Length : %d bytes\n",
StartOfHighMemory,
HighMemoryLength);
printfScreenWithAttribute(debugScreen, LTCYAN, "Low Memory Start : %08X Low Memory Length : %d bytes\n",
StartOfLowMemory,
LowMemoryLength);
printfScreenWithAttribute(debugScreen, LTCYAN, "OS Code Segment : %08X OS Data Segment : %08X\n",
CodeSegment,
DataSegment);
printfScreenWithAttribute(debugScreen, LTCYAN, "OS Debug Segment : %08X OS Debug Size : %08X\n",
DebugSegment,
DebugSize);
printfScreenWithAttribute(debugScreen, LTCYAN, "Startup Segment : %08X Startup Length : %08X\n",
StartupMemory,
StartupLength);
}
void DisplayDOSTable(SCREEN *debugScreen, DOS_TABLE *dos)
{
register int i, j;
SetPauseMode(debugScreen, debugScreen->nLines - 3);
printfScreenWithAttribute(debugScreen, BRITEWHITE, "MS-DOS System Data Table\n");
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS TABLE: :: %8X\n", dos->DOS_TABLE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"GDT TABLE :: %8X\n", dos->GDT_TABLE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"GDT POINTER :: %8X\n", dos->GDT_POINTER);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS IDT TABLE :: %8X\n", dos->DOS_IDT_TABLE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS CriticalError :: %4X:%04X\n", dos->DOS_CE_SEGMENT, dos->DOS_CE_OFFSET);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS ControlC :: %4X:%04X\n", dos->DOS_CC_SEGMENT, dos->DOS_CC_OFFSET);
printfScreenWithAttribute(debugScreen, LTGREEN, "\nDOS Segments\n");
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS DS: :: %8X\n", dos->DOS_DATA_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS SS: :: %8X\n", dos->DOS_STACK_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS ES: :: %8X\n", dos->DOS_EXTRA_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS FS: :: %8X\n", dos->DOS_FS_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS SP :: %8X\n", dos->DOS_STACK_OFFSET);
printfScreenWithAttribute(debugScreen, LTGREEN,
"SYSTEM BUS TYPE :: %8X ", dos->DOS_SYSTEM_BUS_TYPE);
printfScreenWithAttribute(debugScreen, LTGREEN, "(");
if (dos->DOS_SYSTEM_BUS_TYPE & ISA)
printfScreenWithAttribute(debugScreen, LTGREEN, " ISA ");
if (dos->DOS_SYSTEM_BUS_TYPE & MCA)
printfScreenWithAttribute(debugScreen, LTGREEN, " MCA ");
if (dos->DOS_SYSTEM_BUS_TYPE & PS2)
printfScreenWithAttribute(debugScreen, LTGREEN, " PS2 ");
if (dos->DOS_SYSTEM_BUS_TYPE & EISA)
printfScreenWithAttribute(debugScreen, LTGREEN, " EISA ");
if (dos->DOS_SYSTEM_BUS_TYPE & PCI)
printfScreenWithAttribute(debugScreen, LTGREEN, " PCI ");
if (dos->DOS_SYSTEM_BUS_TYPE & PCMCIA)
printfScreenWithAttribute(debugScreen, LTGREEN, " PCMCIA ");
printfScreenWithAttribute(debugScreen, LTGREEN, ")\n");
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS CR0 VALUE :: %8X\n", dos->DOS_CR0);
printfScreenWithAttribute(debugScreen, LTGREEN,
"REAL MODE INT :: %8X\n", dos->REAL_MODE_INT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS EXIT :: %8X\n", dos->DOS_EXIT);
printfScreenWithAttribute(debugScreen, LTGREEN, "CPU VENDOR ID :: ");
for (i=0; i < 12; i++)
printfScreenWithAttribute(debugScreen, LTGREEN, "%c", dos->VENDOR_ID[i]);
printfScreen(debugScreen, "\n");
printfScreenWithAttribute(debugScreen, LTGREEN,
"CPU TYPE :: %8X\n", dos->CPU_TYPE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CPU MODEL :: %8X\n", dos->CPU_MODEL);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CPU STEPPING :: %8X\n", dos->STEPPING);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CPU ID_FLAG :: %8X\n", dos->ID_FLAG);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CPU FEATURES :: %8X\n", dos->FEATURE_FLAGS);
printfScreenWithAttribute(debugScreen, LTGREEN,
"XMS ENTRY POINT :: %8X\n", dos->XMS_FUNCTION);
printfScreenWithAttribute(debugScreen, LTGREEN,
"XMS START ADDRESS :: %8X\n", dos->XMS_MEMORY);
printfScreenWithAttribute(debugScreen, LTGREEN,
"XMS BLOCK SIZE :: %8X (%d)\n", dos->XMS_SIZE, dos->XMS_SIZE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"XMS HANDLE :: %8X\n", dos->XMS_HANDLE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"XMS BASE ADDRESS :: %8X\n", dos->XMS_BASE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"TOTAL HIGH MEMORY :: %8X (%d)\n", dos->MEMORY_HIGH, dos->MEMORY_HIGH);
printfScreenWithAttribute(debugScreen, LTGREEN,
"MEMORY HIGH START :: %8X\n", dos->MEMORY_HIGH_START);
printfScreenWithAttribute(debugScreen, LTGREEN,
"TOTAL LOW MEMORY :: %8X (%d)\n", dos->MEMORY_LOW, dos->MEMORY_LOW);
printfScreenWithAttribute(debugScreen, LTGREEN,
"MEMORY LOW START :: %8X\n", dos->MEMORY_LOW_START);
printfScreenWithAttribute(debugScreen, LTGREEN,
"EXTENDED MEM LEN :: %8X (%d)\n", dos->EXTENDED_MEMORY_LEN, dos->EXTENDED_MEMORY_LEN);
printfScreenWithAttribute(debugScreen, LTGREEN,
"EXTENDED MEM ADDR :: %8X\n", dos->EXTENDED_MEMORY_ADDR);
printfScreenWithAttribute(debugScreen, LTGREEN,
"FP STATUS :: %8X\n", dos->FP_STATUS);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DOS DEFAULT DRIVE :: %8X\n", dos->DOS_DEFAULT_DRIVE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"MASK PIC1 (21h) :: %8X\n", dos->MASK_8259_A);
printfScreenWithAttribute(debugScreen, LTGREEN,
"MASK PIC2 (A1h) :: %8X\n", dos->MASK_8259_B);
printfScreenWithAttribute(debugScreen, LTGREEN,
"FPU TYPE :: %8X\n", dos->FPU_TYPE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"INTEL PROC :: %8X\n", dos->INTEL_PROC);
printfScreenWithAttribute(debugScreen, LTGREEN,
"RESERVED :: %8X\n", dos->RESERVED);
printfScreenWithAttribute(debugScreen, LTGREEN,
"LINE 20 ON :: %8X\n", dos->LINE_20_ON);
printfScreenWithAttribute(debugScreen, LTGREEN,
"LINE 20 OFF :: %8X\n", dos->LINE_20_OFF);
printfScreenWithAttribute(debugScreen, LTGREEN,
"PM STACK :: %8X\n", dos->PM_STACK);
printfScreenWithAttribute(debugScreen, LTGREEN,
"PM CODE SEGMENT :: %8X\n", dos->PM_CODE_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"PM DATA SEGMENT :: %8X\n", dos->PM_DATA_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"JUMP16 SEGMENT :: %8X\n", dos->JUMP16_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CREATE FILE :: %8X\n", dos->MSDOS_CREATE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"OPEN FILE :: %8X\n", dos->MSDOS_OPEN);
printfScreenWithAttribute(debugScreen, LTGREEN,
"LSEEK FILE :: %8X\n", dos->MSDOS_LSEEK);
printfScreenWithAttribute(debugScreen, LTGREEN,
"READ FILE :: %8X\n", dos->MSDOS_READ);
printfScreenWithAttribute(debugScreen, LTGREEN,
"WRITE FILE :: %8X\n", dos->MSDOS_WRITE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CLOSE FILE :: %8X\n", dos->MSDOS_CLOSE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DELETE FILE :: %8X\n", dos->MSDOS_UNLINK);
printfScreenWithAttribute(debugScreen, LTGREEN,
"PE HEADER ADDR :: %8X\n", dos->PE_HEADER_ADDR);
printfScreenWithAttribute(debugScreen, LTGREEN,
"RELOC OFFSET :: %8X\n", dos->RELOC_OFFSET);
printfScreenWithAttribute(debugScreen, LTGREEN,
"RELOC32 OFFSET :: %8X\n", dos->RELOC32_OFFSET);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CODE RVA :: %8X\n", dos->CODE_RVA);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DATA RVA :: %8X\n", dos->DATA_RVA);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CODE SIZE :: %8X\n", dos->CODE_SIZE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DATA SIZE :: %8X\n", dos->DATA_SIZE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"VIDEO ADDRESS :: %8X\n", dos->VIDEO_ADDRESS);
printfScreenWithAttribute(debugScreen, LTGREEN,
"VIDEO CURSOR MODE :: %8X\n", dos->VIDEO_CURSOR_MODE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"VIDEO PORT ADDRESS :: %8X\n", dos->VIDEO_PORT_ADDRESS);
printfScreenWithAttribute(debugScreen, LTGREEN,
"SCREEN TYPE :: %8X\n", dos->VIDEO_SCREEN_TYPE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"COLOR FLAG :: %8X\n", dos->VIDEO_COLOR_FLAG);
printfScreenWithAttribute(debugScreen, LTGREEN,
"START_CODE_16 :: %8X\n", dos->START_CODE_16);
printfScreenWithAttribute(debugScreen, LTGREEN,
"END_CODE_16 :: %8X\n", dos->END_CODE_16);
printfScreenWithAttribute(debugScreen, LTGREEN,
"CODE_16_ENTRY :: %8X\n", dos->CODE_16_ENTRY);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DEBUG_TABLE :: %8X\n", dos->DEBUG_TABLE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DEBUG_SIZE :: %8X\n", dos->DEBUG_SIZE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"STARTUP_SEGMENT :: %8X\n", dos->STARTUP_SEGMENT);
printfScreenWithAttribute(debugScreen, LTGREEN,
"STARTUP_CODE :: %8X\n", dos->STARTUP_CODE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"STARTUP_JUMP :: %8X\n", dos->STARTUP_JUMP);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DEFAULT_DIRECTORY :: %8X\n", dos->CURRENT_DIRECTORY);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DISPLAY CODE :: %8X\n", dos->DISPLAY_CODE);
printfScreenWithAttribute(debugScreen, LTGREEN,
"DISPLAY STATE :: %8X\n", &dos->DISPLAY_STATE[0]);
for (i=0; i < 64; i++)
{
printfScreenWithAttribute(debugScreen, LTGREEN, "%02X", dos->DISPLAY_STATE[i]);
}
printfScreen(debugScreen, "\n");
ClearPauseMode(debugScreen);
return;
}
void DisplayASCIITable(SCREEN *screen)
{
register LONG i;
union bhex
{
unsigned int i;
struct btemp {
unsigned one : 1;
unsigned two : 1;
unsigned three : 1;
unsigned four : 1;
unsigned five : 1;
unsigned six : 1;
unsigned seven : 1;
unsigned eight : 1;
} b;
} val;
SetPauseMode(screen, screen->nLines - 3);
printfScreenWithAttribute(screen, BRITEWHITE, "ASCII Table\n");
for (i=0; i < 256; i++)
{
val.i = i;
switch (i)
{
case 0:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | NULL |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
return;
break;
case 8:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | BKSP |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
return;
break;
case 9:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | TAB |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
break;
break;
case 10:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | <CR> |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
return;
break;
case 13:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | <LF> |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
return;
break;
case 32:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | SPACE |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one))
return;
break;
default:
if (printfScreenWithAttribute(screen, LTCYAN, "| %3i | (0x%02X) | (%1d%1d%1d%1d%1d%1d%1d%1db) | %c |", i, i,
val.b.eight, val.b.seven, val.b.six, val.b.five,
val.b.four, val.b.three, val.b.two, val.b.one, (BYTE) i))
return;
break;
}
if (printfScreen(screen, "\n"))
return;
}
ClearPauseMode(screen);
}
LONG ascTableHelp(SCREEN *screen, BYTE *commandLine, DEBUGGER_PARSER *parser)
{
if (screen) {}
if (commandLine) {}
if (parser) {}
printfScreenWithAttribute(screen, LTCYAN, "a - display ASCII Table\n");
return TRUE;
}
// A
LONG displayASCTable(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
register SCREEN *displayScreen;
register LONG address;
LONG valid;
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
DisplayASCIITable(screen);
return TRUE;
}
LONG disassemble(SCREEN *screen, StackFrame *stackFrame, LONG p, LONG count, LONG attr, LONG use)
{
register LONG i;
LONG exact = 0;
BYTE *symbolName;
LONG debugInfoPresent;
MODULE_HANDLE *executeModuleHandle;
SOURCE_LINE_INFO lineInfo;
extern LONG totalLines;
extern LONG line_info_toggle;
for (i=0; i < count; i++)
{
GetLineInfoFromValue(p, &lineInfo, &executeModuleHandle, &totalLines,
&debugInfoPresent, &exact);
if (line_info_toggle && exact)
{
if (lineInfo.SourcePresent && lineInfo.SourceLine)
{
register LONG length = strlen(lineInfo.SourceLine);
i = length > screen->nCols - 1 ? i + 1 + (length / screen->nCols - 1) : i + 1;
printfScreenWithAttribute(screen, LTGREEN, "%s (%s : line %d)\n",
lineInfo.SourceLine, lineInfo.ModuleName,
lineInfo.LineNumber);
#if (SYMBOL_DEBUG)
printfScreenWithAttribute(screen, LTGREEN, "seg: %d Mndx: %d tbl: %08X addr: %08X \noff: %08X sline: %08X mod: %s line: %d\n",
lineInfo.Segment, lineInfo.ModuleIndex,
lineInfo.LineTable, lineInfo.LineAddress,
lineInfo.Offset, lineInfo.SourceLine,
lineInfo.ModuleName, lineInfo.LineNumber);
#endif
}
else if (line_info_toggle && lineInfo.LineNumber)
{
i++;
printfScreenWithAttribute(screen, BRITEWHITE, "file %s line %d\n",
lineInfo.ModuleName, lineInfo.LineNumber);
}
}
if (i >= count && count != 1)
break;
symbolName = GetSymbolFromValue(p);
if (symbolName)
{
i++;
printfScreenWithAttribute(screen, BRITEWHITE, "%s:\n", symbolName);
}
if (i >= count && count != 1)
break;
p = unassemble(screen, stackFrame, p, use, attr);
}
return p;
}
BYTE *dump(SCREEN *screen, BYTE *p, LONG count)
{
BYTE *symbolName;
register LONG i, r, total;
BYTE str[9];
printfScreenWithAttribute(screen, BRITEWHITE, " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
SetPauseMode(screen, screen->nLines - 3);
for (r=0; r < count; r++)
{
symbolName = GetSymbolFromValue((LONG) p);
if (symbolName)
{
printfScreenWithAttribute(screen, LTCYAN, "%s:\n", symbolName);
if (r++ >= count && count != 1)
break;
}
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
for (total = 0, i=0; i < 16; i++, total++)
{
printfScreenWithAttribute(screen, LTCYAN, " %02X", (BYTE) p[i]);
}
printfScreen(screen, " ");
for (i=0; i < total; i++)
{
if (p[i] < 32 || p[i] > 126) printfScreenWithAttribute(screen, BRITEWHITE, ".");
else printfScreenWithAttribute(screen, BRITEWHITE, "%c", p[i]);
}
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) total);
}
ClearPauseMode(screen);
return p;
}
BYTE *dumpWord(SCREEN *screen, BYTE *p, LONG count)
{
register int i, r;
WORD *wp;
BYTE *symbolName;
char str[9];
SetPauseMode(screen, screen->nLines - 3);
wp = (WORD *) p;
for (r=0; r < count; r++)
{
symbolName = GetSymbolFromValue((LONG) p);
if (symbolName)
{
printfScreenWithAttribute(screen, LTCYAN, "%s:\n", symbolName);
if (r++ >= count && count != 1)
break;
}
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
for (i=0; i < (16 / 2); i++)
{
printfScreenWithAttribute(screen, LTCYAN, " %04X", wp[i]);
}
printfScreen(screen, " ");
for (i=0; i < 16; i++)
{
if (p[i] < 32 || p[i] > 126) printfScreenWithAttribute(screen, BRITEWHITE, ".");
else printfScreenWithAttribute(screen, BRITEWHITE, "%c", p[i]);
}
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) 16);
wp = (WORD *) p;
}
ClearPauseMode(screen);
return p;
}
BYTE *dumpDouble(SCREEN *screen, BYTE *p, LONG count)
{
register int i, r;
LONG *lp;
BYTE *symbolName;
char str[9];
SetPauseMode(screen, screen->nLines - 3);
lp = (LONG *) p;
for (r=0; r < count; r++)
{
symbolName = GetSymbolFromValue((LONG) p);
if (symbolName)
{
printfScreenWithAttribute(screen, LTCYAN, "%s:\n", symbolName);
if (r++ >= count && count != 1)
break;
}
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
for (i=0; i < (16 / 4); i++)
{
printfScreenWithAttribute(screen, LTCYAN, " %08X", (LONG) lp[i]);
}
printfScreen(screen, " ");
for (i=0; i < 16; i++)
{
if (p[i] < 32 || p[i] > 126) printfScreenWithAttribute(screen, BRITEWHITE, ".");
else printfScreenWithAttribute(screen, BRITEWHITE, "%c", p[i]);
}
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) 16);
lp = (LONG *) p;
}
ClearPauseMode(screen);
return p;
}
BYTE *dumpLinkedList(SCREEN *screen, BYTE *p, LONG count)
{
register int i, r;
LONG *lp;
char str[9];
lp = (LONG *) p;
printfScreenWithAttribute(screen, BRITEWHITE, " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
printfScreenWithAttribute(screen, BRITEWHITE, "Linked List -> [%08X] = %08X\n", lp, (*lp));
SetPauseMode(screen, screen->nLines - 3);
for (r=0; r < count; r++)
{
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
for (i=0; i < 16; i++)
{
printfScreenWithAttribute(screen, LTCYAN, " %02X", (BYTE) p[i]);
}
printfScreen(screen, " ");
for (i=0; i < 16; i++)
{
if (p[i] < 32 || p[i] > 126) printfScreenWithAttribute(screen, BRITEWHITE, ".");
else printfScreenWithAttribute(screen, BRITEWHITE, "%c", p[i]);
}
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) 16);
}
ClearPauseMode(screen);
return (BYTE *) (*lp);
}
BYTE *dumpDoubleStack(SCREEN *screen, StackFrame *stackFrame, BYTE *p, LONG count)
{
register int i, r;
LONG *lp;
char str[9];
SetPauseMode(screen, screen->nLines - 3);
lp = (LONG *) p;
printfScreenWithAttribute(screen, BRITEWHITE, "Stack SS:ESP = %04lX:%08X\n", stackFrame->tSS, p);
for (r=0; r < count; r++)
{
printfScreenWithAttribute(screen, BRITEWHITE, "%04X:", (WORD) stackFrame->tSS);
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
for (i=0; i < (16 / 4); i++)
{
printfScreenWithAttribute(screen, LTCYAN, " %08X", (LONG) lp[i]);
}
printfScreen(screen, " ");
for (i=0; i < 16; i++)
{
if (p[i] < 32 || p[i] > 126) printfScreenWithAttribute(screen, BRITEWHITE, ".");
else printfScreenWithAttribute(screen, BRITEWHITE, "%c", p[i]);
}
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) 16);
lp = (LONG *) p;
}
ClearPauseMode(screen);
return p;
}
BYTE *dumpStack(SCREEN *screen, StackFrame *stackFrame, BYTE *p, LONG count)
{
register int i, r;
LONG *lp;
char str[9];
SetPauseMode(screen, screen->nLines - 3);
lp = (LONG *) p;
printfScreenWithAttribute(screen, BRITEWHITE, "Stack SS:ESP = %04X:%08X\n", stackFrame->tSS, p);
for (r=0; r < count; r++)
{
printfScreenWithAttribute(screen, BRITEWHITE, "%08X ", (LONG) p);
printfScreenWithAttribute(screen, LTCYAN, "%08X ", (LONG) *lp);
DisplayClosestSymbol(screen, *lp);
printfScreen(screen, "\n");
p = (void *)((LONG) p + (LONG) 4);
lp = (LONG *) p;
}
ClearPauseMode(screen);
return p;
}
LONG displayScreenStructHelp(SCREEN *screen, BYTE *commandLine, DEBUGGER_PARSER *parser)
{
if (screen) {}
if (commandLine) {}
if (parser) {}
printfScreenWithAttribute(screen, LTCYAN, ".s or .s <address> - display screen structure(s)\n");
return TRUE;
}
// .S
LONG DisplayScreenStructure(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
extern SCREEN *oldScreen;
register SCREEN *displayScreen;
register LONG address;
LONG valid;
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
cmd = &cmd[parser->debugCommandNameLength];
while (*cmd && *cmd == ' ') cmd++;
address = EvaluateExpression(stackFrame, &cmd, &valid);
if (valid)
DisplayScreen(screen, (SCREEN *) address);
else
{
SetPauseMode(screen, screen->nLines - 3);
printfScreenWithAttribute(screen, BRITEWHITE, "Keyboard Owner: %08X\n",
keyboardOwner);
printfScreenWithAttribute(screen, BRITEWHITE, "Screen List\n");
displayScreen = screenListHead;
while (displayScreen)
{
if (printfScreenWithAttribute(screen, YELLOW, "Screen: %08X %s %s\n", displayScreen,
displayScreen->screenName,
displayScreen == oldScreen
? "(RUNNING_ACTIVE)"
: displayScreen == activeScreen
? "(DEBUG_ACTIVE)"
: ""))
break;
displayScreen = displayScreen->next;
}
ClearPauseMode(screen);
}
return TRUE;
}
LONG displayToggleHelp(SCREEN *screen, BYTE *commandLine, DEBUGGER_PARSER *parser)
{
if (screen) {}
if (commandLine) {}
if (parser) {}
printfScreenWithAttribute(screen, LTCYAN, ".tc - toggles control registers (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".tn - toggles coprocessor registers (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".ts - toggles segment registers (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".tg - toggles general registers (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".tr - toggles display of break reason (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".td - toggles full dereference display (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".tl - toggles source line display (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".tu - toggles unasm debug display (ON | OFF)\n");
printfScreenWithAttribute(screen, LTCYAN, ".t or .t <address> - display task state segment (tss)\n");
return TRUE;
}
// .TU
LONG ProcessTUToggle(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
(debug_deref)
? (debug_deref = 0)
: (debug_deref = 1);
printfScreenWithAttribute(screen, BRITEWHITE, "toggle unasm debug display (%s)\n",
debug_deref ? "ON" : "OFF");
return TRUE;
}
// .TD
LONG ProcessTDToggle(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
(full_deref_toggle)
? (full_deref_toggle = 0)
: (full_deref_toggle = 1);
printfScreenWithAttribute(screen, BRITEWHITE, "toggle full dereferencing info (%s) \n",
full_deref_toggle ? "ON" : "OFF");
return TRUE;
}
// .TL
LONG ProcessTLToggle(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
(line_info_toggle)
? (line_info_toggle = 0)
: (line_info_toggle = 1);
printfScreenWithAttribute(screen, BRITEWHITE, "toggle source line info (%s) \n",
line_info_toggle ? "ON" : "OFF");
return TRUE;
}
// .TG
LONG ProcessTGToggle(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
(general_toggle)
? (general_toggle = 0)
: (general_toggle = 1);
printfScreenWithAttribute(screen, BRITEWHITE, "toggle general registers (%s) \n",
general_toggle ? "ON" : "OFF");
return TRUE;
}
// .TC
LONG ProcessTCToggle(SCREEN *screen, BYTE *cmd,
StackFrame *stackFrame, LONG Exception,
DEBUGGER_PARSER *parser)
{
if (screen) {};
if (cmd) {};
if (stackFrame) {};
if (Exception) {};
if (parser) {};
(control_toggle)