Index: win32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/win32-nat.c,v retrieving revision 1.26 diff -u -p -2 -r1.26 win32-nat.c --- win32-nat.c 2001/03/18 21:35:58 1.26 +++ win32-nat.c 2001/04/24 06:33:26 @@ -95,4 +95,6 @@ typedef struct thread_info_struct int suspend_count; CONTEXT context; + int exception_context_present; + CONTEXT exception_context; STACKFRAME sf; } @@ -106,4 +108,5 @@ static DEBUG_EVENT current_event; /* The WaitForDebugEvent */ static HANDLE current_process_handle; /* Currently executing process */ +static DWORD current_process_id; /* Currently executing process id */ static thread_info *current_thread; /* Info on currently selected thread */ static DWORD main_thread_id; /* Thread ID of the main thread */ @@ -219,4 +222,11 @@ thread_rec (DWORD id, int get_context) } +static CONTEXT * +get_thread_context (thread_info* th) +{ + return (th->exception_context_present ? + &th->exception_context : &th->context); +} + /* Add a thread to the thread list */ static thread_info * @@ -290,5 +300,6 @@ static void do_child_fetch_inferior_registers (int r) { - char *context_offset = ((char *) ¤t_thread->context) + mappings[r]; + char *context_offset = ((char *) get_thread_context (current_thread)) + + mappings[r]; long l; if (r == FCS_REGNUM) @@ -322,5 +333,5 @@ do_child_store_inferior_registers (int r { if (r >= 0) - read_register_gen (r, ((char *) ¤t_thread->context) + mappings[r]); + read_register_gen (r, ((char *) get_thread_context (current_thread)) + mappings[r]); else { @@ -689,4 +700,41 @@ info_dll_command (char *ignore ATTRIBUTE } +static int +get_exception_context_info (DWORD pid) +{ + int ret_val = 0; + thread_info* th; + char share_name [64]; + HANDLE share_h = NULL; + struct debugger_info* share_ptr; + + sprintf (share_name, "cygwin_debugger_share%ld", pid); + share_h = OpenFileMapping (FILE_MAP_READ, FALSE, share_name); + if (!share_h) + goto out; + + share_ptr = (struct debugger_info*) MapViewOfFile (share_h, + FILE_MAP_READ, + 0, 0, + sizeof (struct debugger_info)); + if (!share_ptr) + goto out; + + if (!(th = thread_rec (share_ptr->exception_thread_id, 0))) + goto out; + + th->exception_context_present = 1; + memmove (&(th->exception_context), + &share_ptr->exception_context, + sizeof (th->exception_context)); + ret_val = 1; + +out: + if (share_h) + CloseHandle (share_h); + + return ret_val; +} + /* Handle DEBUG_STRING output from child process. Cygwin prepends its messages with a "cygwin:". Interpret this as @@ -745,5 +793,5 @@ handle_exception (struct target_waitstat case STATUS_FLOAT_OVERFLOW: case STATUS_INTEGER_DIVIDE_BY_ZERO: - DEBUG_EXCEPT (("gdb: Target exception STACK_OVERFLOW at 0x%08lx\n", + DEBUG_EXCEPT (("gdb: Target exception DIVIDE_OVERFLOW at 0x%08lx\n", (DWORD) current_event.u.Exception.ExceptionRecord.ExceptionAddress)); ourstatus->value.sig = TARGET_SIGNAL_FPE; @@ -869,4 +917,5 @@ get_child_debug_event (int pid ATTRIBUTE "CREATE_PROCESS_DEBUG_EVENT")); current_process_handle = current_event.u.CreateProcessInfo.hProcess; + current_process_id = current_event.dwProcessId; main_thread_id = current_event.dwThreadId; @@ -916,4 +965,5 @@ get_child_debug_event (int pid ATTRIBUTE (unsigned) current_event.dwThreadId, "EXCEPTION_DEBUG_EVENT")); + get_exception_context_info (current_process_id); handle_exception (ourstatus); retval = current_event.dwThreadId;