Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Add compile info at runtime error. Determine appropiate code for architecture when compiling. | 41baa10ac827df8efb3040c2b82197053d6b43c0 | Jan Allersma | 2018-05-22 12:15:18 |
Remove redundant variables and header includes. | fb31483b36a5f9e249d8fa88f0c3ff66b1fce6cd | Jan Allersma | 2018-05-22 11:40:35 |
Initial commit. | 86c80da5a6a677f1686e50996b61fd51632259ba | Jan Allersma | 2018-05-18 13:12:38 |
File | Lines added | Lines deleted |
---|---|---|
README.md | 1 | 0 |
main.cpp | 8 | 2 |
File README.md changed (mode: 100644) (index 4945c5f..6cb613d) | |||
... | ... | Running `./exe` results in this output: | |
16 | 16 | ``` | ``` |
17 | 17 | Fout 11 at 0: | Fout 11 at 0: |
18 | 18 | Called from 4197438. | Called from 4197438. |
19 | Compiled at: May 22 2018 13:58:27 | ||
19 | 20 | Aborted (geheugendump gemaakt) | Aborted (geheugendump gemaakt) |
20 | 21 | ``` | ``` |
21 | 22 |
File main.cpp changed (mode: 100644) (index f8b1b20..dca9011) | |||
... | ... | void setHandler(void (*handler)(int,siginfo_t *,void *)) { | |
29 | 29 | void faultHandler(int signo, siginfo_t* info, void* extra) { | void faultHandler(int signo, siginfo_t* info, void* extra) { |
30 | 30 | int i; | int i; |
31 | 31 | ||
32 | i = ((ucontext_t*)extra)->uc_mcontext.gregs[REG_RIP]; // x86_64 | ||
33 | //i = ((ucontext_t*)extra)->uc_mcontext.arm_pc; // ARM | ||
32 | #ifdef __x86_64__ | ||
33 | i = ((ucontext_t*)extra)->uc_mcontext.gregs[REG_RIP]; | ||
34 | #elif __arm__ | ||
35 | i = ((ucontext_t*)extra)->uc_mcontext.arm_pc; | ||
36 | #else | ||
37 | #error Compiling for invalid architecture. | ||
38 | #endif | ||
34 | 39 | ||
35 | 40 | std::cout << "Fout " << (int)signo << " at "; | std::cout << "Fout " << (int)signo << " at "; |
36 | 41 | std::cout << (int&)info->si_addr << ": " << std::endl; | std::cout << (int&)info->si_addr << ": " << std::endl; |
37 | 42 | std::cout << "Called from " << (int)i << "." << std::endl; | std::cout << "Called from " << (int)i << "." << std::endl; |
43 | std::cout << "Compiled at: " << __DATE__ << " " << __TIME__ << std::endl; | ||
38 | 44 | ||
39 | 45 | abort(); | abort(); |
40 | 46 | } | } |