OpenTTD Source 20241224-master-gee860a5c8e
crashlog_unix.cpp File Reference

Unix crash log handler. More...

#include "../../stdafx.h"
#include "../../crashlog.h"
#include "../../fileio_func.h"
#include "../../string_func.h"
#include "../../gamelog.h"
#include "../../saveload/saveload.h"
#include <setjmp.h>
#include <signal.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "../../safeguards.h"

Go to the source code of this file.

Data Structures

class  CrashLogUnix
 Unix implementation for the crash logger. More...
 

Functions

static sigset_t SetSignals (void(*handler)(int))
 Set a signal handler for all signals we want to capture.
 
static void CDECL HandleInternalCrash (int signum)
 Entry point for a crash that happened during the handling of a crash.
 
static void CDECL HandleCrash (int signum)
 Entry point for the crash handler.
 

Variables

static constexpr int _signals_to_handle [] = { SIGSEGV, SIGABRT, SIGFPE, SIGBUS, SIGILL, SIGQUIT }
 The signals we want our crash handler to handle.
 

Detailed Description

Unix crash log handler.

Definition in file crashlog_unix.cpp.

Function Documentation

◆ HandleCrash()

static void CDECL HandleCrash ( int  signum)
static

Entry point for the crash handler.

Parameters
signumthe signal that caused us to crash.

Definition at line 184 of file crashlog_unix.cpp.

References _gamelog, CrashLog::AfterCrashLogCleanup(), CrashLogUnix::current, HandleInternalCrash(), CrashLog::MakeCrashLog(), SaveloadCrashWithMissingNewGRFs(), SetSignals(), and Gamelog::TestEmergency().

◆ HandleInternalCrash()

static void CDECL HandleInternalCrash ( int  signum)
static

Entry point for a crash that happened during the handling of a crash.

Parameters
signumthe signal that caused us to crash.

Definition at line 169 of file crashlog_unix.cpp.

References CrashLogUnix::current.

Referenced by HandleCrash().

◆ SetSignals()

static sigset_t SetSignals ( void(*)(int)  handler)
static

Set a signal handler for all signals we want to capture.

Parameters
handlerThe handler to use.
Returns
sigset_t A sigset_t containing all signals we want to capture.

Definition at line 141 of file crashlog_unix.cpp.

References _signals_to_handle.

Referenced by HandleCrash().

Variable Documentation

◆ _signals_to_handle

constexpr int _signals_to_handle[] = { SIGSEGV, SIGABRT, SIGFPE, SIGBUS, SIGILL, SIGQUIT }
staticconstexpr

The signals we want our crash handler to handle.

Definition at line 41 of file crashlog_unix.cpp.

Referenced by SetSignals(), and CrashLogUnix::TryExecute().