GDBMI Debugger: Added work around for wrong stackframe when assert is triggered. Issue #0029959

git-svn-id: trunk@58283 -
This commit is contained in:
martin 2018-06-15 19:23:52 +00:00
parent ff1d04d947
commit 018bda7a2f
3 changed files with 20 additions and 0 deletions

View File

@ -165,6 +165,7 @@ type
FDisableStartupShell: Boolean;
FEncodeCurrentDirPath: TGDBMIDebuggerFilenameEncoding;
FEncodeExeFileName: TGDBMIDebuggerFilenameEncoding;
FFixStackFrameForFpcAssert: Boolean;
FGdbLocalsValueMemLimit: Integer;
{$IFDEF UNIX}
FConsoleTty: String;
@ -224,6 +225,8 @@ type
property AssemblerStyle: TGDBMIDebuggerAssemblerStyle read FAssemblerStyle write FAssemblerStyle default gdasDefault;
property DisableStartupShell: Boolean read FDisableStartupShell
write FDisableStartupShell default False;
property FixStackFrameForFpcAssert: Boolean read FFixStackFrameForFpcAssert
write FFixStackFrameForFpcAssert default True;
end;
TGDBMIDebuggerProperties = class(TGDBMIDebuggerPropertiesBase)
@ -251,6 +254,7 @@ type
property GdbLocalsValueMemLimit;
property AssemblerStyle;
property DisableStartupShell;
property FixStackFrameForFpcAssert;
end;
TGDBMIDebugger = class;
@ -5536,6 +5540,7 @@ function TGDBMIDebuggerCommandExecute.ProcessStopped(const AParams: String;
S: String;
FP: TDBGPtr;
i, cnt: longint;
Frame: TGDBMINameValueList;
begin
FTheDebugger.QueueExecuteLock;
try
@ -5561,6 +5566,17 @@ function TGDBMIDebuggerCommandExecute.ProcessStopped(const AParams: String;
DebugLn(DBG_THREAD_AND_FRAME, ['ProcessStopped GetLocation found fp Stack(Internal) = ', FTheDebugger.FCurrentStackFrame]);
end;
if (FTheDebugger.FCurrentStackFrame > 3) and // must be 2 below fpc_assert, and that again must be below raise_except
TGDBMIDebuggerPropertiesBase(FTheDebugger.GetProperties).FixStackFrameForFpcAssert then begin
s := GetFrame(FTheDebugger.FCurrentStackFrame - 2);
if s <> '' then begin
Frame := TGDBMINameValueList.Create(S);
if Frame.Values['func'] = 'fpc_assert' then
FTheDebugger.FCurrentStackFrame := FTheDebugger.FCurrentStackFrame - 1;
Frame.Free;
end;
end;
if FTheDebugger.FCurrentStackFrame <> 0
then begin
// This frame should have all the info we need
@ -7341,6 +7357,7 @@ begin
FGdbLocalsValueMemLimit := 32000;
FAssemblerStyle := gdasDefault;
FDisableStartupShell := False;
FFixStackFrameForFpcAssert := True;
inherited;
end;
@ -7370,6 +7387,7 @@ begin
FGdbLocalsValueMemLimit := TGDBMIDebuggerPropertiesBase(Source).FGdbLocalsValueMemLimit;
FAssemblerStyle := TGDBMIDebuggerPropertiesBase(Source).FAssemblerStyle;
FDisableStartupShell := TGDBMIDebuggerPropertiesBase(Source).FDisableStartupShell;
FFixStackFrameForFpcAssert := TGDBMIDebuggerPropertiesBase(Source).FFixStackFrameForFpcAssert;
end;

View File

@ -84,6 +84,7 @@ type
property GdbLocalsValueMemLimit;
property AssemblerStyle;
property DisableStartupShell;
property FixStackFrameForFpcAssert;
end;
procedure Register;

View File

@ -98,6 +98,7 @@ type
property GdbLocalsValueMemLimit;
property AssemblerStyle;
property DisableStartupShell;
property FixStackFrameForFpcAssert;
end;
procedure Register;