debugger: disassembler, small optimizations

git-svn-id: trunk@28234 -
This commit is contained in:
martin 2010-11-14 23:50:41 +00:00
parent 334c21803e
commit c2f5f8d325

View File

@ -446,6 +446,7 @@ type
function GetItem(Index: Integer): PDisassemblerEntry; function GetItem(Index: Integer): PDisassemblerEntry;
procedure ParseItem(Index: Integer); procedure ParseItem(Index: Integer);
procedure ParseItemMemDmp(Index: Integer); procedure ParseItemMemDmp(Index: Integer);
procedure SetItem(Index: Integer; const AValue: PDisassemblerEntry);
protected protected
procedure PreParse; override; procedure PreParse; override;
public public
@ -453,7 +454,7 @@ type
procedure AddMemDump(AMemDump: TGDBMIMemoryDumpResultList); procedure AddMemDump(AMemDump: TGDBMIMemoryDumpResultList);
property Count: Integer read FCount; property Count: Integer read FCount;
property HasSourceInfo: Boolean read FHasSourceInfo; property HasSourceInfo: Boolean read FHasSourceInfo;
property Item[Index: Integer]: PDisassemblerEntry read GetItem; property Item[Index: Integer]: PDisassemblerEntry read GetItem write SetItem;
end; end;
{ TGDBMIDebuggerSimpleCommand } { TGDBMIDebuggerSimpleCommand }
@ -1059,6 +1060,13 @@ begin
{$POP} {$POP}
end; end;
procedure TGDBMIDisassembleResultList.SetItem(Index: Integer;
const AValue: PDisassemblerEntry);
begin
FItems[Index].ParsedInfo := AValue^;
FItems[Index].AsmEntry.Ptr := nil;
end;
{ TGDBMIMemoryDumpResultList } { TGDBMIMemoryDumpResultList }
function TGDBMIMemoryDumpResultList.GetItemNum(Index: Integer): Integer; function TGDBMIMemoryDumpResultList.GetItemNum(Index: Integer): Integer;
@ -1385,7 +1393,6 @@ function TGDBMIDebuggerCommandDisassembe.DoExecute: Boolean;
Itm := ADisAssList.Item[i]; Itm := ADisAssList.Item[i];
if ASrcInfoDisAssList <> nil if ASrcInfoDisAssList <> nil
then begin then begin
// Todo, maybe sort first and do bin search then?
j := MinInSrc; j := MinInSrc;
while j <= MaxInSrc do begin while j <= MaxInSrc do begin
Itm2 := ASrcInfoDisAssList.Item[j]; Itm2 := ASrcInfoDisAssList.Item[j];
@ -1397,10 +1404,16 @@ function TGDBMIDebuggerCommandDisassembe.DoExecute: Boolean;
then begin then begin
Itm2^.Dump := Itm^.Dump; Itm2^.Dump := Itm^.Dump;
Itm := Itm2; Itm := Itm2;
// reduce search range
if j = MaxInSrc if j = MaxInSrc
then dec(MaxInSrc); then dec(MaxInSrc)
if j = MinInSrc else if j = MinInSrc
then inc(MinInSrc); then inc(MinInSrc)
else begin
ASrcInfoDisAssList.Item[j] := ASrcInfoDisAssList.Item[MaxInSrc];
dec(MaxInSrc);
end;
end end
end; end;
if (LastItem <> nil) then begin if (LastItem <> nil) then begin
@ -1515,13 +1528,22 @@ function TGDBMIDebuggerCommandDisassembe.DoExecute: Boolean;
if (not FirstLoopRun) and (DisAssList.Item[i]^.Offset <> 0) if (not FirstLoopRun) and (DisAssList.Item[i]^.Offset <> 0)
then begin then begin
// Current block starts with offset. Adjust and disassemble again // Current block starts with offset. Adjust and disassemble again
// Again without Source first.... // Try with source first, in case it returns dat without source
DisAssListNew := ExecDisassmble(DisAssList.Item[i]^.Addr - DisAssList.Item[i]^.Offset,
NextProcAddr, False, DisAssListNew);
DisAssListWithSrc := ExecDisassmble(DisAssList.Item[i]^.Addr - DisAssList.Item[i]^.Offset, DisAssListWithSrc := ExecDisassmble(DisAssList.Item[i]^.Addr - DisAssList.Item[i]^.Offset,
NextProcAddr, True, DisAssListWithSrc); NextProcAddr, True, DisAssListWithSrc);
if (DisAssListWithSrc.Count > 0) and (not DisAssListWithSrc.HasSourceInfo)
then begin
// no source avail, but got data
CopyToRange(DisAssListWithSrc, NewRange, 0, DisAssListWithSrc.Count);
i := NextProcIdx;
Result := True;
continue;
end;
CopyToRange(DisAssListNew, NewRange, 0, DisAssListWithSrc.Count, DisAssListWithSrc); //get the source-less code as reference
DisAssListNew := ExecDisassmble(DisAssList.Item[i]^.Addr - DisAssList.Item[i]^.Offset,
NextProcAddr, False, DisAssListNew);
CopyToRange(DisAssListNew, NewRange, 0, DisAssListNew.Count, DisAssListWithSrc);
i := NextProcIdx; i := NextProcIdx;
Result := True; Result := True;
continue; continue;