diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/Makefile.in | 10 | ||||
-rw-r--r-- | gdb/configure.tgt | 36 | ||||
-rw-r--r-- | gdb/gdbarch.c | 24 | ||||
-rw-r--r-- | gdb/gdbarch.h | 6 | ||||
-rwxr-xr-x | gdb/gdbarch.sh | 3 | ||||
-rw-r--r-- | gdb/ravenscar-sparc-thread.c | 20 | ||||
-rw-r--r-- | gdb/ravenscar-sparc-thread.h | 26 | ||||
-rw-r--r-- | gdb/ravenscar-thread.c | 44 | ||||
-rw-r--r-- | gdb/ravenscar-thread.h | 9 | ||||
-rw-r--r-- | gdb/sparc-tdep.c | 3 |
11 files changed, 159 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cf98752..a35f122 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,34 @@ 2012-12-15 Joel Brobecker <brobecker@adacore.com> + * gdbarch.sh: Add "struct ravenscar_arch_ops" advance + declaration. + (ravenscar_ops): New gdbarch variable. + * gdbarch.h, gdbarch.c: Regenerate. + * ravenscar-thread.h (ravenscar_register_arch_ops): Delete. + * ravenscar-thread.c (current_arch_ops): Delete. + (ravenscar_fetch_registers): Get the ravenscar_arch_ops + from the gdbarch. + (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. + (ravenscar_inferior_created): Add gdbarch_ravenscar_ops check. + (ravenscar_register_arch_ops): Delete. + * ravenscar-sparc-thread.h: New file. + * ravenscar-sparc-thread.c: #include "ravenscar-sparc-thread.h". + (ravenscar_sparc_ops): Define value statically. + (_initialize_ravenscar_sparc): Delete. + (register_sparc_ravenscar_ops): New function. + * sparc-tdep.c: #include "ravenscar-sparc-thread.h". + (sparc32_gdbarch_init): Add call to register_sparc_ravenscar_ops. + * Makefile.in (ALL_TARGET_OBS): Add ravenscar-thread.o and + ravenscar-sparc-thread.o. + (SFILES): Add ravenscar-thread.c. + (HFILES_NO_SRCDIR): Add ravenscar-sparc-thread.h. + (ALLDEPFILES): ravenscar-sparc-thread.c. + * configure.tgt: Add ravenscar-thread.o and ravenscar-sparc-thread.o + to gdb_target_obs + for all the targets that use sparc-tdep.o. + +2012-12-15 Joel Brobecker <brobecker@adacore.com> + * ravenscar-thread.c (ravenscar_is_open): Delete. (ravenscar_initialize): Move most of the code from here... (ravenscar_inferior_created): ... to there. Invert logic. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 8e7b589..3c83a0e 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -570,7 +570,7 @@ ALL_TARGET_OBS = \ score-tdep.o \ sh64-tdep.o sh-linux-tdep.o shnbsd-tdep.o sh-tdep.o \ sparc-linux-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \ - sparc-sol2-tdep.o sparc-tdep.o \ + sparc-sol2-tdep.o sparc-tdep.o ravenscar-sparc-thread.o \ spu-tdep.o spu-multiarch.o solib-spu.o \ tic6x-tdep.o tic6x-linux-tdep.o \ tilegx-tdep.o tilegx-linux-tdep.o \ @@ -589,7 +589,8 @@ ALL_TARGET_OBS = \ xcoffread.o \ symfile-mem.o \ windows-tdep.o \ - linux-record.o + linux-record.o \ + ravenscar-thread.o # Host-dependent makefile fragment comes in here. @host_makefile_frag@ @@ -730,6 +731,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \ proc-service.list progspace.c \ prologue-value.c psymtab.c \ + ravenscar-thread.c \ regcache.c reggroups.c remote.c remote-fileio.c remote-notif.c reverse.c \ sentinel-frame.c \ serial.c ser-base.c ser-unix.c skip.c \ @@ -828,7 +830,8 @@ gnulib/import/extra/snippet/warn-on-use.h \ gnulib/import/stddef.in.h gnulib/import/inttypes.in.h inline-frame.h skip.h \ common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ common/format.h common/host-defs.h utils.h common/queue.h \ -common/linux-osdata.h gdb-dlfcn.h auto-load.h probe.h stap-probe.h gdb_bfd.h +common/linux-osdata.h gdb-dlfcn.h auto-load.h probe.h stap-probe.h \ +gdb_bfd.h ravenscar-sparc-thread.h # Header files that already have srcdir in them, or which are in objdir. @@ -1498,6 +1501,7 @@ ALLDEPFILES = \ sparc64-nat.c sparc64-tdep.c sparc64fbsd-nat.c sparc64fbsd-tdep.c \ sparc64nbsd-nat.c sparc64nbsd-tdep.c sparc64obsd-tdep.c \ sparcnbsd-nat.c sparcnbsd-tdep.c sparcobsd-tdep.c \ + ravenscar-sparc-thread.c \ spu-linux-nat.c spu-tdep.c spu-multiarch.c solib-spu.c \ tilegx-linux-nat.c tilegx-tdep.c tilegx-linux-tdep.c \ v850-tdep.c \ diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 36d4304..c13bd97 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -475,7 +475,8 @@ sparc-*-linux*) # Target: GNU/Linux SPARC gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \ sparc-linux-tdep.o solib-svr4.o symfile-mem.o \ - linux-tdep.o" + linux-tdep.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" if test "x$enable_64_bit_bfd" = "xyes"; then # Target: GNU/Linux UltraSPARC gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o \ @@ -487,52 +488,63 @@ sparc64-*-linux*) # Target: GNU/Linux UltraSPARC gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sol2-tdep.o \ sparc64-linux-tdep.o sparc-tdep.o sparc-sol2-tdep.o \ - sparc-linux-tdep.o solib-svr4.o linux-tdep.o" + sparc-linux-tdep.o solib-svr4.o linux-tdep.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" build_gdbserver=yes ;; sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu) # Target: FreeBSD/sparc64 gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \ - solib-svr4.o" + solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc-*-netbsd* | sparc-*-knetbsd*-gnu) # Target: NetBSD/sparc - gdb_target_obs="sparc-tdep.o sparcnbsd-tdep.o nbsd-tdep.o solib-svr4.o" + gdb_target_obs="sparc-tdep.o sparcnbsd-tdep.o nbsd-tdep.o \ + solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc64-*-netbsd* | sparc64-*-knetbsd*-gnu) # Target: NetBSD/sparc64 gdb_target_obs="sparc64-tdep.o sparc64nbsd-tdep.o sparc-tdep.o \ - sparcnbsd-tdep.o nbsd-tdep.o solib-svr4.o" + sparcnbsd-tdep.o nbsd-tdep.o solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc-*-openbsd*) # Target: OpenBSD/sparc gdb_target_obs="sparc-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \ - nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o" + nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc64-*-openbsd*) # Target: OpenBSD/sparc64 gdb_target_obs="sparc64-tdep.o sparc64nbsd-tdep.o sparc64obsd-tdep.o \ sparc-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \ - nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o" + nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*) # Target: Solaris SPARC - gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o solib-svr4.o" + gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \ + solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*) # Target: Solaris UltraSPARC gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sparc-tdep.o \ - sparc-sol2-tdep.o sol2-tdep.o solib-svr4.o" + sparc-sol2-tdep.o sol2-tdep.o solib-svr4.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; sparc-*-*) # Target: SPARC - gdb_target_obs="sparc-tdep.o ravenscar-thread.o \ - ravenscar-sparc-thread.o" + gdb_target_obs="sparc-tdep.o + ravenscar-thread.o ravenscar-sparc-thread.o" gdb_sim=../sim/erc32/libsim.a ;; sparc64-*-*) # Target: UltraSPARC - gdb_target_obs="sparc-tdep.o sparc64-tdep.o" + gdb_target_obs="sparc-tdep.o sparc64-tdep.o \ + ravenscar-thread.o ravenscar-sparc-thread.o" ;; spu*-*-*) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 32fe26b..e15f911 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -285,6 +285,7 @@ struct gdbarch gdbarch_info_proc_ftype *info_proc; gdbarch_core_info_proc_ftype *core_info_proc; gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order; + struct ravenscar_arch_ops * ravenscar_ops; }; @@ -454,6 +455,7 @@ struct gdbarch startup_gdbarch = 0, /* info_proc */ 0, /* core_info_proc */ default_iterate_over_objfiles_in_search_order, /* iterate_over_objfiles_in_search_order */ + NULL, /* ravenscar_ops */ /* startup_gdbarch() */ }; @@ -544,6 +546,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->auto_wide_charset = default_auto_wide_charset; gdbarch->gen_return_address = default_gen_return_address; gdbarch->iterate_over_objfiles_in_search_order = default_iterate_over_objfiles_in_search_order; + gdbarch->ravenscar_ops = NULL; /* gdbarch_alloc() */ return gdbarch; @@ -754,6 +757,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of info_proc, has predicate. */ /* Skip verify of core_info_proc, has predicate. */ /* Skip verify of iterate_over_objfiles_in_search_order, invalid_p == 0 */ + /* Skip verify of ravenscar_ops, invalid_p == 0 */ buf = ui_file_xstrdup (log, &length); make_cleanup (xfree, buf); if (length > 0) @@ -1201,6 +1205,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: push_dummy_code = <%s>\n", host_address_to_string (gdbarch->push_dummy_code)); fprintf_unfiltered (file, + "gdbarch_dump: ravenscar_ops = %s\n", + host_address_to_string (gdbarch->ravenscar_ops)); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_read_pc_p() = %d\n", gdbarch_read_pc_p (gdbarch)); fprintf_unfiltered (file, @@ -4300,6 +4307,23 @@ set_gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, gdbarch->iterate_over_objfiles_in_search_order = iterate_over_objfiles_in_search_order; } +struct ravenscar_arch_ops * +gdbarch_ravenscar_ops (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Skip verify of ravenscar_ops, invalid_p == 0 */ + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_ravenscar_ops called\n"); + return gdbarch->ravenscar_ops; +} + +void +set_gdbarch_ravenscar_ops (struct gdbarch *gdbarch, + struct ravenscar_arch_ops * ravenscar_ops) +{ + gdbarch->ravenscar_ops = ravenscar_ops; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 572aca3..63157fb 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -57,6 +57,7 @@ struct syscall; struct agent_expr; struct axs_value; struct stap_parse_info; +struct ravenscar_arch_ops; /* The architecture associated with the inferior through the connection to the target. @@ -1221,6 +1222,11 @@ typedef void (gdbarch_iterate_over_objfiles_in_search_order_ftype) (struct gdbar extern void gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile); extern void set_gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order); +/* Ravenscar arch-dependent ops. */ + +extern struct ravenscar_arch_ops * gdbarch_ravenscar_ops (struct gdbarch *gdbarch); +extern void set_gdbarch_ravenscar_ops (struct gdbarch *gdbarch, struct ravenscar_arch_ops * ravenscar_ops); + /* Definition for an unknown syscall, used basically in error-cases. */ #define UNKNOWN_SYSCALL (-1) diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index daa1228..6d7a578 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -963,6 +963,8 @@ M:void:core_info_proc:char *args, enum info_proc_what what:args, what # inspected when the symbol search was requested. m:void:iterate_over_objfiles_in_search_order:iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile:cb, cb_data, current_objfile:0:default_iterate_over_objfiles_in_search_order::0 +# Ravenscar arch-dependent ops. +v:struct ravenscar_arch_ops *:ravenscar_ops:::NULL:NULL::0:host_address_to_string (gdbarch->ravenscar_ops) EOF } @@ -1080,6 +1082,7 @@ struct syscall; struct agent_expr; struct axs_value; struct stap_parse_info; +struct ravenscar_arch_ops; /* The architecture associated with the inferior through the connection to the target. diff --git a/gdb/ravenscar-sparc-thread.c b/gdb/ravenscar-sparc-thread.c index 2a27a63..93888c8 100644 --- a/gdb/ravenscar-sparc-thread.c +++ b/gdb/ravenscar-sparc-thread.c @@ -23,8 +23,7 @@ #include "sparc-tdep.h" #include "inferior.h" #include "ravenscar-thread.h" - -static struct ravenscar_arch_ops ravenscar_sparc_ops; +#include "ravenscar-sparc-thread.h" static void ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum); @@ -179,14 +178,17 @@ ravenscar_sparc_store_registers (struct regcache *regcache, int regnum) buf_size); } -/* Provide a prototype to silence -Wmissing-prototypes. */ -extern void _initialize_ravenscar_sparc (void); +static struct ravenscar_arch_ops ravenscar_sparc_ops = +{ + ravenscar_sparc_fetch_registers, + ravenscar_sparc_store_registers, + ravenscar_sparc_prepare_to_store +}; + +/* Register ravenscar_arch_ops in GDBARCH. */ void -_initialize_ravenscar_sparc (void) +register_sparc_ravenscar_ops (struct gdbarch *gdbarch) { - ravenscar_sparc_ops.to_fetch_registers = ravenscar_sparc_fetch_registers; - ravenscar_sparc_ops.to_store_registers = ravenscar_sparc_store_registers; - ravenscar_sparc_ops.to_prepare_to_store = ravenscar_sparc_prepare_to_store; - ravenscar_register_arch_ops (&ravenscar_sparc_ops); + set_gdbarch_ravenscar_ops (gdbarch, &ravenscar_sparc_ops); } diff --git a/gdb/ravenscar-sparc-thread.h b/gdb/ravenscar-sparc-thread.h new file mode 100644 index 0000000..fc86e69 --- /dev/null +++ b/gdb/ravenscar-sparc-thread.h @@ -0,0 +1,26 @@ +/* Ravenscar SPARC target support. + + Copyright 2012 Free Software Foundation, Inc. + + 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 <http://www.gnu.org/licenses/>. */ + +#ifndef RAVENSCAR_SPARC_THREAD_H +#define RAVENSCAR_SPARC_THREAD_H + +struct gdbarch; + +extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch); +#endif diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index ddbaea6..2d32cd8 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -54,9 +54,6 @@ static const char ravenscar_runtime_initializer[] = static struct observer *update_target_observer = NULL; -/* Architecture-specific hooks. */ -static struct ravenscar_arch_ops* current_arch_ops; - static void ravenscar_find_new_threads (struct target_ops *ops); static ptid_t ravenscar_running_thread (void); static char *ravenscar_extra_thread_info (struct thread_info *tp); @@ -276,7 +273,13 @@ ravenscar_fetch_registers (struct target_ops *ops, || ptid_equal (inferior_ptid, ravenscar_running_thread ())) beneath->to_fetch_registers (beneath, regcache, regnum); else - current_arch_ops->to_fetch_registers (regcache, regnum); + { + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct ravenscar_arch_ops *arch_ops + = gdbarch_ravenscar_ops (gdbarch); + + arch_ops->to_fetch_registers (regcache, regnum); + } } static void @@ -290,7 +293,13 @@ ravenscar_store_registers (struct target_ops *ops, || ptid_equal (inferior_ptid, ravenscar_running_thread ())) beneath->to_store_registers (beneath, regcache, regnum); else - current_arch_ops->to_store_registers (regcache, regnum); + { + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct ravenscar_arch_ops *arch_ops + = gdbarch_ravenscar_ops (gdbarch); + + arch_ops->to_store_registers (regcache, regnum); + } } static void @@ -303,7 +312,13 @@ ravenscar_prepare_to_store (struct regcache *regcache) || ptid_equal (inferior_ptid, ravenscar_running_thread ())) beneath->to_prepare_to_store (regcache); else - current_arch_ops->to_prepare_to_store (regcache); + { + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct ravenscar_arch_ops *arch_ops + = gdbarch_ravenscar_ops (gdbarch); + + arch_ops->to_prepare_to_store (regcache); + } } static void @@ -321,7 +336,11 @@ ravenscar_mourn_inferior (struct target_ops *ops) static void ravenscar_inferior_created (struct target_ops *target, int from_tty) { - if (!ravenscar_task_support || !has_ravenscar_runtime ()) + struct ravenscar_arch_ops *ops; + + if (!ravenscar_task_support + || gdbarch_ravenscar_ops (current_inferior ()->gdbarch) == NULL + || !has_ravenscar_runtime ()) return; base_magic_null_ptid = inferior_ptid; @@ -329,17 +348,6 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty) push_target (&ravenscar_ops); } -void -ravenscar_register_arch_ops (struct ravenscar_arch_ops *ops) -{ - /* FIXME: To be clean, we would need to handle a list of - architectures, just like in remote-wtx-hw.c. However, for now the - only Ravenscar run-time for bare board that is implemented in - GNAT is for only one architecture: erc32-elf. So no need to care about - that for now... */ - current_arch_ops = ops; -} - static ptid_t ravenscar_get_ada_task_ptid (long lwp, long thread) { diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h index 5eeab38..9edc9d7 100644 --- a/gdb/ravenscar-thread.h +++ b/gdb/ravenscar-thread.h @@ -29,13 +29,4 @@ struct ravenscar_arch_ops void (*to_prepare_to_store) (struct regcache *); }; -/* Register implementations for target ops to_store_registers, - to_prepare_to_store and to_fetch_registers when the inferior_ptid - is different from the running thread. In that case, the registers - are saved in a architecture-specific location. */ -/* FIXME: only one architecture can be registered for now. See - implementation. */ - -extern void ravenscar_register_arch_ops (struct ravenscar_arch_ops *ops); - #endif /* !defined (RAVENSCAR_THREAD_H) */ diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 3164ed3..7dfa7da 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -39,6 +39,7 @@ #include "gdb_string.h" #include "sparc-tdep.h" +#include "ravenscar-sparc-thread.h" struct regset; @@ -1683,6 +1684,8 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_regset_from_core_section (gdbarch, sparc_regset_from_core_section); + register_sparc_ravenscar_ops (gdbarch); + return gdbarch; } |