From d1a7880c7763c73413efe8dd1293d7874b7e0ddd Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 7 Jun 2009 22:33:25 +0000 Subject: [PATCH] 2009-06-07 Pedro Alves * procfs.h: New. * proc-utils.h (procfs_first_available): Don't declare here. * sol-thread.c: Include procfs.h instead of sys/procfs.h and proc-utils.h. * procfs.c: Include procfs.h. (procfs_target): Make it public. Don't register procfs_can_use_hw_breakpoint here. (proc_set_watchpoint): Check for PCWATCH or PIOCSWATCH being defined instead of TARGET_HAS_HARDWARE_WATCHPOINTS. (procfs_can_use_hw_breakpoint): Remove check of TARGET_HAS_HARDWARE_WATCHPOINTS. (procfs_use_watchpoints): Register procfs_can_use_hw_breakpoint here. (_initialize_procfs): Don't add the procfs target here. * i386-sol2-nat.c: Include target.h and procfs.h. (_initialize_amd64_sol2_nat): Install the procfs target here, customized with watchpoints support. * irix5-nat.c: Include target.h. (_initialize_core_irix5): Rename to ... (_initialize_irix5_nat): ... this. Install the procfs target here, customized with watchpoints support. * alpha-nat.c: Include procfs.h. (_initialize_core_alpha): Rename to... (_initialize_alpha_nat): ... this. Install the procfs target here, customized with watchpoints support. * sparc-sol2-nat.c: Include target.h and procfs.h. (_initialize_sparc_sol2_nat): New. * config/i386/nm-i386sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete. * config/sparc/nm-sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete. * config/mips/irix5.mh (NAT_FILE): Delete. * config/mips/irix6.mh (NAT_FILE): Delete. * config/mips/nm-irix5.h: Delete. 2009-06-07 Pedro Alves * gdbint.texinfo (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete all references. --- gdb/ChangeLog | 37 ++++++++++++++++++++++++ gdb/alpha-nat.c | 11 ++++++- gdb/config/i386/nm-i386sol2.h | 2 -- gdb/config/mips/irix5.mh | 1 - gdb/config/mips/irix6.mh | 1 - gdb/config/sparc/nm-sol2.h | 9 ------ gdb/doc/ChangeLog | 5 ++++ gdb/doc/gdbint.texinfo | 5 ---- gdb/i386-sol2-nat.c | 13 +++++++++ gdb/irix5-nat.c | 12 +++++++- gdb/proc-utils.h | 5 ---- gdb/procfs.c | 24 +++++---------- gdb/{config/mips/nm-irix5.h => procfs.h} | 23 ++++++++++++--- gdb/sol-thread.c | 3 +- gdb/sparc-sol2-nat.c | 17 +++++++++++ 15 files changed, 120 insertions(+), 48 deletions(-) rename gdb/{config/mips/nm-irix5.h => procfs.h} (50%) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a804dadaa71..74f0071d1ce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,40 @@ +2009-06-07 Pedro Alves + + * procfs.h: New. + * proc-utils.h (procfs_first_available): Don't declare here. + * sol-thread.c: Include procfs.h instead of sys/procfs.h and + proc-utils.h. + * procfs.c: Include procfs.h. + (procfs_target): Make it public. Don't register + procfs_can_use_hw_breakpoint here. + (proc_set_watchpoint): Check for PCWATCH or PIOCSWATCH being + defined instead of TARGET_HAS_HARDWARE_WATCHPOINTS. + (procfs_can_use_hw_breakpoint): Remove check of + TARGET_HAS_HARDWARE_WATCHPOINTS. + (procfs_use_watchpoints): Register procfs_can_use_hw_breakpoint + here. + (_initialize_procfs): Don't add the procfs target here. + + * i386-sol2-nat.c: Include target.h and procfs.h. + (_initialize_amd64_sol2_nat): Install the procfs target here, + customized with watchpoints support. + * irix5-nat.c: Include target.h. + (_initialize_core_irix5): Rename to ... + (_initialize_irix5_nat): ... this. Install the procfs target + here, customized with watchpoints support. + * alpha-nat.c: Include procfs.h. + (_initialize_core_alpha): Rename to... + (_initialize_alpha_nat): ... this. Install the procfs target + here, customized with watchpoints support. + * sparc-sol2-nat.c: Include target.h and procfs.h. + (_initialize_sparc_sol2_nat): New. + + * config/i386/nm-i386sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete. + * config/sparc/nm-sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete. + * config/mips/irix5.mh (NAT_FILE): Delete. + * config/mips/irix6.mh (NAT_FILE): Delete. + * config/mips/nm-irix5.h: Delete. + 20009-06-07 Pedro Alves * auxv.c (procfs_xfer_auxv): Change type of the `object' argument diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c index ff8897f82e6..7417776b912 100644 --- a/gdb/alpha-nat.c +++ b/gdb/alpha-nat.c @@ -22,6 +22,7 @@ #include "inferior.h" #include "gdbcore.h" #include "target.h" +#include "procfs.h" #include "regcache.h" #include "alpha-tdep.h" @@ -183,8 +184,16 @@ static struct core_fns alpha_osf_core_fns = NULL /* next */ }; +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern initialize_file_ftype _initialize_alpha_nat; + void -_initialize_core_alpha (void) +_initialize_alpha_nat (void) { + struct target_ops *t; + + t = procfs_target (); + add_target (t); + deprecated_add_core_fns (&alpha_osf_core_fns); } diff --git a/gdb/config/i386/nm-i386sol2.h b/gdb/config/i386/nm-i386sol2.h index ab8ff19cc3f..495bd64292f 100644 --- a/gdb/config/i386/nm-i386sol2.h +++ b/gdb/config/i386/nm-i386sol2.h @@ -18,8 +18,6 @@ #ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */ -#define TARGET_HAS_HARDWARE_WATCHPOINTS - /* Solaris x86 2.6 and 2.7 targets have a kernel bug when stepping over an instruction that causes a page fault without triggering a hardware watchpoint. The kernel properly notices that it shouldn't diff --git a/gdb/config/mips/irix5.mh b/gdb/config/mips/irix5.mh index 38c9b3045ed..8d07221dedc 100644 --- a/gdb/config/mips/irix5.mh +++ b/gdb/config/mips/irix5.mh @@ -1,4 +1,3 @@ # Host: SGI Iris running irix 5.x -NAT_FILE= nm-irix5.h NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \ proc-api.o proc-events.o proc-flags.o proc-why.o diff --git a/gdb/config/mips/irix6.mh b/gdb/config/mips/irix6.mh index de14401d6a6..de212b2ca5c 100644 --- a/gdb/config/mips/irix6.mh +++ b/gdb/config/mips/irix6.mh @@ -1,4 +1,3 @@ # Host: SGI Iris running irix 6.x -NAT_FILE= nm-irix5.h NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \ proc-api.o proc-events.o proc-flags.o proc-why.o diff --git a/gdb/config/sparc/nm-sol2.h b/gdb/config/sparc/nm-sol2.h index 14fb975159e..3398e2b0ef8 100644 --- a/gdb/config/sparc/nm-sol2.h +++ b/gdb/config/sparc/nm-sol2.h @@ -23,13 +23,4 @@ #define GDB_GREGSET_T prgregset_t #define GDB_FPREGSET_T prfpregset_t -/* Hardware wactchpoints. */ - -/* Solaris 2.6 and above can do HW watchpoints. */ -#ifdef NEW_PROC_API - -#define TARGET_HAS_HARDWARE_WATCHPOINTS - -#endif /* NEW_PROC_API */ - #endif /* nm-sol2.h */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 8f51f179f29..d4c574a98b6 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2009-06-07 Pedro Alves + + * gdbint.texinfo (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete all + references. + 2009-06-04 Ulrich Weigand * gdbint.texinfo: Rename formal parameters to gdbarch function diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 7acdf2c1302..b5771ccf21c 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -694,11 +694,6 @@ changed are announced as hit. watchpoints: @table @code -@findex TARGET_HAS_HARDWARE_WATCHPOINTS -@item TARGET_HAS_HARDWARE_WATCHPOINTS -If defined, the target supports hardware watchpoints. -(Currently only used for several native configs.) - @findex TARGET_CAN_USE_HARDWARE_WATCHPOINT @item TARGET_CAN_USE_HARDWARE_WATCHPOINT (@var{type}, @var{count}, @var{other}) Return the number of hardware watchpoints of type @var{type} that are diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c index 7d6d07b8cf7..68be98d15b2 100644 --- a/gdb/i386-sol2-nat.c +++ b/gdb/i386-sol2-nat.c @@ -22,6 +22,8 @@ #include #include "gregset.h" +#include "target.h" +#include "procfs.h" /* This file provids the (temporary) glue between the Solaris x86 target dependent code and the machine independent SVR4 /proc @@ -134,6 +136,15 @@ extern void _initialize_amd64_sol2_nat (void); void _initialize_amd64_sol2_nat (void) { + struct target_ops *t; + + /* Fill in the generic procfs methods. */ + t = procfs_target (); + +#ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */ + procfs_use_watchpoints (t); +#endif + #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; amd64_native_gregset32_num_regs = @@ -142,4 +153,6 @@ _initialize_amd64_sol2_nat (void) amd64_native_gregset64_num_regs = ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); #endif + + add_target (t); } diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index c53c1158189..91ea948e3d9 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -29,6 +29,7 @@ #include "gdbcore.h" #include "target.h" #include "regcache.h" +#include "procfs.h" #include "gdb_string.h" #include @@ -256,8 +257,17 @@ static struct core_fns irix5_core_fns = NULL /* next */ }; +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern initialize_file_ftype _initialize_irix5_nat; + void -_initialize_core_irix5 (void) +_initialize_irix5_nat (void) { + struct target_ops *t; + + t = procfs_target (); + procfs_use_watchpoints (t); + add_target (t); + deprecated_add_core_fns (&irix5_core_fns); } diff --git a/gdb/proc-utils.h b/gdb/proc-utils.h index cf52ff60cd7..01e33ee6e99 100644 --- a/gdb/proc-utils.h +++ b/gdb/proc-utils.h @@ -96,8 +96,3 @@ typedef PROC_CTL_WORD_TYPE procfs_ctl_t; #else typedef long procfs_ctl_t; #endif - - -/* From procfs.c */ - -extern ptid_t procfs_first_available (void); diff --git a/gdb/procfs.c b/gdb/procfs.c index 1e246bec53d..37074b2aac3 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -50,6 +50,7 @@ #include "gdb_assert.h" #include "inflow.h" #include "auxv.h" +#include "procfs.h" /* * PROCFS.C @@ -181,7 +182,7 @@ procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr, } #endif -static struct target_ops * +struct target_ops * procfs_target (void) { struct target_ops *t = inf_child_target (); @@ -212,7 +213,6 @@ procfs_target (void) t->to_has_thread_control = tc_schedlock; t->to_find_memory_regions = proc_find_memory_regions; t->to_make_corefile_notes = procfs_make_note_section; - t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) t->to_auxv_parse = procfs_auxv_parse; @@ -2902,7 +2902,10 @@ procfs_address_to_host_pointer (CORE_ADDR addr) int proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags) { -#if !defined (TARGET_HAS_HARDWARE_WATCHPOINTS) +#if !defined (PCWATCH) && !defined (PIOCSWATCH) + /* If neither or these is defined, we can't support watchpoints. + This just avoids possibly failing to compile the below on such + systems. */ return 0; #else /* Horrible hack! Detect Solaris 2.5, because this doesn't work on 2.5 */ @@ -5294,9 +5297,6 @@ procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag, static int procfs_can_use_hw_breakpoint (int type, int cnt, int othertype) { -#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS - return 0; -#else /* Due to the way that proc_set_watchpoint() is implemented, host and target pointers must be of the same size. If they are not, we can't use hardware watchpoints. This limitation is due to the @@ -5312,7 +5312,6 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype) /* Other tests here??? */ return 1; -#endif } /* @@ -5394,6 +5393,7 @@ procfs_use_watchpoints (struct target_ops *t) t->to_insert_watchpoint = procfs_insert_watchpoint; t->to_remove_watchpoint = procfs_remove_watchpoint; t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint; + t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; } /* @@ -5988,16 +5988,6 @@ proc_untrace_sysexit_cmd (char *args, int from_tty) void _initialize_procfs (void) { - struct target_ops * t; - - t = procfs_target (); - -#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS - procfs_use_watchpoints (t); -#endif - - add_target (t); - add_info ("proc", info_proc_cmd, _("\ Show /proc process information about any running process.\n\ Specify process id, or use the program being debugged by default.\n\ diff --git a/gdb/config/mips/nm-irix5.h b/gdb/procfs.h similarity index 50% rename from gdb/config/mips/nm-irix5.h rename to gdb/procfs.h index 98ff77a3f5c..6e8b302a23f 100644 --- a/gdb/config/mips/nm-irix5.h +++ b/gdb/procfs.h @@ -1,7 +1,6 @@ -/* Definitions for native support of irix5. +/* Native debugging support for procfs targets. - Copyright 1993, 1996, 1998, 1999, 2000, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 2009 Free Software Foundation, Inc. This file is part of GDB. @@ -18,4 +17,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define TARGET_HAS_HARDWARE_WATCHPOINTS +struct target_ops; + +/* Create a prototype generic procfs target. The client can override + it with local methods. */ + +extern struct target_ops *procfs_target (void); + +/* Call this in the native _initialize routine that creates and + customizes the prototype target returned by procfs_target, if the + native debug interface supports procfs watchpoints. */ + +extern void procfs_use_watchpoints (struct target_ops *t); + +/* Return a ptid for which we guarantee we will be able to find a + 'live' procinfo. */ + +extern ptid_t procfs_first_available (void); diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 8c7865b0cfb..512239eeafb 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -66,8 +66,7 @@ #include "symfile.h" #include "observer.h" #include "gdb_string.h" -#include -#include "proc-utils.h" +#include "procfs.h" struct target_ops sol_thread_ops; diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c index 3854fd920c4..e14af594849 100644 --- a/gdb/sparc-sol2-nat.c +++ b/gdb/sparc-sol2-nat.c @@ -24,6 +24,8 @@ #include "gregset.h" #include "sparc-tdep.h" +#include "target.h" +#include "procfs.h" /* This file provids the (temporary) glue between the Solaris SPARC target dependent code and the machine independent SVR4 /proc @@ -94,3 +96,18 @@ fill_fpregset (const struct regcache *regcache, prfpregset_t *fpregs, int regnum { sparc_collect_fpregset (regcache, regnum, fpregs); } + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern initialize_file_ftype _initialize_sparc_sol2_nat; + +void +_initialize_sparc_sol2_nat (void) +{ + struct target_ops *t; + + t = procfs_target (); +#ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints */ + procfs_use_watchpoints (t); +#endif + add_target (t); +} -- 2.30.2