* Moved Windows-specific code to read the instruction-pointer and base stack pointer register values to fpdbgwinclasses.pas

git-svn-id: trunk@44436 -
This commit is contained in:
joost 2014-03-16 10:18:06 +00:00
parent 178cdf98b7
commit eba8717294
3 changed files with 35 additions and 21 deletions

View File

@ -36,7 +36,11 @@ unit FPDCommand;
interface
uses
SysUtils, Classes, Windows, LCLProc, FpDbgWinExtra, FpDbgInfo, FpDbgClasses, DbgIntfBaseTypes;
SysUtils, Classes,
{$ifdef windows}
Windows,
{$endif}
LCLProc, FpDbgInfo, FpDbgClasses, DbgIntfBaseTypes, FpDbgUtil;
procedure HandleCommand(ACommand: String);
@ -189,11 +193,7 @@ begin
then begin
// current addr
P := '';
{$ifdef cpui386}
Address := GCurrentContext^.Eip;
{$else}
Address := GCurrentContext^.Rip;
{$endif}
Address := GCurrentProcess.GetInstructionPointerRegisterValue;
end
else begin
P := GetPart([], [':'], S);
@ -318,12 +318,8 @@ begin
idx := 1;
Count := 1;
Size := 4;
{$ifdef cpui386}
Address := GCurrentContext^.Eip;
{$else}
Address := GCurrentContext^.Rip;
{$endif}
Address := GCurrentProcess.GetInstructionPointerRegisterValue;
if P[idx] <> ''
then begin
@ -485,15 +481,9 @@ begin
Exit;
end;
{$ifdef cpui386}
Address := GCurrentContext^.Eip;
Frame := GCurrentContext^.Ebp;
Size := 4;
{$else}
Address := GCurrentContext^.Rip;
Frame := GCurrentContext^.Rdi;
Size := 8;
{$endif}
Address := GCurrentProcess.GetInstructionPointerRegisterValue;
Frame := GCurrentProcess.GetStackBasePointerRegisterValue;;
Size := sizeof(pointer);
WriteLN('Callstack:');
WriteLn(' ', FormatAddress(Address));

View File

@ -172,6 +172,9 @@ type
function WriteData(const AAdress: TDbgPtr; const ASize: Cardinal; const AData): Boolean; virtual;
function GetInstructionPointerRegisterValue: TDbgPtr; virtual; abstract;
function GetStackBasePointerRegisterValue: TDbgPtr; virtual; abstract;
property Handle: THandle read GetHandle;
property Name: String read FName write SetName;
property ProcessID: integer read FProcessID;

View File

@ -97,6 +97,9 @@ type
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; override;
procedure StartProcess(const AInfo: TCreateProcessDebugInfo);
function GetInstructionPointerRegisterValue: TDbgPtr; override;
function GetStackBasePointerRegisterValue: TDbgPtr; override;
function AddrOffset: Int64; override;
function AddLib(const AInfo: TLoadDLLDebugInfo): TDbgLibrary;
procedure AddThread(const AID: Integer; const AInfo: TCreateThreadDebugInfo);
@ -831,6 +834,24 @@ begin
FMainThread := OSDbgClasses.DbgThreadClass.Create(Self, ThreadID, AInfo.hThread, AInfo.lpThreadLocalBase, AInfo.lpStartAddress);
end;
function TDbgWinProcess.GetInstructionPointerRegisterValue: TDbgPtr;
begin
{$ifdef cpui386}
Result := GCurrentContext^.Eip;
{$else}
Result := GCurrentContext^.Rip;
{$endif}
end;
function TDbgWinProcess.GetStackBasePointerRegisterValue: TDbgPtr;
begin
{$ifdef cpui386}
Result := GCurrentContext^.Ebp;
{$else}
Result := GCurrentContext^.Rdi;
{$endif}
end;
function TDbgWinProcess.AddrOffset: Int64;
begin
Result:=inherited AddrOffset - TDbgPtr(FInfo.lpBaseOfImage);