From patchwork Thu Jun 30 14:09:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 13515 Received: (qmail 58765 invoked by alias); 30 Jun 2016 14:09:45 -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 58580 invoked by uid 89); 30 Jun 2016 14:09:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:id X-HELO: mail-pa0-f66.google.com Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 30 Jun 2016 14:09:40 +0000 Received: by mail-pa0-f66.google.com with SMTP id av7so7300352pac.3 for ; Thu, 30 Jun 2016 07:09:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=hx4wcaV4TYqhJ+ue4SL3JvJ7qeBsmL7+RaXS+vQgTkc=; b=hCnOprR/PNqBZ7nbfBjuDPqcTVULLkO/8fw0E9MS8bcY6+MZb2zJjpjwQVuK5ReCgE MAbgQCEEecRFs2qsbW55vinOLlnu89VnYK8Yp23j+54ZCq5RKk08MZehzd6GkBwOH3Z4 M2GAhMgdVmYkOpI60S7lNDomzzFywmluX97RXmj1cxidhYlsL7yPkdyX2TDPvK2OPFr1 z9quDP/hEYG+ZdzoQXrXXc8IcwE5Ud7Go/x7RVH2zpFp8OQHVhljpQiCLbNnKR4Nqbip zHNUcLF3D/zW0rr6DYmIhZiO2I78dk4OI1dTHiuMCmh6HsiGHSUGlJfJxV+8eNuNEXEh srIQ== X-Gm-Message-State: ALyK8tLQddymkkvuV4S6Ws5A0K8F/aY5186Kvv0oSBrwg0mVjNRRw2D9iwNVd08mEZ3rbg== X-Received: by 10.66.171.173 with SMTP id av13mr21841331pac.117.1467295778628; Thu, 30 Jun 2016 07:09:38 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id s3sm6263184pfb.87.2016.06.30.07.09.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 07:09:38 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 5/9] Switch current_thread to lwp's thread in install_software_single_step_breakpoints Date: Thu, 30 Jun 2016 15:09:21 +0100 Message-Id: <1467295765-3457-6-git-send-email-yao.qi@linaro.org> In-Reply-To: <1467295765-3457-1-git-send-email-yao.qi@linaro.org> References: <1467295765-3457-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes install_software_single_step_breakpoints has parameter lwp, but still need to switch to current_thread. In order to simplify its caller, we do the current_thread save/restore inside install_software_single_step_breakpoints. gdb/gdbserver: 2016-06-17 Yao Qi * gdbthread.h (make_cleanup_restore_current_thread): Declare. * inferiors.c (do_restore_current_thread_cleanup): New function. (make_cleanup_restore_current_thread): Likewise. * linux-low.c (install_software_single_step_breakpoints): Call make_cleanup_restore_current_thread. Switch current_thread to thread. --- gdb/gdbserver/ChangeLog | 9 +++++++++ gdb/gdbserver/gdbthread.h | 3 +++ gdb/gdbserver/inferiors.c | 12 ++++++++++++ gdb/gdbserver/linux-low.c | 8 ++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 07e6743..b043847 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -47,6 +47,15 @@ 2016-06-17 Yao Qi + * gdbthread.h (make_cleanup_restore_current_thread): Declare. + * inferiors.c (do_restore_current_thread_cleanup): New function. + (make_cleanup_restore_current_thread): Likewise. + * linux-low.c (install_software_single_step_breakpoints): Call + make_cleanup_restore_current_thread. Switch current_thread to + thread. + +2016-06-17 Yao Qi + * mem-break.c (struct reinsert_breakpoint) : New field. (set_reinsert_breakpoint): New parameter ptid. Callers updated. (clone_one_breakpoint): Likewise. diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 4dcb1b7..d2326fb 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -87,4 +87,7 @@ struct thread_info *find_any_thread_of_pid (int pid); /* Get current thread ID (Linux task ID). */ #define current_ptid (current_thread->entry.id) +/* Create a cleanup to restore current_thread. */ +struct cleanup *make_cleanup_restore_current_thread (void); + #endif /* GDB_THREAD_H */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 1f5149f..7888f3c 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -411,3 +411,15 @@ current_process (void) gdb_assert (current_thread != NULL); return get_thread_process (current_thread); } + +static void +do_restore_current_thread_cleanup (void *arg) +{ + current_thread = (struct thread_info *) arg; +} + +struct cleanup * +make_cleanup_restore_current_thread (void) +{ + return make_cleanup (do_restore_current_thread_cleanup, current_thread); +} diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index a55a0a5..941b0e8 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4124,10 +4124,14 @@ install_software_single_step_breakpoints (struct lwp_info *lwp) { int i; CORE_ADDR pc; - struct regcache *regcache = get_thread_regcache (current_thread, 1); + struct thread_info *thread = get_lwp_thread (lwp); + struct regcache *regcache = get_thread_regcache (thread, 1); VEC (CORE_ADDR) *next_pcs = NULL; - struct cleanup *old_chain = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs); + struct cleanup *old_chain = make_cleanup_restore_current_thread (); + + make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs); + current_thread = thread; next_pcs = (*the_low_target.get_next_pcs) (regcache); for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); ++i)