From patchwork Tue Aug 18 15:53:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 8270 Received: (qmail 71552 invoked by alias); 18 Aug 2015 15:53:50 -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 71435 invoked by uid 89); 18 Aug 2015 15:53:49 -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-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 18 Aug 2015 15:53:37 +0000 Received: by pabyb7 with SMTP id yb7so135507556pab.0 for ; Tue, 18 Aug 2015 08:53:34 -0700 (PDT) X-Received: by 10.68.202.36 with SMTP id kf4mr14772370pbc.49.1439913214435; Tue, 18 Aug 2015 08:53:34 -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.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Aug 2015 08:53:34 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 09/13] Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c Date: Tue, 18 Aug 2015 16:53:15 +0100 Message-Id: <1439913199-22882-10-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 gdb: 2015-08-18 Yao Qi * aarch64-linux-nat.c (struct arch64_dr_update_callback_param): Move it to nat/aarch64-linux-hw-point.c. (debug_reg_change_callback): Likewise. (aarch64_notify_debug_reg_change): :Likewise. * nat/aarch64-linux-hw-point.c: Include nat/linux-nat.h. (aarch64_dr_update_callback_param): New. (debug_reg_change_callback): New function. (aarch64_notify_debug_reg_change): Likewise. * nat/aarch64-linux-hw-point.h (aarch64_notify_debug_reg_change): Remove the declaration. gdb/gdbserver: 2015-08-18 Yao Qi * linux-aarch64-low.c (struct arch64_dr_update_callback_param): Remove. (debug_reg_change_callback): Remove. (aarch64_notify_debug_reg_change): Remove. --- gdb/aarch64-linux-nat.c | 85 ------------------------------------- gdb/gdbserver/linux-aarch64-low.c | 82 ------------------------------------ gdb/nat/aarch64-linux-hw-point.c | 88 +++++++++++++++++++++++++++++++++++++++ gdb/nat/aarch64-linux-hw-point.h | 3 -- 4 files changed, 88 insertions(+), 170 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 6594489..1b3ed57 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -147,91 +147,6 @@ aarch64_get_debug_reg_state (pid_t pid) return &aarch64_process_info_get (pid)->state; } -struct aarch64_dr_update_callback_param -{ - int is_watchpoint; - unsigned int idx; -}; - -/* 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 lwp_info *lwp, void *ptr) -{ - struct aarch64_dr_update_callback_param *param_p - = (struct aarch64_dr_update_callback_param *) ptr; - int pid = ptid_get_pid (ptid_of_lwp (lwp)); - int idx = param_p->idx; - int is_watchpoint = param_p->is_watchpoint; - struct arch_lwp_info *info = lwp->arch_private; - dr_changed_t *dr_changed_ptr; - dr_changed_t dr_changed; - - if (info == NULL) - info = lwp->arch_private = XCNEW (struct arch_lwp_info); - - if (show_debug_regs) - { - debug_printf ("debug_reg_change_callback: \n\tOn entry:\n"); - debug_printf ("\tpid%d, dr_changed_bp=0x%s, " - "dr_changed_wp=0x%s\n", pid, - phex (info->dr_changed_bp, 8), - phex (info->dr_changed_wp, 8)); - } - - dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp - : &info->dr_changed_bp; - dr_changed = *dr_changed_ptr; - - gdb_assert (idx >= 0 - && (idx <= (is_watchpoint ? aarch64_num_wp_regs - : aarch64_num_bp_regs))); - - /* The actual update is done later just before resuming the lwp, - we just mark that one register pair needs updating. */ - DR_MARK_N_CHANGED (dr_changed, idx); - *dr_changed_ptr = dr_changed; - - /* If the lwp isn't stopped, force it to momentarily pause, so - we can update its debug registers. */ - if (!lwp->stopped) - linux_stop_lwp (lwp); - - if (show_debug_regs) - { - debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, " - "dr_changed_wp=0x%s\n", pid, - phex (info->dr_changed_bp, 8), - phex (info->dr_changed_wp, 8)); - } - - /* Continue the iteration. */ - return 0; -} - -/* Notify each thread that their IDXth breakpoint/watchpoint register - pair needs to be updated. The message will be recorded in each - thread's arch-specific data area, the actual updating will be done - when the thread is resumed. */ - -void -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; - ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); - - param.is_watchpoint = is_watchpoint; - param.idx = idx; - - iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) ¶m); -} - /* Fill GDB's register array with the general-purpose register values from the current thread. */ diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 4c482a9..3968aee 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -234,88 +234,6 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state) } } -struct aarch64_dr_update_callback_param -{ - int is_watchpoint; - unsigned int idx; -}; - -/* 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 lwp_info *lwp, void *ptr) -{ - struct aarch64_dr_update_callback_param *param_p - = (struct aarch64_dr_update_callback_param *) ptr; - int pid = ptid_get_pid (ptid_of_lwp (lwp)); - int idx = param_p->idx; - int is_watchpoint = param_p->is_watchpoint; - struct arch_lwp_info *info = lwp->arch_private; - dr_changed_t *dr_changed_ptr; - dr_changed_t dr_changed; - - if (show_debug_regs) - { - debug_printf ("debug_reg_change_callback: \n\tOn entry:\n"); - debug_printf ("\tpid%d, dr_changed_bp=0x%s, " - "dr_changed_wp=0x%s\n", pid, - phex (info->dr_changed_bp, 8), - phex (info->dr_changed_wp, 8)); - } - - dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp - : &info->dr_changed_bp; - dr_changed = *dr_changed_ptr; - - gdb_assert (idx >= 0 - && (idx <= (is_watchpoint ? aarch64_num_wp_regs - : aarch64_num_bp_regs))); - - /* The actual update is done later just before resuming the lwp, - we just mark that one register pair needs updating. */ - DR_MARK_N_CHANGED (dr_changed, idx); - *dr_changed_ptr = dr_changed; - - /* If the lwp isn't stopped, force it to momentarily pause, so - we can update its debug registers. */ - if (!lwp->stopped) - linux_stop_lwp (lwp); - - if (show_debug_regs) - { - debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, " - "dr_changed_wp=0x%s\n", pid, - phex (info->dr_changed_bp, 8), - phex (info->dr_changed_wp, 8)); - } - - return 0; -} - -/* Notify each thread that their IDXth breakpoint/watchpoint register - pair needs to be updated. The message will be recorded in each - thread's arch-specific data area, the actual updating will be done - when the thread is resumed. */ - -void -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; - ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); - - param.is_watchpoint = is_watchpoint; - param.idx = idx; - - iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) ¶m); -} - - /* Return the pointer to the debug register state structure in the current process' arch-specific data area. */ diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c index 1d9664e..ba235e5 100644 --- a/gdb/nat/aarch64-linux-hw-point.c +++ b/gdb/nat/aarch64-linux-hw-point.c @@ -18,6 +18,7 @@ #include "common-defs.h" #include "break-common.h" +#include "nat/linux-nat.h" #include "aarch64-linux-hw-point.h" #include @@ -220,6 +221,93 @@ aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p, *next_len_p = len; } +struct aarch64_dr_update_callback_param +{ + int is_watchpoint; + unsigned int idx; +}; + +/* 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 lwp_info *lwp, void *ptr) +{ + struct aarch64_dr_update_callback_param *param_p + = (struct aarch64_dr_update_callback_param *) ptr; + int pid = ptid_get_pid (ptid_of_lwp (lwp)); + int idx = param_p->idx; + int is_watchpoint = param_p->is_watchpoint; + struct arch_lwp_info *info = lwp_arch_private_info (lwp); + dr_changed_t *dr_changed_ptr; + dr_changed_t dr_changed; + + if (info == NULL) + { + info = XCNEW (struct arch_lwp_info); + lwp_set_arch_private_info (lwp, info); + } + + if (show_debug_regs) + { + debug_printf ("debug_reg_change_callback: \n\tOn entry:\n"); + debug_printf ("\tpid%d, dr_changed_bp=0x%s, " + "dr_changed_wp=0x%s\n", pid, + phex (info->dr_changed_bp, 8), + phex (info->dr_changed_wp, 8)); + } + + dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp + : &info->dr_changed_bp; + dr_changed = *dr_changed_ptr; + + gdb_assert (idx >= 0 + && (idx <= (is_watchpoint ? aarch64_num_wp_regs + : aarch64_num_bp_regs))); + + /* The actual update is done later just before resuming the lwp, + we just mark that one register pair needs updating. */ + DR_MARK_N_CHANGED (dr_changed, idx); + *dr_changed_ptr = dr_changed; + + /* If the lwp isn't stopped, force it to momentarily pause, so + we can update its debug registers. */ + if (!lwp_is_stopped (lwp)) + linux_stop_lwp (lwp); + + if (show_debug_regs) + { + debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, " + "dr_changed_wp=0x%s\n", pid, + phex (info->dr_changed_bp, 8), + phex (info->dr_changed_wp, 8)); + } + + return 0; +} + +/* Notify each thread that their IDXth breakpoint/watchpoint register + pair needs to be updated. The message will be recorded in each + thread's arch-specific data area, the actual updating will be done + when the thread is resumed. */ + +static void +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; + ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); + + param.is_watchpoint = is_watchpoint; + param.idx = idx; + + iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) ¶m); +} + /* Record the insertion of one breakpoint/watchpoint, as represented by ADDR and CTRL, in the process' arch-specific data area *STATE. */ diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h index a430a8f..17cc420 100644 --- a/gdb/nat/aarch64-linux-hw-point.h +++ b/gdb/nat/aarch64-linux-hw-point.h @@ -171,9 +171,6 @@ int aarch64_handle_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert, struct aarch64_debug_reg_state *state); -void aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state, - int is_watchpoint, unsigned int idx); - void aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, int tid, int watchpoint);