DBG: Assembler-View: Fixed crash after resting (destroy) debugger

git-svn-id: trunk@28255 -
This commit is contained in:
martin 2010-11-15 21:51:24 +00:00
parent 1ab431705c
commit cc86c3c99e
2 changed files with 51 additions and 9 deletions

View File

@ -72,6 +72,7 @@ type
FGutterWidth: Integer; FGutterWidth: Integer;
FUpdating: Boolean; FUpdating: Boolean;
FUpdateNeeded: Boolean; FUpdateNeeded: Boolean;
procedure DoDebuggerDestroyed(Sender: TObject);
procedure ClearLineMap(AState: TAsmDlgLineMapState = lmsUnknown); procedure ClearLineMap(AState: TAsmDlgLineMapState = lmsUnknown);
procedure DisassemblerChanged(Sender: TObject); procedure DisassemblerChanged(Sender: TObject);
procedure SetDisassembler(const AValue: TIDEDisassembler); procedure SetDisassembler(const AValue: TIDEDisassembler);
@ -224,14 +225,15 @@ procedure TAssemblerDlg.DisassemblerChanged(Sender: TObject);
begin begin
if (FDisassembler = nil) or (FLocation = 0) or (FLineCount = 0) if (FDisassembler = nil) or (FLocation = 0) or (FLineCount = 0)
then exit; then exit;
if FDebugger.State <> dsPause if (FDebugger <> nil) and (FDebugger.State <> dsPause)
then begin then begin
// only for F9, not for F8,F7 single stepping with assembler is no good, if it clears all the time // only for F9, not for F8,F7 single stepping with assembler is no good, if it clears all the time
//ClearLineMap; //ClearLineMap;
end end
else begin else begin
// Check if anything is there, update BaseAddr // Check if anything is there, update BaseAddr
FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5)); if FDisassembler <> nil
then FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5));
UpdateLineData; UpdateLineData;
end; end;
pbAsm.Invalidate; pbAsm.Invalidate;
@ -428,9 +430,24 @@ begin
end; end;
end; end;
procedure TAssemblerDlg.DoDebuggerDestroyed(Sender: TObject);
begin
FDebugger := nil;
FDisassembler := nil;
UpdateLineData;
pbAsm.Invalidate;
end;
procedure TAssemblerDlg.SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr); procedure TAssemblerDlg.SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr);
begin begin
FDebugger := ADebugger; if FDebugger <> ADebugger
then begin
if FDebugger <> nil
then FDebugger.RemoveNotifyEvent(dnrDestroy, @DoDebuggerDestroyed);
FDebugger := ADebugger;
if FDebugger <> nil
then FDebugger.AddNotifyEvent(dnrDestroy, @DoDebuggerDestroyed);
end;
FTopLine := -(FLineCount div 2); FTopLine := -(FLineCount div 2);
FSelectLine := 0; FSelectLine := 0;
FSelectionEndLine := 0; FSelectionEndLine := 0;
@ -439,7 +456,8 @@ begin
if Visible then begin if Visible then begin
// otherwhise in resize // otherwhise in resize
FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5)); if FDisassembler <> nil
then FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5));
UpdateLineData; UpdateLineData;
pbAsm.Invalidate; pbAsm.Invalidate;
end end
@ -486,7 +504,8 @@ begin
SetLength(FLineMap, FLineCount + 1); SetLength(FLineMap, FLineCount + 1);
if FLocation <> 0 if FLocation <> 0
then begin then begin
FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5)); if FDisassembler <> nil
then FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - 5)), Max(0, FTopLine + FLineCount + 1 + 5));
UpdateLineData; UpdateLineData;
end; end;
pbAsm.Invalidate; pbAsm.Invalidate;
@ -504,8 +523,9 @@ begin
then PadFront := 25 then PadFront := 25
else PadEnd := 25; else PadEnd := 25;
FTopLine := ALine; FTopLine := ALine;
if (FDisassembler.CountBefore < Max(0, -(FTopLine - PadFront))) if (FDisassembler <> nil)
or (FDisassembler.CountAfter < Max(0, FTopLine + FLineCount + 1 + PadEnd)) and ( (FDisassembler.CountBefore < Max(0, -(FTopLine - PadFront)))
or (FDisassembler.CountAfter < Max(0, FTopLine + FLineCount + 1 + PadEnd)) )
then FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - PadFront)), Max(0, FTopLine + FLineCount + 1 + PadEnd)); then FDisassembler.PrepareRange(FLocation, Max(0, -(FTopLine - PadFront)), Max(0, FTopLine + FLineCount + 1 + PadEnd));
UpdateLineData; UpdateLineData;
end; end;
@ -554,8 +574,7 @@ var
Itm, NextItm: PDisassemblerEntry; Itm, NextItm: PDisassemblerEntry;
LineIsSrc, HasLineOutOfRange: Boolean; LineIsSrc, HasLineOutOfRange: Boolean;
begin begin
if FDebugger = nil then Exit; if (FDebugger = nil) or (FDisassembler = nil) or (FDebugger.State <> dsPause)
If FDebugger.State <> dsPause
then begin then begin
ClearLineMap; // set all to lmsUnknown; ClearLineMap; // set all to lmsUnknown;
exit; exit;

View File

@ -1431,6 +1431,8 @@ type
const AExceptionText: String; const AExceptionText: String;
out AContinue: Boolean) of object; out AContinue: Boolean) of object;
TDebuggerNotifyReason = (dnrDestroy);
TDebuggerProperties = class(TPersistent) TDebuggerProperties = class(TPersistent)
private private
public public
@ -1466,6 +1468,7 @@ type
FOnState: TDebuggerStateChangedEvent; FOnState: TDebuggerStateChangedEvent;
FOnBreakPointHit: TDebuggerBreakPointHitEvent; FOnBreakPointHit: TDebuggerBreakPointHitEvent;
FWorkingDir: String; FWorkingDir: String;
FDestroyNotificationList: array [TDebuggerNotifyReason] of TMethodList;
procedure DebuggerEnvironmentChanged(Sender: TObject); procedure DebuggerEnvironmentChanged(Sender: TObject);
procedure EnvironmentChanged(Sender: TObject); procedure EnvironmentChanged(Sender: TObject);
function GetState: TDBGState; function GetState: TDBGState;
@ -1534,6 +1537,8 @@ type
out ADump, AStatement, AFile: String; out ALine: Integer): Boolean; deprecated; out ADump, AStatement, AFile: String; out ALine: Integer): Boolean; deprecated;
procedure LockCommandProcessing; virtual; procedure LockCommandProcessing; virtual;
procedure UnLockCommandProcessing; virtual; procedure UnLockCommandProcessing; virtual;
procedure AddNotifyEvent(AReason: TDebuggerNotifyReason; AnEvent: TNotifyEvent);
procedure RemoveNotifyEvent(AReason: TDebuggerNotifyReason; AnEvent: TNotifyEvent);
public public
property Arguments: String read FArguments write FArguments; // Arguments feed to the program property Arguments: String read FArguments write FArguments; // Arguments feed to the program
property BreakPoints: TDBGBreakPoints read FBreakPoints; // list of all breakpoints property BreakPoints: TDBGBreakPoints read FBreakPoints; // list of all breakpoints
@ -1729,8 +1734,11 @@ end;
constructor TDebugger.Create(const AExternalDebugger: String); constructor TDebugger.Create(const AExternalDebugger: String);
var var
list: TStringList; list: TStringList;
nr: TDebuggerNotifyReason;
begin begin
inherited Create; inherited Create;
for nr := low(TDebuggerNotifyReason) to high(TDebuggerNotifyReason) do
FDestroyNotificationList[nr] := TMethodList.Create;
FOnState := nil; FOnState := nil;
FOnCurrent := nil; FOnCurrent := nil;
FOnOutput := nil; FOnOutput := nil;
@ -1820,7 +1828,12 @@ begin
end; end;
destructor TDebugger.Destroy; destructor TDebugger.Destroy;
var
nr: TDebuggerNotifyReason;
begin begin
FDestroyNotificationList[dnrDestroy].CallNotifyEvents(Self);
for nr := low(TDebuggerNotifyReason) to high(TDebuggerNotifyReason) do
FreeAndNil(FDestroyNotificationList[nr]);
// don't call events // don't call events
FOnState := nil; FOnState := nil;
FOnCurrent := nil; FOnCurrent := nil;
@ -1868,6 +1881,16 @@ begin
// nothing // nothing
end; end;
procedure TDebugger.AddNotifyEvent(AReason: TDebuggerNotifyReason; AnEvent: TNotifyEvent);
begin
FDestroyNotificationList[AReason].Add(TMethod(AnEvent));
end;
procedure TDebugger.RemoveNotifyEvent(AReason: TDebuggerNotifyReason; AnEvent: TNotifyEvent);
begin
FDestroyNotificationList[AReason].Remove(TMethod(AnEvent));
end;
procedure TDebugger.Done; procedure TDebugger.Done;
begin begin
SetState(dsNone); SetState(dsNone);