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
|
||||
*.fsu
|
||||
*.root
|
||||
core.FSUDAQ*
|
||||
|
||||
FSUDAQ_Qt6
|
||||
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.
|
||||
|
||||
# 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
|
||||
|
||||
|
|
24
main.cpp
24
main.cpp
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user