public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] scox/strace: Refactor out redundant code.
@ 2016-08-26 21:22 scox
0 siblings, 0 replies; only message in thread
From: scox @ 2016-08-26 21:22 UTC (permalink / raw)
To: archer-commits
The branch, scox/strace has been updated
via 25e20ac21cf4916614b2b4d63d1cd998046b08a9 (commit)
from fc4a7a9c2ca31630b3d4f343de80b5f146c12f50 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 25e20ac21cf4916614b2b4d63d1cd998046b08a9
Author: Stan Cox <scox@redhat.com>
Date: Fri Aug 26 17:21:40 2016 -0400
Refactor out redundant code.
* (setup_multiplexing, notify_clients, do_multiplexing): Refactor.
-----------------------------------------------------------------------
Summary of changes:
gdb/gdbserver/ChangeLog | 4 +
gdb/gdbserver/server.c | 245 ++++++++++++++++++----------------------------
2 files changed, 100 insertions(+), 149 deletions(-)
First 500 lines of diff:
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 2031237..2df9fb1 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,7 @@
+2016-08-26 Stan Cox <scox@redhat.com>
+
+ * server.c (setup_multiplexing, notify_clients, do_multiplexing): Refactor.
+
2016-08-24 Stan Cox <scox@redhat.com>
* server.c (add_client_breakpoint, delete_client_breakpoint): Remove.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 6d8a6de..237bf12 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -625,10 +625,7 @@ setup_multiplexing (client_state *current_cs)
/* Current client is continuing and found another waitee client */
case /* current_cs->packet_type */ vContc:
{
- if (!(non_stop
- && current_cs->catch_syscalls
- && same_pid_cs->packet_type == vContc))
- current_cs->pending = pending_cont_waiter;
+ current_cs->pending = pending_cont_waiter;
}
break;
}
@@ -664,7 +661,7 @@ setup_multiplexing (client_state *current_cs)
}
-/* Send a notification to a shadow client.
+/* Send a notification to a pending client.
Called via the handle_target_event notification mechanism. */
int
@@ -701,21 +698,14 @@ notify_clients (char *buffer, int have_first_notify)
set_client_state (save_client_fd);
return 1;
case TARGET_WAITKIND_STOPPED:
- if ((same_pid_cs->pending == pending_cont_waiter
- && same_pid_cs->packet_type == vContc))
- {
- CORE_ADDR point_addr;
- struct regcache *regcache = same_pid_cs->ss->current_thread_->regcache_data;
- point_addr = (*the_target->read_pc) (regcache);
- }
- /* Have more than 1 notify so also send to shadow client */
+ /* pending client will also want a notify */
if (save_client_cs->packet_type == vStopped)
{
same_pid_cs->nonstop_pending = pending_notifier;
}
default:
- /* Only syscall clients need to see a syscall packet */
+ /* syscall clients only need to see a syscall packet */
if (save_client_cs->catch_syscalls)
{
set_client_state (same_pid_cs->file_desc);
@@ -731,15 +721,14 @@ notify_clients (char *buffer, int have_first_notify)
/* client wants the notification */
if (same_pid_cs->nonstop_pending == pending_notifier)
{
- /* Also send the notification to the attached client */
+ /* Also send the notification to the pending client */
set_client_state (same_pid_cs->file_desc);
if (debug_threads)
debug_printf ("%s:%d Notifying fd=%d\n", __FUNCTION__, __LINE__, same_pid_cs->file_desc);
/* This is the first notification */
if (have_first_notify
&& (is_waiter (same_pid_cs)
- || (save_client_cs->packet_type != vStopped
- && same_pid_cs->nonstop_pending == pending_notifier)))
+ || (save_client_cs->packet_type != vStopped)))
{
putpkt (okay_buf);
putpkt_notif (buffer);
@@ -760,47 +749,6 @@ notify_clients (char *buffer, int have_first_notify)
}
-void
-notify_all_stop_clients ()
-{
- client_state *same_pid_cs = NULL;
- client_state *current_cs = client_states.current_cs;
-
- /* TODO Can this handle all the cases that notify_clients does? */
-
- if (non_stop)
- return;
- for (same_pid_cs = client_states.first;
- same_pid_cs != NULL;
- same_pid_cs = same_pid_cs->next)
- {
- /* Is this a client attached to the same process? */
- if (! attached_to_same_proc (client_states.current_cs, same_pid_cs))
- continue;
-
- switch (last_status.kind)
- {
- case TARGET_WAITKIND_SYSCALL_ENTRY:
- case TARGET_WAITKIND_SYSCALL_RETURN:
- case TARGET_WAITKIND_EXITED:
- case TARGET_WAITKIND_STOPPED:
- break;
- default:
- if (current_cs->catch_syscalls)
- {
- /* Only syscall clients need to see a syscall packet */
- resolve_waiter (same_pid_cs, current_cs);
- dump_client_state (__FUNCTION__, "resolved all stop syscall");
- current_cs->pending = same_pid_cs->pending;
- same_pid_cs->pending = pending_waitee;
- set_client_state (same_pid_cs->file_desc);
- return;
- }
- }
- }
-}
-
-
/* Resolve the state of client WAITEE_CS with respect to other clients connected to the same server process */
static int
@@ -839,17 +787,7 @@ do_multiplexing (client_state *current_cs)
current_cs->last_packet_type = other_packet;
return 0;
}
- case Hg:
- if (current_cs->last_packet_type != vRun
- && current_cs->last_packet_type != vAttach)
- current_cs->last_packet_type = current_cs->packet_type;
- break;
- case vContc:
- case vConts:
- case vRun:
- case vAttach:
- case g_or_m:
- case vStopped:
+ default:
current_cs->last_packet_type = current_cs->packet_type;
}
@@ -863,9 +801,7 @@ do_multiplexing (client_state *current_cs)
case vConts:
if (current_cs->pending == pending_waitee)
break;
- default: /* fall through */
- if (current_cs->catch_syscalls)
- break;
+ default:
dump_client_state (__FUNCTION__, "no action taken");
return 1;
}
@@ -878,95 +814,107 @@ do_multiplexing (client_state *current_cs)
int current_cs_has_bp = 0;
int same_pid_cs_has_bp = 0;
- /* Insure another client is attached to the cs process */
- if (! attached_to_same_proc (current_cs, same_pid_cs))
+ /* Is this a waiting continuing client attached to the cs process */
+ if (! attached_to_same_proc (current_cs, same_pid_cs)
+ || (same_pid_cs->pending != pending_cont_waiter)
+ || (same_pid_cs->packet_type != vContc))
continue;
-
- switch (same_pid_cs->pending)
+
+ switch (current_cs->packet_type)
{
- case /* same_pid_cs->pending */ pending_cont_waiter:
- /* Found a vContc packet that is waiting */
- switch (same_pid_cs->packet_type)
+ case vContc:
+ switch (last_status.kind)
{
- case /* same_pid_cs->packet_type */ vContc:
- if (current_cs->packet_type == vContc
- && (current_cs->ss->last_status_.kind == TARGET_WAITKIND_SYSCALL_ENTRY
- || current_cs->ss->last_status_.kind == TARGET_WAITKIND_SYSCALL_RETURN))
+ case TARGET_WAITKIND_SYSCALL_ENTRY:
+ case TARGET_WAITKIND_SYSCALL_RETURN:
+ {
+ if (same_pid_cs->catch_syscalls)
+ {
+ resolve_waiter (same_pid_cs, current_cs);
+ dump_client_state (__FUNCTION__, "resolved syscall");
+ same_pid_cs->pending = pending_waitee;
+ }
+ else if (current_cs->catch_syscalls)
+ {
+ current_cs_has_bp = 1;
+ same_pid_cs_has_bp = 1;
+ }
+ }
+ break;
+ case TARGET_WAITKIND_EXITED:
+ case TARGET_WAITKIND_STOPPED:
+ break;
+ default:
+ if (! non_stop && current_cs->catch_syscalls)
{
- if (same_pid_cs->catch_syscalls)
- {
- resolve_waiter (same_pid_cs, current_cs);
- dump_client_state (__FUNCTION__, "resolved syscall");
- same_pid_cs->pending = pending_waitee;
- }
- else if (current_cs->catch_syscalls)
- {
- current_cs_has_bp = 1;
- same_pid_cs_has_bp = 1;
- }
+ /* syscall clients only need to see a syscall packet */
+ resolve_waiter (same_pid_cs, current_cs);
+ dump_client_state (__FUNCTION__, "resolved all stop syscall");
+ current_cs->pending = same_pid_cs->pending;
+ same_pid_cs->pending = pending_waitee;
+ set_client_state (same_pid_cs->file_desc);
+ return 1;
}
+ }
+ break; /* vContc */
+
+ case vConts:
+ current_cs->last_cont_ptid = current_cs->ss->general_thread_;
+ current_cs->last_cont_waitstatus = current_cs->ss->last_status_;
+ }
- else if (current_cs->packet_type == vConts)
- {
- current_cs->last_cont_ptid = current_cs->ss->general_thread_;
- current_cs->last_cont_waitstatus = current_cs->ss->last_status_;
- }
+ switch (last_status.kind)
+ {
+ case TARGET_WAITKIND_EXITED:
+ waiter_cs = set_client_state (same_pid_cs->file_desc);
+ current_cs_has_bp = 1;
+ same_pid_cs_has_bp = 1;
+ break;
+ default:
+ /* Does current client have a breakpoint at PC? */
+ if (get_first_thread () != NULL)
+ {
+ struct regcache *regcache;
+ CORE_ADDR point_addr = 0;
- if (current_cs->ss->last_status_.kind == TARGET_WAITKIND_EXITED)
+ if ((*the_target->stopped_by_watchpoint)())
+ point_addr = (*the_target->stopped_data_address) ();
+ else
{
- waiter_cs = set_client_state (same_pid_cs->file_desc);
- current_cs_has_bp = 1;
- same_pid_cs_has_bp = 1;
+ regcache = client_states.current_cs->ss->current_thread_->regcache_data;
+ point_addr = (*the_target->read_pc) (regcache);
}
- else /* not exited */
+ if (point_addr)
{
- /* Does current client have a breakpoint at PC? */
- if (get_first_thread () != NULL)
- {
- struct regcache *regcache;
- CORE_ADDR point_addr = 0;
-
- if ((*the_target->stopped_by_watchpoint)())
- point_addr = (*the_target->stopped_data_address) ();
- else
- {
- regcache = client_states.current_cs->ss->current_thread_->regcache_data;
- point_addr = (*the_target->read_pc) (regcache);
- }
- if (point_addr)
- {
- waiter_cs = set_client_state (same_pid_cs->file_desc);
- /* Does found client have a breakpoint at PC? */
- same_pid_cs_has_bp = gdb_breakpoint_here (point_addr);
- }
- else if (current_cs->packet_type == vConts
- && last_status.kind == TARGET_WAITKIND_STOPPED)
- {
- /* there is no target->stopped_by_single_step so just assume that */
- waiter_cs = set_client_state (same_pid_cs->file_desc);
- same_pid_cs_has_bp = 1;
- }
- }
+ waiter_cs = set_client_state (same_pid_cs->file_desc);
+ /* Does found client have a breakpoint at PC? */
+ same_pid_cs_has_bp = gdb_breakpoint_here (point_addr);
}
-
- if (same_pid_cs_has_bp)
+ else if (current_cs->packet_type == vConts
+ && last_status.kind == TARGET_WAITKIND_STOPPED)
{
- /* Belatedly reply to the waiter client */
- resolve_waiter (waiter_cs, current_cs);
- current_cs->pending = none_pending;
- if (!current_cs_has_bp)
- waiter_cs->pending = pending_waitee;
- else
- waiter_cs->pending = none_pending;
- /* If the waitee did not reach the breakpoint then it needs to wait */
- if (!current_cs_has_bp)
- make_waitee_a_waiter = 1;
+ /* there is no target->stopped_by_single_step so just assume that */
+ waiter_cs = set_client_state (same_pid_cs->file_desc);
+ same_pid_cs_has_bp = 1;
}
- current_cs = set_client_state (current_cs->file_desc);
- } /* switch same_pid_cs->packet_type */
- break; /* case vContc */
- } /* switch same_pid_cs->pending */
- }
+ }
+ }
+
+ if (same_pid_cs_has_bp)
+ {
+ /* Belatedly reply to the waiter client */
+ resolve_waiter (waiter_cs, current_cs);
+ current_cs->pending = none_pending;
+ if (!current_cs_has_bp)
+ waiter_cs->pending = pending_waitee;
+ else
+ waiter_cs->pending = none_pending;
+ /* If the waitee did not reach the breakpoint then it needs to wait */
+ if (!current_cs_has_bp)
+ make_waitee_a_waiter = 1;
+ }
+ current_cs = set_client_state (current_cs->file_desc);
+ } /* for (same_pid_cs */
if (make_waitee_a_waiter && current_cs->packet_type == vContc)
{
@@ -5255,7 +5203,6 @@ process_serial_event (void)
if (! do_multiplexing (get_client_state()))
return 0;
- notify_all_stop_clients ();
if (new_packet_len != -1)
putpkt_binary (own_buffer, new_packet_len);
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-26 21:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 21:22 [SCM] scox/strace: Refactor out redundant code scox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).