From patchwork Sat Oct 21 16:37:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 23751 Received: (qmail 53136 invoked by alias); 21 Oct 2017 16:37:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53118 invoked by uid 89); 21 Oct 2017 16:37:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=32676 X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 21 Oct 2017 16:37:51 +0000 X-ASG-Debug-ID: 1508603865-0c856e65d43816950001-fS2M51 Received: from smtp.electronicbox.net (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id aZPzDVFAnMkPfKrt (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 21 Oct 2017 12:37:45 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (cable-192.222.251.162.electronicbox.net [192.222.251.162]) by smtp.electronicbox.net (Postfix) with ESMTP id D5928441B21; Sat, 21 Oct 2017 12:37:45 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: cable-192.222.251.162.electronicbox.net[192.222.251.162] X-Barracuda-Apparent-Source-IP: 192.222.251.162 X-Barracuda-RBL-IP: 192.222.251.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/3] Remove usages of find_inferior in handle_status Date: Sat, 21 Oct 2017 12:37:42 -0400 X-ASG-Orig-Subj: [PATCH 1/3] Remove usages of find_inferior in handle_status Message-Id: <20171021163744.17005-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1508603865 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2590 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.44089 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes From: Simon Marchi Replace one with find_thread, the other with for_each_thread. gdb/gdbserver/ChangeLog: * server.c (queue_stop_reply_callback): Change prototype, return void. (find_status_pending_thread_callback): Remove. (handle_status): Replace find_inferior with find_thread and for_each_thread. --- gdb/gdbserver/server.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 892d765714..650cf1c674 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -3230,8 +3230,8 @@ myresume (char *own_buf, int step, int sig) /* Callback for for_each_inferior. Make a new stop reply for each stopped thread. */ -static int -queue_stop_reply_callback (thread_info *thread, void *arg) +static void +queue_stop_reply_callback (thread_info *thread) { /* For now, assume targets that don't have this callback also don't manage the thread's last_status field. */ @@ -3267,8 +3267,6 @@ queue_stop_reply_callback (thread_info *thread, void *arg) queue_stop_reply (thread->id, &thread->last_status); } } - - return 0; } /* Set this inferior threads's state as "want-stopped". We won't @@ -3324,15 +3322,6 @@ set_pending_status_callback (thread_info *thread) thread->status_pending_p = 1; } -/* Callback for find_inferior. Return true if ENTRY (a thread) has a - pending status to report to GDB. */ - -static int -find_status_pending_thread_callback (thread_info *thread, void *data) -{ - return thread->status_pending_p; -} - /* Status handler for the '?' packet. */ static void @@ -3349,7 +3338,7 @@ handle_status (char *own_buf) if (non_stop) { - find_inferior (&all_threads, queue_stop_reply_callback, NULL); + for_each_thread (queue_stop_reply_callback); /* The first is sent immediatly. OK is sent if there is no stopped thread, which is the same handling of the vStopped @@ -3382,8 +3371,10 @@ handle_status (char *own_buf) /* If the last event thread is not found for some reason, look for some other thread that might have an event to report. */ if (thread == NULL) - thread = find_inferior (&all_threads, - find_status_pending_thread_callback, NULL); + thread = find_thread ([] (thread_info *thread) + { + return thread->status_pending_p; + }); /* If we're still out of luck, simply pick the first thread in the thread list. */