winedbg: Added the ability to break into the program when using the gdb proxy
David Welch
welch at cwcom.net
Mon May 23 18:32:04 CDT 2005
Changelog:
programs/winedbg/gdbproxy.c: check_for_interrupt
New function to check gdb trying to break in.
programs/winedbg/gdbproxy.c: wait_for_debuggee
Check for a break while waiting for a debug event.
-------------- next part --------------
Index: gdbproxy.c
===================================================================
RCS file: /home/wine/wine/programs/winedbg/gdbproxy.c,v
retrieving revision 1.22
diff -u -p -r1.22 gdbproxy.c
--- gdbproxy.c 10 Feb 2005 21:18:12 -0000 1.22
+++ gdbproxy.c 23 May 2005 23:11:45 -0000
@@ -605,13 +602,63 @@ static void resume_debuggee_thread(st
fprintf(stderr, "Cannot find last thread\n");
}
+static BOOL check_for_interrupt(struct gdb_context* gdbctx)
+{
+ struct pollfd pollfd;
+ int ret;
+ char pkt;
+
+ pollfd.fd = gdbctx->sock;
+ pollfd.events = POLLIN;
+ pollfd.revents = 0;
+
+ if ((ret = poll(&pollfd, 1, 0)) == 1) {
+ ret = read(gdbctx->sock, &pkt, 1);
+ if (ret != 1) {
+ if (gdbctx->trace & GDBPXY_TRC_WIN32_ERROR) {
+ fprintf(stderr, "read failed\n");
+ }
+ return FALSE;
+ }
+ if (pkt != '\003') {
+ if (gdbctx->trace & GDBPXY_TRC_COMMAND_ERROR) {
+ fprintf(stderr, "Unexpected break packet (%c/0x%X)\n", pkt, pkt);
+ }
+ return FALSE;
+ }
+ return TRUE;
+ } else if (ret == -1) {
+ fprintf(stderr, "poll failed\n");
+ }
+ return FALSE;
+}
+
static void wait_for_debuggee(struct gdb_context* gdbctx)
{
DEBUG_EVENT de;
gdbctx->in_trap = FALSE;
- while (WaitForDebugEvent(&de, INFINITE))
+ for (;;)
{
+ if (!WaitForDebugEvent(&de, 10))
+ {
+ if (GetLastError() == ERROR_SEM_TIMEOUT)
+ {
+ if (check_for_interrupt(gdbctx)) {
+ if (!DebugBreakProcess(gdbctx->process->handle)) {
+ if (gdbctx->trace & GDBPXY_TRC_WIN32_ERROR) {
+ fprintf(stderr, "Failed to break into debugee\n");
+ }
+ break;
+ }
+ WaitForDebugEvent(&de, INFINITE);
+ } else {
+ continue;
+ }
+ } else {
+ break;
+ }
+ }
handle_debug_event(gdbctx, &de);
assert(!gdbctx->process ||
gdbctx->process->pid == 0 ||
More information about the wine-patches
mailing list