/main.cpp (dca90112a35353b07bef4d7831231bbd419f2b63) (1224 bytes) (mode 100644) (type blob)
#include <iostream>
#include <unistd.h>
#include <signal.h>
void setHandler(void (*handler)(int,siginfo_t *,void *)) {
struct sigaction action;
action.sa_flags = SA_SIGINFO;
action.sa_sigaction = handler;
if (sigaction(SIGFPE, &action, NULL) == -1) {
std::cerr << "sigfpe: sigaction";
_exit(1);
}
if (sigaction(SIGSEGV, &action, NULL) == -1) {
std::cerr << "sigsegv: sigaction";
_exit(1);
}
if (sigaction(SIGILL, &action, NULL) == -1) {
std::cerr << "sigill: sigaction";
_exit(1);
}
if (sigaction(SIGBUS, &action, NULL) == -1) {
std::cerr << "sigbus: sigaction";
_exit(1);
}
}
void faultHandler(int signo, siginfo_t* info, void* extra) {
int i;
#ifdef __x86_64__
i = ((ucontext_t*)extra)->uc_mcontext.gregs[REG_RIP];
#elif __arm__
i = ((ucontext_t*)extra)->uc_mcontext.arm_pc;
#else
#error Compiling for invalid architecture.
#endif
std::cout << "Fout " << (int)signo << " at ";
std::cout << (int&)info->si_addr << ": " << std::endl;
std::cout << "Called from " << (int)i << "." << std::endl;
std::cout << "Compiled at: " << __DATE__ << " " << __TIME__ << std::endl;
abort();
}
int main() {
int* badptr = nullptr;
setHandler(faultHandler);
*badptr = 15;
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
35 |
01db9050b22128aa65021833d1ed5117a99fa651 |
.gitignore |
100644 |
blob |
528 |
6cb613dc437b68d983291ecee281b1116c31119c |
README.md |
100644 |
blob |
1224 |
dca90112a35353b07bef4d7831231bbd419f2b63 |
main.cpp |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/Post-mortem-debugging
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/Post-mortem-debugging
Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/Post-mortem-debugging
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main