From: Jon Turney <jon.turney@dronecode.org.uk>
To: gdb-patches@sourceware.org
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 2/5] windows-nat: Cleanups in get_windows_debug_event
Date: Thu, 16 Apr 2015 19:23:00 -0000 [thread overview]
Message-ID: <1429212209-20548-3-git-send-email-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <1429212209-20548-1-git-send-email-jon.turney@dronecode.org.uk>
gdb/ChangeLog:
2015-04-16 Jon Turney <jon.turney@dronecode.org.uk>
* windows-nat.c (get_windows_debug_event): Replace retval with
thread_id throughout. Update stale comment.
---
gdb/ChangeLog | 5 +++++
gdb/windows-nat.c | 30 +++++++++++++++---------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index dea4368..4b08d4d 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1307,8 +1307,8 @@ ctrl_c_handler (DWORD event_type)
return TRUE;
}
-/* Get the next event from the child. Return 1 if the event requires
- handling by WFI (or whatever). */
+/* Get the next event from the child. Returns a non-zero thread id if the event
+ requires handling by WFI (or whatever). */
static int
get_windows_debug_event (struct target_ops *ops,
int pid, struct target_waitstatus *ourstatus)
@@ -1317,7 +1317,7 @@ get_windows_debug_event (struct target_ops *ops,
DWORD continue_status, event_code;
windows_thread_info *th;
static windows_thread_info dummy_thread_info;
- int retval = 0;
+ DWORD thread_id = 0;
last_sig = GDB_SIGNAL_0;
@@ -1348,14 +1348,14 @@ get_windows_debug_event (struct target_ops *ops,
/* Kludge around a Windows bug where first event is a create
thread event. Caused when attached process does not have
a main thread. */
- retval = fake_create_process ();
- if (retval)
+ thread_id = fake_create_process ();
+ if (thread_id)
saw_create++;
}
break;
}
/* Record the existence of this thread. */
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
current_event.u.CreateThread.hThread,
@@ -1398,7 +1398,7 @@ get_windows_debug_event (struct target_ops *ops,
current_event.dwThreadId),
current_event.u.CreateProcessInfo.hThread,
current_event.u.CreateProcessInfo.lpThreadLocalBase);
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
break;
case EXIT_PROCESS_DEBUG_EVENT:
@@ -1417,7 +1417,7 @@ get_windows_debug_event (struct target_ops *ops,
{
ourstatus->kind = TARGET_WAITKIND_EXITED;
ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
- retval = main_thread_id;
+ thread_id = main_thread_id;
}
break;
@@ -1432,7 +1432,7 @@ get_windows_debug_event (struct target_ops *ops,
catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL);
ourstatus->kind = TARGET_WAITKIND_LOADED;
ourstatus->value.integer = 0;
- retval = main_thread_id;
+ thread_id = main_thread_id;
break;
case UNLOAD_DLL_DEBUG_EVENT:
@@ -1445,7 +1445,7 @@ get_windows_debug_event (struct target_ops *ops,
catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL);
ourstatus->kind = TARGET_WAITKIND_LOADED;
ourstatus->value.integer = 0;
- retval = main_thread_id;
+ thread_id = main_thread_id;
break;
case EXCEPTION_DEBUG_EVENT:
@@ -1461,7 +1461,7 @@ get_windows_debug_event (struct target_ops *ops,
continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
case 1:
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
break;
case -1:
last_sig = 1;
@@ -1477,7 +1477,7 @@ get_windows_debug_event (struct target_ops *ops,
"OUTPUT_DEBUG_STRING_EVENT"));
if (saw_create != 1)
break;
- retval = handle_output_debug_string (ourstatus);
+ thread_id = handle_output_debug_string (ourstatus);
break;
default:
@@ -1491,7 +1491,7 @@ get_windows_debug_event (struct target_ops *ops,
break;
}
- if (!retval || saw_create != 1)
+ if (!thread_id || saw_create != 1)
{
if (continue_status == -1)
windows_resume (ops, minus_one_ptid, 0, 1);
@@ -1501,14 +1501,14 @@ get_windows_debug_event (struct target_ops *ops,
else
{
inferior_ptid = ptid_build (current_event.dwProcessId, 0,
- retval);
+ thread_id);
current_thread = th;
if (!current_thread)
current_thread = thread_rec (current_event.dwThreadId, TRUE);
}
out:
- return retval;
+ return thread_id;
}
/* Wait for interesting events to occur in the target process. */
--
2.1.4
next prev parent reply other threads:[~2015-04-16 19:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 11:03 [PATCH] Fixes to Cygwin-specific signal handling Jon Turney
2015-04-14 13:16 ` Joel Brobecker
2015-04-14 14:38 ` Eli Zaretskii
2015-04-16 19:24 ` Jon TURNEY
2015-04-22 14:23 ` Joel Brobecker
2015-04-16 19:23 ` [PATCH 0/5] Fix to Cygwin-specific signal handling (v2) Jon Turney
2015-04-16 19:23 ` Jon Turney [this message]
2015-04-22 13:52 ` [PATCH 2/5] windows-nat: Cleanups in get_windows_debug_event Joel Brobecker
2015-04-16 19:24 ` [PATCH 4/5] windows-nat: Report an error if ContinueDebugEvent() fails Jon Turney
2015-04-22 14:10 ` Joel Brobecker
2015-04-16 19:24 ` [PATCH 1/5] windows-nat: Don't use ternary conditional operator in get_windows_debug_event Jon Turney
2015-04-22 13:50 ` Joel Brobecker
2015-04-16 19:24 ` [PATCH 5/5] windows-nat: Don't change current_event.dwThreadId in handle_output_debug_string() Jon Turney
2015-04-22 14:18 ` Joel Brobecker
2015-04-16 19:24 ` [PATCH 3/5] windows-nat: Fix misspelling in debug output Jon Turney
2015-04-22 13:55 ` Joel Brobecker
2015-06-10 13:06 ` [PATCH 0/5] Fix to Cygwin-specific signal handling (v2) Jon TURNEY
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429212209-20548-3-git-send-email-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox