From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8694 invoked by alias); 25 Aug 2010 16:26:41 -0000 Received: (qmail 8619 invoked by uid 22791); 25 Aug 2010 16:26:39 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Aug 2010 16:26:34 +0000 Received: (qmail 28643 invoked from network); 25 Aug 2010 16:26:31 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 25 Aug 2010 16:26:31 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [gdbserver 2/N] move a bit of code from the linux backend to common code Date: Wed, 25 Aug 2010 16:26:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.33-29-realtime; KDE/4.4.2; x86_64; ; ) References: <201008091604.36329.pedro@codesourcery.com> In-Reply-To: <201008091604.36329.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201008251726.26559.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00433.txt.bz2 On Monday 09 August 2010 16:04:36, Pedro Alves wrote: > This moves a bit of code from the linux backend to gdbserver's common code, > since #1, this is state that all backends would need for non-stop support; > #2, it should be possible to move the transparent step-over-breakpoints > support to common code And here's a follow up, continuing the trend. The main bit here is having linux_wait not need to know about the stabilizing_threads global. Tested on x86_64-linux, and applied. -- Pedro Alves 2010-08-25 Pedro Alves * linux-low.c (linux_wait_1): Don't set last_status here. * server.c (push_event, queue_stop_reply_callback): Assert we're not pushing a TARGET_WAITKIND_IGNORE event. (start_inferior, start_inferior, attach_inferior, handle_v_cont) (myresume, handle_target_event): Set the thread's last_resume_kind and last_status from the target returned status. --- gdb/gdbserver/linux-low.c | 3 --- gdb/gdbserver/server.c | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) Index: src/gdb/gdbserver/linux-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-low.c 2010-08-25 15:20:55.000000000 +0100 +++ src/gdb/gdbserver/linux-low.c 2010-08-25 17:04:42.000000000 +0100 @@ -2391,9 +2391,6 @@ Check if we're already there.\n", ourstatus->kind, ourstatus->value.sig); - if (!stabilizing_threads) - current_inferior->last_status = *ourstatus; - return ptid_of (event_child); } Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c 2010-08-24 20:51:14.000000000 +0100 +++ src/gdb/gdbserver/server.c 2010-08-25 17:04:42.000000000 +0100 @@ -158,6 +158,8 @@ queue_stop_reply (ptid_t ptid, struct ta void push_event (ptid_t ptid, struct target_waitstatus *status) { + gdb_assert (status->kind != TARGET_WAITKIND_IGNORE); + queue_stop_reply (ptid, status); /* If this is the first stop reply in the queue, then inform GDB @@ -292,9 +294,14 @@ start_inferior (char **argv) mywait (pid_to_ptid (signal_pid), &last_status, 0, 0); if (last_status.kind != TARGET_WAITKIND_STOPPED) return signal_pid; + + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; } while (last_status.value.sig != TARGET_SIGNAL_TRAP); + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; return signal_pid; } @@ -302,6 +309,13 @@ start_inferior (char **argv) (assuming success). */ last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0); + if (last_status.kind != TARGET_WAITKIND_EXITED + && last_status.kind != TARGET_WAITKIND_SIGNALLED) + { + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; + } + return signal_pid; } @@ -332,6 +346,9 @@ attach_inferior (int pid) if (last_status.kind == TARGET_WAITKIND_STOPPED && last_status.value.sig == TARGET_SIGNAL_STOP) last_status.value.sig = TARGET_SIGNAL_TRAP; + + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; } return 0; @@ -1780,6 +1797,10 @@ handle_v_cont (char *own_buf) { last_ptid = mywait (minus_one_ptid, &last_status, 0, 1); + if (last_status.kind != TARGET_WAITKIND_EXITED + && last_status.kind != TARGET_WAITKIND_SIGNALLED) + current_inferior->last_status = last_status; + /* From the client's perspective, all-stop mode always stops all threads implicitly (and the target backend has already done so by now). Tag all threads as "want-stopped", so we don't @@ -2089,6 +2110,14 @@ myresume (char *own_buf, int step, int s else { last_ptid = mywait (minus_one_ptid, &last_status, 0, 1); + + if (last_status.kind != TARGET_WAITKIND_EXITED + && last_status.kind != TARGET_WAITKIND_SIGNALLED) + { + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; + } + prepare_resume_reply (own_buf, last_ptid, &last_status); disable_async_io (); @@ -2128,6 +2157,8 @@ queue_stop_reply_callback (struct inferi target_pid_to_str (entry->id), target_waitstatus_to_string (&thread->last_status)); + gdb_assert (thread->last_status.kind != TARGET_WAITKIND_IGNORE); + /* Pass the last stop reply back to GDB, but don't notify yet. */ queue_stop_reply (entry->id, &thread->last_status); @@ -3135,10 +3166,13 @@ handle_target_event (int err, gdb_client mourn_inferior (process); } else - /* We're reporting this thread as stopped. Update it's - "want-stopped" state to what the client wants, until it gets - a new resume action. */ - gdb_wants_thread_stopped (¤t_inferior->entry); + { + /* We're reporting this thread as stopped. Update its + "want-stopped" state to what the client wants, until it + gets a new resume action. */ + current_inferior->last_resume_kind = resume_stop; + current_inferior->last_status = last_status; + } if (forward_event) {