add core dump when segfault
This commit is contained in:
parent
968259787b
commit
b3692705ab
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
*.o
|
*.o
|
||||||
*.fsu
|
*.fsu
|
||||||
*.root
|
*.root
|
||||||
|
core.FSUDAQ*
|
||||||
|
|
||||||
FSUDAQ_Qt6
|
FSUDAQ_Qt6
|
||||||
test
|
test
|
||||||
|
|
17
README.md
17
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.
|
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
|
# Known Issues
|
||||||
|
|
||||||
|
|
24
main.cpp
24
main.cpp
|
@ -12,26 +12,28 @@
|
||||||
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
// class CustomApplication : public QApplication{
|
#include <csignal>
|
||||||
// public:
|
#include <cstdlib>
|
||||||
// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {}
|
#include <iostream>
|
||||||
|
|
||||||
// protected:
|
void abortHandler(int signal) {
|
||||||
// bool notify(QObject *receiver, QEvent *event) override{
|
std::cerr << "Signal received: " << signal << ", aborting..." << std::endl;
|
||||||
// qDebug() << event->type() << "Receiver:" << receiver;
|
std::abort(); // Calls abort to generate core dump
|
||||||
// return QApplication::notify(receiver, event);
|
}
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
|
std::signal(SIGSEGV, abortHandler);
|
||||||
|
|
||||||
|
setpriority(PRIO_PROCESS, 0, -20);
|
||||||
|
|
||||||
// CustomApplication a(argc, argv);
|
// CustomApplication a(argc, argv);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
// Set Locale
|
||||||
QLocale::setDefault(QLocale::system());
|
QLocale::setDefault(QLocale::system());
|
||||||
|
|
||||||
setpriority(PRIO_PROCESS, 0, -20);
|
// Set Lock file
|
||||||
|
|
||||||
bool isLock = false;
|
bool isLock = false;
|
||||||
int pid = 0;
|
int pid = 0;
|
||||||
QFile lockFile(DAQLockFile);
|
QFile lockFile(DAQLockFile);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user