diff --git a/debugger/windebug/fpwd/fpwd.lpi b/debugger/windebug/fpwd/fpwd.lpi
index bde06ac072..e0b734c897 100644
--- a/debugger/windebug/fpwd/fpwd.lpi
+++ b/debugger/windebug/fpwd/fpwd.lpi
@@ -7,7 +7,7 @@
-
+
@@ -27,45 +27,45 @@
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
@@ -74,16 +74,16 @@
-
+
-
-
-
-
+
+
+
+
@@ -113,8 +113,8 @@
-
-
+
+
@@ -122,9 +122,7 @@
-
-
@@ -154,10 +152,10 @@
-
-
-
-
+
+
+
+
@@ -165,8 +163,8 @@
-
-
+
+
@@ -174,132 +172,89 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -314,7 +269,13 @@
+
+
+
+
+
+
diff --git a/debugger/windebug/fpwd/fpwdcommand.pas b/debugger/windebug/fpwd/fpwdcommand.pas
index e8fa05611f..f0ebf7eee1 100644
--- a/debugger/windebug/fpwd/fpwdcommand.pas
+++ b/debugger/windebug/fpwd/fpwdcommand.pas
@@ -253,10 +253,12 @@ begin
idx := 1;
Count := 1;
Size := 4;
- case GMode of
- dm32: Adress := GCurrentContext.Eip;
- dm64: Adress := GCurrentContext64.Rip;
- end;
+
+ {$ifdef cpui386}
+ Adress := GCurrentContext.Eip;
+ {$else}
+ Adress := GCurrentContext.Rip;
+ {$endif}
if P[idx] <> ''
then begin
@@ -418,18 +420,15 @@ begin
Exit;
end;
- case GMode of
- dm32: begin
- Adress := GCurrentContext.Eip;
- Frame := GCurrentContext.Ebp;
- Size := 4;
- end;
- dm64: begin
- Adress := GCurrentContext64.Rip;
- Frame := GCurrentContext64.Rdi;
- Size := 8;
- end;
- end;
+ {$ifdef cpui386}
+ Adress := GCurrentContext.Eip;
+ Frame := GCurrentContext.Ebp;
+ Size := 4;
+ {$else}
+ Adress := GCurrentContext.Rip;
+ Frame := GCurrentContext.Rdi;
+ Size := 8;
+ {$endif}
WriteLN('Callstack:');
WriteLn(' ', FormatAdress(Adress));
diff --git a/debugger/windebug/fpwd/fpwdglobal.pas b/debugger/windebug/fpwd/fpwdglobal.pas
index 031519152c..4a1e471e49 100644
--- a/debugger/windebug/fpwd/fpwdglobal.pas
+++ b/debugger/windebug/fpwd/fpwdglobal.pas
@@ -45,9 +45,12 @@ type
var
GState: TMWDState;
GFileName: String;
+ {$ifdef cpui386}
GMode: TMWDMode = dm32;
- GCurrentContext64: TContextAMD64;
- GCurrentContext: TContext absolute GCurrentContext64;
+ {$else}
+ GMode: TMWDMode = dm64;
+ {$endif}
+ GCurrentContext: TContext;
GMainProcess: TDbgProcess = nil;
GCurrentProcess: TDbgProcess = nil;
diff --git a/debugger/windebug/fpwd/fpwdloop.pas b/debugger/windebug/fpwd/fpwdloop.pas
index 1fca3a19d6..316fb8c806 100644
--- a/debugger/windebug/fpwd/fpwdloop.pas
+++ b/debugger/windebug/fpwd/fpwdloop.pas
@@ -1,4 +1,4 @@
-{ $Id: $ }
+{ $Id $ }
{
---------------------------------------------------------------------------
fpwdloop.pas - FP standalone windows debugger - Debugger main loop
@@ -117,35 +117,32 @@ begin
else
Write(' Unknown code: ', AEvent.Exception.ExceptionRecord.ExceptionCode);
end;
- case GMode of
- dm64: Info0 := AEvent.Exception64.ExceptionRecord.ExceptionAddress;
- dm32: Info0 := Cardinal(AEvent.Exception.ExceptionRecord.ExceptionAddress);
- else
- Info0 := 0;
- end;
+ {$ifdef cpui386}
+ Info0 := Cardinal(AEvent.Exception.ExceptionRecord.ExceptionAddress);
+ {$else}
+ Info0 := AEvent.Exception64.ExceptionRecord.ExceptionAddress;
+ {$endif}
Write(' at: ', FormatAdress(Info0));
Write(' Flags:', Format('%x', [AEvent.Exception.ExceptionRecord.ExceptionFlags]), ' [');
if AEvent.Exception.ExceptionRecord.ExceptionFlags = 0
then Write('Continuable')
else Write('Not continuable');
Write(']');
- case GMode of
- dm64: Write(' ParamCount:', AEvent.Exception64.ExceptionRecord.NumberParameters);
- dm32: Write(' ParamCount:', AEvent.Exception.ExceptionRecord.NumberParameters);
- end;
+ {$ifdef cpui386}
+ Write(' ParamCount:', AEvent.Exception.ExceptionRecord.NumberParameters);
+ {$else}
+ Write(' ParamCount:', AEvent.Exception64.ExceptionRecord.NumberParameters);
+ {$endif}
case AEvent.Exception.ExceptionRecord.ExceptionCode of
EXCEPTION_ACCESS_VIOLATION: begin
- case GMode of
- dm64: begin
- Info0 := AEvent.Exception64.ExceptionRecord.ExceptionInformation[0];
- Info1Str := IntToHex(AEvent.Exception64.ExceptionRecord.ExceptionInformation[1], 16);
- end;
- dm32: begin
- Info0 := AEvent.Exception.ExceptionRecord.ExceptionInformation[0];
- Info1Str := IntToHex(AEvent.Exception.ExceptionRecord.ExceptionInformation[1], 8);
- end;
- end;
+ {$ifdef cpui386}
+ Info0 := AEvent.Exception.ExceptionRecord.ExceptionInformation[0];
+ Info1Str := IntToHex(AEvent.Exception.ExceptionRecord.ExceptionInformation[1], 8);
+ {$else}
+ Info0 := AEvent.Exception64.ExceptionRecord.ExceptionInformation[0];
+ Info1Str := IntToHex(AEvent.Exception64.ExceptionRecord.ExceptionInformation[1], 16);
+ {$endif}
case Info0 of
0: begin
@@ -160,32 +157,29 @@ begin
WriteLN;
Write(' Info: ');
- case GMode of
- dm64: begin
- with AEvent.Exception64.ExceptionRecord do
- for n := Low(ExceptionInformation) to high(ExceptionInformation) do
- begin
- Write(IntToHex(ExceptionInformation[n], 16), ' ');
- if n and 3 = 3
- then begin
- WriteLN;
- Write(' ');
- end;
- end;
+ {$ifdef cpui386}
+ with AEvent.Exception.ExceptionRecord do
+ for n := Low(ExceptionInformation) to high(ExceptionInformation) do
+ begin
+ Write(IntToHex(ExceptionInformation[n], 8), ' ');
+ if n and 7 = 7
+ then begin
+ WriteLN;
+ Write(' ');
+ end;
end;
- dm32: begin
- with AEvent.Exception.ExceptionRecord do
- for n := Low(ExceptionInformation) to high(ExceptionInformation) do
- begin
- Write(IntToHex(ExceptionInformation[n], 8), ' ');
- if n and 7 = 7
- then begin
- WriteLN;
- Write(' ');
- end;
- end;
+ {$else}
+ with AEvent.Exception64.ExceptionRecord do
+ for n := Low(ExceptionInformation) to high(ExceptionInformation) do
+ begin
+ Write(IntToHex(ExceptionInformation[n], 16), ' ');
+ if n and 3 = 3
+ then begin
+ WriteLN;
+ Write(' ');
+ end;
end;
- end;
+ {$endif}
WriteLn;
GState := dsPause;
end;
@@ -270,56 +264,54 @@ procedure DebugLoop;
if GCurrentThread = nil then Exit;
- case GMode of
- dm64: begin
- with GCurrentContext64 do WriteLN(Format('SegDS: 0x%4.4x, SegES: 0x%4.4x, SegFS: 0x%4.4x, SegGS: 0x%4.4x', [SegDs, SegEs, SegFs, SegGs]));
- with GCurrentContext64 do WriteLN(Format('RAX: 0x%16.16x, RBX: 0x%16.16x, RCX: 0x%16.16x, RDX: 0x%16.16x, RDI: 0x%16.16x, RSI: 0x%16.16x, R9: 0x%16.16x, R10: 0x%16.16x, R11: 0x%16.16x, R12: 0x%16.16x, R13: 0x%16.16x, R14: 0x%16.16x, R15: 0x%16.16x', [Rax, Rbx, Rcx, Rdx, Rdi, Rsi, R9, R10, R11, R12, R13, R14, R15]));
- with GCurrentContext64 do WriteLN(Format('SegCS: 0x%4.4x, SegSS: 0x%4.4x, RBP: 0x%16.16x, RIP: 0x%16.16x, RSP: 0x%16.16x, EFlags: 0x%8.8x', [SegCs, SegSs, Rbp, Rip, Rsp, EFlags]));
- end;
- dm32: begin
- with GCurrentContext do WriteLN(Format('DS: 0x%x, ES: 0x%x, FS: 0x%x, GS: 0x%x', [SegDs, SegEs, SegFs, SegGs]));
- with GCurrentContext do WriteLN(Format('EAX: 0x%x, EBX: 0x%x, ECX: 0x%x, EDX: 0x%x, EDI: 0x%x, ESI: 0x%x', [Eax, Ebx, Ecx, Edx, Edi, Esi]));
- with GCurrentContext do WriteLN(Format('CS: 0x%x, SS: 0x%x, EBP: 0x%x, EIP: 0x%x, ESP: 0x%x, EFlags: 0x%x', [SegCs, SegSs, Ebp, Eip, Esp, EFlags]));
- with GCurrentContext do begin
- Write(Format('DR0: 0x%x, DR1: 0x%x, DR2: 0x%x, DR3: 0x%x', [Dr0, Dr1, Dr2, Dr3]));
- Write(' DR6: 0x', IntToHex(Dr6, 8), ' [');
- if Dr6 and $0001 <> 0 then Write('B0 ');
- if Dr6 and $0002 <> 0 then Write('B1 ');
- if Dr6 and $0004 <> 0 then Write('B2 ');
- if Dr6 and $0008 <> 0 then Write('B3 ');
- if Dr6 and $2000 <> 0 then Write('BD ');
- if Dr6 and $4000 <> 0 then Write('BS ');
- if Dr6 and $8000 <> 0 then Write('BT ');
- Write('] DR7: 0x', IntToHex(Dr7, 8), ' [');
- if Dr7 and $01 <> 0 then Write('L0 ');
- if Dr7 and $02 <> 0 then Write('G0 ');
- if Dr7 and $04 <> 0 then Write('L1 ');
- if Dr7 and $08 <> 0 then Write('G1 ');
- if Dr7 and $10 <> 0 then Write('L2 ');
- if Dr7 and $20 <> 0 then Write('G2 ');
- if Dr7 and $40 <> 0 then Write('L3 ');
- if Dr7 and $80 <> 0 then Write('G3 ');
- if Dr7 and $100 <> 0 then Write('LE ');
- if Dr7 and $200 <> 0 then Write('GE ');
- if Dr7 and $2000 <> 0 then Write('GD ');
- f := Dr7 shr 16;
- for n := 0 to 3 do
- begin
- Write('R/W', n,':');
- case f and 3 of
- 0: Write('ex');
- 1: Write('wo');
- 2: Write('IO');
- 3: Write('rw');
- end;
- f := f shr 2;
- Write(' LEN', n,':', f and 3 + 1, ' ');
- f := f shr 2;
- end;
- WriteLN(']');
+ {$ifdef cpui386}
+ with GCurrentContext do WriteLN(Format('DS: 0x%x, ES: 0x%x, FS: 0x%x, GS: 0x%x', [SegDs, SegEs, SegFs, SegGs]));
+ with GCurrentContext do WriteLN(Format('EAX: 0x%x, EBX: 0x%x, ECX: 0x%x, EDX: 0x%x, EDI: 0x%x, ESI: 0x%x', [Eax, Ebx, Ecx, Edx, Edi, Esi]));
+ with GCurrentContext do WriteLN(Format('CS: 0x%x, SS: 0x%x, EBP: 0x%x, EIP: 0x%x, ESP: 0x%x, EFlags: 0x%x', [SegCs, SegSs, Ebp, Eip, Esp, EFlags]));
+ with GCurrentContext do
+ begin
+ Write(Format('DR0: 0x%x, DR1: 0x%x, DR2: 0x%x, DR3: 0x%x', [Dr0, Dr1, Dr2, Dr3]));
+ Write(' DR6: 0x', IntToHex(Dr6, 8), ' [');
+ if Dr6 and $0001 <> 0 then Write('B0 ');
+ if Dr6 and $0002 <> 0 then Write('B1 ');
+ if Dr6 and $0004 <> 0 then Write('B2 ');
+ if Dr6 and $0008 <> 0 then Write('B3 ');
+ if Dr6 and $2000 <> 0 then Write('BD ');
+ if Dr6 and $4000 <> 0 then Write('BS ');
+ if Dr6 and $8000 <> 0 then Write('BT ');
+ Write('] DR7: 0x', IntToHex(Dr7, 8), ' [');
+ if Dr7 and $01 <> 0 then Write('L0 ');
+ if Dr7 and $02 <> 0 then Write('G0 ');
+ if Dr7 and $04 <> 0 then Write('L1 ');
+ if Dr7 and $08 <> 0 then Write('G1 ');
+ if Dr7 and $10 <> 0 then Write('L2 ');
+ if Dr7 and $20 <> 0 then Write('G2 ');
+ if Dr7 and $40 <> 0 then Write('L3 ');
+ if Dr7 and $80 <> 0 then Write('G3 ');
+ if Dr7 and $100 <> 0 then Write('LE ');
+ if Dr7 and $200 <> 0 then Write('GE ');
+ if Dr7 and $2000 <> 0 then Write('GD ');
+ f := Dr7 shr 16;
+ for n := 0 to 3 do
+ begin
+ Write('R/W', n,':');
+ case f and 3 of
+ 0: Write('ex');
+ 1: Write('wo');
+ 2: Write('IO');
+ 3: Write('rw');
end;
+ f := f shr 2;
+ Write(' LEN', n,':', f and 3 + 1, ' ');
+ f := f shr 2;
end;
+ WriteLN(']');
end;
+ {$else}
+ with GCurrentContext do WriteLN(Format('SegDS: 0x%4.4x, SegES: 0x%4.4x, SegFS: 0x%4.4x, SegGS: 0x%4.4x', [SegDs, SegEs, SegFs, SegGs]));
+ with GCurrentContext do WriteLN(Format('RAX: 0x%16.16x, RBX: 0x%16.16x, RCX: 0x%16.16x, RDX: 0x%16.16x, RDI: 0x%16.16x, RSI: 0x%16.16x, R9: 0x%16.16x, R10: 0x%16.16x, R11: 0x%16.16x, R12: 0x%16.16x, R13: 0x%16.16x, R14: 0x%16.16x, R15: 0x%16.16x', [Rax, Rbx, Rcx, Rdx, Rdi, Rsi, R9, R10, R11, R12, R13, R14, R15]));
+ with GCurrentContext do WriteLN(Format('SegCS: 0x%4.4x, SegSS: 0x%4.4x, RBP: 0x%16.16x, RIP: 0x%16.16x, RSP: 0x%16.16x, EFlags: 0x%8.8x', [SegCs, SegSs, Rbp, Rip, Rsp, EFlags]));
+ {$endif}
WriteLN('---');
end;
@@ -356,17 +348,16 @@ begin
else WriteLN('LOOP: ID:', MDebugEvent.dwTHreadID, ' -> H:', GCurrentThread.Handle);
end;
- FillChar(GCurrentContext64, SizeOf(GCurrentContext64), $EE);
+ FillChar(GCurrentContext, SizeOf(GCurrentContext), $EE);
if GCurrentThread <> nil
then begin
// TODO: move to TDbgThread
- case GMode of
- dm64: GCurrentContext64.ContextFlags := CONTEXT_SEGMENTS_AMD64 or CONTEXT_INTEGER_AMD64 or CONTEXT_CONTROL_AMD64;
- dm32: GCurrentContext.ContextFlags := CONTEXT_SEGMENTS or CONTEXT_INTEGER or CONTEXT_CONTROL {or CONTEXT_DEBUG_REGISTERS};
- else
- WriteLN('LOOP: Unknown mode');
- end;
+ {$ifdef cpui386}
+ GCurrentContext.ContextFlags := CONTEXT_SEGMENTS or CONTEXT_INTEGER or CONTEXT_CONTROL {or CONTEXT_DEBUG_REGISTERS};
+ {$else}
+ GCurrentContext.ContextFlags := CONTEXT_SEGMENTS_AMD64 or CONTEXT_INTEGER_AMD64 or CONTEXT_CONTROL_AMD64;
+ {$endif}
SetLastError(0);
// SuspendTHread(GCurrentThread.Handle);
if not GetThreadContext(GCurrentThread.Handle, GCurrentContext)
diff --git a/debugger/windebug/fpwd/fpwdtype.pas b/debugger/windebug/fpwd/fpwdtype.pas
index 9671ace30c..fca377e4c0 100644
--- a/debugger/windebug/fpwd/fpwdtype.pas
+++ b/debugger/windebug/fpwd/fpwdtype.pas
@@ -1,4 +1,4 @@
-{ $Id: $ }
+{ $Id $ }
{
---------------------------------------------------------------------------
fpwdtype.pas - FP standalone windows debugger - Type definitions
@@ -44,9 +44,9 @@ interface
uses
Windows;
-type
- DWORD64 = QWORD;
- ULONGLONG = QWORD;
+//type
+// DWORD64 = QWORD;
+// ULONGLONG = QWORD;
// LONGLONG = int64;
//QWORD = type cardinal;
diff --git a/debugger/windebug/windebugger.pp b/debugger/windebug/windebugger.pp
index 09592ec4ad..f8d97eb664 100644
--- a/debugger/windebug/windebugger.pp
+++ b/debugger/windebug/windebugger.pp
@@ -449,8 +449,13 @@ begin
Context.ContextFlags := CONTEXT_DEBUG_REGISTERS;
+ {$ifdef cpui386}
Context.Dr0 := Context.Eip;
Context.Dr7 := (Context.Dr7 and $FFF0FFFF) or $1;
+ {$else}
+ Context.Dr0 := Context.Rip;
+ Context.Dr7 := (Context.Dr7 and $FFFFFFFFFFF0FFFF) or $1;
+ {$endif}
// Context.EFlags := Context.EFlags or $100;
@@ -645,7 +650,11 @@ begin
end;
Context.ContextFlags := CONTEXT_CONTROL;
+ {$ifdef cpui386}
Dec(Context.Eip);
+ {$else}
+ Dec(Context.Rip);
+ {$endif}
if not SetThreadContext(Thread.Handle, Context)
then begin