procedure e_LogWriteln (const s: AnsiString; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
+procedure e_WriteStackTrace (const msg: AnsiString);
+
+
var
e_WriteToStdOut: Boolean = False;
end;
+{$I-}
+procedure e_WriteStackTrace (const msg: AnsiString);
+var
+ tfo: TextFile;
+begin
+ e_LogWriteln(msg, MSG_FATALERROR);
+ if (Length(FileName) > 0) then
+ begin
+ if xlogFileOpened then CloseFile(xlogFile);
+ xlogFileOpened := false;
+ AssignFile(tfo, FileName);
+ Append(tfo);
+ if (IOResult <> 0) then Rewrite(tfo);
+ if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
+ end;
+end;
+
+
procedure e_DeinitLog ();
begin
if xlogFileOpened then CloseFile(xlogFile);
var
f: Integer;
noct: Boolean = false;
+ tfo: Text;
begin
for f := 1 to ParamCount do
begin
Main();
e_WriteLog('Shutdown with no errors.', MSG_NOTIFY);
except
- on E: Exception do
- e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
+ on e: Exception do
+ begin
+ e_WriteStackTrace(e.message);
+ //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
+ AssignFile(tfo, GameDir+'/trace.log');
+ {$I-}
+ Append(tfo);
+ if (IOResult <> 0) then Rewrite(tfo);
+ if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
+ end
else
- e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
+ begin
+ //e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
+ e_WriteStackTrace('FATAL ERROR');
+ end;
end;
end;
e_DeinitLog();
cp.cheat := acheat;
end;
+
+procedure segfault (p: SArray);
+var
+ pp: PByte = nil;
+begin
+ pp^ := 0;
+end;
+
+
procedure g_Console_Init();
var
a: Integer;
Time := 0;
end;
+ AddCommand('segfault', segfault, 'make segfault');
+
AddCommand('clear', ConsoleCommands, 'clear console');
AddCommand('clearhistory', ConsoleCommands);
AddCommand('showhistory', ConsoleCommands);
g_Console_Add(Format(_lc[I_CONSOLE_UNKNOWN], [Arr[0]]));
end;
+
end.