diff --git a/.gitignore b/.gitignore index 91497de..84e79bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.fsu *.root +core.FSUDAQ* FSUDAQ_Qt6 test diff --git a/README.md b/README.md index 3bb01f4..aa95aaa 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,23 @@ if you want to use GDB debugger, in the *.pro file add There is a folder Aux, this folder contains many auxillary programs, such as EventBuilder. User can `make` under the folder to compile the programs. +# Enable Core dump + +The program has abort handler to save core dump. + +first, enable the gdb in compilation by edit the FSUDAQ_Qt6.pro by commen out the following lines: +```sh +QMAKE_CXXFLAGS += -g +QMAKE_CXXFLAGS_RELEASE = -O0 +QMAKE_CFLAGS_RELEASE = -O0 +``` + +second, ensure the core dump file has unlimited size and set the core dump file name +```sh +>ulimit -c unlimited +>echo "core.%e.%p" | sudo tee /proc/sys/kernel/core_pattern +``` + # Known Issues diff --git a/main.cpp b/main.cpp index 22e28cb..e096e98 100644 --- a/main.cpp +++ b/main.cpp @@ -12,26 +12,28 @@ #include -// class CustomApplication : public QApplication{ -// public: -// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {} +#include +#include +#include -// protected: -// bool notify(QObject *receiver, QEvent *event) override{ -// qDebug() << event->type() << "Receiver:" << receiver; -// return QApplication::notify(receiver, event); -// } -// }; +void abortHandler(int signal) { + std::cerr << "Signal received: " << signal << ", aborting..." << std::endl; + std::abort(); // Calls abort to generate core dump +} int main(int argc, char *argv[]){ + std::signal(SIGSEGV, abortHandler); + + setpriority(PRIO_PROCESS, 0, -20); + // CustomApplication a(argc, argv); QApplication a(argc, argv); + // Set Locale QLocale::setDefault(QLocale::system()); - setpriority(PRIO_PROCESS, 0, -20); - + // Set Lock file bool isLock = false; int pid = 0; QFile lockFile(DAQLockFile);