Dbg: Fix a race condition, nil pointer access

git-svn-id: trunk@32390 -
This commit is contained in:
martin 2011-09-17 17:43:15 +00:00
parent 7e8d161edb
commit 77825e7849

View File

@ -10042,6 +10042,9 @@ end;
procedure TGDBMIDebuggerCommandEvaluate.DoWatchFreed(Sender: TObject); procedure TGDBMIDebuggerCommandEvaluate.DoWatchFreed(Sender: TObject);
begin begin
{$IFDEF DBGMI_QUEUE_DEBUG}
debugln(['DoWatchFreed: ', DebugText]);
{$ENDIF}
FWatchValue := nil; FWatchValue := nil;
Cancel; Cancel;
end; end;
@ -11233,24 +11236,27 @@ end;
function TGDBMIDebuggerCommandEvaluate.SelectContext: Boolean; function TGDBMIDebuggerCommandEvaluate.SelectContext: Boolean;
var var
R: TGDBMIExecResult; R: TGDBMIExecResult;
t, f: Integer;
begin begin
Result := True; Result := True;
FThreadChanged := False; FThreadChanged := False;
FStackFrameChanged := False; FStackFrameChanged := False;
if FWatchValue = nil then exit; if FWatchValue = nil then exit;
t := FWatchValue.ThreadId;
f := FWatchValue.StackFrame;
if FWatchValue.ThreadId <> FTheDebugger.FCurrentThreadId then begin if t <> FTheDebugger.FCurrentThreadId then begin
FThreadChanged := True; FThreadChanged := True;
Result := ExecuteCommand('-thread-select %d', [FWatchValue.ThreadId], R); Result := ExecuteCommand('-thread-select %d', [t], R);
FTheDebugger.FInternalThreadId := FWatchValue.ThreadId; FTheDebugger.FInternalThreadId := t;
Result := Result and (R.State <> dsError); Result := Result and (R.State <> dsError);
end; end;
if not Result then exit; if not Result then exit;
if (FWatchValue.StackFrame <> FTheDebugger.FCurrentStackFrame) or FThreadChanged then begin if (f <> FTheDebugger.FCurrentStackFrame) or FThreadChanged then begin
FStackFrameChanged := True; FStackFrameChanged := True;
Result := ExecuteCommand('-stack-select-frame %d', [FWatchValue.StackFrame], R); Result := ExecuteCommand('-stack-select-frame %d', [f], R);
FTheDebugger.FInternalStackFrame := FWatchValue.StackFrame; FTheDebugger.FInternalStackFrame := f;
Result := Result and (R.State <> dsError); Result := Result and (R.State <> dsError);
end; end;
end; end;