Admitting Ignorance (AI)

I have to admit after researching "-ansi -D_GNU_SOURCE" and the definition "REG_RIP" and some searching through many headers, and dependencies, I still don't get it. It works, it works consistently, is does not fault. However, I have no sense of the complete picture. I have become entangled by the IFS, IFDEFS, #if defined, #if else, whiles and fors. I think I understand it and I hope that it will become clear the next time I visit this code, but as it sits, I wouldn't sign a statement that it would continue to work tomorrow. It works like I think it should, and I did write an extension to this code. The problem is that I am flying blind. I don't have a sense of the complete operation and I just code and then burn some incense, then chant OM, and then I spit over my left shoulder and compile. If it doesn't warn, I use it.

#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64) # if defined(SIGSEGV_STACK_IA64) ip = (void*)ucontext->uc_mcontext.gregs[REG_RIP]; bp = (void**)ucontext->uc_mcontext.gregs[REG_RBP]; # elif defined(SIGSEGV_STACK_X86) ip = (void*)ucontext->uc_mcontext.gregs[REG_EIP]; bp = (void**)ucontext->uc_mcontext.gregs[REG_EBP]; # endif fprintf(stderr, "Stack trace:\n"); while(bp && ip) { if(!dladdr(ip, &dlinfo)){break;} symname = dlinfo.dli_sname; fprintf(stderr, "% 2d: %p <%s+%u> (%s)\n",++f,ip ,symname ,(unsigned int)((long unsigned int)ip - (long unsigned int)dlinfo.dli_saddr) ,dlinfo.dli_fname); if(dlinfo.dli_sname && !strcmp(dlinfo.dli_sname, "main")){break;} ip = bp[1]; bp = (void**)bp[0]; } #ifdef EXTENSIVE2 sz = backtrace(bt, 20); strings = backtrace_symbols(bt, sz); for (i=0; i < sz; i++) { if ( bt[i] < (void *)0x420000 && bt[i] > (void *)0x400000) { sprintf(syscom,"addr2line %p -f -e solver",bt[i]); system(syscom);} } #endif

0 comments:

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen