delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/03/17:44:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 3 Oct 2002 17:45:09 -0400
From: Allen Leung <allen DOT leung AT aleri DOT com>
To: cygwin AT cygwin DOT com
Subject: Bypassing cygwin's signal handling
Message-ID: <20021003174509.A24847@aleri.com>
Reply-To: allen DOT leung AT aleri DOT com
Mime-Version: 1.0
User-Agent: Mutt/1.2.5.1i

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019