From db3cb7cb3e51e5eb834412adbf90e81bb76846c6 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Tue, 25 Aug 2015 11:38:29 +0100 Subject: Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c gdb: 2015-08-25 Yao Qi * Makefile.in (aarch64-liunx.o): New rule. (HFILES_NO_SRCDIR): Add aarch64-linux.h. * config/aarch64/linux.mh (NAT_FILE): Add aarch64-linux.o. * aarch64-linux-nat.c: Include nat/aarch64-linux.h. * aarch64-linux-nat.c (aarch64_get_debug_reg_state): Make it extern. (aarch64_linux_prepare_to_resume): Move it nat/aarch64-linux.c. * nat/aarch64-linux-hw-point.h (aarch64_debug_reg_state): Declare * nat/aarch64-linux.c: New file. * nat/aarch64-linux.h: New file. gdb/gdbserver: 2015-08-25 Yao Qi * Makefile.in (aarch64-linux.o): New rule. * configure.srv (aarch64*-*-linux*): Append aarch64-linux.o to srv_tgtobj. * linux-aarch64-low.c: Include nat/aarch64-linux.h. (aarch64_init_debug_reg_state): Make it extern. (aarch64_linux_prepare_to_resume): Remove. --- gdb/ChangeLog | 13 ++++++++ gdb/Makefile.in | 6 +++- gdb/aarch64-linux-nat.c | 44 ++------------------------- gdb/config/aarch64/linux.mh | 3 +- gdb/gdbserver/ChangeLog | 9 ++++++ gdb/gdbserver/Makefile.in | 3 ++ gdb/gdbserver/configure.srv | 1 + gdb/gdbserver/linux-aarch64-low.c | 39 ++---------------------- gdb/nat/aarch64-linux-hw-point.h | 2 ++ gdb/nat/aarch64-linux.c | 64 +++++++++++++++++++++++++++++++++++++++ gdb/nat/aarch64-linux.h | 24 +++++++++++++++ 11 files changed, 127 insertions(+), 81 deletions(-) create mode 100644 gdb/nat/aarch64-linux.c create mode 100644 gdb/nat/aarch64-linux.h (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6ffaaca..97c3a48 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 2015-08-25 Yao Qi + * Makefile.in (aarch64-liunx.o): New rule. + (HFILES_NO_SRCDIR): Add aarch64-linux.h. + * config/aarch64/linux.mh (NAT_FILE): Add aarch64-linux.o. + * aarch64-linux-nat.c: Include nat/aarch64-linux.h. + * aarch64-linux-nat.c (aarch64_get_debug_reg_state): Make it + extern. + (aarch64_linux_prepare_to_resume): Move it nat/aarch64-linux.c. + * nat/aarch64-linux-hw-point.h (aarch64_debug_reg_state): Declare + * nat/aarch64-linux.c: New file. + * nat/aarch64-linux.h: New file. + +2015-08-25 Yao Qi + * aarch64-linux-nat.c (aarch64_linux_prepare_to_resume): Use lwp_arch_private_info and ptid_of_lwp. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 924979b..0d7cf97 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -937,7 +937,7 @@ tui/tui-winsource.h tui/tui-regs.h tui/tui-io.h tui/tui-layout.h \ tui/tui-source.h sol2-tdep.h gregset.h sh-tdep.h sh64-tdep.h \ expression.h score-tdep.h gdb_select.h ser-tcp.h \ extension.h extension-priv.h nat/aarch64-linux-hw-point.h \ -build-id.h buildsym.h valprint.h \ +build-id.h buildsym.h valprint.h nat/aarch64-linux.h \ typeprint.h mi/mi-getopt.h mi/mi-parse.h mi/mi-console.h \ mi/mi-out.h mi/mi-main.h mi/mi-common.h mi/mi-cmds.h linux-nat.h \ complaints.h gdb_proc_service.h gdb_regex.h xtensa-tdep.h inf-loop.h \ @@ -2332,6 +2332,10 @@ aarch64-linux-hw-point.o: ${srcdir}/nat/aarch64-linux-hw-point.c $(COMPILE) $(srcdir)/nat/aarch64-linux-hw-point.c $(POSTCOMPILE) +aarch64-linux.o: ${srcdir}/nat/aarch64-linux.c + $(COMPILE) $(srcdir)/nat/aarch64-linux.c + $(POSTCOMPILE) + # # gdb/tui/ dependencies # diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index b23026a..ea56238 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -30,6 +30,7 @@ #include "aarch64-tdep.h" #include "aarch64-linux-tdep.h" #include "aarch32-linux-nat.h" +#include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" #include "elf/external.h" @@ -141,7 +142,7 @@ aarch64_forget_process (pid_t pid) /* Get debug registers state for process PID. */ -static struct aarch64_debug_reg_state * +struct aarch64_debug_reg_state * aarch64_get_debug_reg_state (pid_t pid) { return &aarch64_process_info_get (pid)->state; @@ -425,47 +426,6 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) AARCH64_LINUX_SIZEOF_FPREGSET); } -/* Called when resuming a thread. - The hardware debug registers are updated when there is any change. */ - -static void -aarch64_linux_prepare_to_resume (struct lwp_info *lwp) -{ - struct arch_lwp_info *info = lwp_arch_private_info (lwp); - - /* NULL means this is the main thread still going through the shell, - or, no watchpoint has been set yet. In that case, there's - nothing to do. */ - if (info == NULL) - return; - - if (DR_HAS_CHANGED (info->dr_changed_bp) - || DR_HAS_CHANGED (info->dr_changed_wp)) - { - ptid_t ptid = ptid_of_lwp (lwp); - int tid = ptid_get_lwp (ptid); - struct aarch64_debug_reg_state *state - = aarch64_get_debug_reg_state (ptid_get_pid (ptid)); - - if (show_debug_regs) - fprintf_unfiltered (gdb_stdlog, "prepare_to_resume thread %d\n", tid); - - /* Watchpoints. */ - if (DR_HAS_CHANGED (info->dr_changed_wp)) - { - aarch64_linux_set_debug_regs (state, tid, 1); - DR_CLEAR_CHANGED (info->dr_changed_wp); - } - - /* Breakpoints. */ - if (DR_HAS_CHANGED (info->dr_changed_bp)) - { - aarch64_linux_set_debug_regs (state, tid, 0); - DR_CLEAR_CHANGED (info->dr_changed_bp); - } - } -} - static void aarch64_linux_new_thread (struct lwp_info *lp) { diff --git a/gdb/config/aarch64/linux.mh b/gdb/config/aarch64/linux.mh index 231aea1..ea56ff6 100644 --- a/gdb/config/aarch64/linux.mh +++ b/gdb/config/aarch64/linux.mh @@ -22,7 +22,8 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o aarch64-linux-nat.o aarch32-linux-nat.o \ proc-service.o linux-thread-db.o linux-nat.o linux-fork.o \ linux-procfs.o linux-ptrace.o linux-osdata.o linux-waitpid.o \ - linux-personality.o linux-namespaces.o aarch64-linux-hw-point.o + linux-personality.o linux-namespaces.o aarch64-linux-hw-point.o \ + aarch64-linux.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES= -ldl $(RDYNAMIC) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 6fdc29c..274f850 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,14 @@ 2015-08-25 Yao Qi + * Makefile.in (aarch64-linux.o): New rule. + * configure.srv (aarch64*-*-linux*): Append aarch64-linux.o to + srv_tgtobj. + * linux-aarch64-low.c: Include nat/aarch64-linux.h. + (aarch64_init_debug_reg_state): Make it extern. + (aarch64_linux_prepare_to_resume): Remove. + +2015-08-25 Yao Qi + * linux-aarch64-low.c (aarch64_linux_prepare_to_resume): Use lwp_arch_private_info and ptid_of_lwp. diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index 5e04e530..b715a32 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -609,6 +609,9 @@ linux-personality.o: ../nat/linux-personality.c aarch64-linux-hw-point.o: ../nat/aarch64-linux-hw-point.c $(COMPILE) $< $(POSTCOMPILE) +aarch64-linux.o: ../nat/aarch64-linux.c + $(COMPILE) $< + $(POSTCOMPILE) btrace-common.o: ../common/btrace-common.c $(COMPILE) $< $(POSTCOMPILE) diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 320c26a..aa232f8 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -52,6 +52,7 @@ case "${target}" in srv_regobj="${srv_regobj} arm-with-neon.o" srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o" srv_tgtobj="$srv_tgtobj linux-aarch32-low.o" + srv_tgtobj="$srv_tgtobj aarch64-linux.o" srv_tgtobj="${srv_tgtobj} $srv_linux_obj" srv_xmlfiles="aarch64.xml" srv_xmlfiles="${srv_xmlfiles} aarch64-core.xml" diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 4b1d7d5..d35d4e9 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -21,6 +21,7 @@ #include "server.h" #include "linux-low.h" +#include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" #include "linux-aarch32-low.h" #include "elf/common.h" @@ -237,7 +238,7 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state) /* Return the pointer to the debug register state structure in the current process' arch-specific data area. */ -static struct aarch64_debug_reg_state * +struct aarch64_debug_reg_state * aarch64_get_debug_reg_state (pid_t pid) { struct process_info *proc = find_process_pid (pid); @@ -482,42 +483,6 @@ aarch64_linux_new_fork (struct process_info *parent, *child->priv->arch_private = *parent->priv->arch_private; } -/* Implementation of linux_target_ops method "linux_prepare_to_resume". - - If the debug regs have changed, update the thread's copies. */ - -static void -aarch64_linux_prepare_to_resume (struct lwp_info *lwp) -{ - struct arch_lwp_info *info = lwp_arch_private_info (lwp); - - if (DR_HAS_CHANGED (info->dr_changed_bp) - || DR_HAS_CHANGED (info->dr_changed_wp)) - { - ptid_t ptid = ptid_of_lwp (lwp); - int tid = ptid_get_lwp (ptid); - struct aarch64_debug_reg_state *state - = aarch64_get_debug_reg_state (ptid_get_pid (ptid)); - - if (show_debug_regs) - fprintf (stderr, "prepare_to_resume thread %d\n", tid); - - /* Watchpoints. */ - if (DR_HAS_CHANGED (info->dr_changed_wp)) - { - aarch64_linux_set_debug_regs (state, tid, 1); - DR_CLEAR_CHANGED (info->dr_changed_wp); - } - - /* Breakpoints. */ - if (DR_HAS_CHANGED (info->dr_changed_bp)) - { - aarch64_linux_set_debug_regs (state, tid, 0); - DR_CLEAR_CHANGED (info->dr_changed_bp); - } - } -} - /* Return the right target description according to the ELF file of current thread. */ diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h index 17cc420..a27a201 100644 --- a/gdb/nat/aarch64-linux-hw-point.h +++ b/gdb/nat/aarch64-linux-hw-point.h @@ -180,4 +180,6 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, void aarch64_linux_get_debug_reg_capacity (int tid); +struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid); + #endif /* AARCH64_LINUX_HW_POINT_H */ diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c new file mode 100644 index 0000000..7b4ead7 --- /dev/null +++ b/gdb/nat/aarch64-linux.c @@ -0,0 +1,64 @@ +/* Copyright (C) 2009-2015 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "common-defs.h" +#include "break-common.h" +#include "nat/linux-nat.h" +#include "nat/aarch64-linux-hw-point.h" +#include "nat/aarch64-linux.h" + +/* Called when resuming a thread LWP. + The hardware debug registers are updated when there is any change. */ + +void +aarch64_linux_prepare_to_resume (struct lwp_info *lwp) +{ + struct arch_lwp_info *info = lwp_arch_private_info (lwp); + + /* NULL means this is the main thread still going through the shell, + or, no watchpoint has been set yet. In that case, there's + nothing to do. */ + if (info == NULL) + return; + + if (DR_HAS_CHANGED (info->dr_changed_bp) + || DR_HAS_CHANGED (info->dr_changed_wp)) + { + ptid_t ptid = ptid_of_lwp (lwp); + int tid = ptid_get_lwp (ptid); + struct aarch64_debug_reg_state *state + = aarch64_get_debug_reg_state (ptid_get_pid (ptid)); + + if (show_debug_regs) + debug_printf ("prepare_to_resume thread %d\n", tid); + + /* Watchpoints. */ + if (DR_HAS_CHANGED (info->dr_changed_wp)) + { + aarch64_linux_set_debug_regs (state, tid, 1); + DR_CLEAR_CHANGED (info->dr_changed_wp); + } + + /* Breakpoints. */ + if (DR_HAS_CHANGED (info->dr_changed_bp)) + { + aarch64_linux_set_debug_regs (state, tid, 0); + DR_CLEAR_CHANGED (info->dr_changed_bp); + } + } +} diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h new file mode 100644 index 0000000..cf4e468 --- /dev/null +++ b/gdb/nat/aarch64-linux.h @@ -0,0 +1,24 @@ +/* Copyright (C) 2009-2015 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef AARCH64_LINUX_H +#define AARCH64_LINUX_H 1 + +void aarch64_linux_prepare_to_resume (struct lwp_info *lwp); + +#endif /* AARCH64_LINUX_H */ -- cgit v1.1