This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bypassing cygwin's signal handling


Dear List,

   In a system I'm writing I need to catch page faults and find out 
the fault address and the fault type (read or write).  On most unices 
I can get this information inside a sigaction handler.  
E.g. on Linux, something like this works:

==========================================================
  void fault_handler(int sig, siginfo_t * info, void * uap)
  {  
     vm_addr_t    addr; 
     VM::access_t access;

     /* fault address */
     addr = (vm_addr_t)info->si_addr;
     /* 1 for write; 0 for read */
     access = (VM::access_t)
               ((((ucontext_t *)uap)->uc_mcontext.gregs[13] & 0x2) != 0);
     ...
  }
==========================================================

However, cygwin's signal handling mechanism doesn't propagate these 
information to the signal handler.  On mingw, I can use window's API
to get the info I need:

==========================================================
LONG WINAPI fault_handler(LPEXCEPTION_POINTERS info)
{
   vm_addr_t    addr;
   VM::access_t access;

   if (info->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
      return EXCEPTION_CONTINUE_SEARCH;

   access = (VM::access_t)info->ExceptionRecord->ExceptionInformation[0];
   addr   = (vm_addr_t)info->ExceptionRecord->ExceptionInformation[1];

   ...
}

 SetUnhandledExceptionFilter(fault_handler);
==========================================================

However, this doesn't work on cygwin because apparently cygwin is
overriding my own fault handler.  So I'm wondering: how can I bypass 
cygwin's signal handling mechanism so that I get hold of the page fault 
information?  

Thanks,
Allen

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]