From patchwork Tue Aug 18 15:53:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 8259 Received: (qmail 66905 invoked by alias); 18 Aug 2015 15:53:27 -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 66846 invoked by uid 89); 18 Aug 2015 15:53:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 18 Aug 2015 15:53:26 +0000 Received: by pabyb7 with SMTP id yb7so135504989pab.0 for ; Tue, 18 Aug 2015 08:53:24 -0700 (PDT) X-Received: by 10.68.218.136 with SMTP id pg8mr14642333pbc.169.1439913204624; Tue, 18 Aug 2015 08:53:24 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id fn15sm18590925pdb.50.2015.08.18.08.53.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Aug 2015 08:53:23 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 01/13] [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change Date: Tue, 18 Aug 2015 16:53:07 +0100 Message-Id: <1439913199-22882-2-git-send-email-yao.qi@linaro.org> In-Reply-To: <1439913199-22882-1-git-send-email-yao.qi@linaro.org> References: <1439913199-22882-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch makes more bits on aarch64 watchpoint between GDB and GDBserver look similar. gdb/gdbserver: 2015-08-18 Yao Qi * linux-aarch64-low.c (aarch64_dr_update_callback_param) : Remove. (debug_reg_change_callback): Remove argument entry and add argument lwp. Remove local variable thread. Don't print thread id in the debugging output. Don't check whether pid of thread equals to pid. (aarch64_notify_debug_reg_change): Don't set param.pid. Call iterate_over_lwps instead find_inferior. --- gdb/gdbserver/linux-aarch64-low.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index da472ae..d39a54f 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -236,25 +236,23 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state) struct aarch64_dr_update_callback_param { - int pid; int is_watchpoint; unsigned int idx; }; -/* Callback function which records the information about the change of - one hardware breakpoint/watchpoint setting for the thread ENTRY. +/* Callback for iterate_over_lwps. Records the + information about the change of one hardware breakpoint/watchpoint + setting for the thread LWP. The information is passed in via PTR. N.B. The actual updating of hardware debug registers is not carried out until the moment the thread is resumed. */ static int -debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr) +debug_reg_change_callback (struct lwp_info *lwp, void *ptr) { - struct thread_info *thread = (struct thread_info *) entry; - struct lwp_info *lwp = get_thread_lwp (thread); struct aarch64_dr_update_callback_param *param_p = (struct aarch64_dr_update_callback_param *) ptr; - int pid = param_p->pid; + int pid = pid_of (lwp->thread); int idx = param_p->idx; int is_watchpoint = param_p->is_watchpoint; struct arch_lwp_info *info = lwp->arch_private; @@ -264,9 +262,9 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr) if (show_debug_regs) { fprintf (stderr, "debug_reg_change_callback: \n\tOn entry:\n"); - fprintf (stderr, "\tpid%d, tid: %ld, dr_changed_bp=0x%llx, " + fprintf (stderr, "\tpid%d, dr_changed_bp=0x%llx, " "dr_changed_wp=0x%llx\n", - pid, lwpid_of (thread), info->dr_changed_bp, + pid, info->dr_changed_bp, info->dr_changed_wp); } @@ -274,9 +272,6 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr) : &info->dr_changed_bp; dr_changed = *dr_changed_ptr; - /* Only update the threads of this process. */ - if (pid_of (thread) == pid) - { gdb_assert (idx >= 0 && (idx <= (is_watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs))); @@ -310,13 +305,12 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr) we can update its debug registers. */ if (!lwp->stopped) linux_stop_lwp (lwp); - } if (show_debug_regs) { - fprintf (stderr, "\tOn exit:\n\tpid%d, tid: %ld, dr_changed_bp=0x%llx, " + fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%llx, " "dr_changed_wp=0x%llx\n", - pid, lwpid_of (thread), info->dr_changed_bp, + pid, info->dr_changed_bp, info->dr_changed_wp); } @@ -333,14 +327,12 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state, int is_watchpoint, unsigned int idx) { struct aarch64_dr_update_callback_param param; - - /* Only update the threads of this process. */ - param.pid = pid_of (current_thread); + ptid_t pid_ptid = pid_to_ptid (pid_of (current_thread)); param.is_watchpoint = is_watchpoint; param.idx = idx; - find_inferior (&all_threads, debug_reg_change_callback, (void *) ¶m); + iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) ¶m); }