This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

[RFC] handle signal passing to debuggee for win32 native target.



The following patch handles (to the best of what 
I discovered can be done) the passing of signals
to the inferior for native win32 targets.

Known limitation:
  -- 
   The main problem is that this will only partially work because of a known bug
in the win32 API:

Extracted from
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0898/bugslayer0898.htm&nav=/msj/0898/newnav.htm

There are a couple of issues to remember when using SetUnhandledExceptionFilter. 
The first is that any exception filter that you set cannot be debugged. This is a known bug. 
Knowledge Base article Q173652 says that under a debugger the process wide filter is not called. 
This can be a bit of a pain, but in a C++ program you can just use your function in a regular SEH exception 
filter to debug it. If you look at the CH_TEST.CPP test program, which is part of this month's source code 
(Aug98Bugslayer.exe ), this is exactly what I did to debug it. 
An alternative is to use a kernel debugger like WinDBG to get around this limitation.

But I don't really know if Cygwin library uses SetUnhandledExceptionFilter
(I suspect it does as my patch does not work as intended...).

The other problem seems to be that changes to the ExceptionRecord structure in the current_event
do not seem to be reflected when the exception is passed to the debuggee.
(See the disabled code in the patch for child_resume). Passing another signal value 
then the one generated does not seem possible.

Simple test program to check the changes:

 >>>>test.c begin
int x;
int * y;
int
main ()
{
   (int) y = 0xfffffff0;
   x = 56;
   *y = x;
   return 0;
}
 >>>>test.c end
gcc -g -o test.exe test.c
Use the newly build gdb (with the patch below applied)
./gdb ./test
(gdb)run
(gdb)cont
 > You should get a stackdump due to an SIGSEGV signal.
(gdb)run 
(gdb)handle SIGSEGV nopass
(gdb)cont
 > You should get a second SIGSEGV report
but if you check the assembler instruction
(gdb) x /i $eip
it should give you something like 
(gdb) mov %edx,(%eax)
with $eax containing 0xfffffff0
if you change the value of $eax to &x
you should be able to finish the program without any error.




2002-02-05  Pierre Muller  <muller@ics.u-strasbg.fr>
	win32-nat.c (last_sig): Changed type of variable to target_signal,
	to allow easier handling of pass state.
	(DEBUG_EXCEPTION_SIMPLE): New macro, used in handle_exception,
	that gives exception name and address.
	(handle_exception): Use DEBUG_EXCEPTION_SIMPLE macro
	and set last_sig value to ourstatus->value.sig. Some missing 
	exceptions added.
	(child_continue): Correctly report continue_status.	
	(get_child_debug_event,do_initial_child_stuff): Set last_sig to 
	TARGET_SIGNAL_0 (new default value).
	(child_resume): consider sig argument passed to decide if 
	the exception should be passed to debuggee or not.

Attachment: win32-nat.diffs
Description: Text document



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99

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