diff --git a/lcl/forms.pp b/lcl/forms.pp index 0f324ff091..f0f7bcb2cc 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -1584,6 +1584,7 @@ Begin DebugLn('[FORMS.PP] ExceptionOccurred '); if HaltingProgram or HandlingException then Halt; HandlingException:=true; + {$ifdef DEBUG_ALLOW_DUMPBACKTRACE} if Sender<>nil then begin DebugLn(' Sender=',Sender.ClassName); if Sender is Exception then begin @@ -1595,6 +1596,7 @@ Begin end; end else DebugLn(' Sender=nil'); + {$endif} if Application<>nil then Application.HandleException(Sender); HandlingException:=false; diff --git a/lcl/include/application.inc b/lcl/include/application.inc index 91ed0fc89d..14ec5540fc 100644 --- a/lcl/include/application.inc +++ b/lcl/include/application.inc @@ -1073,7 +1073,9 @@ begin DebugLn('TApplication.HandleException: ', 'there was another exception during showing the first exception'); HaltingProgram:=true; + {$ifdef DEBUG_ALLOW_DUMPBACKTRACE} DumpExceptionBackTrace; + {$endif} Halt; end; Include(FFlags,AppHandlingException); @@ -1083,6 +1085,7 @@ begin Skip := ExceptObject is EAbort; + {$ifdef DEBUG_ALLOW_DUMPBACKTRACE} if not (AppNoExceptionMessages in FFlags) then begin // before we do anything, write it down @@ -1099,6 +1102,7 @@ begin DumpExceptionBackTrace; end; end; + {$endif} // release capture and hide all forms with stay on top, so that // a message can be shown if GetCapture <> 0 then SendMessage(GetCapture, LM_CANCELMODE, 0, 0); diff --git a/lcl/lclproc.pas b/lcl/lclproc.pas index 498331414c..bf785ff6fa 100644 --- a/lcl/lclproc.pas +++ b/lcl/lclproc.pas @@ -183,7 +183,9 @@ function StrToDouble(const s: string): double; // debugging procedure RaiseGDBException(const Msg: string); +{$ifdef DEBUG_ALLOW_DUMPBACKTRACE} procedure DumpExceptionBackTrace; +{$endif} procedure DumpStack; function GetStackTrace(UseCache: boolean): string; procedure GetStackTracePointers(var AStack: TStackTracePointers); @@ -1504,6 +1506,7 @@ begin if (length(Msg) div (length(Msg) div 10000))=0 then ; end; +{$ifdef DEBUG_ALLOW_DUMPBACKTRACE} procedure DumpExceptionBackTrace; var FrameCount: integer; @@ -1517,6 +1520,7 @@ begin for FrameNumber := 0 to FrameCount-1 do DebugLn(BackTraceStrFunc(Frames[FrameNumber])); end; +{$endif} procedure DumpStack; begin diff --git a/lcl/translations.pas b/lcl/translations.pas index d10d0cecba..e0cbe93054 100644 --- a/lcl/translations.pas +++ b/lcl/translations.pas @@ -404,11 +404,13 @@ begin {$endif ver2_0} Result:=true; except + {$ifdef DEBUG_ALLOW_DUMPBACKTRACE} on e: Exception do begin DebugLn('Exception while translating ', ResUnitName); DebugLn(e.Message); DumpExceptionBackTrace; end; + {$endif} end; end;