add core dump when segfault

This commit is contained in:
Ryan Tang 2024-09-09 14:00:43 -04:00
parent 968259787b
commit b3692705ab
3 changed files with 31 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.o
*.fsu
*.root
core.FSUDAQ*
FSUDAQ_Qt6
test

View File

@ -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

View File

@ -12,26 +12,28 @@
#include <sys/resource.h>
// class CustomApplication : public QApplication{
// public:
// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {}
#include <csignal>
#include <cstdlib>
#include <iostream>
// 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);