push latest gdb commander changes to fix 32bit build

This commit is contained in:
Basile Burg 2016-03-27 18:55:24 +02:00
parent 2699a0a2d5
commit 7131f5b956
1 changed files with 119 additions and 59 deletions

View File

@ -8,7 +8,7 @@ uses
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics, RegExpr, Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics, RegExpr,
ComCtrls, PropEdits, GraphPropEdits, RTTIGrids, Dialogs, ExtCtrls, Menus, strutils, ComCtrls, PropEdits, GraphPropEdits, RTTIGrids, Dialogs, ExtCtrls, Menus, strutils,
Buttons, StdCtrls, process ,ce_common, ce_interfaces, ce_widget, ce_processes, Buttons, StdCtrls, process ,ce_common, ce_interfaces, ce_widget, ce_processes,
ce_observer, ce_synmemo, ce_sharedres; ce_observer, ce_synmemo, ce_sharedres, ce_stringrange;
type type
@ -20,11 +20,11 @@ type
{$ENDIF} {$ENDIF}
{$IFDEF CPU32} {$IFDEF CPU32}
TCpuRegs = (eax, ebx, ecx, edx, esi, edi, ebp, esp, eip); TCpuRegister = (eax, ebx, ecx, edx, esi, edi, ebp, esp, eip);
{$ENDIF} {$ENDIF}
TFLAG = (F_ID, F_VIP, F_VIF, F_AC, F_VM, F_RF, F_NT, F_IOPL, F_OF, F_DF, F_IF, TFLAG = (CS, PF, AF, ZF, SF, TF, IF_, DF, OF_, NT, RF, VM,
F_TF, F_SF, F_ZF, F_AF, F_PF, F_CF); AC, VIF, VIP, ID);
TEFLAG = set of TFLAG; TEFLAG = set of TFLAG;
TSegmentRegister = (S_CS, S_SS, S_DS, S_ES, S_FS, S_GS); TSegmentRegister = (S_CS, S_SS, S_DS, S_ES, S_FS, S_GS);
@ -277,25 +277,89 @@ var
str: string; str: string;
reg: string; reg: string;
val: string; val: string;
rng: TStringRange = (ptr: nil; pos: 0; len: 0);
begin begin
rdr := TStringList.Create;
try setLength(str, stream.Size);
rdr.LoadFromStream(stream); stream.Read(str[1], str.length);
if (rdr.Count = 0) or (pos('(gdb)', rdr[0]) = -1) then rng.init(str);
if rng.empty then
exit; exit;
// fix first line if not rng.startsWith('&"info registers\n"') then
str := rdr[0]; exit;
rdr[0] := str[7 .. str.length]; rng.popUntil(#10)^.popFront;
// each line = reg hex dec
for str in rdr do while not rng.empty do
begin begin
reg := ''; if rng.front <> '~' then
if fWordSpliter.Exec(str) then exit;
rng.popFront;
if rng.front <> '"' then
exit;
rng.popFront;
reg := rng.takeUntil([' ', #9]).yield;
if (reg = 'rip') or (reg = 'eip') then
begin begin
reg := fWordSpliter.Match[0]; rng.popUntil(#10)^.popFront;
if fWordSpliter.ExecNext and fWordSpliter.ExecNext then rng.popUntil(#10)^.popFront;
continue;
end;
rng.popUntil(#10)^.popFront;
if rng.front <> '~' then
exit;
rng.popFront;
if rng.front <> '"' then
exit;
rng.popFront;
if rng.front <> '\' then
exit;
rng.popFront;
if rng.front <> 't' then
exit;
rng.popFront;
if reg = 'eflags' then
begin begin
val := fWordSpliter.Match[0]; fFlags := [];
if rng.front <> '[' then
exit;
rng.popFront;
while rng.front <> ']' do
begin
val := rng.popWhile([' ', #9])^.takeUntil([' ', #9, ']']).yield;
case val of
'CS': include(fFlags, TFLAG.CS);
'PF': include(fFlags, TFLAG.PF);
'AF': include(fFlags, TFLAG.AF);
'ZF': include(fFlags, TFLAG.ZF);
'SF': include(fFlags, TFLAG.SF);
'TF': include(fFlags, TFLAG.TF);
'IF': include(fFlags, TFLAG.IF_);
'DF': include(fFlags, TFLAG.DF);
'OF': include(fFlags, TFLAG.OF_);
//'NT': include(fFlags, TFLAG.NT);
//'RF': include(fFlags, TFLAG.RF);
//'VM': include(fFlags, TFLAG.VM);
//'AC': include(fFlags, TFLAG.AC);
//'VIF':include(fFlags, TFLAG.VIF);
//'VIP':include(fFlags, TFLAG.VIP);
//'ID': include(fFlags, TFLAG.ID);
end;
end;
rng.popUntil(#10)^.popFront;
rng.popUntil(#10)^.popFront;
continue;
end;
val := rng.takeWhile(['0','1','2','3','4','5','6','7','8','9']).yield;
rng.popUntil(#10)^.popFront;
rng.popUntil(#10)^.popFront;
case reg of case reg of
'cs': fSegment[TSegmentRegister.S_CS] := StrToInt(val); 'cs': fSegment[TSegmentRegister.S_CS] := StrToInt(val);
'ds': fSegment[TSegmentRegister.S_DS] := StrToInt(val); 'ds': fSegment[TSegmentRegister.S_DS] := StrToInt(val);
@ -333,11 +397,7 @@ begin
'eip': fRegisters[TCpuRegister.eip] := StrToInt(val); 'eip': fRegisters[TCpuRegister.eip] := StrToInt(val);
{$ENDIF} {$ENDIF}
end; end;
end;
end;
end;
finally
rdr.free;
end; end;
end; end;
{$ENDREGION} {$ENDREGION}
@ -494,7 +554,7 @@ begin
fGdb.Executable:= 'gdb' + exeExt; fGdb.Executable:= 'gdb' + exeExt;
fgdb.Options:= [poUsePipes, poStderrToOutPut]; fgdb.Options:= [poUsePipes, poStderrToOutPut];
fgdb.Parameters.Add(str); fgdb.Parameters.Add(str);
//fgdb.Parameters.Add('--interpreter=mi'); fgdb.Parameters.Add('--interpreter=mi');
fGdb.OnReadData:= @gdbOutput; fGdb.OnReadData:= @gdbOutput;
fGdb.OnTerminate:= @gdbOutput; fGdb.OnTerminate:= @gdbOutput;
fgdb.execute; fgdb.execute;