1 /* Low level interface to Windows debugging, for gdbserver.
2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
4 Contributed by Leo Zayas. Based on "win32-nat.c" from GDB.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "gdb/signals.h"
24 #include "mem-break.h"
25 #include "win32-low.h"
32 #include <sys/param.h>
37 #include <sys/cygwin.h>
42 #define OUTMSG(X) do { printf X; fflush (stdout); } while (0)
44 #define OUTMSG2(X) do { printf X; fflush (stdout); } while (0)
46 #define OUTMSG2(X) do ; while (0)
50 #define _T(x) TEXT (x)
54 #define COUNTOF(STR) (sizeof (STR) / sizeof ((STR)[0]))
58 # define GETPROCADDRESS(DLL, PROC) \
59 ((winapi_ ## PROC) GetProcAddress (DLL, TEXT (#PROC)))
61 # define GETPROCADDRESS(DLL, PROC) \
62 ((winapi_ ## PROC) GetProcAddress (DLL, #PROC))
65 int using_threads
= 1;
68 static int attaching
= 0;
69 static HANDLE current_process_handle
= NULL
;
70 static DWORD current_process_id
= 0;
71 static enum target_signal last_sig
= TARGET_SIGNAL_0
;
73 /* The current debug event from WaitForDebugEvent. */
74 static DEBUG_EVENT current_event
;
76 /* Non zero if an interrupt request is to be satisfied by suspending
78 static int soft_interrupt_requested
= 0;
80 /* Non zero if the inferior is stopped in a simulated breakpoint done
81 by suspending all the threads. */
82 static int faked_breakpoint
= 0;
84 #define NUM_REGS (the_low_target.num_regs)
86 typedef BOOL
WINAPI (*winapi_DebugActiveProcessStop
) (DWORD dwProcessId
);
87 typedef BOOL
WINAPI (*winapi_DebugSetProcessKillOnExit
) (BOOL KillOnExit
);
88 typedef BOOL
WINAPI (*winapi_DebugBreakProcess
) (HANDLE
);
89 typedef BOOL
WINAPI (*winapi_GenerateConsoleCtrlEvent
) (DWORD
, DWORD
);
91 static DWORD main_thread_id
= 0;
93 static void win32_resume (struct thread_resume
*resume_info
);
95 /* Get the thread ID from the current selected inferior (the current
98 current_inferior_tid (void)
100 win32_thread_info
*th
= inferior_target_data (current_inferior
);
104 /* Get the thread context of the thread associated with TH. */
107 win32_get_thread_context (win32_thread_info
*th
)
109 memset (&th
->context
, 0, sizeof (CONTEXT
));
110 (*the_low_target
.get_thread_context
) (th
, ¤t_event
);
112 memcpy (&th
->base_context
, &th
->context
, sizeof (CONTEXT
));
116 /* Set the thread context of the thread associated with TH. */
119 win32_set_thread_context (win32_thread_info
*th
)
122 /* Calling SuspendThread on a thread that is running kernel code
123 will report that the suspending was successful, but in fact, that
124 will often not be true. In those cases, the context returned by
125 GetThreadContext will not be correct by the time the thread
126 stops, hence we can't set that context back into the thread when
127 resuming - it will most likelly crash the inferior.
128 Unfortunately, there is no way to know when the thread will
129 really stop. To work around it, we'll only write the context
130 back to the thread when either the user or GDB explicitly change
131 it between stopping and resuming. */
132 if (memcmp (&th
->context
, &th
->base_context
, sizeof (CONTEXT
)) != 0)
134 (*the_low_target
.set_thread_context
) (th
, ¤t_event
);
137 /* Find a thread record given a thread id. If GET_CONTEXT is set then
138 also retrieve the context for this thread. */
139 static win32_thread_info
*
140 thread_rec (DWORD id
, int get_context
)
142 struct thread_info
*thread
;
143 win32_thread_info
*th
;
145 thread
= (struct thread_info
*) find_inferior_id (&all_threads
, id
);
149 th
= inferior_target_data (thread
);
150 if (get_context
&& th
->context
.ContextFlags
== 0)
154 if (SuspendThread (th
->h
) == (DWORD
) -1)
156 DWORD err
= GetLastError ();
157 OUTMSG (("warning: SuspendThread failed in thread_rec, "
158 "(error %d): %s\n", (int) err
, strwinerror (err
)));
164 win32_get_thread_context (th
);
170 /* Add a thread to the thread list. */
171 static win32_thread_info
*
172 child_add_thread (DWORD tid
, HANDLE h
)
174 win32_thread_info
*th
;
176 if ((th
= thread_rec (tid
, FALSE
)))
179 th
= calloc (1, sizeof (*th
));
183 add_thread (tid
, th
, (unsigned int) tid
);
184 set_inferior_regcache_data ((struct thread_info
*)
185 find_inferior_id (&all_threads
, tid
),
186 new_register_cache ());
188 if (the_low_target
.thread_added
!= NULL
)
189 (*the_low_target
.thread_added
) (th
);
194 /* Delete a thread from the list of threads. */
196 delete_thread_info (struct inferior_list_entry
*thread
)
198 win32_thread_info
*th
= inferior_target_data ((struct thread_info
*) thread
);
200 remove_thread ((struct thread_info
*) thread
);
205 /* Delete a thread from the list of threads. */
207 child_delete_thread (DWORD id
)
209 struct inferior_list_entry
*thread
;
211 /* If the last thread is exiting, just return. */
212 if (all_threads
.head
== all_threads
.tail
)
215 thread
= find_inferior_id (&all_threads
, id
);
219 delete_thread_info (thread
);
222 /* Transfer memory from/to the debugged process. */
224 child_xfer_memory (CORE_ADDR memaddr
, char *our
, int len
,
225 int write
, struct target_ops
*target
)
228 long addr
= (long) memaddr
;
232 WriteProcessMemory (current_process_handle
, (LPVOID
) addr
,
233 (LPCVOID
) our
, len
, &done
);
234 FlushInstructionCache (current_process_handle
, (LPCVOID
) addr
, len
);
238 ReadProcessMemory (current_process_handle
, (LPCVOID
) addr
, (LPVOID
) our
,
244 /* Generally, what has the program done? */
247 /* The program has exited. The exit status is in value.integer. */
248 TARGET_WAITKIND_EXITED
,
250 /* The program has stopped with a signal. Which signal is in
252 TARGET_WAITKIND_STOPPED
,
254 /* The program is letting us know that it dynamically loaded
255 or unloaded something. */
256 TARGET_WAITKIND_LOADED
,
258 /* The program has exec'ed a new executable file. The new file's
259 pathname is pointed to by value.execd_pathname. */
260 TARGET_WAITKIND_EXECD
,
262 /* Nothing interesting happened, but we stopped anyway. We take the
263 chance to check if GDB requested an interrupt. */
264 TARGET_WAITKIND_SPURIOUS
,
267 struct target_waitstatus
269 enum target_waitkind kind
;
271 /* Forked child pid, execd pathname, exit status or signal number. */
275 enum target_signal sig
;
277 char *execd_pathname
;
283 /* Clear out any old thread list and reinitialize it to a pristine
286 child_init_thread_list (void)
288 for_each_inferior (&all_threads
, delete_thread_info
);
292 do_initial_child_stuff (DWORD pid
)
294 last_sig
= TARGET_SIGNAL_0
;
296 memset (¤t_event
, 0, sizeof (current_event
));
298 child_init_thread_list ();
300 if (the_low_target
.initial_stuff
!= NULL
)
301 (*the_low_target
.initial_stuff
) ();
304 /* Resume all artificially suspended threads if we are continuing
307 continue_one_thread (struct inferior_list_entry
*this_thread
, void *id_ptr
)
309 struct thread_info
*thread
= (struct thread_info
*) this_thread
;
310 int thread_id
= * (int *) id_ptr
;
311 win32_thread_info
*th
= inferior_target_data (thread
);
313 if ((thread_id
== -1 || thread_id
== th
->tid
)
316 if (th
->context
.ContextFlags
)
318 win32_set_thread_context (th
);
319 th
->context
.ContextFlags
= 0;
322 if (ResumeThread (th
->h
) == (DWORD
) -1)
324 DWORD err
= GetLastError ();
325 OUTMSG (("warning: ResumeThread failed in continue_one_thread, "
326 "(error %d): %s\n", (int) err
, strwinerror (err
)));
335 child_continue (DWORD continue_status
, int thread_id
)
337 /* The inferior will only continue after the ContinueDebugEvent
339 find_inferior (&all_threads
, continue_one_thread
, &thread_id
);
340 faked_breakpoint
= 0;
342 if (!ContinueDebugEvent (current_event
.dwProcessId
,
343 current_event
.dwThreadId
,
350 /* Fetch register(s) from the current thread context. */
352 child_fetch_inferior_registers (int r
)
355 win32_thread_info
*th
= thread_rec (current_inferior_tid (), TRUE
);
356 if (r
== -1 || r
== 0 || r
> NUM_REGS
)
357 child_fetch_inferior_registers (NUM_REGS
);
359 for (regno
= 0; regno
< r
; regno
++)
360 (*the_low_target
.fetch_inferior_register
) (th
, regno
);
363 /* Store a new register value into the current thread context. We don't
364 change the program's context until later, when we resume it. */
366 child_store_inferior_registers (int r
)
369 win32_thread_info
*th
= thread_rec (current_inferior_tid (), TRUE
);
370 if (r
== -1 || r
== 0 || r
> NUM_REGS
)
371 child_store_inferior_registers (NUM_REGS
);
373 for (regno
= 0; regno
< r
; regno
++)
374 (*the_low_target
.store_inferior_register
) (th
, regno
);
377 /* Map the Windows error number in ERROR to a locale-dependent error
378 message string and return a pointer to it. Typically, the values
379 for ERROR come from GetLastError.
381 The string pointed to shall not be modified by the application,
382 but may be overwritten by a subsequent call to strwinerror
384 The strwinerror function does not change the current setting
388 strwinerror (DWORD error
)
390 static char buf
[1024];
392 DWORD lasterr
= GetLastError ();
393 DWORD chars
= FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
394 | FORMAT_MESSAGE_ALLOCATE_BUFFER
,
397 0, /* Default language */
403 /* If there is an \r\n appended, zap it. */
405 && msgbuf
[chars
- 2] == '\r'
406 && msgbuf
[chars
- 1] == '\n')
412 if (chars
> ((COUNTOF (buf
)) - 1))
414 chars
= COUNTOF (buf
) - 1;
419 wcstombs (buf
, msgbuf
, chars
+ 1);
421 strncpy (buf
, msgbuf
, chars
+ 1);
426 sprintf (buf
, "unknown win32 error (%ld)", error
);
428 SetLastError (lasterr
);
433 create_process (const char *program
, char *args
,
434 DWORD flags
, PROCESS_INFORMATION
*pi
)
439 wchar_t *p
, *wprogram
, *wargs
;
442 wprogram
= alloca ((strlen (program
) + 1) * sizeof (wchar_t));
443 mbstowcs (wprogram
, program
, strlen (program
) + 1);
445 for (p
= wprogram
; *p
; ++p
)
449 argslen
= strlen (args
);
450 wargs
= alloca ((argslen
+ 1) * sizeof (wchar_t));
451 mbstowcs (wargs
, args
, argslen
+ 1);
453 ret
= CreateProcessW (wprogram
, /* image name */
454 wargs
, /* command line */
455 NULL
, /* security, not supported */
456 NULL
, /* thread, not supported */
457 FALSE
, /* inherit handles, not supported */
458 flags
, /* start flags */
459 NULL
, /* environment, not supported */
460 NULL
, /* current directory, not supported */
461 NULL
, /* start info, not supported */
464 STARTUPINFOA si
= { sizeof (STARTUPINFOA
) };
466 ret
= CreateProcessA (program
, /* image name */
467 args
, /* command line */
470 TRUE
, /* inherit handles */
471 flags
, /* start flags */
472 NULL
, /* environment */
473 NULL
, /* current directory */
474 &si
, /* start info */
481 /* Start a new process.
482 PROGRAM is a path to the program to execute.
483 ARGS is a standard NULL-terminated array of arguments,
484 to be passed to the inferior as ``argv''.
485 Returns the new PID on success, -1 on failure. Registers the new
486 process with the process list. */
488 win32_create_inferior (char *program
, char **program_args
)
491 char real_path
[MAXPATHLEN
];
492 char *orig_path
, *new_path
, *path_ptr
;
499 PROCESS_INFORMATION pi
;
502 /* win32_wait needs to know we're not attaching. */
506 error ("No executable specified, specify executable to debug.\n");
508 flags
= DEBUG_PROCESS
| DEBUG_ONLY_THIS_PROCESS
;
512 path_ptr
= getenv ("PATH");
515 orig_path
= alloca (strlen (path_ptr
) + 1);
516 new_path
= alloca (cygwin_posix_to_win32_path_list_buf_size (path_ptr
));
517 strcpy (orig_path
, path_ptr
);
518 cygwin_posix_to_win32_path_list (path_ptr
, new_path
);
519 setenv ("PATH", new_path
, 1);
521 cygwin_conv_to_win32_path (program
, real_path
);
526 for (argc
= 1; program_args
[argc
]; argc
++)
527 argslen
+= strlen (program_args
[argc
]) + 1;
528 args
= alloca (argslen
);
530 for (argc
= 1; program_args
[argc
]; argc
++)
532 /* FIXME: Can we do better about quoting? How does Cygwin
535 strcat (args
, program_args
[argc
]);
537 OUTMSG2 (("Command line is \"%s\"\n", args
));
539 #ifdef CREATE_NEW_PROCESS_GROUP
540 flags
|= CREATE_NEW_PROCESS_GROUP
;
543 ret
= create_process (program
, args
, flags
, &pi
);
544 err
= GetLastError ();
545 if (!ret
&& err
== ERROR_FILE_NOT_FOUND
)
547 char *exename
= alloca (strlen (program
) + 5);
548 strcat (strcpy (exename
, program
), ".exe");
549 ret
= create_process (exename
, args
, flags
, &pi
);
550 err
= GetLastError ();
555 setenv ("PATH", orig_path
, 1);
560 error ("Error creating process \"%s%s\", (error %d): %s\n",
561 program
, args
, (int) err
, strwinerror (err
));
565 OUTMSG2 (("Process created: %s\n", (char *) args
));
569 /* On Windows CE this handle can't be closed. The OS reuses
570 it in the debug events, while the 9x/NT versions of Windows
571 probably use a DuplicateHandle'd one. */
572 CloseHandle (pi
.hThread
);
575 current_process_handle
= pi
.hProcess
;
576 current_process_id
= pi
.dwProcessId
;
578 do_initial_child_stuff (current_process_id
);
580 return current_process_id
;
583 /* Attach to a running process.
584 PID is the process ID to attach to, specified by the user
585 or a higher layer. */
587 win32_attach (unsigned long pid
)
590 winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit
= NULL
;
593 HMODULE dll
= GetModuleHandle (_T("COREDLL.DLL"));
595 HMODULE dll
= GetModuleHandle (_T("KERNEL32.DLL"));
597 DebugSetProcessKillOnExit
= GETPROCADDRESS (dll
, DebugSetProcessKillOnExit
);
599 h
= OpenProcess (PROCESS_ALL_ACCESS
, FALSE
, pid
);
602 if (DebugActiveProcess (pid
))
604 if (DebugSetProcessKillOnExit
!= NULL
)
605 DebugSetProcessKillOnExit (FALSE
);
607 /* win32_wait needs to know we're attaching. */
609 current_process_handle
= h
;
610 current_process_id
= pid
;
611 do_initial_child_stuff (pid
);
618 err
= GetLastError ();
619 error ("Attach to process failed (error %d): %s\n",
620 (int) err
, strwinerror (err
));
623 /* Handle OUTPUT_DEBUG_STRING_EVENT from child process. */
625 handle_output_debug_string (struct target_waitstatus
*ourstatus
)
627 #define READ_BUFFER_LEN 1024
629 char s
[READ_BUFFER_LEN
+ 1] = { 0 };
630 DWORD nbytes
= current_event
.u
.DebugString
.nDebugStringLength
;
635 if (nbytes
> READ_BUFFER_LEN
)
636 nbytes
= READ_BUFFER_LEN
;
638 addr
= (CORE_ADDR
) (size_t) current_event
.u
.DebugString
.lpDebugStringData
;
640 if (current_event
.u
.DebugString
.fUnicode
)
642 /* The event tells us how many bytes, not chars, even
644 WCHAR buffer
[(READ_BUFFER_LEN
+ 1) / sizeof (WCHAR
)] = { 0 };
645 if (read_inferior_memory (addr
, (unsigned char *) buffer
, nbytes
) != 0)
647 wcstombs (s
, buffer
, (nbytes
+ 1) / sizeof (WCHAR
));
651 if (read_inferior_memory (addr
, (unsigned char *) s
, nbytes
) != 0)
655 if (strncmp (s
, "cYg", 3) != 0)
665 #undef READ_BUFFER_LEN
668 /* Kill all inferiors. */
672 win32_thread_info
*current_thread
;
674 if (current_process_handle
== NULL
)
677 TerminateProcess (current_process_handle
, 0);
680 if (!child_continue (DBG_CONTINUE
, -1))
682 if (!WaitForDebugEvent (¤t_event
, INFINITE
))
684 if (current_event
.dwDebugEventCode
== EXIT_PROCESS_DEBUG_EVENT
)
686 else if (current_event
.dwDebugEventCode
== OUTPUT_DEBUG_STRING_EVENT
)
688 struct target_waitstatus our_status
= { 0 };
689 handle_output_debug_string (&our_status
);
693 CloseHandle (current_process_handle
);
695 current_thread
= inferior_target_data (current_inferior
);
696 if (current_thread
&& current_thread
->h
)
698 /* This may fail in an attached process, so don't check. */
699 (void) CloseHandle (current_thread
->h
);
703 /* Detach from all inferiors. */
709 winapi_DebugActiveProcessStop DebugActiveProcessStop
= NULL
;
710 winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit
= NULL
;
712 HMODULE dll
= GetModuleHandle (_T("COREDLL.DLL"));
714 HMODULE dll
= GetModuleHandle (_T("KERNEL32.DLL"));
716 DebugActiveProcessStop
= GETPROCADDRESS (dll
, DebugActiveProcessStop
);
717 DebugSetProcessKillOnExit
= GETPROCADDRESS (dll
, DebugSetProcessKillOnExit
);
719 if (DebugSetProcessKillOnExit
== NULL
720 || DebugActiveProcessStop
== NULL
)
723 /* We need a new handle, since DebugActiveProcessStop
724 closes all the ones that came through the events. */
725 if ((h
= OpenProcess (PROCESS_ALL_ACCESS
,
727 current_process_id
)) == NULL
)
729 /* The process died. */
734 struct thread_resume resume
;
738 resume
.leave_stopped
= 0;
739 win32_resume (&resume
);
742 if (!DebugActiveProcessStop (current_process_id
))
747 DebugSetProcessKillOnExit (FALSE
);
749 current_process_handle
= h
;
753 /* Wait for inferiors to end. */
757 if (current_process_id
== 0
758 || current_process_handle
== NULL
)
761 WaitForSingleObject (current_process_handle
, INFINITE
);
762 CloseHandle (current_process_handle
);
764 current_process_handle
= NULL
;
765 current_process_id
= 0;
768 /* Return 1 iff the thread with thread ID TID is alive. */
770 win32_thread_alive (unsigned long tid
)
774 /* Our thread list is reliable; don't bother to poll target
776 if (find_inferior_id (&all_threads
, tid
) != NULL
)
783 /* Resume the inferior process. RESUME_INFO describes how we want
786 win32_resume (struct thread_resume
*resume_info
)
789 enum target_signal sig
;
791 win32_thread_info
*th
;
792 DWORD continue_status
= DBG_CONTINUE
;
794 /* This handles the very limited set of resume packets that GDB can
795 currently produce. */
797 if (resume_info
[0].thread
== -1)
799 else if (resume_info
[1].thread
== -1 && !resume_info
[1].leave_stopped
)
802 /* Yes, we're ignoring resume_info[0].thread. It'd be tricky to make
803 the Windows resume code do the right thing for thread switching. */
804 tid
= current_event
.dwThreadId
;
806 if (resume_info
[0].thread
!= -1)
808 sig
= resume_info
[0].sig
;
809 step
= resume_info
[0].step
;
817 if (sig
!= TARGET_SIGNAL_0
)
819 if (current_event
.dwDebugEventCode
!= EXCEPTION_DEBUG_EVENT
)
821 OUTMSG (("Cannot continue with signal %d here.\n", sig
));
823 else if (sig
== last_sig
)
824 continue_status
= DBG_EXCEPTION_NOT_HANDLED
;
826 OUTMSG (("Can only continue with recieved signal %d.\n", last_sig
));
829 last_sig
= TARGET_SIGNAL_0
;
831 /* Get context for the currently selected thread. */
832 th
= thread_rec (current_event
.dwThreadId
, FALSE
);
835 if (th
->context
.ContextFlags
)
837 /* Move register values from the inferior into the thread
838 context structure. */
839 regcache_invalidate ();
843 if (the_low_target
.single_step
!= NULL
)
844 (*the_low_target
.single_step
) (th
);
846 error ("Single stepping is not supported "
847 "in this configuration.\n");
850 win32_set_thread_context (th
);
851 th
->context
.ContextFlags
= 0;
855 /* Allow continuing with the same signal that interrupted us.
856 Otherwise complain. */
858 child_continue (continue_status
, tid
);
862 win32_add_one_solib (const char *name
, CORE_ADDR load_addr
)
864 char buf
[MAX_PATH
+ 1];
865 char buf2
[MAX_PATH
+ 1];
868 WIN32_FIND_DATA w32_fd
;
869 WCHAR wname
[MAX_PATH
+ 1];
870 mbstowcs (wname
, name
, MAX_PATH
);
871 HANDLE h
= FindFirstFile (wname
, &w32_fd
);
873 WIN32_FIND_DATAA w32_fd
;
874 HANDLE h
= FindFirstFileA (name
, &w32_fd
);
877 if (h
== INVALID_HANDLE_VALUE
)
885 char cwd
[MAX_PATH
+ 1];
887 if (GetCurrentDirectoryA (MAX_PATH
+ 1, cwd
))
889 p
= strrchr (buf
, '\\');
892 SetCurrentDirectoryA (buf
);
893 GetFullPathNameA (w32_fd
.cFileName
, MAX_PATH
, buf
, &p
);
894 SetCurrentDirectoryA (cwd
);
901 cygwin_conv_to_posix_path (buf
, buf2
);
906 loaded_dll (buf2
, load_addr
);
910 get_image_name (HANDLE h
, void *address
, int unicode
)
912 static char buf
[(2 * MAX_PATH
) + 1];
913 DWORD size
= unicode
? sizeof (WCHAR
) : sizeof (char);
919 /* Attempt to read the name of the dll that was detected.
920 This is documented to work only when actively debugging
921 a program. It will not work for attached processes. */
926 /* Windows CE reports the address of the image name,
927 instead of an address of a pointer into the image name. */
928 address_ptr
= address
;
930 /* See if we could read the address of a string, and that the
931 address isn't null. */
932 if (!ReadProcessMemory (h
, address
, &address_ptr
,
933 sizeof (address_ptr
), &done
)
934 || done
!= sizeof (address_ptr
)
939 /* Find the length of the string */
940 while (ReadProcessMemory (h
, address_ptr
+ len
++ * size
, &b
, size
, &done
)
941 && (b
[0] != 0 || b
[size
- 1] != 0) && done
== size
)
945 ReadProcessMemory (h
, address_ptr
, buf
, len
, &done
);
948 WCHAR
*unicode_address
= (WCHAR
*) alloca (len
* sizeof (WCHAR
));
949 ReadProcessMemory (h
, address_ptr
, unicode_address
, len
* sizeof (WCHAR
),
952 WideCharToMultiByte (CP_ACP
, 0, unicode_address
, len
, buf
, len
, 0, 0);
958 typedef BOOL (WINAPI
*winapi_EnumProcessModules
) (HANDLE
, HMODULE
*,
960 typedef BOOL (WINAPI
*winapi_GetModuleInformation
) (HANDLE
, HMODULE
,
961 LPMODULEINFO
, DWORD
);
962 typedef DWORD (WINAPI
*winapi_GetModuleFileNameExA
) (HANDLE
, HMODULE
,
965 static winapi_EnumProcessModules win32_EnumProcessModules
;
966 static winapi_GetModuleInformation win32_GetModuleInformation
;
967 static winapi_GetModuleFileNameExA win32_GetModuleFileNameExA
;
972 static int psapi_loaded
= 0;
973 static HMODULE dll
= NULL
;
978 dll
= LoadLibrary (TEXT("psapi.dll"));
981 win32_EnumProcessModules
=
982 GETPROCADDRESS (dll
, EnumProcessModules
);
983 win32_GetModuleInformation
=
984 GETPROCADDRESS (dll
, GetModuleInformation
);
985 win32_GetModuleFileNameExA
=
986 GETPROCADDRESS (dll
, GetModuleFileNameExA
);
989 return (win32_EnumProcessModules
!= NULL
990 && win32_GetModuleInformation
!= NULL
991 && win32_GetModuleFileNameExA
!= NULL
);
995 psapi_get_dll_name (DWORD BaseAddress
, char *dll_name_ret
)
1001 HMODULE
*DllHandle
= dh_buf
;
1009 ok
= (*win32_EnumProcessModules
) (current_process_handle
,
1014 if (!ok
|| !cbNeeded
)
1017 DllHandle
= (HMODULE
*) alloca (cbNeeded
);
1021 ok
= (*win32_EnumProcessModules
) (current_process_handle
,
1028 for (i
= 0; i
< ((size_t) cbNeeded
/ sizeof (HMODULE
)); i
++)
1030 if (!(*win32_GetModuleInformation
) (current_process_handle
,
1035 DWORD err
= GetLastError ();
1036 error ("Can't get module info: (error %d): %s\n",
1037 (int) err
, strwinerror (err
));
1040 if ((DWORD
) (mi
.lpBaseOfDll
) == BaseAddress
)
1042 len
= (*win32_GetModuleFileNameExA
) (current_process_handle
,
1048 DWORD err
= GetLastError ();
1049 error ("Error getting dll name: (error %d): %s\n",
1050 (int) err
, strwinerror (err
));
1057 dll_name_ret
[0] = '\0';
1061 typedef HANDLE (WINAPI
*winapi_CreateToolhelp32Snapshot
) (DWORD
, DWORD
);
1062 typedef BOOL (WINAPI
*winapi_Module32First
) (HANDLE
, LPMODULEENTRY32
);
1063 typedef BOOL (WINAPI
*winapi_Module32Next
) (HANDLE
, LPMODULEENTRY32
);
1065 static winapi_CreateToolhelp32Snapshot win32_CreateToolhelp32Snapshot
;
1066 static winapi_Module32First win32_Module32First
;
1067 static winapi_Module32Next win32_Module32Next
;
1069 typedef BOOL (WINAPI
*winapi_CloseToolhelp32Snapshot
) (HANDLE
);
1070 static winapi_CloseToolhelp32Snapshot win32_CloseToolhelp32Snapshot
;
1074 load_toolhelp (void)
1076 static int toolhelp_loaded
= 0;
1077 static HMODULE dll
= NULL
;
1079 if (!toolhelp_loaded
)
1081 toolhelp_loaded
= 1;
1083 dll
= GetModuleHandle (_T("KERNEL32.DLL"));
1085 dll
= LoadLibrary (L
"TOOLHELP.DLL");
1090 win32_CreateToolhelp32Snapshot
=
1091 GETPROCADDRESS (dll
, CreateToolhelp32Snapshot
);
1092 win32_Module32First
= GETPROCADDRESS (dll
, Module32First
);
1093 win32_Module32Next
= GETPROCADDRESS (dll
, Module32Next
);
1095 win32_CloseToolhelp32Snapshot
=
1096 GETPROCADDRESS (dll
, CloseToolhelp32Snapshot
);
1100 return (win32_CreateToolhelp32Snapshot
!= NULL
1101 && win32_Module32First
!= NULL
1102 && win32_Module32Next
!= NULL
1104 && win32_CloseToolhelp32Snapshot
!= NULL
1110 toolhelp_get_dll_name (DWORD BaseAddress
, char *dll_name_ret
)
1112 HANDLE snapshot_module
;
1113 MODULEENTRY32 modEntry
= { sizeof (MODULEENTRY32
) };
1116 if (!load_toolhelp ())
1119 snapshot_module
= win32_CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
,
1120 current_event
.dwProcessId
);
1121 if (snapshot_module
== INVALID_HANDLE_VALUE
)
1124 /* Ignore the first module, which is the exe. */
1125 if (win32_Module32First (snapshot_module
, &modEntry
))
1126 while (win32_Module32Next (snapshot_module
, &modEntry
))
1127 if ((DWORD
) modEntry
.modBaseAddr
== BaseAddress
)
1130 wcstombs (dll_name_ret
, modEntry
.szExePath
, MAX_PATH
+ 1);
1132 strcpy (dll_name_ret
, modEntry
.szExePath
);
1139 win32_CloseToolhelp32Snapshot (snapshot_module
);
1141 CloseHandle (snapshot_module
);
1147 handle_load_dll (void)
1149 LOAD_DLL_DEBUG_INFO
*event
= ¤t_event
.u
.LoadDll
;
1150 char dll_buf
[MAX_PATH
+ 1];
1151 char *dll_name
= NULL
;
1154 dll_buf
[0] = dll_buf
[sizeof (dll_buf
) - 1] = '\0';
1156 /* Windows does not report the image name of the dlls in the debug
1157 event on attaches. We resort to iterating over the list of
1158 loaded dlls looking for a match by image base. */
1159 if (!psapi_get_dll_name ((DWORD
) event
->lpBaseOfDll
, dll_buf
))
1161 if (!server_waiting
)
1162 /* On some versions of Windows and Windows CE, we can't create
1163 toolhelp snapshots while the inferior is stopped in a
1164 LOAD_DLL_DEBUG_EVENT due to a dll load, but we can while
1165 Windows is reporting the already loaded dlls. */
1166 toolhelp_get_dll_name ((DWORD
) event
->lpBaseOfDll
, dll_buf
);
1171 if (*dll_name
== '\0')
1172 dll_name
= get_image_name (current_process_handle
,
1173 event
->lpImageName
, event
->fUnicode
);
1177 /* The symbols in a dll are offset by 0x1000, which is the
1178 the offset from 0 of the first byte in an image - because
1179 of the file header and the section alignment. */
1181 load_addr
= (DWORD
) event
->lpBaseOfDll
+ 0x1000;
1182 win32_add_one_solib (dll_name
, load_addr
);
1186 handle_unload_dll (void)
1188 CORE_ADDR load_addr
=
1189 (CORE_ADDR
) (DWORD
) current_event
.u
.UnloadDll
.lpBaseOfDll
;
1190 load_addr
+= 0x1000;
1191 unloaded_dll (NULL
, load_addr
);
1195 handle_exception (struct target_waitstatus
*ourstatus
)
1197 DWORD code
= current_event
.u
.Exception
.ExceptionRecord
.ExceptionCode
;
1199 ourstatus
->kind
= TARGET_WAITKIND_STOPPED
;
1203 case EXCEPTION_ACCESS_VIOLATION
:
1204 OUTMSG2 (("EXCEPTION_ACCESS_VIOLATION"));
1205 ourstatus
->value
.sig
= TARGET_SIGNAL_SEGV
;
1207 case STATUS_STACK_OVERFLOW
:
1208 OUTMSG2 (("STATUS_STACK_OVERFLOW"));
1209 ourstatus
->value
.sig
= TARGET_SIGNAL_SEGV
;
1211 case STATUS_FLOAT_DENORMAL_OPERAND
:
1212 OUTMSG2 (("STATUS_FLOAT_DENORMAL_OPERAND"));
1213 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1215 case EXCEPTION_ARRAY_BOUNDS_EXCEEDED
:
1216 OUTMSG2 (("EXCEPTION_ARRAY_BOUNDS_EXCEEDED"));
1217 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1219 case STATUS_FLOAT_INEXACT_RESULT
:
1220 OUTMSG2 (("STATUS_FLOAT_INEXACT_RESULT"));
1221 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1223 case STATUS_FLOAT_INVALID_OPERATION
:
1224 OUTMSG2 (("STATUS_FLOAT_INVALID_OPERATION"));
1225 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1227 case STATUS_FLOAT_OVERFLOW
:
1228 OUTMSG2 (("STATUS_FLOAT_OVERFLOW"));
1229 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1231 case STATUS_FLOAT_STACK_CHECK
:
1232 OUTMSG2 (("STATUS_FLOAT_STACK_CHECK"));
1233 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1235 case STATUS_FLOAT_UNDERFLOW
:
1236 OUTMSG2 (("STATUS_FLOAT_UNDERFLOW"));
1237 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1239 case STATUS_FLOAT_DIVIDE_BY_ZERO
:
1240 OUTMSG2 (("STATUS_FLOAT_DIVIDE_BY_ZERO"));
1241 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1243 case STATUS_INTEGER_DIVIDE_BY_ZERO
:
1244 OUTMSG2 (("STATUS_INTEGER_DIVIDE_BY_ZERO"));
1245 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1247 case STATUS_INTEGER_OVERFLOW
:
1248 OUTMSG2 (("STATUS_INTEGER_OVERFLOW"));
1249 ourstatus
->value
.sig
= TARGET_SIGNAL_FPE
;
1251 case EXCEPTION_BREAKPOINT
:
1252 OUTMSG2 (("EXCEPTION_BREAKPOINT"));
1253 ourstatus
->value
.sig
= TARGET_SIGNAL_TRAP
;
1255 /* Remove the initial breakpoint. */
1256 check_breakpoints ((CORE_ADDR
) (long) current_event
1257 .u
.Exception
.ExceptionRecord
.ExceptionAddress
);
1261 OUTMSG2 (("DBG_CONTROL_C"));
1262 ourstatus
->value
.sig
= TARGET_SIGNAL_INT
;
1264 case DBG_CONTROL_BREAK
:
1265 OUTMSG2 (("DBG_CONTROL_BREAK"));
1266 ourstatus
->value
.sig
= TARGET_SIGNAL_INT
;
1268 case EXCEPTION_SINGLE_STEP
:
1269 OUTMSG2 (("EXCEPTION_SINGLE_STEP"));
1270 ourstatus
->value
.sig
= TARGET_SIGNAL_TRAP
;
1272 case EXCEPTION_ILLEGAL_INSTRUCTION
:
1273 OUTMSG2 (("EXCEPTION_ILLEGAL_INSTRUCTION"));
1274 ourstatus
->value
.sig
= TARGET_SIGNAL_ILL
;
1276 case EXCEPTION_PRIV_INSTRUCTION
:
1277 OUTMSG2 (("EXCEPTION_PRIV_INSTRUCTION"));
1278 ourstatus
->value
.sig
= TARGET_SIGNAL_ILL
;
1280 case EXCEPTION_NONCONTINUABLE_EXCEPTION
:
1281 OUTMSG2 (("EXCEPTION_NONCONTINUABLE_EXCEPTION"));
1282 ourstatus
->value
.sig
= TARGET_SIGNAL_ILL
;
1285 if (current_event
.u
.Exception
.dwFirstChance
)
1287 ourstatus
->kind
= TARGET_WAITKIND_SPURIOUS
;
1290 OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at 0x%08lx",
1291 current_event
.u
.Exception
.ExceptionRecord
.ExceptionCode
,
1292 (DWORD
) current_event
.u
.Exception
.ExceptionRecord
.
1294 ourstatus
->value
.sig
= TARGET_SIGNAL_UNKNOWN
;
1298 last_sig
= ourstatus
->value
.sig
;
1303 suspend_one_thread (struct inferior_list_entry
*entry
)
1305 struct thread_info
*thread
= (struct thread_info
*) entry
;
1306 win32_thread_info
*th
= inferior_target_data (thread
);
1310 if (SuspendThread (th
->h
) == (DWORD
) -1)
1312 DWORD err
= GetLastError ();
1313 OUTMSG (("warning: SuspendThread failed in suspend_one_thread, "
1314 "(error %d): %s\n", (int) err
, strwinerror (err
)));
1322 fake_breakpoint_event (void)
1324 OUTMSG2(("fake_breakpoint_event\n"));
1326 faked_breakpoint
= 1;
1328 memset (¤t_event
, 0, sizeof (current_event
));
1329 current_event
.dwThreadId
= main_thread_id
;
1330 current_event
.dwDebugEventCode
= EXCEPTION_DEBUG_EVENT
;
1331 current_event
.u
.Exception
.ExceptionRecord
.ExceptionCode
1332 = EXCEPTION_BREAKPOINT
;
1334 for_each_inferior (&all_threads
, suspend_one_thread
);
1337 /* Get the next event from the child. */
1340 get_child_debug_event (struct target_waitstatus
*ourstatus
)
1342 last_sig
= TARGET_SIGNAL_0
;
1343 ourstatus
->kind
= TARGET_WAITKIND_SPURIOUS
;
1345 /* Check if GDB sent us an interrupt request. */
1346 check_remote_input_interrupt_request ();
1348 if (soft_interrupt_requested
)
1350 soft_interrupt_requested
= 0;
1351 fake_breakpoint_event ();
1360 /* WinCE doesn't set an initial breakpoint automatically. To
1361 stop the inferior, we flush all currently pending debug
1362 events -- the thread list and the dll list are always
1363 reported immediatelly without delay, then, we suspend all
1364 threads and pretend we saw a trap at the current PC of the
1367 Contrary to desktop Windows, Windows CE *does* report the dll
1368 names on LOAD_DLL_DEBUG_EVENTs resulting from a
1369 DebugActiveProcess call. This limits the way we can detect
1370 if all the dlls have already been reported. If we get a real
1371 debug event before leaving attaching, the worst that will
1372 happen is the user will see a spurious breakpoint. */
1374 current_event
.dwDebugEventCode
= 0;
1375 if (!WaitForDebugEvent (¤t_event
, 0))
1377 OUTMSG2(("no attach events left\n"));
1378 fake_breakpoint_event ();
1382 OUTMSG2(("got attach event\n"));
1387 /* Keep the wait time low enough for confortable remote
1388 interruption, but high enough so gdbserver doesn't become a
1390 if (!WaitForDebugEvent (¤t_event
, 250))
1397 (struct thread_info
*) find_inferior_id (&all_threads
,
1398 current_event
.dwThreadId
);
1400 switch (current_event
.dwDebugEventCode
)
1402 case CREATE_THREAD_DEBUG_EVENT
:
1403 OUTMSG2 (("gdbserver: kernel event CREATE_THREAD_DEBUG_EVENT "
1404 "for pid=%d tid=%x)\n",
1405 (unsigned) current_event
.dwProcessId
,
1406 (unsigned) current_event
.dwThreadId
));
1408 /* Record the existence of this thread. */
1409 child_add_thread (current_event
.dwThreadId
,
1410 current_event
.u
.CreateThread
.hThread
);
1413 case EXIT_THREAD_DEBUG_EVENT
:
1414 OUTMSG2 (("gdbserver: kernel event EXIT_THREAD_DEBUG_EVENT "
1415 "for pid=%d tid=%x\n",
1416 (unsigned) current_event
.dwProcessId
,
1417 (unsigned) current_event
.dwThreadId
));
1418 child_delete_thread (current_event
.dwThreadId
);
1421 case CREATE_PROCESS_DEBUG_EVENT
:
1422 OUTMSG2 (("gdbserver: kernel event CREATE_PROCESS_DEBUG_EVENT "
1423 "for pid=%d tid=%x\n",
1424 (unsigned) current_event
.dwProcessId
,
1425 (unsigned) current_event
.dwThreadId
));
1426 CloseHandle (current_event
.u
.CreateProcessInfo
.hFile
);
1428 current_process_handle
= current_event
.u
.CreateProcessInfo
.hProcess
;
1429 main_thread_id
= current_event
.dwThreadId
;
1431 ourstatus
->kind
= TARGET_WAITKIND_EXECD
;
1432 ourstatus
->value
.execd_pathname
= "Main executable";
1434 /* Add the main thread. */
1435 child_add_thread (main_thread_id
,
1436 current_event
.u
.CreateProcessInfo
.hThread
);
1438 ourstatus
->value
.related_pid
= current_event
.dwThreadId
;
1442 /* Windows CE doesn't set the initial breakpoint
1443 automatically like the desktop versions of Windows do.
1444 We add it explicitly here. It will be removed as soon as
1446 set_breakpoint_at ((CORE_ADDR
) (long) current_event
.u
1447 .CreateProcessInfo
.lpStartAddress
,
1448 delete_breakpoint_at
);
1453 case EXIT_PROCESS_DEBUG_EVENT
:
1454 OUTMSG2 (("gdbserver: kernel event EXIT_PROCESS_DEBUG_EVENT "
1455 "for pid=%d tid=%x\n",
1456 (unsigned) current_event
.dwProcessId
,
1457 (unsigned) current_event
.dwThreadId
));
1458 ourstatus
->kind
= TARGET_WAITKIND_EXITED
;
1459 ourstatus
->value
.integer
= current_event
.u
.ExitProcess
.dwExitCode
;
1460 CloseHandle (current_process_handle
);
1461 current_process_handle
= NULL
;
1464 case LOAD_DLL_DEBUG_EVENT
:
1465 OUTMSG2 (("gdbserver: kernel event LOAD_DLL_DEBUG_EVENT "
1466 "for pid=%d tid=%x\n",
1467 (unsigned) current_event
.dwProcessId
,
1468 (unsigned) current_event
.dwThreadId
));
1469 CloseHandle (current_event
.u
.LoadDll
.hFile
);
1472 ourstatus
->kind
= TARGET_WAITKIND_LOADED
;
1473 ourstatus
->value
.sig
= TARGET_SIGNAL_TRAP
;
1476 case UNLOAD_DLL_DEBUG_EVENT
:
1477 OUTMSG2 (("gdbserver: kernel event UNLOAD_DLL_DEBUG_EVENT "
1478 "for pid=%d tid=%x\n",
1479 (unsigned) current_event
.dwProcessId
,
1480 (unsigned) current_event
.dwThreadId
));
1481 handle_unload_dll ();
1482 ourstatus
->kind
= TARGET_WAITKIND_LOADED
;
1483 ourstatus
->value
.sig
= TARGET_SIGNAL_TRAP
;
1486 case EXCEPTION_DEBUG_EVENT
:
1487 OUTMSG2 (("gdbserver: kernel event EXCEPTION_DEBUG_EVENT "
1488 "for pid=%d tid=%x\n",
1489 (unsigned) current_event
.dwProcessId
,
1490 (unsigned) current_event
.dwThreadId
));
1491 handle_exception (ourstatus
);
1494 case OUTPUT_DEBUG_STRING_EVENT
:
1495 /* A message from the kernel (or Cygwin). */
1496 OUTMSG2 (("gdbserver: kernel event OUTPUT_DEBUG_STRING_EVENT "
1497 "for pid=%d tid=%x\n",
1498 (unsigned) current_event
.dwProcessId
,
1499 (unsigned) current_event
.dwThreadId
));
1500 handle_output_debug_string (ourstatus
);
1504 OUTMSG2 (("gdbserver: kernel event unknown "
1505 "for pid=%d tid=%x code=%ld\n",
1506 (unsigned) current_event
.dwProcessId
,
1507 (unsigned) current_event
.dwThreadId
,
1508 current_event
.dwDebugEventCode
));
1513 (struct thread_info
*) find_inferior_id (&all_threads
,
1514 current_event
.dwThreadId
);
1518 /* Wait for the inferior process to change state.
1519 STATUS will be filled in with a response code to send to GDB.
1520 Returns the signal which caused the process to stop. */
1521 static unsigned char
1522 win32_wait (char *status
)
1524 struct target_waitstatus our_status
;
1530 if (!get_child_debug_event (&our_status
))
1533 switch (our_status
.kind
)
1535 case TARGET_WAITKIND_EXITED
:
1536 OUTMSG2 (("Child exited with retcode = %x\n",
1537 our_status
.value
.integer
));
1540 return our_status
.value
.integer
;
1541 case TARGET_WAITKIND_STOPPED
:
1542 case TARGET_WAITKIND_LOADED
:
1543 OUTMSG2 (("Child Stopped with signal = %d \n",
1544 our_status
.value
.sig
));
1548 child_fetch_inferior_registers (-1);
1550 if (our_status
.kind
== TARGET_WAITKIND_LOADED
1553 /* When gdb connects, we want to be stopped at the
1554 initial breakpoint, not in some dll load event. */
1555 child_continue (DBG_CONTINUE
, -1);
1559 return our_status
.value
.sig
;
1561 OUTMSG (("Ignoring unknown internal event, %d\n", our_status
.kind
));
1563 case TARGET_WAITKIND_SPURIOUS
:
1564 case TARGET_WAITKIND_EXECD
:
1565 /* do nothing, just continue */
1566 child_continue (DBG_CONTINUE
, -1);
1572 /* Fetch registers from the inferior process.
1573 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
1575 win32_fetch_inferior_registers (int regno
)
1577 child_fetch_inferior_registers (regno
);
1580 /* Store registers to the inferior process.
1581 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
1583 win32_store_inferior_registers (int regno
)
1585 child_store_inferior_registers (regno
);
1588 /* Read memory from the inferior process. This should generally be
1589 called through read_inferior_memory, which handles breakpoint shadowing.
1590 Read LEN bytes at MEMADDR into a buffer at MYADDR. */
1592 win32_read_inferior_memory (CORE_ADDR memaddr
, unsigned char *myaddr
, int len
)
1594 return child_xfer_memory (memaddr
, (char *) myaddr
, len
, 0, 0) != len
;
1597 /* Write memory to the inferior process. This should generally be
1598 called through write_inferior_memory, which handles breakpoint shadowing.
1599 Write LEN bytes from the buffer at MYADDR to MEMADDR.
1600 Returns 0 on success and errno on failure. */
1602 win32_write_inferior_memory (CORE_ADDR memaddr
, const unsigned char *myaddr
,
1605 return child_xfer_memory (memaddr
, (char *) myaddr
, len
, 1, 0) != len
;
1608 /* Send an interrupt request to the inferior process. */
1610 win32_request_interrupt (void)
1612 winapi_DebugBreakProcess DebugBreakProcess
;
1613 winapi_GenerateConsoleCtrlEvent GenerateConsoleCtrlEvent
;
1616 HMODULE dll
= GetModuleHandle (_T("COREDLL.DLL"));
1618 HMODULE dll
= GetModuleHandle (_T("KERNEL32.DLL"));
1621 GenerateConsoleCtrlEvent
= GETPROCADDRESS (dll
, GenerateConsoleCtrlEvent
);
1623 if (GenerateConsoleCtrlEvent
!= NULL
1624 && GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT
, current_process_id
))
1627 /* GenerateConsoleCtrlEvent can fail if process id being debugged is
1628 not a process group id.
1629 Fallback to XP/Vista 'DebugBreakProcess', which generates a
1630 breakpoint exception in the interior process. */
1632 DebugBreakProcess
= GETPROCADDRESS (dll
, DebugBreakProcess
);
1634 if (DebugBreakProcess
!= NULL
1635 && DebugBreakProcess (current_process_handle
))
1638 /* Last resort, suspend all threads manually. */
1639 soft_interrupt_requested
= 1;
1643 win32_arch_string (void)
1645 return the_low_target
.arch_string
;
1648 static struct target_ops win32_target_ops
= {
1649 win32_create_inferior
,
1657 win32_fetch_inferior_registers
,
1658 win32_store_inferior_registers
,
1659 win32_read_inferior_memory
,
1660 win32_write_inferior_memory
,
1662 win32_request_interrupt
,
1673 /* Initialize the Win32 backend. */
1675 initialize_low (void)
1677 set_target_ops (&win32_target_ops
);
1678 if (the_low_target
.breakpoint
!= NULL
)
1679 set_breakpoint_data (the_low_target
.breakpoint
,
1680 the_low_target
.breakpoint_len
);